On Wed, 7 Feb 2007, Oliver Neukum wrote:

> > Since we suspend entire devices, and not single interfaces, any value
> > coming from userspace will have to refer to the entire device.  So are you
> 
> No, user space can set values for each interface.
> 
> User space can know which value would be the best for each interface,
> but it doesn't know which interfaces want to be autosuspended when idle
> at all.
> 
> If you will each interface would have three states
> 
> 3) don't autosuspend
> 2) autosuspend when idle, delay = x
> 1) autosuspend immediately
> 
> The whole device is in the state dictated by the maximum of these values.
> In case the device is in state 2, a delay must be chosen. You need to take
> the maximum of the interfaces in that state. To do so each interface needs
> its own delay.

First of all, note that 3) above isn't a problem.  If a driver doesn't 
have supports_autosuspend set, or if it calls usb_autopm_get_interface(), 
then the device won't be autosuspended at all.  So we can eliminate this 
case; it's already handled okay.

1) reduces to 2) with x = 0.  So let's concentrate on 2).  The "when idle"  
part is solved by adding the USB_DF_DEVICE_BUSY flag, leaving only the
"delay = x" part.  You want this delay to be per-interface, and you want
it to be settable by the user.  I'm not so sure this is a good 
combination.

Obviously the entire question is moot for devices with a single interface.  
It only matters when there's more than one.

Let's consider a hypothetical example: an HID device with two interfaces,
one for a keyboard and one for a mouse.  (By the way, this isn't how real
USB mouse/keyboard combos work -- they are compound devices with an
embedded hub, not composite devices.)  The user is willing to let the
keboard autosuspend after 3 seconds of inactivity, but doesn't want the
mouse to suspend until after 20 seconds.  However it's not possible to
suspend one or the other; we can only suspend both or neither.

A simple approach is to use a single device-wide inactivity delay of 20 
seconds.  This won't be optimal; it doesn't handle situations where the 
mouse has been idle for a long time while the keyboard gets used.  But at 
least it's correct.  Futhermore it doesn't require the user to specify 
two different delay values -- it would be one device, one delay.

A more complicated approach is to keep track of the activity level of each
interface separately.  Apparently this is what you're in favor of, but it
would involve considerably more work.  We would have to store the last
time each interface was used (a jiffies value, not just an activity flag).  
Deciding when the inactivity timer should expire would involve a
non-trivial computation.

The complicated approach is doable, but do we really want to?  How often
will it really happen that different interfaces on the same device have
radically differing autosuspend delay values?  My feeling is that
autosuspend is of relatively low importance, and it should not be made any
more complicated than necessary.

Alan Stern


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier.
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to