> -----Original Message----- > From: Alan Stern [mailto:[EMAIL PROTECTED] > Sent: Wednesday, July 13, 2005 10:21 PM > To: Li Yang-r58472 > Cc: linux-usb-devel@lists.sourceforge.net > Subject: Re: [linux-usb-devel] question about mass storage gadget > > 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.
Ok. Let's change the situation to that client reply shorter DATA than host CBW requested. There will be a stall and CSW. > > > 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. I think it's reasonable to check the queue doing set_halt while ignore it when clear_halt. However, looking into set_halt function in omap udc driver, it returns -EAGAIN when the queue is not empty for both set_halt/clear_halt operations. It should have been tested, which makes me really confused. > > > 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. Yes, that's the phenomenon I got when the clear_halt hangs. Host keep resetting once for a while. > > 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 _______________________________________________ linux-usb-devel@lists.sourceforge.net To unsubscribe, use the last form field at: https://lists.sourceforge.net/lists/listinfo/linux-usb-devel