On Wed, 13 Jul 2005, Li Yang-r58472 wrote:

> Hi,
>  
> While I was working on a device controller driver tested with mass
> storage, I got a question regarding on the stall condition.  For mass
> storage device, the driver stalls the bulk-in ep when there is an error
> processing CBW.  Then the host will send clear_feature to clear the halt
> condition.  However set_halt in all udc drivers always checks if the IN
> ep queue is empty, and returns -EAGAIN when the ep queue is not empty.
>  
> Here comes the problem:
> A problem with CBW is found.  Device stalls bulk-in ep.  Host sends
> clear_feature control transfer.  Gadget layer queues error CSW to the
> bulk-in ep.

That can't happen.  The driver doesn't queue a CSW if it hasn't received a 
valid CBW.

> At this time, the bulk-in ep is halted, there is a CSW request queued in
> the bulk-in ep, and clear_feature can't be executed as the queue is not
> empty.  They form a dead-lock, and stop working.

You're a little confused.  Above you mentioned that set_halt fails if the
queue is non-empty, which is correct.  Here you state that clear_halt
fails if the queue is non-empty, and that's wrong.

> How did we do to avoid such a situation?  Or to break it?

You might ask more generally: What happens if the gadget driver tries to 
halt the bulk-in endpoint when there is data in the queue and the host 
isn't reading it?  Answer: The gadget will hang until the host issues 
either a class-specific reset or a USB port reset.

Alan Stern



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
[email protected]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to