Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/usb Use callout_halt and usb_rem_task_wait in zyd(4)...



details:   https://anonhg.NetBSD.org/src/rev/281e0111e91d
branches:  trunk
changeset: 834132:281e0111e91d
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Jul 29 02:07:33 2018 +0000

description:
Use callout_halt and usb_rem_task_wait in zyd(4) detach.

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

diffstat:

 sys/dev/usb/if_zyd.c |  15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)

diffs (44 lines):

diff -r 782d77f457ed -r 281e0111e91d sys/dev/usb/if_zyd.c
--- a/sys/dev/usb/if_zyd.c      Sun Jul 29 02:07:22 2018 +0000
+++ b/sys/dev/usb/if_zyd.c      Sun Jul 29 02:07:33 2018 +0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: if_zyd.c,v 1.52 2007/02/11 00:08:04 jsg Exp $ */
-/*     $NetBSD: if_zyd.c,v 1.48 2018/06/26 06:48:02 msaitoh Exp $      */
+/*     $NetBSD: if_zyd.c,v 1.49 2018/07/29 02:07:33 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2006 by Damien Bergamini <damien.bergamini%free.fr@localhost>
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.48 2018/06/26 06:48:02 msaitoh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_zyd.c,v 1.49 2018/07/29 02:07:33 riastradh Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -466,9 +466,9 @@
        s = splusb();
 
        zyd_stop(ifp, 1);
-       usb_rem_task(sc->sc_udev, &sc->sc_task);
-       callout_stop(&sc->sc_scan_ch);
-       callout_stop(&sc->sc_amrr_ch);
+       callout_halt(&sc->sc_scan_ch, NULL);
+       callout_halt(&sc->sc_amrr_ch, NULL);
+       usb_rem_task_wait(sc->sc_udev, &sc->sc_task, USB_TASKQ_DRIVER);
 
        /* Abort, etc. done by zyd_stop */
        zyd_close_pipes(sc);
@@ -761,6 +761,11 @@
        if (!sc->attached)
                return ENXIO;
 
+       /*
+        * 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);
        callout_stop(&sc->sc_scan_ch);
        callout_stop(&sc->sc_amrr_ch);



Home | Main Index | Thread Index | Old Index