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: Omit needless callout_halt and usb_rem_t...



details:   https://anonhg.NetBSD.org/src/rev/e2eed9b9a880
branches:  trunk
changeset: 362498:e2eed9b9a880
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Thu Mar 03 05:48:45 2022 +0000

description:
usbnet: Omit needless callout_halt and usb_rem_task_wait.

The callout and tasks cannot be pending at this point -- it is a bug
if usbnet_if_stop failed to quiesce everything, so turn these into
KASSERTs.

diffstat:

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

diffs (35 lines):

diff -r af89d25ed3c6 -r e2eed9b9a880 sys/dev/usb/usbnet.c
--- a/sys/dev/usb/usbnet.c      Thu Mar 03 05:48:37 2022 +0000
+++ b/sys/dev/usb/usbnet.c      Thu Mar 03 05:48:45 2022 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usbnet.c,v 1.58 2022/03/03 05:48:37 riastradh Exp $    */
+/*     $NetBSD: usbnet.c,v 1.59 2022/03/03 05:48:45 riastradh Exp $    */
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.58 2022/03/03 05:48:37 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.59 2022/03/03 05:48:45 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1601,9 +1601,13 @@
        }
        IFNET_UNLOCK(ifp);
 
-       callout_halt(&unp->unp_stat_ch, NULL);
-       usb_rem_task_wait(un->un_udev, &unp->unp_ticktask, USB_TASKQ_DRIVER,
-           NULL);
+       /*
+        * The callout and tick task can't be scheduled anew at this
+        * point, and usbnet_if_stop has waited for them to complete.
+        */
+       KASSERT(!callout_pending(&unp->unp_stat_ch));
+       KASSERT(!usb_task_pending(un->un_udev, &unp->unp_ticktask));
+
        usb_rem_task_wait(un->un_udev, &unp->unp_mcasttask, USB_TASKQ_DRIVER,
            NULL);
 



Home | Main Index | Thread Index | Old Index