Source-Changes-HG archive

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

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



details:   https://anonhg.NetBSD.org/src/rev/8c9739d2277c
branches:  netbsd-9
changeset: 1026770:8c9739d2277c
user:      martin <martin%NetBSD.org@localhost>
date:      Mon Dec 06 19:28:57 2021 +0000

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

        sys/dev/usb/ehci.c: revision 1.287

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 22c7dc319427 -r 8c9739d2277c sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Fri Dec 03 19:51:52 2021 +0000
+++ b/sys/dev/usb/ehci.c        Mon Dec 06 19:28:57 2021 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.267.2.5 2021/09/03 10:25:36 martin Exp $ */
+/*     $NetBSD: ehci.c,v 1.267.2.6 2021/12/06 19:28:57 martin Exp $ */
 
 /*
  * Copyright (c) 2004-2012 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.267.2.5 2021/09/03 10:25:36 martin Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.267.2.6 2021/12/06 19:28:57 martin Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -1384,10 +1384,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.
  */
@@ -1400,9 +1396,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;
@@ -1438,9 +1432,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;
 }
@@ -1454,6 +1446,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));
@@ -1499,6 +1493,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