Re: [RFC PATCH] usb/acpi: Add support usb port power off mechanism for device fixed on the motherboard

Sergei Shtylyov
2012-05-12T12:48:29Z

Hello.

On 11-05-2012 22:12, Sarah Sharp wrote:

>>> For external ports, this should be associated with sys file control. The users
>>> need to determine when they should be power off.

>> You don't mean "external", you mean "not described as unconnectable by
>> ACPI".

>>> So I should work on the external ports without devices firstly and
>>> add the sys file for user to control?

>> Yes, I think so. It will be less controversial and probably simpler.
>> When that mechanism is ready, you should be able to use it
>> automatically for unconnectable ports.

>> One tricky thing: In theory, there should be a separate sysfs file for
>> each port. That seems like a lot of overhead though; is there any way
>> to present the information in a single file that won't offend sysfs
>> purists?

> Tianyu proposed having one file per hub, with a bit field that
> controlled each port power. However, I was concerned about different
> userspace applications racing with each other to turn or off ports. For
> example, one app could read the bit field, attempt to power off just
> port 1, but before it can write to the sysfs file, a second app powers
> on port2, and the first app then writes to the sysfs file, leaving port
> 1 powered off, and port 2 powered off, which is not what the second app
> wanted.

> But if you can think of a better way to coalesce the port power off
> mechanisms into one file, we're all ears. :)

How about two files? You write 1 to the bit that matcheas port you want
powered on in the 'poweron' file, and vice versa, you write 1 to the bit that
matches port you want powered off in the 'poweroff' file.

> Sarah Sharp

WBR, Sergei