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: 38ac0f1 ACPI: Add _PLD support da0af6e usb: Bind devices to ACPI devices when possible 54d3f8c usb: Set device removable state based on ACPI USB data f397d7c usb: add struct usb_hub_port to store port related members. bebc56d usb: move struct usb_device->children to struct usb_hub_port->child 336c5c3 usb: convert port_owners type from void * to struct dev_state * 7fc2cc3 usb: Rename temp variable "config" to "val" in the set_avoid_reset_quirk() 4d9e408 usb: add decriptor of persist fail for some morph usb devices 2d36684 usb/endpoint: Set release callback in the struct device_type instead of in the device itself directly 7fda953 usb: convert USB_QUIRK_RESET_MORPHS to USB_QUIRK_RESET 9c20890 usb: redefine DeviceRemovable and wHubDelay as _le16 fa2a956 usb: make usb port a real device ff823c7 usb: move children to struct usb_port d557542 usb/acpi: Bind ACPI node to USB port, not usb_device. 05f9168 usb/acpi: Store info on device removability. 693d8eb xhci: Handle clear PORT_POWER feature. f7ac778 usb/acpi: Use ACPI methods to power off ports. 3a22b87 usb: Fail a get config when the port is powered off. ca9c9d0 usb : Add sysfs files to control port power. ca3c153 usb: add little-endian transform for DeviceRemovable of usb3.0 hub 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. 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. We should probably turn that on by default and see if anyone has issues. 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