On Friday, September 21, 2012, Sarah Sharp wrote: > Two weeks ago at Linux Plumbers Conference, I presented about the Intel > Lynx Point USB port power off mechanism. This email is a report out of > what was discussed, and a kick off point for further discussion. > > LPC Report out > -------------- > > Slides are here: > http://dl.dropbox.com/u/96820575/sarah-sharp-lpt-port-power-off2-mini.pdf > The video is here: > http://linuxplumbers.ubicast.tv/videos/usb-port-power-off-kerneluserspace-api/ > (I apologize in advance for the mispronunciation of Tianyu's name.) > > Basic idea: The Intel Lynx Point port power off mechanism is a way for > Linux to use ACPI to completely power off USB ports, but that means we > lose hot plug/unplug events. > > The general consensus was: > > - If we come up with a sensible automatic port power policy, and have > all ports use it by default, then we're likely to run into a lot of > broken ACPI tables. We could add a boot option to change > the policy to "on" so that users have an easy way to test if the ACPI > tables are bad. > > - If we have the port power policy default to on, but add a Power Top > option to turn the policy to auto, we really won't get a lot of users > or testing. It might be best to turn it to 'auto' and see if any > users scream. We can always change it to 'on' later. > > - We probably don't want to power external ports off by default. > There's just too much risk of users seeing "dead" USB ports. > Powering off internal empty ports by default is fine. > > - We need to expose all information ACPI provides to userspace via > sysfs. Some users will want to know which ports are power ganged > together, because they may have a USB device that is charging but not > enumerated on a port, and we have no way of detecting that. The > power resources may not have a name or number, so we will have to > arbitrarily number them. > > - Len Brown mentioned that it's likely that other types of system > devices will expose power resources in the same way it's done for USB > devices. Rafael Wysocki mentioned that it would be nice to get a > more generic representation of the power resources into struct > device. > > - Possibly lsusb should show the power policy for each port, as part of > the roothub verbose listing. > > Next Steps > ---------- > > Rafael wanted to see the whole patchset series. The patches have gone > in over several months (and some of them are only in greg/usb-next or > linux-next). Here is the series from earliest to latest patches: Well, someone may want to have links here, for example to be able to review the patches using something different from a development PC. Actually I do, so here they go: > 38ac0f1 ACPI: Add _PLD support http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=38ac0f1 > da0af6e usb: Bind devices to ACPI devices when possible http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=da0af6e > 54d3f8c usb: Set device removable state based on ACPI USB data http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=54d3f8c > f397d7c usb: add struct usb_hub_port to store port related members. http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=f397d7c > bebc56d usb: move struct usb_device->children to struct usb_hub_port->child http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=bebc56d > 336c5c3 usb: convert port_owners type from void * to struct dev_state * http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=336c5c3 > 7fc2cc3 usb: Rename temp variable "config" to "val" in the set_avoid_reset_quirk() http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=7fc2cc3 > 4d9e408 usb: add decriptor of persist fail for some morph usb devices http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=4d9e408 > 2d36684 usb/endpoint: Set release callback in the struct device_type instead of in the device itself directly http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=2d36684 > 7fda953 usb: convert USB_QUIRK_RESET_MORPHS to USB_QUIRK_RESET http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=7fda953 > 9c20890 usb: redefine DeviceRemovable and wHubDelay as _le16 http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=9c20890 > fa2a956 usb: make usb port a real device http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=fa2a956 > ff823c7 usb: move children to struct usb_port http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=ff823c7 > d557542 usb/acpi: Bind ACPI node to USB port, not usb_device. http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=d557542 > 05f9168 usb/acpi: Store info on device removability. http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=05f9168 > 693d8eb xhci: Handle clear PORT_POWER feature. http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=693d8eb > f7ac778 usb/acpi: Use ACPI methods to power off ports. http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=f7ac778 > 3a22b87 usb: Fail a get config when the port is powered off. http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=3a22b87 > ca9c9d0 usb : Add sysfs files to control port power. http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=ca9c9d0 > ca3c153 usb: add little-endian transform for DeviceRemovable of usb3.0 hub http://git.kernel.org/?p=linux/kernel/git/gregkh/usb.git;a=commit;h=ca3c153 That's quite a number of patches, BTW. :-) > The end result of those patches is that we expose a sysfs file per USB > port to userspace to allow users to set power to either on or off. The > port will only be powered off if all ports under the same power resource > have the sysfs file set to off. I wonder why people are so fond of adding new sysfs interfaces covering their own particular use case only. There's no practical way user space may use all of these things simultaneously and still have an idea about what it's actually doing. > There's no kernel policy behind the "auto" power policy. Tianyu sent > a recent patchset to add a policy that turns off ports that ACPI says is > not user visible and is not connectable, but only if there isn't a USB > device currently connected to it: > > http://marc.info/?l=linux-usb&m=134668553729981&w=2 > http://marc.info/?l=linux-usb&m=134668554029982&w=2 > > Next steps are to get those auto policy patches merged (they're probably > too late for 3.7 right now), and agree on a generic power resource > management in struct device. > > Where I would like to see this work go is to have a certain set of > "safe" internal USB devices be powered off by default when they are > suspended. I think fingerprint readers and webcams would be a good > start, but we probably can't do bluetooth, 3G modems, BMCs, etc. We > would need a new USB driver flag to allow drivers to opt-in to the > automatic port power off on suspend. Well, why don't we have a device PM QoS flag for that instead? It looks like that may be useful for more subsystems. > We should probably turn that on by default and see if anyone has issues. That's going to turn out I guess. Thanks, Rafael -- 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