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: Set and clear IFF_RUNNING slightly earli...



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

description:
usbnet: Set and clear IFF_RUNNING slightly earlier and later.

- Set IFF_RUNNING before any calls to usbnet_rxeof are possible.
- Don't clear IFF_RUNNING until all transfers have been aborted.

diffstat:

 sys/dev/usb/usbnet.c |  27 ++++++++++++++-------------
 1 files changed, 14 insertions(+), 13 deletions(-)

diffs (69 lines):

diff -r 9f423e713523 -r c181dd01394b sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Thu Mar 03 05:46:50 2022 +0000
+++ b/sys/dev/usb/usbnet.c      Thu Mar 03 05:46:58 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.45 2022/03/03 05:46:50 riastradh Exp $    */
+/*     $NetBSD: usbnet.c,v 1.46 2022/03/03 05:46: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.45 2022/03/03 05:46:50 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.46 2022/03/03 05:46:58 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -850,9 +850,6 @@
                goto out;
        }
 
-       /* Start up the receive pipe(s). */
-       usbnet_rx_start_pipes(un);
-
        /* Indicate we are up and running. */
 #if 0
        /* XXX if_mcast_op() can call this without ifnet locked */
@@ -860,6 +857,9 @@
 #endif
        ifp->if_flags |= IFF_RUNNING;
 
+       /* Start up the receive pipe(s). */
+       usbnet_rx_start_pipes(un);
+
        callout_schedule(&unp->unp_stat_ch, hz);
 
 out:
@@ -1126,14 +1126,6 @@
 
        uno_stop(un, ifp, disable);
 
-       /*
-        * XXXSMP Would like to
-        *      KASSERT(IFNET_LOCKED(ifp))
-        * here but the locking order is:
-        *      ifnet -> core_lock -> rxlock -> txlock
-        * and core_lock is already held.
-        */
-       ifp->if_flags &= ~IFF_RUNNING;
        unp->unp_timer = 0;
 
        callout_halt(&unp->unp_stat_ch, &unp->unp_core_lock);
@@ -1150,6 +1142,15 @@
        /* Close pipes. */
        usbnet_ep_close_pipes(un);
 
+       /*
+        * XXXSMP Would like to
+        *      KASSERT(IFNET_LOCKED(ifp))
+        * here but the locking order is:
+        *      ifnet -> core_lock -> rxlock -> txlock
+        * and core_lock is already held.
+        */
+       ifp->if_flags &= ~IFF_RUNNING;
+
        usbnet_unbusy(un);
 }
 



Home | Main Index | Thread Index | Old Index