Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/pci Suspend the getrfkill thread while we're suspended.



details:   https://anonhg.NetBSD.org/src/rev/84c517143156
branches:  trunk
changeset: 365526:84c517143156
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Mon Aug 20 04:50:56 2018 +0000

description:
Suspend the getrfkill thread while we're suspended.

Otherwise it tries to futz with device registers, which doesn't work,
and who knows, maybe is bad.

diffstat:

 sys/dev/pci/if_wpi.c    |  27 ++++++++++++++++++++++++---
 sys/dev/pci/if_wpivar.h |   6 ++++--
 2 files changed, 28 insertions(+), 5 deletions(-)

diffs (87 lines):

diff -r 62088d7a6778 -r 84c517143156 sys/dev/pci/if_wpi.c
--- a/sys/dev/pci/if_wpi.c      Mon Aug 20 02:33:17 2018 +0000
+++ b/sys/dev/pci/if_wpi.c      Mon Aug 20 04:50:56 2018 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: if_wpi.c,v 1.81 2018/08/20 02:33:17 riastradh Exp $    */
+/*     $NetBSD: if_wpi.c,v 1.82 2018/08/20 04:50:56 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2006, 2007
@@ -18,7 +18,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.81 2018/08/20 02:33:17 riastradh Exp $");
+__KERNEL_RCSID(0, "$NetBSD: if_wpi.c,v 1.82 2018/08/20 04:50:56 riastradh Exp $");
 
 /*
  * Driver for Intel PRO/Wireless 3945ABG 802.11 network adapters.
@@ -229,6 +229,8 @@
        }
        mutex_init(&sc->sc_rsw_mtx, MUTEX_DEFAULT, IPL_NONE);
        cv_init(&sc->sc_rsw_cv, "wpirsw");
+       sc->sc_rsw_suspend = false;
+       sc->sc_rsw_suspended = false;
        if (kthread_create(PRI_NONE, 0, NULL,
            wpi_rsw_thread, sc, &sc->sc_rsw_lwp, "%s", device_xname(self))) {
                aprint_error_dev(self, "couldn't create switch thread\n");
@@ -3268,6 +3270,10 @@
                error = EBUSY;
                goto fail1;
        }
+       sc->sc_rsw_suspend = false;
+       cv_broadcast(&sc->sc_rsw_cv);
+       while (sc->sc_rsw_suspend)
+               cv_wait(&sc->sc_rsw_cv, &sc->sc_rsw_mtx);
        mutex_exit(&sc->sc_rsw_mtx);
 
        /* wait for thermal sensors to calibrate */
@@ -3318,6 +3324,14 @@
 
        ieee80211_new_state(ic, IEEE80211_S_INIT, -1);
 
+       /* suspend rfkill test thread */
+       mutex_enter(&sc->sc_rsw_mtx);
+       sc->sc_rsw_suspend = true;
+       cv_broadcast(&sc->sc_rsw_cv);
+       while (!sc->sc_rsw_suspended)
+               cv_wait(&sc->sc_rsw_cv, &sc->sc_rsw_mtx);
+       mutex_exit(&sc->sc_rsw_mtx);
+
        /* disable interrupts */
        WPI_WRITE(sc, WPI_MASK, 0);
        WPI_WRITE(sc, WPI_INTR, WPI_INTR_MASK);
@@ -3463,7 +3477,14 @@
                        mutex_exit(&sc->sc_rsw_mtx);
                        kthread_exit(0);
                }
+               if (sc->sc_rsw_suspend) {
+                       sc->sc_rsw_suspended = true;
+                       cv_broadcast(&sc->sc_rsw_cv);
+                       while (sc->sc_rsw_suspend || sc->sc_dying)
+                               cv_wait(&sc->sc_rsw_cv, &sc->sc_rsw_mtx);
+                       sc->sc_rsw_suspended = false;
+                       cv_broadcast(&sc->sc_rsw_cv);
+               }
                wpi_getrfkill(sc);
        }
 }
-
diff -r 62088d7a6778 -r 84c517143156 sys/dev/pci/if_wpivar.h
--- a/sys/dev/pci/if_wpivar.h   Mon Aug 20 02:33:17 2018 +0000
+++ b/sys/dev/pci/if_wpivar.h   Mon Aug 20 04:50:56 2018 +0000
@@ -1,4 +1,4 @@
-/*  $NetBSD: if_wpivar.h,v 1.21 2017/02/02 10:05:35 nonaka Exp $    */
+/*  $NetBSD: if_wpivar.h,v 1.22 2018/08/20 04:50:56 riastradh Exp $    */
 
 /*-
  * Copyright (c) 2006
@@ -197,5 +197,7 @@
        struct lwp              *sc_rsw_lwp;
        struct kmutex           sc_rsw_mtx;
        struct kcondvar         sc_rsw_cv;
-       int                     sc_dying;
+       bool                    sc_dying;
+       bool                    sc_rsw_suspend;
+       bool                    sc_rsw_suspended;
 };



Home | Main Index | Thread Index | Old Index