summaryrefslogtreecommitdiffstats
path: root/sys/powerpc
diff options
context:
space:
mode:
authorjhb <jhb@FreeBSD.org>2005-10-25 19:48:48 +0000
committerjhb <jhb@FreeBSD.org>2005-10-25 19:48:48 +0000
commite20e5c07ce4cea9d83ea29f37035a800261a5025 (patch)
treec0e88867c475b0bb7f3b0c1dc5799cf5ad98997f /sys/powerpc
parentb5662e2acad3b391e8117ba16eaca7a1cb878179 (diff)
downloadFreeBSD-src-e20e5c07ce4cea9d83ea29f37035a800261a5025.zip
FreeBSD-src-e20e5c07ce4cea9d83ea29f37035a800261a5025.tar.gz
Reorganize the interrupt handling code a bit to make a few things cleaner
and increase flexibility to allow various different approaches to be tried in the future. - Split struct ithd up into two pieces. struct intr_event holds the list of interrupt handlers associated with interrupt sources. struct intr_thread contains the data relative to an interrupt thread. Currently we still provide a 1:1 relationship of events to threads with the exception that events only have an associated thread if there is at least one threaded interrupt handler attached to the event. This means that on x86 we no longer have 4 bazillion interrupt threads with no handlers. It also means that interrupt events with only INTR_FAST handlers no longer have an associated thread either. - Renamed struct intrhand to struct intr_handler to follow the struct intr_foo naming convention. This did require renaming the powerpc MD struct intr_handler to struct ppc_intr_handler. - INTR_FAST no longer implies INTR_EXCL on all architectures except for powerpc. This means that multiple INTR_FAST handlers can attach to the same interrupt and that INTR_FAST and non-INTR_FAST handlers can attach to the same interrupt. Sharing INTR_FAST handlers may not always be desirable, but having sio(4) and uhci(4) fight over an IRQ isn't fun either. Drivers can always still use INTR_EXCL to ask for an interrupt exclusively. The way this sharing works is that when an interrupt comes in, all the INTR_FAST handlers are executed first, and if any threaded handlers exist, the interrupt thread is scheduled afterwards. This type of layout also makes it possible to investigate using interrupt filters ala OS X where the filter determines whether or not its companion threaded handler should run. - Aside from the INTR_FAST changes above, the impact on MD interrupt code is mostly just 's/ithread/intr_event/'. - A new MI ddb command 'show intrs' walks the list of interrupt events dumping their state. It also has a '/v' verbose switch which dumps info about all of the handlers attached to each event. - We currently don't destroy an interrupt thread when the last threaded handler is removed because it would suck for things like ppbus(8)'s braindead behavior. The code is present, though, it is just under #if 0 for now. - Move the code to actually execute the threaded handlers for an interrrupt event into a separate function so that ithread_loop() becomes more readable. Previously this code was all in the middle of ithread_loop() and indented halfway across the screen. - Made struct intr_thread private to kern_intr.c and replaced td_ithd with a thread private flag TDP_ITHREAD. - In statclock, check curthread against idlethread directly rather than curthread's proc against idlethread's proc. (Not really related to intr changes) Tested on: alpha, amd64, i386, sparc64 Tested on: arm, ia64 (older version of patch by cognet and marcel)
Diffstat (limited to 'sys/powerpc')
-rw-r--r--sys/powerpc/include/intr_machdep.h6
-rw-r--r--sys/powerpc/powerpc/intr_machdep.c67
2 files changed, 38 insertions, 35 deletions
diff --git a/sys/powerpc/include/intr_machdep.h b/sys/powerpc/include/intr_machdep.h
index f4024d3..3336dea 100644
--- a/sys/powerpc/include/intr_machdep.h
+++ b/sys/powerpc/include/intr_machdep.h
@@ -30,12 +30,12 @@
typedef void ih_func_t(void *);
-struct ithd;
+struct intr_event;
-struct intr_handler {
+struct ppc_intr_handler {
ih_func_t *ih_func;
void *ih_arg;
- struct ithd *ih_ithd;
+ struct intr_event *ih_event;
u_int ih_irq;
u_int ih_flags;
u_int ih_index;
diff --git a/sys/powerpc/powerpc/intr_machdep.c b/sys/powerpc/powerpc/intr_machdep.c
index 0cde8c5..521a25d 100644
--- a/sys/powerpc/powerpc/intr_machdep.c
+++ b/sys/powerpc/powerpc/intr_machdep.c
@@ -85,7 +85,7 @@ MALLOC_DEFINE(M_INTR, "intr", "interrupt handler data");
static int intr_initialized = 0;
static u_int intr_nirq;
-static struct intr_handler *intr_handlers;
+static struct ppc_intr_handler *intr_handlers;
static struct mtx intr_table_lock;
@@ -100,7 +100,7 @@ static void (*irq_enable)(uintptr_t);
static void (*irq_disable)(uintptr_t);
static void intrcnt_setname(const char *name, int index);
-static void intrcnt_updatename(struct intr_handler *ih);
+static void intrcnt_updatename(struct ppc_intr_handler *ih);
static void
intrcnt_setname(const char *name, int index)
@@ -110,18 +110,18 @@ intrcnt_setname(const char *name, int index)
}
static void
-intrcnt_updatename(struct intr_handler *ih)
+intrcnt_updatename(struct ppc_intr_handler *ih)
{
- intrcnt_setname(ih->ih_ithd->it_td->td_proc->p_comm, ih->ih_index);
+ intrcnt_setname(ih->ih_event->ie_fullname, ih->ih_index);
}
static void
-intrcnt_register(struct intr_handler *ih)
+intrcnt_register(struct ppc_intr_handler *ih)
{
char straystr[MAXCOMLEN + 1];
- KASSERT(ih->ih_ithd != NULL,
- ("%s: intr_handler with no ithread", __func__));
+ KASSERT(ih->ih_event != NULL,
+ ("%s: ppc_intr_handler with no event", __func__));
ih->ih_index = intrcnt_index;
intrcnt_index += 2;
@@ -145,7 +145,7 @@ intr_init(void (*handler)(void), int nirq, void (*irq_e)(uintptr_t),
intr_initialized++;
intr_nirq = nirq;
- intr_handlers = malloc(nirq * sizeof(struct intr_handler), M_INTR,
+ intr_handlers = malloc(nirq * sizeof(struct ppc_intr_handler), M_INTR,
M_NOWAIT|M_ZERO);
if (intr_handlers == NULL)
panic("intr_init: unable to allocate interrupt handler array");
@@ -172,7 +172,7 @@ intr_init(void (*handler)(void), int nirq, void (*irq_e)(uintptr_t),
irq_enable = irq_e;
irq_disable = irq_d;
- mtx_init(&intr_table_lock, "ithread table lock", NULL, MTX_SPIN);
+ mtx_init(&intr_table_lock, "intr table", NULL, MTX_SPIN);
}
void
@@ -195,10 +195,10 @@ int
inthand_add(const char *name, u_int irq, void (*handler)(void *), void *arg,
int flags, void **cookiep)
{
- struct intr_handler *ih;
- struct ithd *ithd, *orphan;
+ struct ppc_intr_handler *ih;
+ struct intr_event *event, *orphan;
int error = 0;
- int created_ithd = 0;
+ int created_event = 0;
/*
* Work around a race where more than one CPU may be registering
@@ -206,30 +206,33 @@ inthand_add(const char *name, u_int irq, void (*handler)(void *), void *arg,
*/
ih = &intr_handlers[irq];
mtx_lock_spin(&intr_table_lock);
- ithd = ih->ih_ithd;
+ event = ih->ih_event;
mtx_unlock_spin(&intr_table_lock);
- if (ithd == NULL) {
- error = ithread_create(&ithd, irq, 0, irq_disable,
- irq_enable, "irq%d:", irq);
+ if (event == NULL) {
+ error = intr_event_create(&event, (void *)irq, 0,
+ (void (*)(void *))irq_enable, "irq%d:", irq);
if (error)
return (error);
mtx_lock_spin(&intr_table_lock);
- if (ih->ih_ithd == NULL) {
- ih->ih_ithd = ithd;
- created_ithd++;
+ if (ih->ih_event == NULL) {
+ ih->ih_event = event;
+ created_event++;
mtx_unlock_spin(&intr_table_lock);
} else {
- orphan = ithd;
- ithd = ih->ih_ithd;
+ orphan = event;
+ event = ih->ih_event;
mtx_unlock_spin(&intr_table_lock);
- ithread_destroy(orphan);
+ intr_event_destroy(orphan);
}
}
- error = ithread_add_handler(ithd, name, handler, arg,
- ithread_priority(flags), flags, cookiep);
+ /* XXX: Should probably fix support for multiple FAST. */
+ if (flags & INTR_FAST)
+ flags |= INTR_EXCL;
+ error = intr_event_add_handler(event, name, handler, arg,
+ intr_priority(flags), flags, cookiep);
if ((flags & INTR_FAST) == 0 || error) {
intr_setup(irq, sched_ithd, ih, flags);
@@ -250,17 +253,17 @@ inthand_add(const char *name, u_int irq, void (*handler)(void *), void *arg,
int
inthand_remove(u_int irq, void *cookie)
{
- struct intr_handler *ih;
+ struct ppc_intr_handler *ih;
int error;
- error = ithread_remove_handler(cookie);
+ error = intr_event_remove_handler(cookie);
if (error == 0) {
ih = &intr_handlers[irq];
mtx_lock_spin(&intr_table_lock);
- if (ih->ih_ithd == NULL) {
+ if (ih->ih_event == NULL) {
intr_setup(irq, intr_stray_handler, ih, 0);
} else {
intr_setup(irq, sched_ithd, ih, 0);
@@ -286,9 +289,9 @@ intr_handle(u_int irq)
static void
intr_stray_handler(void *cookie)
{
- struct intr_handler *ih;
+ struct ppc_intr_handler *ih;
- ih = (struct intr_handler *)cookie;
+ ih = (struct ppc_intr_handler *)cookie;
if (*intr_handlers[ih->ih_irq].ih_straycount < MAX_STRAY_LOG) {
printf("stray irq %d\n", ih->ih_irq);
@@ -303,12 +306,12 @@ intr_stray_handler(void *cookie)
static void
sched_ithd(void *cookie)
{
- struct intr_handler *ih;
+ struct ppc_intr_handler *ih;
int error;
- ih = (struct intr_handler *)cookie;
+ ih = (struct ppc_intr_handler *)cookie;
- error = ithread_schedule(ih->ih_ithd);
+ error = intr_event_schedule_thread(ih->ih_event);
if (error == EINVAL)
intr_stray_handler(ih);
OpenPOWER on IntegriCloud