On Wed, 28 Apr 2004 15:09:39 -0400 (EDT)
Alan Stern <[EMAIL PROTECTED]> wrote:

> > Perhaps I could keep the proc_ioctls from running until the device isn't
> > being used by usb-storage,
> 
> That sounds feasible.

It is feasible, but it runs into difficulties with locking order.
I tried to fiddle with the patch Stuart dropped into RH Bugzilla.
I do not have a confidence in it, and unfortunately, the 2.4 development
is closed. I do not want to push it to Marcelo and collect failure
reports at this stage of development.

> >  or maybe just make the transport layer of
> > usb-storage retry the clear_feature command for a while if the pipe
> > already has an URB going, instead of simply failing and moving on to
> > the next step without clearing the stall...?
> 
> You could do that.  Check for -ENXIO error codes and retry in a short 
> loop with usb_stor_control_msg().

Stuart, why don't we do something like the attached? Please back out
your patch with semaphores and give it a try, tell me how it went.

Busy waits are bad, I know. HOWEVER, this particular thing is clearly
local in its scope. THEREFORE, if it solves your problem, I can ship
it with Red Hat and even push to Marcelo.

Critique and testing are appreciated.

-- Pete

diff -urN -X dontdiff linux-2.4.26/drivers/usb/storage/transport.c 
linux-2.4.26-nip/drivers/usb/storage/transport.c
--- linux-2.4.26/drivers/usb/storage/transport.c        2004-02-26 14:09:59.000000000 
-0800
+++ linux-2.4.26-nip/drivers/usb/storage/transport.c    2004-04-30 11:07:18.000000000 
-0700
@@ -471,6 +471,7 @@
        int result;
        int endp = usb_pipeendpoint(pipe) | (usb_pipein(pipe) << 7);
 
+retry_devio:
        result = usb_stor_control_msg(us,
                usb_sndctrlpipe(us->pusb_dev, 0),
                USB_REQ_CLEAR_FEATURE, USB_RECIP_ENDPOINT, 0,
@@ -478,8 +479,21 @@
        US_DEBUGP("usb_stor_clear_halt: result=%d\n", result);
 
        /* this is a failure case */
-       if (result < 0)
+       if (result < 0) {
+               if (result == -ENXIO) {
+                       /*
+                        * usb-uhci cannot queue. If lsusb ran on this device
+                        * (by a startup script or something), we lose.
+                        * But we cannot afford for halts not to clear
+                        * for a reason so silly, so we persist rudely.
+                        */
+                       set_current_state(TASK_UNINTERRUPTIBLE);
+                       schedule_timeout(2);
+                       set_current_state(TASK_RUNNING);
+                       goto retry_devio;
+               }
                return result;
+       }
 
        /* reset the toggles and endpoint flags */
        usb_endpoint_running(us->pusb_dev, usb_pipeendpoint(pipe),


-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE. 
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to