The evilness of struct usb_device->auto_pm
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 4 lines · Oliver Neukum
Quoted 4 lines
Quoted 4 lines
Quoted 1 line
What exactly would you like to do?
Put the stuff into struct device and move the autosuspend code into driver core.
Moving some of the data fields might be acceptable. Moving the code is premature at best. You must always bear in mind that the autosuspend model used by USB is not suitable for every type of device. Each subsystem needs to implement its own form of runtime PM; the core should contain only the lowest-denominator common parts.
Quoted 4 lines
Quoted 2 lines
Well, I thought that it would be nicer if drivers handled autosuspend in a transparent (from the point of view of the core) way.
That is possible only for drivers which are leaves in the device tree.
Not true. For example, the USB hub driver handles autosuspend perfectly well. The main issue is what to do when the autosuspend notifications need to cross a subsystem boundary.
Quoted 6 lines
Quoted 2 lines
Now, it seems to follow from what you're saying that this is not possible in general, because of USB mass storage devices that need some special handling.
No, they need the ordinary handling. All a device's children must be suspended if a device is suspended.
Quoted 6 lines
Quoted 2 lines
I'm not familiar with the USB code, so can you please tell me how the USB autosuspend is handled at present and what exactly the problem with that is?
The drivers for interfaces manage a count. If all a device's interfaces' count goes to zero, the device is suspended. The drivers are notified through the normal
suspend()method. But children of these devices are not notified.
That's because the notifications go up the device tree, not down. When a child is suspended, the parent is notified. Then if the driver sees that all the children are suspended, the parent can be suspended as well.
Oliver has been trying to subvert this model by making usb-storage responsible for suspending the SCSI disk and CD/DVD drivers, which are located beneath it in the device tree. I've been trying to convince him that the proper way to handle things is to let the SCSI drivers decide for themselves when their devices can be suspended, and then have them inform usb-storage.
Alan Stern