Source-Changes-HG archive

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

[src/netbsd-7]: src/sys/dev/usb Pull up following revision(s) (requested by r...



details:   https://anonhg.NetBSD.org/src/rev/1ff0647d4ef4
branches:  netbsd-7
changeset: 800516:1ff0647d4ef4
user:      martin <martin%NetBSD.org@localhost>
date:      Wed Aug 08 10:17:11 2018 +0000

description:
Pull up following revision(s) (requested by riastradh in ticket #1626):

        sys/dev/usb/if_cue.c: revision 1.80
        sys/dev/usb/umcs.c: revision 1.11
        sys/dev/usb/umcs.c: revision 1.12
        sys/dev/usb/if_ural.c: revision 1.56
        sys/dev/usb/if_run.c: revision 1.28
        sys/dev/usb/if_ural.c: revision 1.57
        sys/dev/usb/if_run.c: revision 1.29
        sys/dev/usb/uatp.c: revision 1.16
        sys/dev/usb/uatp.c: revision 1.17
        sys/dev/usb/if_axe.c: revision 1.91
        sys/dev/usb/if_axe.c: revision 1.92
        sys/dev/usb/if_zyd.c: revision 1.49
        sys/dev/usb/if_axen.c: revision 1.15
        sys/dev/usb/if_url.c: revision 1.60
        sys/dev/usb/if_udav.c: revision 1.54
        sys/dev/usb/if_axen.c: revision 1.16
        sys/dev/usb/if_udav.c: revision 1.55
        sys/dev/usb/if_athn_usb.c: revision 1.28
        sys/dev/usb/if_athn_usb.c: revision 1.29
        sys/dev/usb/if_urtw.c: revision 1.16
        sys/dev/usb/if_urtw.c: revision 1.17
        sys/dev/usb/if_cue.c: revision 1.79
        sys/dev/usb/if_rum.c: revision 1.62
        sys/dev/usb/if_urtwn.c: revision 1.61
        sys/dev/usb/if_rum.c: revision 1.63
        sys/dev/usb/if_urtwn.c: revision 1.63
        sys/dev/usb/usb.c: revision 1.170
        sys/dev/usb/usb.c: revision 1.171
        sys/dev/usb/if_smsc.c: revision 1.35
        sys/dev/usb/if_smsc.c: revision 1.36
        sys/dev/usb/if_zyd.c: revision 1.50
        sys/dev/usb/if_aue.c: revision 1.144
        sys/dev/usb/if_aue.c: revision 1.145
        sys/dev/usb/usb_subr.c: revision 1.225
        sys/dev/usb/usb_subr.c: revision 1.226
        sys/dev/usb/if_upgt.c: revision 1.21
        sys/dev/usb/usbdi.h: revision 1.93
        sys/dev/usb/if_upgt.c: revision 1.22
        sys/dev/usb/if_url.c: revision 1.59
        sys/dev/usb/usbdi.h: revision 1.95
        sys/dev/usb/if_otus.c: revision 1.34
        sys/dev/usb/if_atu.c: revision 1.62
        sys/dev/usb/if_otus.c: revision 1.35
        sys/dev/usb/if_atu.c: revision 1.63

New function usb_rem_task_wait(dev, task, queue).

If task is scheduled to run, removes it from the queue.  If it may
have already begun to run, waits for it to complete.  Caller must
guarantee it will not switch to another queue.  If caller guarantees
it will not be scheduled again, then usb_rem_task_wait guarantees it
is not running on return.

This will enable us to fix a litany of bugs in detach where we
currently fail to wait for a pending task.

Use usb_rem_task_wait in various drivers.

diffstat:

 sys/dev/usb/if_athn_usb.c |  10 +++--
 sys/dev/usb/if_atu.c      |   6 +-
 sys/dev/usb/if_aue.c      |  19 ++++++---
 sys/dev/usb/if_axe.c      |  12 ++---
 sys/dev/usb/if_axen.c     |  12 ++---
 sys/dev/usb/if_cue.c      |  19 ++++++---
 sys/dev/usb/if_otus.c     |   6 +-
 sys/dev/usb/if_rum.c      |  15 +++++--
 sys/dev/usb/if_run.c      |   9 +++-
 sys/dev/usb/if_smsc.c     |  14 +++----
 sys/dev/usb/if_udav.c     |  12 +++--
 sys/dev/usb/if_upgt.c     |  17 ++++++--
 sys/dev/usb/if_ural.c     |  15 +++++--
 sys/dev/usb/if_url.c      |  19 +++++++--
 sys/dev/usb/if_urtw.c     |  16 ++++++--
 sys/dev/usb/if_urtwn.c    |  11 +++--
 sys/dev/usb/if_zyd.c      |  15 +++++--
 sys/dev/usb/uatp.c        |   7 ++-
 sys/dev/usb/umcs.c        |   7 ++-
 sys/dev/usb/usb.c         |  89 ++++++++++++++++++++++++++++++++++++++++++++--
 sys/dev/usb/usb_subr.c    |   7 ++-
 sys/dev/usb/usbdi.h       |   4 +-
 22 files changed, 240 insertions(+), 101 deletions(-)

diffs (truncated from 890 to 300 lines):

diff -r 9bb1c0df5a60 -r 1ff0647d4ef4 sys/dev/usb/if_athn_usb.c
--- a/sys/dev/usb/if_athn_usb.c Tue Aug 07 16:07:49 2018 +0000
+++ b/sys/dev/usb/if_athn_usb.c Wed Aug 08 10:17:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_athn_usb.c,v 1.6.6.3 2018/02/19 19:33:06 snj Exp $  */
+/*     $NetBSD: if_athn_usb.c,v 1.6.6.4 2018/08/08 10:17:11 martin Exp $       */
 /*     $OpenBSD: if_athn_usb.c,v 1.12 2013/01/14 09:50:31 jsing Exp $  */
 
 /*-
@@ -22,7 +22,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.6.3 2018/02/19 19:33:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_athn_usb.c,v 1.6.6.4 2018/08/08 10:17:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -334,7 +334,8 @@
        athn_usb_free_tx_cmd(usc);
        athn_usb_free_tx_msg(usc);
        athn_usb_close_pipes(usc);
-       usb_rem_task(usc->usc_udev, &usc->usc_task);
+       usb_rem_task_wait(usc->usc_udev, &usc->usc_task, USB_TASKQ_DRIVER,
+           NULL);
 
        cv_destroy(&usc->usc_cmd_cv);
        cv_destroy(&usc->usc_msg_cv);
@@ -500,7 +501,8 @@
 
        athn_usb_wait_async(usc);
 
-       usb_rem_task(usc->usc_udev, &usc->usc_task);
+       usb_rem_task_wait(usc->usc_udev, &usc->usc_task, USB_TASKQ_DRIVER,
+           NULL);
 
        /* Abort Tx/Rx pipes. */
        athn_usb_abort_pipes(usc);
diff -r 9bb1c0df5a60 -r 1ff0647d4ef4 sys/dev/usb/if_atu.c
--- a/sys/dev/usb/if_atu.c      Tue Aug 07 16:07:49 2018 +0000
+++ b/sys/dev/usb/if_atu.c      Wed Aug 08 10:17:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_atu.c,v 1.49.10.2 2018/02/19 19:33:06 snj Exp $ */
+/*     $NetBSD: if_atu.c,v 1.49.10.3 2018/08/08 10:17:11 martin Exp $ */
 /*     $OpenBSD: if_atu.c,v 1.48 2004/12/30 01:53:21 dlg Exp $ */
 /*
  * Copyright (c) 2003, 2004
@@ -48,7 +48,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.49.10.2 2018/02/19 19:33:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_atu.c,v 1.49.10.3 2018/08/08 10:17:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -2241,7 +2241,7 @@
        ifp->if_flags &= ~(IFF_RUNNING | IFF_OACTIVE);
        ifp->if_timer = 0;
 
-       usb_rem_task(sc->atu_udev, &sc->sc_task);
+       usb_rem_task_wait(sc->atu_udev, &sc->sc_task, USB_TASKQ_DRIVER, NULL);
        ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
 
        /* Stop transfers. */
diff -r 9bb1c0df5a60 -r 1ff0647d4ef4 sys/dev/usb/if_aue.c
--- a/sys/dev/usb/if_aue.c      Tue Aug 07 16:07:49 2018 +0000
+++ b/sys/dev/usb/if_aue.c      Wed Aug 08 10:17:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_aue.c,v 1.132.2.2 2018/02/19 19:33:06 snj Exp $     */
+/*     $NetBSD: if_aue.c,v 1.132.2.3 2018/08/08 10:17:11 martin Exp $  */
 
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
@@ -77,7 +77,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.132.2.2 2018/02/19 19:33:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_aue.c,v 1.132.2.3 2018/08/08 10:17:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -883,13 +883,18 @@
                return 0;
        }
 
-       callout_stop(&sc->aue_stat_ch);
        /*
-        * Remove any pending tasks.  They cannot be executing because they run
-        * in the same thread as detach.
+        * XXX Halting callout guarantees no more tick tasks.  What
+        * guarantees no more stop tasks?  What guarantees no more
+        * calls to aue_send?  Don't we need to wait for if_detach or
+        * something?  Should we set sc->aue_dying here?  Is device
+        * deactivation guaranteed to have already happened?
         */
-       usb_rem_task(sc->aue_udev, &sc->aue_tick_task);
-       usb_rem_task(sc->aue_udev, &sc->aue_stop_task);
+       callout_halt(&sc->aue_stat_ch, NULL);
+       usb_rem_task_wait(sc->aue_udev, &sc->aue_tick_task, USB_TASKQ_DRIVER,
+           NULL);
+       usb_rem_task_wait(sc->aue_udev, &sc->aue_stop_task, USB_TASKQ_DRIVER,
+           NULL);
 
        sc->aue_closing = 1;
 
diff -r 9bb1c0df5a60 -r 1ff0647d4ef4 sys/dev/usb/if_axe.c
--- a/sys/dev/usb/if_axe.c      Tue Aug 07 16:07:49 2018 +0000
+++ b/sys/dev/usb/if_axe.c      Wed Aug 08 10:17:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axe.c,v 1.67.2.3 2018/02/19 19:33:06 snj Exp $      */
+/*     $NetBSD: if_axe.c,v 1.67.2.4 2018/08/08 10:17:11 martin Exp $   */
 /*     $OpenBSD: if_axe.c,v 1.137 2016/04/13 11:03:37 mpi Exp $ */
 
 /*
@@ -87,7 +87,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.67.2.3 2018/02/19 19:33:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axe.c,v 1.67.2.4 2018/08/08 10:17:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -1123,11 +1123,9 @@
        if (sc->axe_ep[AXE_ENDPT_INTR] != NULL)
                usbd_abort_pipe(sc->axe_ep[AXE_ENDPT_INTR]);
 
-       /*
-        * Remove any pending tasks.  They cannot be executing because they run
-        * in the same thread as detach.
-        */
-       usb_rem_task(sc->axe_udev, &sc->axe_tick_task);
+       callout_halt(&sc->axe_stat_ch, NULL);
+       usb_rem_task_wait(sc->axe_udev, &sc->axe_tick_task, USB_TASKQ_DRIVER,
+           NULL);
 
        s = splusb();
 
diff -r 9bb1c0df5a60 -r 1ff0647d4ef4 sys/dev/usb/if_axen.c
--- a/sys/dev/usb/if_axen.c     Tue Aug 07 16:07:49 2018 +0000
+++ b/sys/dev/usb/if_axen.c     Wed Aug 08 10:17:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_axen.c,v 1.3.2.3 2018/02/19 19:33:06 snj Exp $      */
+/*     $NetBSD: if_axen.c,v 1.3.2.4 2018/08/08 10:17:11 martin Exp $   */
 /*     $OpenBSD: if_axen.c,v 1.3 2013/10/21 10:10:22 yuo Exp $ */
 
 /*
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.3.2.3 2018/02/19 19:33:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_axen.c,v 1.3.2.4 2018/08/08 10:17:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -834,11 +834,9 @@
 
        sc->axen_dying = true;
 
-       /*
-        * Remove any pending tasks.  They cannot be executing because they run
-        * in the same thread as detach.
-        */
-       usb_rem_task(sc->axen_udev, &sc->axen_tick_task);
+       callout_halt(&sc->axen_stat_ch, NULL);
+       usb_rem_task_wait(sc->axen_udev, &sc->axen_tick_task,
+           USB_TASKQ_DRIVER, NULL);
 
        s = splusb();
 
diff -r 9bb1c0df5a60 -r 1ff0647d4ef4 sys/dev/usb/if_cue.c
--- a/sys/dev/usb/if_cue.c      Tue Aug 07 16:07:49 2018 +0000
+++ b/sys/dev/usb/if_cue.c      Wed Aug 08 10:17:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_cue.c,v 1.68.2.2 2018/02/19 19:33:06 snj Exp $      */
+/*     $NetBSD: if_cue.c,v 1.68.2.3 2018/08/08 10:17:11 martin Exp $   */
 /*
  * Copyright (c) 1997, 1998, 1999, 2000
  *     Bill Paul <wpaul%ee.columbia.edu@localhost>.  All rights reserved.
@@ -56,7 +56,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.68.2.2 2018/02/19 19:33:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_cue.c,v 1.68.2.3 2018/08/08 10:17:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_inet.h"
@@ -581,13 +581,18 @@
 
        DPRINTFN(2,("%s: %s: enter\n", device_xname(sc->cue_dev), __func__));
 
-       callout_stop(&sc->cue_stat_ch);
        /*
-        * Remove any pending task.  It cannot be executing because it run
-        * in the same thread as detach.
+        * XXX Halting callout guarantees no more tick tasks.  What
+        * guarantees no more stop tasks?  What guarantees no more
+        * calls to cue_send?  Don't we need to wait for if_detach or
+        * something?  Should we set sc->cue_dying here?  Is device
+        * deactivation guaranteed to have already happened?
         */
-       usb_rem_task(sc->cue_udev, &sc->cue_tick_task);
-       usb_rem_task(sc->cue_udev, &sc->cue_stop_task);
+       callout_halt(&sc->cue_stat_ch, NULL);
+       usb_rem_task_wait(sc->cue_udev, &sc->cue_tick_task, USB_TASKQ_DRIVER,
+           NULL);
+       usb_rem_task_wait(sc->cue_udev, &sc->cue_stop_task, USB_TASKQ_DRIVER,
+           NULL);
 
        if (!sc->cue_attached) {
                /* Detached before attached finished, so just bail out. */
diff -r 9bb1c0df5a60 -r 1ff0647d4ef4 sys/dev/usb/if_otus.c
--- a/sys/dev/usb/if_otus.c     Tue Aug 07 16:07:49 2018 +0000
+++ b/sys/dev/usb/if_otus.c     Wed Aug 08 10:17:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_otus.c,v 1.25.4.2 2018/02/19 19:33:06 snj Exp $     */
+/*     $NetBSD: if_otus.c,v 1.25.4.3 2018/08/08 10:17:11 martin Exp $  */
 /*     $OpenBSD: if_otus.c,v 1.18 2010/08/27 17:08:00 jsg Exp $        */
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.25.4.2 2018/02/19 19:33:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_otus.c,v 1.25.4.3 2018/08/08 10:17:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -705,7 +705,7 @@
        if (ifp != NULL)        /* Failed to attach properly */
                otus_stop(ifp);
 
-       usb_rem_task(sc->sc_udev, &sc->sc_task);
+       usb_rem_task_wait(sc->sc_udev, &sc->sc_task, USB_TASKQ_DRIVER, NULL);
        callout_destroy(&sc->sc_scan_to);
        callout_destroy(&sc->sc_calib_to);
 
diff -r 9bb1c0df5a60 -r 1ff0647d4ef4 sys/dev/usb/if_rum.c
--- a/sys/dev/usb/if_rum.c      Tue Aug 07 16:07:49 2018 +0000
+++ b/sys/dev/usb/if_rum.c      Wed Aug 08 10:17:11 2018 +0000
@@ -1,5 +1,5 @@
 /*     $OpenBSD: if_rum.c,v 1.40 2006/09/18 16:20:20 damien Exp $      */
-/*     $NetBSD: if_rum.c,v 1.48.4.2 2018/02/19 19:33:06 snj Exp $      */
+/*     $NetBSD: if_rum.c,v 1.48.4.3 2018/08/08 10:17:11 martin Exp $   */
 
 /*-
  * Copyright (c) 2005-2007 Damien Bergamini <damien.bergamini%free.fr@localhost>
@@ -24,7 +24,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.48.4.2 2018/02/19 19:33:06 snj Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_rum.c,v 1.48.4.3 2018/08/08 10:17:11 martin Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_usb.h"
@@ -507,9 +507,9 @@
        s = splusb();
 
        rum_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, NULL);
 
        bpf_detach(ifp);
        ieee80211_ifdetach(ic); /* free all nodes */
@@ -746,6 +746,11 @@
 {
        struct rum_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);
        callout_stop(&sc->sc_scan_ch);
        callout_stop(&sc->sc_amrr_ch);
diff -r 9bb1c0df5a60 -r 1ff0647d4ef4 sys/dev/usb/if_run.c
--- a/sys/dev/usb/if_run.c      Tue Aug 07 16:07:49 2018 +0000
+++ b/sys/dev/usb/if_run.c      Wed Aug 08 10:17:11 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_run.c,v 1.10.4.3 2018/02/19 19:33:06 snj Exp $      */
+/*     $NetBSD: if_run.c,v 1.10.4.4 2018/08/08 10:17:11 martin Exp $   */
 /*     $OpenBSD: if_run.c,v 1.90 2012/03/24 15:11:04 jsg Exp $ */
 
 /*-
@@ -23,7 +23,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_run.c,v 1.10.4.3 2018/02/19 19:33:06 snj Exp $");



Home | Main Index | Thread Index | Old Index