On Wed, Jul 18, 2012 at 09:03:59PM +0200, Oliver Neukum wrote: > On Wednesday 18 July 2012 12:40:38 Alan Stern wrote: > > > Oliver, you seem to be arguing both sides of this discussion. You > > But there are more than two sides in this discussion. > > > point out the the power-off operation is too dangerous in general for > > the kernel to do it, and now you say that it's too racy for userspace > > to do it. > > It is too dangerous in general. Therefore it may be safe in particular. > > > Are we to infer that you don't want it to be done at all? > > No, now that I think about it an attribute for the drivers is necessary. > Like drivers have "supports_autosuspend" they also should have > "supports_power_off". In addition it is necessary for ports to have > an attribute in sysfs which allows user space to block power off. > > And it is a bit complicated. Power may be cut, if > > a) a port is internal and unpluggable, or > > b) a port is internal and it's interfaces' drivers set "supports_power_off", unless: > > 1) remote wakeup is requested > 2) user space has blocked it via the new sysfs attribute > 3) USB_QUIRK_RESET_MORPHS is set Yes, that sounds like a good kernel policy. Thanks for pointing out the USB_QUIRK_RESET_MORPHS; I didn't know we had a specific quirk for devices that will morph into a different class of USB devices on a reset. > > What about things like the ubiquitous USB webcams one finds in laptops > > these days? I practically never use the one in my laptop, so turning > > off its bus power seems like a good idea. Even if that means I have to > > turn the power on explicitly before using the webcam. > > That would work. Btusb wouldn't work. What if the user really wants the bluetooth device off? I have only used the bluetooth on my laptop once in the year I've had it. Whenever I boot my Ubuntu box, I go up to the bluetooth icon in the tray and turn it off. It would be nice at that point to have the bluetooth driver unloaded and the port turned completely off. I think we're going to need to help userspace serialize port power management somehow. Why not create a new sysfs file with ioctls similar to the usbfs claim port interface to allow only one userspace process to control the port power at a time? Sarah Sharp -- To unsubscribe from this list: send the line "unsubscribe linux-usb" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html