That fixed everything, Alan, you are the man!  Thank you so much, if
you need anything else tested just let me know.

On Fri, 13 Aug 2004 11:56:16 -0400 (EDT), Alan Stern
<[EMAIL PROTECTED]> wrote:
> On Fri, 13 Aug 2004, Michael Guterl wrote:
> 
> > Okay I applied this patch to 2.6.8-rc3-mm1 and recorded dmesg's output
> > with no devices attached, after the keyboard was plugged in and
> > unplugged, and then rebooted, plugged the mouse and then unplugged it.
> >  All the corresponding files are attached.  I don't know if this was
> > intended to fix anything or provide more useful output, but it did not
> > fix anything.
> 
> Thanks to both of you for your testing.  (And yes, the patch wasn't
> intended to fix anything but only to provide more useful information --
> which it did.)
> 
> It turns out there are two bugs in the HID core causing this problem:
> 
>     (1) The calls to usb_unlink_urb() in hid_init_reports() are
>         being carried out using synchronous unlinking, since the
>         URB_ASYNC_UNLINK flag isn't set in either the control or
>         the output URB.  Synchronous unlinking prevents resubmission
>         from within the completion handler, which means that
>         hid_submit_ctrl() fails and returns an error code.
> 
>     (2) hid_submit_report() calls hid_submit_out() and hid_submit_ctrl()
>         but doesn't check the return codes.  So if there's an error
>         in submission, the HID_OUT_RUNNING or HID_CTRL_RUNNING bits
>         remain set even though the queue isn't running.  Of course
>         this causes the driver to stop working.
> 
> (1) can be fixed easily enough by setting the URB_ASYNC_UNLINK flag in the
> two URBs.  The patch below includes this change, together with some places
> where I changed usb_unlink_urb() to usb_kill_urb() in cases where
> synchronous unlinking clearly is needed.  However I'm not very familiar
> with the HID driver, so it's possible that setting the flag will have
> other, bad consequences or that some other places need to be changed too.
> 
> I don't know how to fix (2).  Someone who knows the driver will have to do
> this.  Fortunately in your cases, once (1) is fixed then (2) shouldn't
> occur.
> 
> There remains the question of what caused the original timeout that
> started the cascade of bugs.  I can't tell, but maybe it will turn out not
> to matter once the bugs are gone.
> 
> In the meantime, you can try out this patch and see if it helps at all.
> You won't need the previous patch -- although if things still don't work
> you should apply both patches and send the dmesg as before.  It won't be
> surprising if the final fix for these bugs turns out to be quite different
> from the patch below.
> 
> Vojtech, maybe you can look more deeply into these problems and check
> whether my attempted fix for (1) is really okay.
> 
> Alan Stern
> 
> ===== drivers/usb/input/hid-core.c 1.119 vs edited =====
> --- 1.119/drivers/usb/input/hid-core.c  Fri Jul 23 09:29:18 2004
> +++ edited/drivers/usb/input/hid-core.c Fri Aug 13 11:31:17 2004
> @@ -1282,7 +1282,7 @@
>  void hid_close(struct hid_device *hid)
>  {
>         if (!--hid->open)
> -               usb_unlink_urb(hid->urbin);
> +               usb_kill_urb(hid->urbin);
>  }
> 
>  /*
> @@ -1654,7 +1654,8 @@
>                         usb_fill_int_urb(hid->urbout, dev, pipe, hid->outbuf, 0,
>                                          hid_irq_out, hid, interval);
>                         hid->urbout->transfer_dma = hid->outbuf_dma;
> -                       hid->urbout->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
> +                       hid->urbout->transfer_flags |= (URB_ASYNC_UNLINK |
> +                                       URB_NO_TRANSFER_DMA_MAP);
>                 }
>         }
> 
> @@ -1704,8 +1705,8 @@
>                              hid->ctrlbuf, 1, hid_ctrl, hid);
>         hid->urbctrl->setup_dma = hid->cr_dma;
>         hid->urbctrl->transfer_dma = hid->ctrlbuf_dma;
> -       hid->urbctrl->transfer_flags |= (URB_NO_TRANSFER_DMA_MAP
> -                               | URB_NO_SETUP_DMA_MAP);
> +       hid->urbctrl->transfer_flags |= (URB_ASYNC_UNLINK |
> +                       URB_NO_TRANSFER_DMA_MAP | URB_NO_SETUP_DMA_MAP);
> 
>         return hid;
> 
> @@ -1731,9 +1732,9 @@
>                 return;
> 
>         usb_set_intfdata(intf, NULL);
> -       usb_unlink_urb(hid->urbin);
> -       usb_unlink_urb(hid->urbout);
> -       usb_unlink_urb(hid->urbctrl);
> +       usb_kill_urb(hid->urbin);
> +       usb_kill_urb(hid->urbout);
> +       usb_kill_urb(hid->urbctrl);
> 
>         if (hid->claimed & HID_CLAIMED_INPUT)
>                 hidinput_disconnect(hid);
> 
>


-------------------------------------------------------
SF.Net email is sponsored by Shop4tech.com-Lowest price on Blank Media
100pk Sonic DVD-R 4x for only $29 -100pk Sonic DVD+R for only $33
Save 50% off Retail on Ink & Toner - Free Shipping and Free Gift.
http://www.shop4tech.com/z/Inkjet_Cartridges/9_108_r285
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to