Module Name:    src
Committed By:   riastradh
Date:           Thu Mar  3 05:48:45 UTC 2022

Modified Files:
        src/sys/dev/usb: usbnet.c

Log Message:
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.


To generate a diff of this commit:
cvs rdiff -u -r1.58 -r1.59 src/sys/dev/usb/usbnet.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/dev/usb/usbnet.c
diff -u src/sys/dev/usb/usbnet.c:1.58 src/sys/dev/usb/usbnet.c:1.59
--- src/sys/dev/usb/usbnet.c:1.58	Thu Mar  3 05:48:37 2022
+++ src/sys/dev/usb/usbnet.c	Thu Mar  3 05:48:45 2022
@@ -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 @@ usbnet_detach(device_t self, int flags)
 	}
 	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);
 

Reply via email to