Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Fix missing workqueue_destroy(). ok by msaitoh@n.o



details:   https://anonhg.NetBSD.org/src/rev/1675f7d95847
branches:  trunk
changeset: 744398:1675f7d95847
user:      knakahara <knakahara%NetBSD.org@localhost>
date:      Fri Jan 31 12:04:57 2020 +0000

description:
Fix missing workqueue_destroy().  ok by msaitoh@n.o

diffstat:

 sys/dev/pci/if_wm.c |  17 +++++++++++++++--
 1 files changed, 15 insertions(+), 2 deletions(-)

diffs (45 lines):

diff -r 8b6cdcddf90d -r 1675f7d95847 sys/dev/pci/if_wm.c
--- a/sys/dev/pci/if_wm.c       Fri Jan 31 12:03:23 2020 +0000
+++ b/sys/dev/pci/if_wm.c       Fri Jan 31 12:04:57 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wm.c,v 1.664 2020/01/31 12:03:23 knakahara Exp $    */
+/*     $NetBSD: if_wm.c,v 1.665 2020/01/31 12:04:57 knakahara Exp $    */
 
 /*
  * Copyright (c) 2001, 2002, 2003, 2004 Wasabi Systems, Inc.
@@ -82,7 +82,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.664 2020/01/31 12:03:23 knakahara Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wm.c,v 1.665 2020/01/31 12:04:57 knakahara Exp $");
 
 #ifdef _KERNEL_OPT
 #include "opt_net_mpsafe.h"
@@ -3127,6 +3127,9 @@
        }
        pci_intr_release(sc->sc_pc, sc->sc_intrs, sc->sc_nintrs);
 
+       /* wm_stop() ensure workqueue is stopped. */
+       workqueue_destroy(sc->sc_queue_wq);
+
        for (i = 0; i < sc->sc_nqueues; i++)
                softint_disestablish(sc->sc_queue[i].wmq_si);
 
@@ -6401,6 +6404,16 @@
        WM_CORE_LOCK(sc);
        wm_stop_locked(ifp, disable);
        WM_CORE_UNLOCK(sc);
+
+       /*
+        * After wm_set_stopping_flags(), it is guaranteed
+        * wm_handle_queue_work() does not call workqueue_enqueue().
+        * However, workqueue_wait() cannot call in wm_stop_locked()
+        * because it can sleep...
+        * so, call workqueue_wait() here.
+        */
+       for (int i = 0; i < sc->sc_nqueues; i++)
+               workqueue_wait(sc->sc_queue_wq, &sc->sc_queue[i].wmq_cookie);
 }
 
 static void



Home | Main Index | Thread Index | Old Index