Module Name:    src
Committed By:   riastradh
Date:           Thu Mar  3 05:49:37 UTC 2022

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

Log Message:
usbnet: Clear watchdog timer before stopping hardware.

No need to take the lock again -- which might not be necessary
because the callout and task have completed, but let's obviate the
need to think about that.


To generate a diff of this commit:
cvs rdiff -u -r1.65 -r1.66 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.65 src/sys/dev/usb/usbnet.c:1.66
--- src/sys/dev/usb/usbnet.c:1.65	Thu Mar  3 05:49:29 2022
+++ src/sys/dev/usb/usbnet.c	Thu Mar  3 05:49:37 2022
@@ -1,4 +1,4 @@
-/*	$NetBSD: usbnet.c,v 1.65 2022/03/03 05:49:29 riastradh Exp $	*/
+/*	$NetBSD: usbnet.c,v 1.66 2022/03/03 05:49:37 riastradh Exp $	*/
 
 /*
  * Copyright (c) 2019 Matthew R. Green
@@ -31,7 +31,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.65 2022/03/03 05:49:29 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbnet.c,v 1.66 2022/03/03 05:49:37 riastradh Exp $");
 
 #include <sys/param.h>
 #include <sys/kernel.h>
@@ -1128,9 +1128,14 @@ usbnet_stop(struct usbnet *un, struct if
 
 	usbnet_busy(un);
 
+	/*
+	 * Prevent new activity (rescheduling ticks, xfers, &c.) and
+	 * clear the watchdog timer.
+	 */
 	mutex_enter(&unp->unp_rxlock);
 	mutex_enter(&unp->unp_txlock);
 	unp->unp_stopping = true;
+	unp->unp_timer = 0;
 	mutex_exit(&unp->unp_txlock);
 	mutex_exit(&unp->unp_rxlock);
 
@@ -1152,11 +1157,6 @@ usbnet_stop(struct usbnet *un, struct if
 	 */
 	uno_stop(un, ifp, disable);
 
-	/* Clear the watchdog timer.  */
-	mutex_enter(&unp->unp_txlock);
-	unp->unp_timer = 0;
-	mutex_exit(&unp->unp_txlock);
-
 	/* Stop transfers. */
 	usbnet_ep_stop_pipes(un);
 

Reply via email to