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 several changes to the MP usb apis, and...
details: https://anonhg.NetBSD.org/src/rev/79c06cfcd52b
branches: jmcneill-usbmp
changeset: 771793:79c06cfcd52b
user: mrg <mrg%NetBSD.org@localhost>
date: Mon Feb 20 02:12:23 2012 +0000
description:
several changes to the MP usb apis, and other misc changes:
- usb_transfer_complete()/usb_insert_transfer()/usb_start_next() all
must have the thread lock held
- (*soft_intr) now is called with the thread lock held unless we are
in polling mode. add a usb_soft_intr() to deal with this
- XXX usbd_set_polling() api exists to increase/decrease the polling
count, but only ukbd uses. everyone else open codes it, but this
should probably be changed
- (*abort) is now called with the thread lock held
- update several comments to not refer to splusb() anymore
- add many more asserts
- use more c99 struct initialisers
diffstat:
sys/dev/usb/ehci.c | 57 ++++++++++++++++++++++-----------------------
sys/dev/usb/ohci.c | 61 +++++++++++++++++++++++++++++++++----------------
sys/dev/usb/uhci.c | 54 +++++++++++++++++++++++++++++++------------
sys/dev/usb/ukbd.c | 10 ++++----
sys/dev/usb/usb.c | 21 ++++++++++++++--
sys/dev/usb/usbdi.c | 23 +++++++++++++-----
sys/dev/usb/usbdivar.h | 11 ++++++--
7 files changed, 155 insertions(+), 82 deletions(-)
diffs (truncated from 880 to 300 lines):
diff -r de396ce5659a -r 79c06cfcd52b sys/dev/usb/ehci.c
--- a/sys/dev/usb/ehci.c Sun Feb 19 21:37:12 2012 +0000
+++ b/sys/dev/usb/ehci.c Mon Feb 20 02:12:23 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci.c,v 1.181.6.5 2011/12/09 01:52:59 mrg Exp $ */
+/* $NetBSD: ehci.c,v 1.181.6.6 2012/02/20 02:12:23 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.5 2011/12/09 01:52:59 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.181.6.6 2012/02/20 02:12:23 mrg Exp $");
#include "ohci.h"
#include "uhci.h"
@@ -744,11 +744,11 @@
ehci_softc_t *sc = bus->hci_private;
struct ehci_xfer *ex, *nextex;
+ KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
+
DPRINTFN(10,("%s: ehci_softintr (%d)\n", device_xname(sc->sc_dev),
sc->sc_bus.intr_context));
- mutex_enter(&sc->sc_lock);
-
sc->sc_bus.intr_context++;
/*
@@ -765,8 +765,8 @@
/* Schedule a callout to catch any dropped transactions. */
if ((sc->sc_flags & EHCIF_DROPPED_INTR_WORKAROUND) &&
!TAILQ_EMPTY(&sc->sc_intrhead))
- callout_reset(&(sc->sc_tmo_intrlist),
- (hz), (ehci_intrlist_timeout), (sc));
+ callout_reset(&sc->sc_tmo_intrlist,
+ hz, ehci_intrlist_timeout, sc);
if (sc->sc_softwake) {
sc->sc_softwake = 0;
@@ -774,8 +774,6 @@
}
sc->sc_bus.intr_context--;
-
- mutex_exit(&sc->sc_lock);
}
/* Check for an interrupt. */
@@ -1116,7 +1114,9 @@
/* Timeout */
DPRINTF(("ehci_waitintr: timeout\n"));
xfer->status = USBD_TIMEOUT;
+ mutex_enter(&sc->sc_lock);
usb_transfer_complete(xfer);
+ mutex_exit(&sc->sc_lock);
/* XXX should free TD */
}
@@ -1813,7 +1813,7 @@
}
/*
- * Add an ED to the schedule. Called at splusb().
+ * Add an ED to the schedule. Called with USB thread lock held.
*/
Static void
ehci_add_qh(ehci_softc_t *sc, ehci_soft_qh_t *sqh, ehci_soft_qh_t *head)
@@ -1841,7 +1841,7 @@
}
/*
- * Remove an ED from the schedule. Called at splusb().
+ * Remove an ED from the schedule. Called with USB thread lock held.
*/
Static void
ehci_rem_qh(ehci_softc_t *sc, ehci_soft_qh_t *sqh, ehci_soft_qh_t *head)
@@ -2600,14 +2600,13 @@
{
ehci_softc_t *sc = xfer->pipe->device->bus->hci_private;
- mutex_enter(&sc->sc_lock);
+ KASSERT(mutex_owned(&sc->sc_lock));
if (xfer->pipe->intrxfer == xfer) {
DPRINTF(("ehci_root_intr_abort: remove\n"));
xfer->pipe->intrxfer = NULL;
}
xfer->status = USBD_CANCELLED;
usb_transfer_complete(xfer);
- mutex_exit(&sc->sc_lock);
}
/* Close the root pipe. */
@@ -3003,21 +3002,19 @@
DPRINTF(("ehci_abort_xfer: xfer=%p pipe=%p\n", xfer, epipe));
+ KASSERT(mutex_owned(&sc->sc_lock));
+
if (sc->sc_dying) {
/* If we're dying, just do the software part. */
- mutex_enter(&sc->sc_lock);
xfer->status = status; /* make software ignore it */
callout_stop(&xfer->timeout_handle);
usb_transfer_complete(xfer);
- mutex_exit(&sc->sc_lock);
return;
}
if (xfer->device->bus->intr_context)
panic("ehci_abort_xfer: not in process context");
- mutex_enter(&sc->sc_lock);
-
/*
* If an abort is already in progress then just wait for it to
* complete and return.
@@ -3034,7 +3031,6 @@
xfer->hcflags |= UXFER_ABORTWAIT;
while (xfer->hcflags & UXFER_ABORTING)
cv_wait(&xfer->hccv, &sc->sc_lock);
- mutex_exit(&sc->sc_lock);
return;
}
xfer->hcflags |= UXFER_ABORTING;
@@ -3129,7 +3125,7 @@
cv_broadcast(&xfer->hccv);
}
- mutex_exit(&sc->sc_lock);
+ KASSERT(mutex_owned(&sc->sc_lock));
#undef exfer
}
@@ -3149,30 +3145,28 @@
DPRINTF(("ehci_abort_isoc_xfer: xfer %p pipe %p\n", xfer, epipe));
+ KASSERT(mutex_owned(&sc->sc_lock));
+
if (sc->sc_dying) {
- mutex_enter(&sc->sc_lock);
xfer->status = status;
callout_stop(&xfer->timeout_handle);
usb_transfer_complete(xfer);
- mutex_exit(&sc->sc_lock);
return;
}
- mutex_enter(&sc->sc_lock);
-
if (xfer->hcflags & UXFER_ABORTING) {
DPRINTFN(2, ("ehci_abort_isoc_xfer: already aborting\n"));
#ifdef DIAGNOSTIC
if (status == USBD_TIMEOUT)
- printf("ehci_abort_xfer: TIMEOUT while aborting\n");
+ printf("ehci_abort_isoc_xfer: TIMEOUT while aborting\n");
#endif
xfer->status = status;
- DPRINTFN(2, ("ehci_abort_xfer: waiting for abort to finish\n"));
+ DPRINTFN(2, ("ehci_abort_isoc_xfer: waiting for abort to finish\n"));
xfer->hcflags |= UXFER_ABORTWAIT;
while (xfer->hcflags & UXFER_ABORTING)
- cv_wait(&xfer->hccv, &sc->sc_intr_lock);
+ cv_wait(&xfer->hccv, &sc->sc_lock);
goto done;
}
xfer->hcflags |= UXFER_ABORTING;
@@ -3200,7 +3194,7 @@
sc->sc_softwake = 1;
usb_schedsoftintr(&sc->sc_bus);
- cv_wait(&sc->sc_softwake_cv, &sc->sc_intr_lock);
+ cv_wait(&sc->sc_softwake_cv, &sc->sc_lock);
#ifdef DIAGNOSTIC
exfer->isdone = 1;
@@ -3213,7 +3207,7 @@
}
done:
- mutex_exit(&sc->sc_lock);
+ KASSERT(mutex_owned(&sc->sc_lock));
return;
}
@@ -3231,7 +3225,9 @@
#endif
if (sc->sc_dying) {
+ mutex_enter(&sc->sc_lock);
ehci_abort_xfer(&exfer->xfer, USBD_TIMEOUT);
+ mutex_exit(&sc->sc_lock);
return;
}
@@ -3245,10 +3241,13 @@
ehci_timeout_task(void *addr)
{
usbd_xfer_handle xfer = addr;
+ ehci_softc_t *sc = xfer->pipe->device->bus->hci_private;
DPRINTF(("ehci_timeout_task: xfer=%p\n", xfer));
+ mutex_enter(&sc->sc_lock);
ehci_abort_xfer(xfer, USBD_TIMEOUT);
+ mutex_exit(&sc->sc_lock);
}
/************************/
@@ -3533,9 +3532,7 @@
ehci_softc_t *sc = arg;
DPRINTF(("ehci_intrlist_timeout\n"));
- mutex_spin_enter(&sc->sc_intr_lock);
usb_schedsoftintr(&sc->sc_bus);
- mutex_spin_exit(&sc->sc_intr_lock);
}
/************************/
@@ -3714,7 +3711,9 @@
sqh->islot = islot;
isp = &sc->sc_islots[islot];
+ mutex_enter(&sc->sc_lock);
ehci_add_qh(sc, sqh, isp->sqh);
+ mutex_exit(&sc->sc_lock);
return (USBD_NORMAL_COMPLETION);
}
diff -r de396ce5659a -r 79c06cfcd52b sys/dev/usb/ohci.c
--- a/sys/dev/usb/ohci.c Sun Feb 19 21:37:12 2012 +0000
+++ b/sys/dev/usb/ohci.c Mon Feb 20 02:12:23 2012 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.218.6.8 2011/12/09 01:53:00 mrg Exp $ */
+/* $NetBSD: ohci.c,v 1.218.6.9 2012/02/20 02:12:24 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.8 2011/12/09 01:53:00 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.9 2012/02/20 02:12:24 mrg Exp $");
#include "opt_usb.h"
@@ -1285,10 +1285,10 @@
int i, j, actlen, iframes, uedir;
ohci_physaddr_t done;
+ KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
+
DPRINTFN(10,("ohci_softintr: enter\n"));
- mutex_enter(&sc->sc_lock);
-
sc->sc_bus.intr_context++;
usb_syncmem(&sc->sc_hccadma, offsetof(struct ohci_hcca, hcca_done_head),
@@ -1489,7 +1489,6 @@
}
sc->sc_bus.intr_context--;
- mutex_exit(&sc->sc_lock);
DPRINTFN(10,("ohci_softintr: done:\n"));
}
@@ -1868,7 +1867,7 @@
}
/*
- * Add an ED to the schedule. Called at splusb().
+ * Add an ED to the schedule. Called with USB thread lock held.
*/
Static void
ohci_add_ed(ohci_softc_t *sc, ohci_soft_ed_t *sed, ohci_soft_ed_t *head)
@@ -1893,7 +1892,7 @@
}
/*
- * Remove an ED from the schedule. Called at splusb().
+ * Remove an ED from the schedule. Called with USB thread lock held.
*/
Static void
ohci_rem_ed(ohci_softc_t *sc, ohci_soft_ed_t *sed, ohci_soft_ed_t *head)
@@ -1928,7 +1927,7 @@
*/
#define HASH(a) (((a) >> 4) % OHCI_HASH_SIZE)
-/* Called at splusb() */
+/* Called with USB thread lock held. */
void
ohci_hash_add_td(ohci_softc_t *sc, ohci_soft_td_t *std)
Home |
Main Index |
Thread Index |
Old Index