Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb usbnet: Don't waste time calling uno_stop if dev...



details:   https://anonhg.NetBSD.org/src/rev/88fd3a4d5482
branches:  trunk
changeset: 362508:88fd3a4d5482
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 03 05:49:58 2022 +0000

description:
usbnet: Don't waste time calling uno_stop if device is detaching.

The hardware is most likely gone, so trying to write to its registers
(and, in some cases, wait until a timeout for a device to reset) is a
waste of time.  Even if it was detached only in software with drvctl,
reattaching it will reset the device anyway.

diffstat:

 sys/dev/usb/usbnet.c |  11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)

diffs (33 lines):

diff -r 24e29811fc6f -r 88fd3a4d5482 sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Thu Mar 03 05:49:51 2022 +0000
+++ b/sys/dev/usb/usbnet.c      Thu Mar 03 05:49:58 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.67 2022/03/03 05:49:44 riastradh Exp $    */
+/*     $NetBSD: usbnet.c,v 1.68 2022/03/03 05:49:58 riastradh Exp $    */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.67 2022/03/03 05:49:44 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.68 2022/03/03 05:49:58 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1154,8 +1154,13 @@
         * the hardware.  The driver's uno_stop routine now has
         * exclusive access to any registers that might previously have
         * been used by to ifmedia, mii, or ioctl callbacks.
+        *
+        * Don't bother if the device is being detached, though -- if
+        * it's been unplugged then there's no point in trying to touch
+        * the registers.
         */
-       uno_stop(un, ifp, disable);
+       if (!unp->unp_dying)
+               uno_stop(un, ifp, disable);
 
        /* Stop transfers. */
        usbnet_ep_stop_pipes(un);



Home | Main Index | Thread Index | Old Index