Source-Changes-HG archive

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

[src/trunk]: src/sys/dev/usb ehci: Replace bogus polling during suspend by ta...



details:   https://anonhg.NetBSD.org/src/rev/84fe2e559eaa
branches:  trunk
changeset: 1026742:84fe2e559eaa
user:      riastradh <riastradh%NetBSD.org@localhost>
date:      Sun Dec 05 11:05:37 2021 +0000

description:
ehci: Replace bogus polling during suspend by taking bus lock.

The system is not at high IPL or limited to a single CPU at this
point; it is running essentially normally, just with some devices
suspended.  Other threads might be trying to touch EHCI registers,
which might have bad outcomes while we're suspending stuff.  Enabling
polling only makes sense if there is a single thread and single CPU
running, such as when we enter ddb on crash.

diffstat:

 sys/dev/usb/ehci.c |  20 ++++++++------------
 1 files changed, 8 insertions(+), 12 deletions(-)

diffs (69 lines):

diff -r d2045a50f5c7 -r 84fe2e559eaa sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Sun Dec 05 10:13:44 2021 +0000
+++ b/sys/dev/usb/ehci.c        Sun Dec 05 11:05:37 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.286 2021/08/31 08:22:28 mrg Exp $ */
+/*     $NetBSD: ehci.c,v 1.287 2021/12/05 11:05:37 riastradh Exp $ */
 
 /*
  * Copyright (c) 2004-2012,2016,2020 The NetBSD Foundation, Inc.
@@ -54,7 +54,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.286 2021/08/31 08:22:28 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.287 2021/12/05 11:05:37 riastradh Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -1385,10 +1385,6 @@
 /*
  * Handle suspend/resume.
  *
- * We need to switch to polling mode here, because this routine is
- * called from an interrupt context.  This is all right since we
- * are almost suspended anyway.
- *
  * Note that this power handler isn't to be registered directly; the
  * bus glue needs to call out to it.
  */
@@ -1401,9 +1397,7 @@
 
        EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
-       mutex_spin_enter(&sc->sc_intr_lock);
-       sc->sc_bus.ub_usepolling++;
-       mutex_spin_exit(&sc->sc_intr_lock);
+       mutex_enter(&sc->sc_lock);
 
        for (i = 1; i <= sc->sc_noport; i++) {
                cmd = EOREAD4(sc, EHCI_PORTSC(i)) & ~EHCI_PS_CLEAR;
@@ -1439,9 +1433,7 @@
        if (hcr != EHCI_STS_HCH)
                printf("%s: config timeout\n", device_xname(dv));
 
-       mutex_spin_enter(&sc->sc_intr_lock);
-       sc->sc_bus.ub_usepolling--;
-       mutex_spin_exit(&sc->sc_intr_lock);
+       mutex_exit(&sc->sc_lock);
 
        return true;
 }
@@ -1455,6 +1447,8 @@
 
        EHCIHIST_FUNC(); EHCIHIST_CALLED();
 
+       mutex_enter(&sc->sc_lock);
+
        /* restore things in case the bios sucks */
        EOWRITE4(sc, EHCI_CTRLDSSEGMENT, 0);
        EOWRITE4(sc, EHCI_PERIODICLISTBASE, DMAADDR(&sc->sc_fldma, 0));
@@ -1500,6 +1494,8 @@
        if (hcr == EHCI_STS_HCH)
                printf("%s: config timeout\n", device_xname(dv));
 
+       mutex_exit(&sc->sc_lock);
+
        return true;
 }
 



Home | Main Index | Thread Index | Old Index