Module Name: src
Committed By: mrg
Date: Sat Feb 25 20:46:34 UTC 2012
Modified Files:
src/sys/dev/usb [jmcneill-usbmp]: ehci.c ohci.c uhci.c usbdi.c
usbdivar.h
Log Message:
replace the (diagnostic-only) intr_context with checks against LP_INTR
and cpu_intr_p().
XXX: there's one check that changes behaviour
To generate a diff of this commit:
cvs rdiff -u -r1.181.6.12 -r1.181.6.13 src/sys/dev/usb/ehci.c
cvs rdiff -u -r1.218.6.14 -r1.218.6.15 src/sys/dev/usb/ohci.c
cvs rdiff -u -r1.240.6.13 -r1.240.6.14 src/sys/dev/usb/uhci.c
cvs rdiff -u -r1.134.2.12 -r1.134.2.13 src/sys/dev/usb/usbdi.c
cvs rdiff -u -r1.93.8.9 -r1.93.8.10 src/sys/dev/usb/usbdivar.h
Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.
Modified files:
Index: src/sys/dev/usb/ehci.c
diff -u src/sys/dev/usb/ehci.c:1.181.6.12 src/sys/dev/usb/ehci.c:1.181.6.13
--- src/sys/dev/usb/ehci.c:1.181.6.12 Sat Feb 25 10:26:23 2012
+++ src/sys/dev/usb/ehci.c Sat Feb 25 20:46:33 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ehci.c,v 1.181.6.12 2012/02/25 10:26:23 mrg Exp $ */
+/* $NetBSD: ehci.c,v 1.181.6.13 2012/02/25 20:46:33 mrg 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.181.6.12 2012/02/25 10:26:23 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.181.6.13 2012/02/25 20:46:33 mrg Exp $");
#include "ohci.h"
#include "uhci.h"
@@ -69,6 +69,7 @@ __KERNEL_RCSID(0, "$NetBSD: ehci.c,v 1.1
#include <sys/queue.h>
#include <sys/mutex.h>
#include <sys/bus.h>
+#include <sys/cpu.h>
#include <machine/endian.h>
@@ -648,7 +649,6 @@ ehci_intr1(ehci_softc_t *sc)
return (0);
EOWRITE4(sc, EHCI_USBSTS, intrs); /* Acknowledge */
- sc->sc_bus.intr_context++;
sc->sc_bus.no_intrs++;
if (eintrs & EHCI_STS_IAA) {
DPRINTF(("ehci_intr1: door bell\n"));
@@ -676,8 +676,6 @@ ehci_intr1(ehci_softc_t *sc)
eintrs &= ~EHCI_STS_PCD;
}
- sc->sc_bus.intr_context--;
-
if (eintrs != 0) {
/* Block unprocessed interrupts. */
sc->sc_eintrs &= ~eintrs;
@@ -745,10 +743,7 @@ ehci_softintr(void *v)
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));
-
- sc->sc_bus.intr_context++;
+ DPRINTFN(10,("%s: ehci_softintr\n", device_xname(sc->sc_dev)));
/*
* The only explanation I can think of for why EHCI is as brain dead
@@ -771,8 +766,6 @@ ehci_softintr(void *v)
sc->sc_softwake = 0;
cv_broadcast(&sc->sc_softwake_cv);
}
-
- sc->sc_bus.intr_context--;
}
/* Check for an interrupt. */
@@ -3010,7 +3003,7 @@ ehci_abort_xfer(usbd_xfer_handle xfer, u
return;
}
- if (xfer->device->bus->intr_context)
+ if (cpu_intr_p() || (curlwp->l_pflag & LP_INTR) != 0)
panic("ehci_abort_xfer: not in process context");
/*
Index: src/sys/dev/usb/ohci.c
diff -u src/sys/dev/usb/ohci.c:1.218.6.14 src/sys/dev/usb/ohci.c:1.218.6.15
--- src/sys/dev/usb/ohci.c:1.218.6.14 Sat Feb 25 12:53:34 2012
+++ src/sys/dev/usb/ohci.c Sat Feb 25 20:46:34 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: ohci.c,v 1.218.6.14 2012/02/25 12:53:34 mrg Exp $ */
+/* $NetBSD: ohci.c,v 1.218.6.15 2012/02/25 20:46:34 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.14 2012/02/25 12:53:34 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.218.6.15 2012/02/25 20:46:34 mrg Exp $");
#include "opt_usb.h"
@@ -54,6 +54,7 @@ __KERNEL_RCSID(0, "$NetBSD: ohci.c,v 1.2
#include <sys/select.h>
#include <sys/proc.h>
#include <sys/queue.h>
+#include <sys/cpu.h>
#include <sys/bus.h>
#include <machine/endian.h>
@@ -1187,7 +1188,6 @@ ohci_intr1(ohci_softc_t *sc)
return (0);
}
- sc->sc_bus.intr_context++;
sc->sc_bus.no_intrs++;
if (eintrs & OHCI_SO) {
sc->sc_overrun_cnt++;
@@ -1224,8 +1224,6 @@ ohci_intr1(ohci_softc_t *sc)
softint_schedule(sc->sc_rhsc_si);
}
- sc->sc_bus.intr_context--;
-
if (eintrs != 0) {
/* Block unprocessed interrupts. */
OWRITE4(sc, OHCI_INTERRUPT_DISABLE, eintrs);
@@ -1287,8 +1285,6 @@ ohci_softintr(void *v)
DPRINTFN(10,("ohci_softintr: enter\n"));
- sc->sc_bus.intr_context++;
-
usb_syncmem(&sc->sc_hccadma, offsetof(struct ohci_hcca, hcca_done_head),
sizeof(sc->sc_hcca->hcca_done_head),
BUS_DMASYNC_POSTWRITE | BUS_DMASYNC_POSTREAD);
@@ -1486,8 +1482,6 @@ ohci_softintr(void *v)
cv_broadcast(&sc->sc_softwake_cv);
}
- sc->sc_bus.intr_context--;
-
DPRINTFN(10,("ohci_softintr: done:\n"));
}
@@ -2323,7 +2317,7 @@ ohci_abort_xfer(usbd_xfer_handle xfer, u
return;
}
- if (xfer->device->bus->intr_context)
+ if (cpu_intr_p() || (curlwp->l_pflag & LP_INTR) != 0)
panic("ohci_abort_xfer: not in process context");
/*
Index: src/sys/dev/usb/uhci.c
diff -u src/sys/dev/usb/uhci.c:1.240.6.13 src/sys/dev/usb/uhci.c:1.240.6.14
--- src/sys/dev/usb/uhci.c:1.240.6.13 Sat Feb 25 12:53:34 2012
+++ src/sys/dev/usb/uhci.c Sat Feb 25 20:46:33 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: uhci.c,v 1.240.6.13 2012/02/25 12:53:34 mrg Exp $ */
+/* $NetBSD: uhci.c,v 1.240.6.14 2012/02/25 20:46:33 mrg Exp $ */
/* $FreeBSD: src/sys/dev/usb/uhci.c,v 1.33 1999/11/17 22:33:41 n_hibma Exp $ */
/*
@@ -43,7 +43,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.240.6.13 2012/02/25 12:53:34 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.240.6.14 2012/02/25 20:46:33 mrg Exp $");
#include "opt_usb.h"
@@ -57,6 +57,7 @@ __KERNEL_RCSID(0, "$NetBSD: uhci.c,v 1.2
#include <sys/proc.h>
#include <sys/queue.h>
#include <sys/bus.h>
+#include <sys/cpu.h>
#include <machine/endian.h>
@@ -1033,9 +1034,7 @@ uhci_poll_hub(void *addr)
xfer->actlen = 1;
xfer->status = USBD_NORMAL_COMPLETION;
mutex_enter(&sc->sc_lock);
- xfer->device->bus->intr_context++;
usb_transfer_complete(xfer);
- xfer->device->bus->intr_context--;
mutex_exit(&sc->sc_lock);
}
@@ -1391,10 +1390,7 @@ uhci_softintr(void *v)
KASSERT(sc->sc_bus.use_polling || mutex_owned(&sc->sc_lock));
- DPRINTFN(10,("%s: uhci_softintr (%d)\n", device_xname(sc->sc_dev),
- sc->sc_bus.intr_context));
-
- sc->sc_bus.intr_context++;
+ DPRINTFN(10,("%s: uhci_softintr\n", device_xname(sc->sc_dev)));
/*
* Interrupts on UHCI really suck. When the host controller
@@ -1416,8 +1412,6 @@ uhci_softintr(void *v)
sc->sc_softwake = 0;
cv_broadcast(&sc->sc_softwake_cv);
}
-
- sc->sc_bus.intr_context--;
}
/* Check for an interrupt. */
@@ -2152,7 +2146,7 @@ uhci_abort_xfer(usbd_xfer_handle xfer, u
return;
}
- if (xfer->device->bus->intr_context)
+ if (cpu_intr_p() || (curlwp->l_pflag & LP_INTR) != 0)
panic("uhci_abort_xfer: not in process context");
/*
Index: src/sys/dev/usb/usbdi.c
diff -u src/sys/dev/usb/usbdi.c:1.134.2.12 src/sys/dev/usb/usbdi.c:1.134.2.13
--- src/sys/dev/usb/usbdi.c:1.134.2.12 Sat Feb 25 10:26:24 2012
+++ src/sys/dev/usb/usbdi.c Sat Feb 25 20:46:34 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdi.c,v 1.134.2.12 2012/02/25 10:26:24 mrg Exp $ */
+/* $NetBSD: usbdi.c,v 1.134.2.13 2012/02/25 20:46:34 mrg Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdi.c,v 1.28 1999/11/17 22:33:49 n_hibma Exp $ */
/*
@@ -32,7 +32,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.12 2012/02/25 10:26:24 mrg Exp $");
+__KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.134.2.13 2012/02/25 20:46:34 mrg Exp $");
#include "opt_compat_netbsd.h"
#include "opt_usb.h"
@@ -43,8 +43,8 @@ __KERNEL_RCSID(0, "$NetBSD: usbdi.c,v 1.
#include <sys/device.h>
#include <sys/malloc.h>
#include <sys/proc.h>
-
#include <sys/bus.h>
+#include <sys/cpu.h>
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
@@ -968,7 +968,7 @@ usbd_do_request_flags_pipe(usbd_device_h
usbd_status err;
#ifdef DIAGNOSTIC
- if (dev->bus->intr_context) {
+ if (cpu_intr_p() || (curlwp->l_pflag & LP_INTR) != 0) {
printf("usbd_do_request: not in process context\n");
return (USBD_INVAL);
}
Index: src/sys/dev/usb/usbdivar.h
diff -u src/sys/dev/usb/usbdivar.h:1.93.8.9 src/sys/dev/usb/usbdivar.h:1.93.8.10
--- src/sys/dev/usb/usbdivar.h:1.93.8.9 Sat Feb 25 10:26:24 2012
+++ src/sys/dev/usb/usbdivar.h Sat Feb 25 20:46:34 2012
@@ -1,4 +1,4 @@
-/* $NetBSD: usbdivar.h,v 1.93.8.9 2012/02/25 10:26:24 mrg Exp $ */
+/* $NetBSD: usbdivar.h,v 1.93.8.10 2012/02/25 20:46:34 mrg Exp $ */
/* $FreeBSD: src/sys/dev/usb/usbdivar.h,v 1.11 1999/11/17 22:33:51 n_hibma Exp $ */
/*
@@ -62,7 +62,8 @@
* cleartoggle -
* done x
*
- * The above semantics are likely to change.
+ * The above semantics are likely to change. Little performance
+ * evaluation has been done on this code and the locking strategy.
*
* USB functions known to expect the lock taken include (this list is
* probably not exhaustive):
@@ -152,7 +153,6 @@ struct usbd_bus {
char use_polling;
device_t usbctl;
struct usb_device_stats stats;
- int intr_context;
u_int no_intrs;
int usbrev; /* USB revision */
#define USBREV_UNKNOWN 0