Re: Overcurrent behavior of linux usb stack

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 10 Jan 2011, Pratyush Anand wrote:

> Hi All,
> 
> As per USB 2.0 specification(Section 11.12.5 Over-current Reporting
> and Recovery):
> 
> When a hub experiences an over-current condition, it must place all
> affected ports in the Powered-off state.
> 
> It does not specify whether this action is to be done by hardware or software.

Yes it does.  It says "When a hub ... it must place ..."  The word "it" 
refers back to the word "hub".  This means that the hub must place all 
affected ports in the Powered-off state.  In others words, the action 
is to be done by hardware.

> I am working with controller where it expects port power off to be
> done by software in case of overcurrent detection interrupt.

Root hubs are different from external hubs.  It is reasonable to expect 
software to turn off port power for root hubs.

> So , implementation would be something like:
> 
> 			if (hubchange & HUB_CHANGE_OVERCURRENT) {
> 				dev_dbg (hub_dev, "overcurrent change\n");
> 
> hub_power_off(hub);
> 				msleep(500);	/* Cool down */
> 				clear_hub_feature(hdev, C_HUB_OVER_CURRENT);
>                                                     	hub_power_on(hub, true);
> 			}
> 
> Is this implementation correct?

Not really.  The spec also states: "Host waits for over-current status
bit to be cleared to 0".  Your code always waits for 500 ms, which
could be either too long or too short.  On the other hand, you mustn't
wait indefinitely.

Also, you have to do more or less the same thing when any ports report
over-current status.  In this case you would have to first turn off the 
power to all the affected ports, then wait, then turn on power to all 
of them.

Alan Stern

--
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


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux