Module Name:    src
Committed By:   riastradh
Date:           Sun Jul 29 02:01:54 UTC 2018

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

Log Message:
Use callout_halt and usb_rem_task_wait in upgt(4).

Also comment in sketchiness in upgt_newstate that is beyond my scope
right now.


To generate a diff of this commit:
cvs rdiff -u -r1.20 -r1.21 src/sys/dev/usb/if_upgt.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/if_upgt.c
diff -u src/sys/dev/usb/if_upgt.c:1.20 src/sys/dev/usb/if_upgt.c:1.21
--- src/sys/dev/usb/if_upgt.c:1.20	Tue Jun 26 06:48:02 2018
+++ src/sys/dev/usb/if_upgt.c	Sun Jul 29 02:01:54 2018
@@ -1,4 +1,4 @@
-/*	$NetBSD: if_upgt.c,v 1.20 2018/06/26 06:48:02 msaitoh Exp $	*/
+/*	$NetBSD: if_upgt.c,v 1.21 2018/07/29 02:01:54 riastradh Exp $	*/
 /*	$OpenBSD: if_upgt.c,v 1.49 2010/04/20 22:05:43 tedu Exp $ */
 
 /*
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.20 2018/06/26 06:48:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_upgt.c,v 1.21 2018/07/29 02:01:54 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -504,8 +504,10 @@ upgt_detach(device_t self, int flags)
 		upgt_stop(sc);
 
 	/* remove tasks and timeouts */
-	usb_rem_task(sc->sc_udev, &sc->sc_task_newstate);
-	usb_rem_task(sc->sc_udev, &sc->sc_task_tx);
+	callout_halt(&sc->scan_to, NULL);
+	callout_halt(&sc->led_to, NULL);
+	usb_rem_task_wait(sc->sc_udev, &sc->sc_task_newstate, USB_TASKQ_DRIVER);
+	usb_rem_task_wait(sc->sc_udev, &sc->sc_task_tx, USB_TASKQ_DRIVER);
 	callout_destroy(&sc->scan_to);
 	callout_destroy(&sc->led_to);
 
@@ -1346,6 +1348,11 @@ upgt_newstate(struct ieee80211com *ic, e
 {
 	struct upgt_softc *sc = ic->ic_ifp->if_softc;
 
+	/*
+	 * XXXSMP: This does not wait for the task, if it is in flight,
+	 * to complete.  If this code works at all, it must rely on the
+	 * kernel lock to serialize with the USB task thread.
+	 */
 	usb_rem_task(sc->sc_udev, &sc->sc_task_newstate);
 	callout_stop(&sc->scan_to);
 

Reply via email to