Source-Changes-HG archive

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

[src/jmcneill-usbmp]: src/sys/dev/usb need to ensure kpreempt_disable() for s...



details:   https://anonhg.NetBSD.org/src/rev/9c684784953d
branches:  jmcneill-usbmp
changeset: 771778:9c684784953d
user:      mrg <mrg%NetBSD.org@localhost>
date:      Tue Dec 06 02:10:01 2011 +0000

description:
need to ensure kpreempt_disable() for softint_schedule().

fix the locking in ohci_timeout_task(), ohci_device_isoc_start(),
ohci_device_isoc_abort() and ohci_device_isoc_close().

uaudio(4) can still play with these, but mixerctl -a against it will
hang the writer.  however, mixerctl continues to run in a tight loop
and the system isn't soft-locked up at this point, an advance from
how it is in -current.

diffstat:

 sys/dev/usb/ehci.c |   8 ++++++--
 sys/dev/usb/ohci.c |  18 +++++++++---------
 sys/dev/usb/usb.c  |   8 ++++++--
 3 files changed, 21 insertions(+), 13 deletions(-)

diffs (143 lines):

diff -r e58c7e324bef -r 9c684784953d sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c        Sun Dec 04 21:02:27 2011 +0000
+++ b/sys/dev/usb/ehci.c        Tue Dec 06 02:10:01 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ehci.c,v 1.181.6.2 2011/12/04 19:22:56 jmcneill Exp $ */
+/*     $NetBSD: ehci.c,v 1.181.6.3 2011/12/06 02:10:01 mrg Exp $ */
 
 /*
  * Copyright (c) 2004-2011 The NetBSD Foundation, Inc.
@@ -53,7 +53,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.181.6.2 2011/12/04 19:22:56 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.181.6.3 2011/12/06 02:10:01 mrg Exp $");
 
 #include "ohci.h"
 #include "uhci.h"
@@ -652,7 +652,9 @@
        sc->sc_bus.no_intrs++;
        if (eintrs & EHCI_STS_IAA) {
                DPRINTF(("ehci_intr1: door bell\n"));
+               kpreempt_disable();
                softint_schedule(sc->sc_doorbell_si);
+               kpreempt_enable();
                eintrs &= ~EHCI_STS_IAA;
        }
        if (eintrs & (EHCI_STS_INT | EHCI_STS_ERRINT)) {
@@ -668,7 +670,9 @@
                /* XXX what else */
        }
        if (eintrs & EHCI_STS_PCD) {
+               kpreempt_disable();
                softint_schedule(sc->sc_pcd_si);
+               kpreempt_enable();
                eintrs &= ~EHCI_STS_PCD;
        }
 
diff -r e58c7e324bef -r 9c684784953d sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c        Sun Dec 04 21:02:27 2011 +0000
+++ b/sys/dev/usb/ohci.c        Tue Dec 06 02:10:01 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: ohci.c,v 1.218.6.2 2011/12/04 21:02:27 jmcneill Exp $  */
+/*     $NetBSD: ohci.c,v 1.218.6.3 2011/12/06 02:10:01 mrg Exp $       */
 /*     $FreeBSD: src/sys/dev/usb/ohci.c,v 1.22 1999/11/17 22:33:40 n_hibma Exp $       */
 
 /*
@@ -42,7 +42,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.2 2011/12/04 21:02:27 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.3 2011/12/06 02:10:01 mrg Exp $");
 
 #include "opt_usb.h"
 
@@ -2020,14 +2020,10 @@
 ohci_timeout_task(void *addr)
 {
        usbd_xfer_handle xfer = addr;
-       ohci_softc_t *sc = xfer->pipe->device->bus->hci_private;
 
        DPRINTF(("ohci_timeout_task: xfer=%p\n", xfer));
 
-       KASSERT(mutex_owned(&sc->sc_lock));
-       //mutex_enter(&sc->sc_lock);
        ohci_abort_xfer(xfer, USBD_TIMEOUT);
-       //mutex_exit(&sc->sc_lock);
 }
 
 #ifdef OHCI_DEBUG
@@ -3540,6 +3536,8 @@
 
        /* XXX anything to do? */
 
+       mutex_exit(&sc->sc_lock);
+
        return (USBD_IN_PROGRESS);
 }
 
@@ -3551,9 +3549,9 @@
        ohci_soft_ed_t *sed;
        ohci_soft_itd_t *sitd;
 
-       DPRINTFN(1,("ohci_device_isoc_abort: xfer=%p\n", xfer));
-
-       KASSERT(mutex_owned(&sc->sc_lock));
+       DPRINTFN(1,("ohci_device_isoc_abort: xfer=%p lock=%p\n", xfer, &sc->sc_lock));
+
+       mutex_enter(&sc->sc_lock);
 
        /* Transfer is already done. */
        if (xfer->status != USBD_NOT_STARTED &&
@@ -3635,9 +3633,11 @@
        ohci_softc_t *sc = pipe->device->bus->hci_private;
 
        DPRINTF(("ohci_device_isoc_close: pipe=%p\n", pipe));
+       mutex_enter(&sc->sc_lock);
        ohci_close_pipe(pipe, sc->sc_isoc_head);
 #ifdef DIAGNOSTIC
        opipe->tail.itd->isdone = 1;
 #endif
+       mutex_exit(&sc->sc_lock);
        ohci_free_sitd(sc, opipe->tail.itd);
 }
diff -r e58c7e324bef -r 9c684784953d sys/dev/usb/usb.c
--- a/sys/dev/usb/usb.c Sun Dec 04 21:02:27 2011 +0000
+++ b/sys/dev/usb/usb.c Tue Dec 06 02:10:01 2011 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: usb.c,v 1.125.6.1 2011/12/04 13:23:17 jmcneill Exp $   */
+/*     $NetBSD: usb.c,v 1.125.6.2 2011/12/06 02:10:01 mrg Exp $        */
 
 /*
  * Copyright (c) 1998, 2002, 2008 The NetBSD Foundation, Inc.
@@ -37,7 +37,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.125.6.1 2011/12/04 13:23:17 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usb.c,v 1.125.6.2 2011/12/06 02:10:01 mrg Exp $");
 
 #include "opt_compat_netbsd.h"
 #include "opt_usb.h"
@@ -890,7 +890,9 @@
        wakeup(&usb_events);
        selnotify(&usb_selevent, 0, 0);
        if (usb_async_proc != NULL) {
+               kpreempt_disable();
                softint_schedule(usb_async_sih);
+               kpreempt_enable();
        }
        splx(s);
 }
@@ -913,7 +915,9 @@
        if (bus->use_polling) {
                bus->methods->soft_intr(bus);
        } else {
+               kpreempt_disable();
                softint_schedule(bus->soft);
+               kpreempt_enable();
        }
 }
 



Home | Main Index | Thread Index | Old Index