Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb Fix system freeze when USB NICs with multiple ou...



details:   https://anonhg.NetBSD.org/src/rev/7f8228ce5afa
branches:  trunk
changeset: 448975:7f8228ce5afa
user:      rin <rin%NetBSD.org@localhost>
date:      Sun Feb 17 04:17:31 2019 +0000

description:
Fix system freeze when USB NICs with multiple outstanding transfers
are detached from xhci(4) or ehci(4), that enable up_serialise for
bulk transfers.

The cause of problem is that usbd_ar_pipe() waits xfers of
USBD_NOT_STARTED to be removed, although underlying upm_abort
functions do not remove such queues, as reported by "sc dying".

Therefore, remove xfers of USBD_NOT_STARTED when pipe is closed.

Patch provided by Nick Hudson.

diffstat:

 sys/dev/usb/usbdi.c |  14 +++++++++-----
 1 files changed, 9 insertions(+), 5 deletions(-)

diffs (35 lines):

diff -r 3f1624df053b -r 7f8228ce5afa sys/dev/usb/usbdi.c
--- a/sys/dev/usb/usbdi.c       Sun Feb 17 04:05:41 2019 +0000
+++ b/sys/dev/usb/usbdi.c       Sun Feb 17 04:17:31 2019 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbdi.c,v 1.181 2019/01/10 22:13:07 skrll Exp $        */
+/*     $NetBSD: usbdi.c,v 1.182 2019/02/17 04:17:31 rin Exp $  */
 
 /*
  * Copyright (c) 1998, 2012, 2015 The NetBSD Foundation, Inc.
@@ -32,7 +32,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.181 2019/01/10 22:13:07 skrll Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.182 2019/02/17 04:17:31 rin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -884,9 +884,13 @@
                USBHIST_LOG(usbdebug, "pipe = %#jx xfer = %#jx "
                    "(methods = %#jx)", (uintptr_t)pipe, (uintptr_t)xfer,
                    (uintptr_t)pipe->up_methods, 0);
-               /* Make the HC abort it (and invoke the callback). */
-               pipe->up_methods->upm_abort(xfer);
-               /* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
+               if (xfer->ux_status == USBD_NOT_STARTED) {
+                       SIMPLEQ_REMOVE_HEAD(&pipe->up_queue, ux_next);
+               } else {
+                       /* Make the HC abort it (and invoke the callback). */
+                       pipe->up_methods->upm_abort(xfer);
+                       /* XXX only for non-0 usbd_clear_endpoint_stall(pipe); */
+               }
        }
        pipe->up_aborting = 0;
        return USBD_NORMAL_COMPLETION;



Home | Main Index | Thread Index | Old Index