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)
This commit is contained in:
parent
eb2893ec18
commit
e0f66ef861
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=151658
@ -325,8 +325,9 @@ LIST_HEAD(alpha_intr_list, alpha_intr);
|
|||||||
struct alpha_intr {
|
struct alpha_intr {
|
||||||
LIST_ENTRY(alpha_intr) list; /* chain handlers in this hash bucket */
|
LIST_ENTRY(alpha_intr) list; /* chain handlers in this hash bucket */
|
||||||
uintptr_t vector; /* vector to match */
|
uintptr_t vector; /* vector to match */
|
||||||
struct ithd *ithd; /* interrupt thread */
|
struct intr_event *ie; /* interrupt event structure */
|
||||||
volatile long *cntp; /* interrupt counter */
|
volatile long *cntp; /* interrupt counter */
|
||||||
|
void (*disable)(uintptr_t);
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct mtx alpha_intr_hash_lock;
|
static struct mtx alpha_intr_hash_lock;
|
||||||
@ -338,7 +339,7 @@ static void
|
|||||||
ithds_init(void *dummy)
|
ithds_init(void *dummy)
|
||||||
{
|
{
|
||||||
|
|
||||||
mtx_init(&alpha_intr_hash_lock, "ithread table lock", NULL, MTX_SPIN);
|
mtx_init(&alpha_intr_hash_lock, "intr table", NULL, MTX_SPIN);
|
||||||
}
|
}
|
||||||
SYSINIT(ithds_init, SI_SUB_INTR, SI_ORDER_SECOND, ithds_init, NULL);
|
SYSINIT(ithds_init, SI_SUB_INTR, SI_ORDER_SECOND, ithds_init, NULL);
|
||||||
|
|
||||||
@ -371,8 +372,9 @@ alpha_setup_intr(const char *name, uintptr_t vector, driver_intr_t handler, void
|
|||||||
return ENOMEM;
|
return ENOMEM;
|
||||||
i->vector = vector;
|
i->vector = vector;
|
||||||
i->cntp = cntp;
|
i->cntp = cntp;
|
||||||
errcode = ithread_create(&i->ithd, vector, 0, disable, enable,
|
i->disable = disable;
|
||||||
"intr:");
|
errcode = intr_event_create(&i->ie, (void *)vector, 0,
|
||||||
|
(void (*)(void *))enable, "intr:");
|
||||||
if (errcode) {
|
if (errcode) {
|
||||||
free(i, M_DEVBUF);
|
free(i, M_DEVBUF);
|
||||||
return errcode;
|
return errcode;
|
||||||
@ -384,44 +386,49 @@ alpha_setup_intr(const char *name, uintptr_t vector, driver_intr_t handler, void
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Second, add this handler. */
|
/* Second, add this handler. */
|
||||||
return (ithread_add_handler(i->ithd, name, handler, arg,
|
return (intr_event_add_handler(i->ie, name, handler, arg,
|
||||||
ithread_priority(flags), flags, cookiep));
|
intr_priority(flags), flags, cookiep));
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
alpha_teardown_intr(void *cookie)
|
alpha_teardown_intr(void *cookie)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (ithread_remove_handler(cookie));
|
return (intr_event_remove_handler(cookie));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* XXX: Alpha doesn't count stray interrupts like some of the other archs.
|
||||||
|
*/
|
||||||
void
|
void
|
||||||
alpha_dispatch_intr(void *frame, unsigned long vector)
|
alpha_dispatch_intr(void *frame, unsigned long vector)
|
||||||
{
|
{
|
||||||
int h = HASHVEC(vector);
|
int h = HASHVEC(vector);
|
||||||
struct alpha_intr *i;
|
struct alpha_intr *i;
|
||||||
struct ithd *ithd; /* our interrupt thread */
|
struct intr_event *ie;
|
||||||
struct intrhand *ih;
|
struct intr_handler *ih;
|
||||||
int error;
|
int error, thread;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Walk the hash bucket for this vector looking for this vector's
|
* Walk the hash bucket for this vector looking for this vector's
|
||||||
* interrupt thread.
|
* interrupt structure.
|
||||||
*/
|
*/
|
||||||
for (i = LIST_FIRST(&alpha_intr_hash[h]); i && i->vector != vector;
|
for (i = LIST_FIRST(&alpha_intr_hash[h]); i && i->vector != vector;
|
||||||
i = LIST_NEXT(i, list))
|
i = LIST_NEXT(i, list))
|
||||||
; /* nothing */
|
; /* nothing */
|
||||||
if (i == NULL)
|
|
||||||
return; /* no ithread for this vector */
|
|
||||||
|
|
||||||
ithd = i->ithd;
|
/* No interrupt structure for this vector. */
|
||||||
KASSERT(ithd != NULL, ("interrupt vector without a thread"));
|
if (i == NULL)
|
||||||
|
return;
|
||||||
|
|
||||||
|
ie = i->ie;
|
||||||
|
KASSERT(ie != NULL, ("interrupt structure without an event"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As an optimization, if an ithread has no handlers, don't
|
* As an optimization, if an event has no handlers, don't
|
||||||
* schedule it to run.
|
* schedule it to run.
|
||||||
*/
|
*/
|
||||||
if (TAILQ_EMPTY(&ithd->it_handlers))
|
if (TAILQ_EMPTY(&ie->ie_handlers))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
atomic_add_long(i->cntp, 1);
|
atomic_add_long(i->cntp, 1);
|
||||||
@ -433,25 +440,32 @@ alpha_dispatch_intr(void *frame, unsigned long vector)
|
|||||||
*/
|
*/
|
||||||
sched_pin();
|
sched_pin();
|
||||||
|
|
||||||
/*
|
/* Execute all fast interrupt handlers directly. */
|
||||||
* Handle a fast interrupt if there is no actual thread for this
|
thread = 0;
|
||||||
* interrupt by calling the handler directly without Giant. Note
|
critical_enter();
|
||||||
* that this means that any fast interrupt handler must be MP safe.
|
TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
|
||||||
*/
|
if (!(ih->ih_flags & IH_FAST)) {
|
||||||
ih = TAILQ_FIRST(&ithd->it_handlers);
|
thread = 1;
|
||||||
if ((ih->ih_flags & IH_FAST) != 0) {
|
continue;
|
||||||
critical_enter();
|
}
|
||||||
|
CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__,
|
||||||
|
ih->ih_handler, ih->ih_argument, ih->ih_name);
|
||||||
ih->ih_handler(ih->ih_argument);
|
ih->ih_handler(ih->ih_argument);
|
||||||
critical_exit();
|
}
|
||||||
} else {
|
critical_exit();
|
||||||
if (ithd->it_disable) {
|
|
||||||
|
/*
|
||||||
|
* If the ithread needs to run, disable the source and schedule the
|
||||||
|
* thread.
|
||||||
|
*/
|
||||||
|
if (thread) {
|
||||||
|
if (i->disable) {
|
||||||
CTR1(KTR_INTR,
|
CTR1(KTR_INTR,
|
||||||
"alpha_dispatch_intr: disabling vector 0x%x",
|
"alpha_dispatch_intr: disabling vector 0x%x",
|
||||||
i->vector);
|
i->vector);
|
||||||
ithd->it_disable(ithd->it_vector);
|
i->disable(i->vector);
|
||||||
}
|
}
|
||||||
|
error = intr_event_schedule_thread(ie);
|
||||||
error = ithread_schedule(ithd);
|
|
||||||
KASSERT(error == 0, ("got an impossible stray interrupt"));
|
KASSERT(error == 0, ("got an impossible stray interrupt"));
|
||||||
}
|
}
|
||||||
sched_unpin();
|
sched_unpin();
|
||||||
|
@ -389,14 +389,14 @@ isa_teardown_intr(device_t dev, device_t child,
|
|||||||
struct resource *irq, void *cookie)
|
struct resource *irq, void *cookie)
|
||||||
{
|
{
|
||||||
struct isa_intr *ii = cookie;
|
struct isa_intr *ii = cookie;
|
||||||
struct intrhand *ih, *handler = (struct intrhand *)ii->ih;
|
struct intr_handler *ih, *handler = (struct intr_handler *)ii->ih;
|
||||||
struct ithd *ithread = handler->ih_ithread;
|
struct intr_event *ie = handler->ih_event;
|
||||||
int num_handlers = 0;
|
int num_handlers = 0;
|
||||||
|
|
||||||
mtx_lock(&ithread->it_lock);
|
mtx_lock(&ie->ie_lock);
|
||||||
TAILQ_FOREACH(ih, &ithread->it_handlers, ih_next)
|
TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next)
|
||||||
num_handlers++;
|
num_handlers++;
|
||||||
mtx_unlock(&ithread->it_lock);
|
mtx_unlock(&ie->ie_lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Only disable the interrupt in hardware if there are no
|
* Only disable the interrupt in hardware if there are no
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#define MAX_STRAY_LOG 5
|
#define MAX_STRAY_LOG 5
|
||||||
|
|
||||||
typedef void (*mask_fn)(uintptr_t vector);
|
typedef void (*mask_fn)(void *);
|
||||||
|
|
||||||
static int intrcnt_index;
|
static int intrcnt_index;
|
||||||
static struct intsrc *interrupt_sources[NUM_IO_INTS];
|
static struct intsrc *interrupt_sources[NUM_IO_INTS];
|
||||||
@ -81,15 +81,14 @@ intr_register_source(struct intsrc *isrc)
|
|||||||
vector = isrc->is_pic->pic_vector(isrc);
|
vector = isrc->is_pic->pic_vector(isrc);
|
||||||
if (interrupt_sources[vector] != NULL)
|
if (interrupt_sources[vector] != NULL)
|
||||||
return (EEXIST);
|
return (EEXIST);
|
||||||
error = ithread_create(&isrc->is_ithread, (uintptr_t)isrc, 0,
|
error = intr_event_create(&isrc->is_event, isrc, 0,
|
||||||
(mask_fn)isrc->is_pic->pic_disable_source,
|
|
||||||
(mask_fn)isrc->is_pic->pic_enable_source, "irq%d:", vector);
|
(mask_fn)isrc->is_pic->pic_enable_source, "irq%d:", vector);
|
||||||
if (error)
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
mtx_lock_spin(&intr_table_lock);
|
mtx_lock_spin(&intr_table_lock);
|
||||||
if (interrupt_sources[vector] != NULL) {
|
if (interrupt_sources[vector] != NULL) {
|
||||||
mtx_unlock_spin(&intr_table_lock);
|
mtx_unlock_spin(&intr_table_lock);
|
||||||
ithread_destroy(isrc->is_ithread);
|
intr_event_destroy(isrc->is_event);
|
||||||
return (EEXIST);
|
return (EEXIST);
|
||||||
}
|
}
|
||||||
intrcnt_register(isrc);
|
intrcnt_register(isrc);
|
||||||
@ -115,8 +114,8 @@ intr_add_handler(const char *name, int vector, driver_intr_t handler,
|
|||||||
isrc = intr_lookup_source(vector);
|
isrc = intr_lookup_source(vector);
|
||||||
if (isrc == NULL)
|
if (isrc == NULL)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
error = ithread_add_handler(isrc->is_ithread, name, handler, arg,
|
error = intr_event_add_handler(isrc->is_event, name, handler, arg,
|
||||||
ithread_priority(flags), flags, cookiep);
|
intr_priority(flags), flags, cookiep);
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
intrcnt_updatename(isrc);
|
intrcnt_updatename(isrc);
|
||||||
isrc->is_pic->pic_enable_intr(isrc);
|
isrc->is_pic->pic_enable_intr(isrc);
|
||||||
@ -130,7 +129,7 @@ intr_remove_handler(void *cookie)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = ithread_remove_handler(cookie);
|
error = intr_event_remove_handler(cookie);
|
||||||
#ifdef XXX
|
#ifdef XXX
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
intrcnt_updatename(/* XXX */);
|
intrcnt_updatename(/* XXX */);
|
||||||
@ -153,12 +152,11 @@ void
|
|||||||
intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
||||||
{
|
{
|
||||||
struct thread *td;
|
struct thread *td;
|
||||||
struct ithd *it;
|
struct intr_event *ie;
|
||||||
struct intrhand *ih;
|
struct intr_handler *ih;
|
||||||
int error, vector;
|
int error, vector, thread;
|
||||||
|
|
||||||
td = curthread;
|
td = curthread;
|
||||||
td->td_intr_nesting_level++;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We count software interrupts when we process them. The
|
* We count software interrupts when we process them. The
|
||||||
@ -169,11 +167,7 @@ intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
|||||||
(*isrc->is_count)++;
|
(*isrc->is_count)++;
|
||||||
PCPU_LAZY_INC(cnt.v_intr);
|
PCPU_LAZY_INC(cnt.v_intr);
|
||||||
|
|
||||||
it = isrc->is_ithread;
|
ie = isrc->is_event;
|
||||||
if (it == NULL)
|
|
||||||
ih = NULL;
|
|
||||||
else
|
|
||||||
ih = TAILQ_FIRST(&it->it_handlers);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX: We assume that IRQ 0 is only used for the ISA timer
|
* XXX: We assume that IRQ 0 is only used for the ISA timer
|
||||||
@ -183,40 +177,12 @@ intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
|||||||
if (vector == 0)
|
if (vector == 0)
|
||||||
clkintr_pending = 1;
|
clkintr_pending = 1;
|
||||||
|
|
||||||
if (ih != NULL && ih->ih_flags & IH_FAST) {
|
/*
|
||||||
/*
|
* For stray interrupts, mask and EOI the source, bump the
|
||||||
* Execute fast interrupt handlers directly.
|
* stray count, and log the condition.
|
||||||
* To support clock handlers, if a handler registers
|
*/
|
||||||
* with a NULL argument, then we pass it a pointer to
|
if (ie == NULL || TAILQ_EMPTY(&ie->ie_handlers)) {
|
||||||
* a trapframe as its argument.
|
|
||||||
*/
|
|
||||||
critical_enter();
|
|
||||||
TAILQ_FOREACH(ih, &it->it_handlers, ih_next) {
|
|
||||||
MPASS(ih->ih_flags & IH_FAST);
|
|
||||||
CTR3(KTR_INTR, "%s: executing handler %p(%p)",
|
|
||||||
__func__, ih->ih_handler,
|
|
||||||
ih->ih_argument == NULL ? iframe :
|
|
||||||
ih->ih_argument);
|
|
||||||
if (ih->ih_argument == NULL)
|
|
||||||
ih->ih_handler(iframe);
|
|
||||||
else
|
|
||||||
ih->ih_handler(ih->ih_argument);
|
|
||||||
}
|
|
||||||
isrc->is_pic->pic_eoi_source(isrc);
|
|
||||||
error = 0;
|
|
||||||
critical_exit();
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* For stray and threaded interrupts, we mask and EOI the
|
|
||||||
* source.
|
|
||||||
*/
|
|
||||||
isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
|
isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
|
||||||
if (ih == NULL)
|
|
||||||
error = EINVAL;
|
|
||||||
else
|
|
||||||
error = ithread_schedule(it);
|
|
||||||
}
|
|
||||||
if (error == EINVAL) {
|
|
||||||
(*isrc->is_straycount)++;
|
(*isrc->is_straycount)++;
|
||||||
if (*isrc->is_straycount < MAX_STRAY_LOG)
|
if (*isrc->is_straycount < MAX_STRAY_LOG)
|
||||||
log(LOG_ERR, "stray irq%d\n", vector);
|
log(LOG_ERR, "stray irq%d\n", vector);
|
||||||
@ -225,6 +191,46 @@ intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
|||||||
"too many stray irq %d's: not logging anymore\n",
|
"too many stray irq %d's: not logging anymore\n",
|
||||||
vector);
|
vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Execute fast interrupt handlers directly.
|
||||||
|
* To support clock handlers, if a handler registers
|
||||||
|
* with a NULL argument, then we pass it a pointer to
|
||||||
|
* an intrframe as its argument.
|
||||||
|
*/
|
||||||
|
td->td_intr_nesting_level++;
|
||||||
|
thread = 0;
|
||||||
|
critical_enter();
|
||||||
|
TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
|
||||||
|
if (!(ih->ih_flags & IH_FAST)) {
|
||||||
|
thread = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__,
|
||||||
|
ih->ih_handler, ih->ih_argument == NULL ? iframe :
|
||||||
|
ih->ih_argument, ih->ih_name);
|
||||||
|
if (ih->ih_argument == NULL)
|
||||||
|
ih->ih_handler(iframe);
|
||||||
|
else
|
||||||
|
ih->ih_handler(ih->ih_argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there are any threaded handlers that need to run,
|
||||||
|
* mask the source as well as sending it an EOI. Otherwise,
|
||||||
|
* just send it an EOI but leave it unmasked.
|
||||||
|
*/
|
||||||
|
if (thread)
|
||||||
|
isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
|
||||||
|
else
|
||||||
|
isrc->is_pic->pic_eoi_source(isrc);
|
||||||
|
critical_exit();
|
||||||
|
|
||||||
|
/* Schedule the ithread if needed. */
|
||||||
|
if (thread) {
|
||||||
|
error = intr_event_schedule_thread(ie);
|
||||||
|
KASSERT(error == 0, ("bad stray interrupt"));
|
||||||
|
}
|
||||||
td->td_intr_nesting_level--;
|
td->td_intr_nesting_level--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +272,7 @@ static void
|
|||||||
intrcnt_updatename(struct intsrc *is)
|
intrcnt_updatename(struct intsrc *is)
|
||||||
{
|
{
|
||||||
|
|
||||||
intrcnt_setname(is->is_ithread->it_td->td_proc->p_comm, is->is_index);
|
intrcnt_setname(is->is_event->ie_fullname, is->is_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -275,7 +281,7 @@ intrcnt_register(struct intsrc *is)
|
|||||||
char straystr[MAXCOMLEN + 1];
|
char straystr[MAXCOMLEN + 1];
|
||||||
|
|
||||||
/* mtx_assert(&intr_table_lock, MA_OWNED); */
|
/* mtx_assert(&intr_table_lock, MA_OWNED); */
|
||||||
KASSERT(is->is_ithread != NULL, ("%s: isrc with no ithread", __func__));
|
KASSERT(is->is_event != NULL, ("%s: isrc with no event", __func__));
|
||||||
is->is_index = intrcnt_index;
|
is->is_index = intrcnt_index;
|
||||||
intrcnt_index += 2;
|
intrcnt_index += 2;
|
||||||
snprintf(straystr, MAXCOMLEN + 1, "stray irq%d",
|
snprintf(straystr, MAXCOMLEN + 1, "stray irq%d",
|
||||||
@ -325,6 +331,6 @@ DB_SHOW_COMMAND(irqs, db_show_irqs)
|
|||||||
db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
|
db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
|
||||||
for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++)
|
for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++)
|
||||||
if (*isrc != NULL)
|
if (*isrc != NULL)
|
||||||
db_dump_ithread((*isrc)->is_ithread, verbose);
|
db_dump_intr_event((*isrc)->is_event, verbose);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,7 +75,7 @@ enum {
|
|||||||
*/
|
*/
|
||||||
struct intsrc {
|
struct intsrc {
|
||||||
struct pic *is_pic;
|
struct pic *is_pic;
|
||||||
struct ithd *is_ithread;
|
struct intr_event *is_event;
|
||||||
u_long *is_count;
|
u_long *is_count;
|
||||||
u_long *is_straycount;
|
u_long *is_straycount;
|
||||||
u_int is_index;
|
u_int is_index;
|
||||||
|
@ -472,10 +472,10 @@ atpic_handle_intr(void *cookie, struct intrframe iframe)
|
|||||||
isrc = &atintrs[vec].at_intsrc;
|
isrc = &atintrs[vec].at_intsrc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we don't have an ithread, see if this is a spurious
|
* If we don't have an event, see if this is a spurious
|
||||||
* interrupt.
|
* interrupt.
|
||||||
*/
|
*/
|
||||||
if (isrc->is_ithread == NULL && (vec == 7 || vec == 15)) {
|
if (isrc->is_event == NULL && (vec == 7 || vec == 15)) {
|
||||||
int port, isr;
|
int port, isr;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -50,7 +50,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <machine/intr.h>
|
#include <machine/intr.h>
|
||||||
#include <machine/cpu.h>
|
#include <machine/cpu.h>
|
||||||
|
|
||||||
static struct ithd *ithreads[NIRQ];
|
static struct intr_event *intr_events[NIRQ];
|
||||||
static int intrcnt_tab[NIRQ];
|
static int intrcnt_tab[NIRQ];
|
||||||
static int intrcnt_index = 0;
|
static int intrcnt_index = 0;
|
||||||
static int last_printed = 0;
|
static int last_printed = 0;
|
||||||
@ -61,18 +61,18 @@ void
|
|||||||
arm_setup_irqhandler(const char *name, void (*hand)(void*), void *arg,
|
arm_setup_irqhandler(const char *name, void (*hand)(void*), void *arg,
|
||||||
int irq, int flags, void **cookiep)
|
int irq, int flags, void **cookiep)
|
||||||
{
|
{
|
||||||
struct ithd *cur_ith;
|
struct intr_event *event;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
if (irq < 0 || irq >= NIRQ)
|
if (irq < 0 || irq >= NIRQ)
|
||||||
return;
|
return;
|
||||||
cur_ith = ithreads[irq];
|
event = intr_events[irq];
|
||||||
if (cur_ith == NULL) {
|
if (event == NULL) {
|
||||||
error = ithread_create(&cur_ith, irq, 0, arm_mask_irq,
|
error = intr_event_create(&event, (void *)irq, 0,
|
||||||
arm_unmask_irq, "intr%d:", irq);
|
(void (*)(void *))arm_unmask_irq, "intr%d:", irq);
|
||||||
if (error)
|
if (error)
|
||||||
return;
|
return;
|
||||||
ithreads[irq] = cur_ith;
|
intr_events[irq] = event;
|
||||||
last_printed +=
|
last_printed +=
|
||||||
snprintf(intrnames + last_printed,
|
snprintf(intrnames + last_printed,
|
||||||
MAXCOMLEN + 1,
|
MAXCOMLEN + 1,
|
||||||
@ -82,14 +82,14 @@ arm_setup_irqhandler(const char *name, void (*hand)(void*), void *arg,
|
|||||||
intrcnt_index++;
|
intrcnt_index++;
|
||||||
|
|
||||||
}
|
}
|
||||||
ithread_add_handler(cur_ith, name, hand, arg,
|
intr_event_add_handler(event, name, hand, arg,
|
||||||
ithread_priority(flags), flags, cookiep);
|
intr_priority(flags), flags, cookiep);
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
arm_remove_irqhandler(void *cookie)
|
arm_remove_irqhandler(void *cookie)
|
||||||
{
|
{
|
||||||
return (ithread_remove_handler(cookie));
|
return (intr_event_remove_handler(cookie));
|
||||||
}
|
}
|
||||||
|
|
||||||
void dosoftints(void);
|
void dosoftints(void);
|
||||||
@ -101,28 +101,34 @@ dosoftints(void)
|
|||||||
void
|
void
|
||||||
arm_handler_execute(void *frame, int irqnb)
|
arm_handler_execute(void *frame, int irqnb)
|
||||||
{
|
{
|
||||||
struct ithd *ithd;
|
struct intr_event *event;
|
||||||
int i;
|
struct intr_handler *ih;
|
||||||
struct intrhand *ih;
|
|
||||||
struct thread *td = curthread;
|
struct thread *td = curthread;
|
||||||
|
int i, thread;
|
||||||
|
|
||||||
td->td_intr_nesting_level++;
|
td->td_intr_nesting_level++;
|
||||||
while ((i = arm_get_next_irq()) != -1) {
|
while ((i = arm_get_next_irq()) != -1) {
|
||||||
arm_mask_irq(i);
|
arm_mask_irq(i);
|
||||||
intrcnt[intrcnt_tab[i]]++;
|
intrcnt[intrcnt_tab[i]]++;
|
||||||
ithd = ithreads[i];
|
event = intr_events[i];
|
||||||
if (!ithd)
|
if (!event || TAILQ_EMPTY(&event->ie_handlers))
|
||||||
continue;
|
continue;
|
||||||
ih = TAILQ_FIRST(&ithd->it_handlers);
|
|
||||||
if (ih && ih->ih_flags & IH_FAST) {
|
/* Execute fast handlers. */
|
||||||
TAILQ_FOREACH(ih, &ithd->it_handlers,
|
thread = 0;
|
||||||
ih_next) {
|
TAILQ_FOREACH(ih, &event->ie_handlers, ih_next) {
|
||||||
|
if (!(ih->ih_flags & IH_FAST))
|
||||||
|
thread = 1;
|
||||||
|
else
|
||||||
ih->ih_handler(ih->ih_argument ?
|
ih->ih_handler(ih->ih_argument ?
|
||||||
ih->ih_argument : frame);
|
ih->ih_argument : frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Schedule thread if needed. */
|
||||||
|
if (thread)
|
||||||
|
intr_event_schedule_thread(event);
|
||||||
|
else
|
||||||
arm_unmask_irq(i);
|
arm_unmask_irq(i);
|
||||||
} else if (ih)
|
|
||||||
ithread_schedule(ithd);
|
|
||||||
}
|
}
|
||||||
td->td_intr_nesting_level--;
|
td->td_intr_nesting_level--;
|
||||||
}
|
}
|
||||||
|
@ -1055,9 +1055,9 @@ determined_type: ;
|
|||||||
printf("\n");
|
printf("\n");
|
||||||
|
|
||||||
if (sio_fast_ih == NULL) {
|
if (sio_fast_ih == NULL) {
|
||||||
swi_add(&tty_ithd, "sio", siopoll, NULL, SWI_TTY, 0,
|
swi_add(&tty_intr_event, "sio", siopoll, NULL, SWI_TTY, 0,
|
||||||
&sio_fast_ih);
|
&sio_fast_ih);
|
||||||
swi_add(&clk_ithd, "sio", siopoll, NULL, SWI_CLOCK, 0,
|
swi_add(&clk_intr_event, "sio", siopoll, NULL, SWI_CLOCK, 0,
|
||||||
&sio_slow_ih);
|
&sio_slow_ih);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ sunkbd_attach(struct uart_softc *sc)
|
|||||||
#endif
|
#endif
|
||||||
sunkbd_enable(&sunkbd_softc.sc_kbd);
|
sunkbd_enable(&sunkbd_softc.sc_kbd);
|
||||||
|
|
||||||
swi_add(&tty_ithd, uart_driver_name, sunkbd_uart_intr,
|
swi_add(&tty_intr_event, uart_driver_name, sunkbd_uart_intr,
|
||||||
&sunkbd_softc, SWI_TTY, INTR_TYPE_TTY, &sc->sc_softih);
|
&sunkbd_softc, SWI_TTY, INTR_TYPE_TTY, &sc->sc_softih);
|
||||||
|
|
||||||
sc->sc_opened = 1;
|
sc->sc_opened = 1;
|
||||||
|
@ -377,7 +377,7 @@ uart_tty_attach(struct uart_softc *sc)
|
|||||||
ttyconsolemode(tp, 0);
|
ttyconsolemode(tp, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
swi_add(&tty_ithd, uart_driver_name, uart_tty_intr, sc, SWI_TTY,
|
swi_add(&tty_intr_event, uart_driver_name, uart_tty_intr, sc, SWI_TTY,
|
||||||
INTR_TYPE_TTY, &sc->sc_softih);
|
INTR_TYPE_TTY, &sc->sc_softih);
|
||||||
|
|
||||||
ttycreate(tp, TS_CALLOUT, "u%r", unit);
|
ttycreate(tp, TS_CALLOUT, "u%r", unit);
|
||||||
@ -392,7 +392,7 @@ int uart_tty_detach(struct uart_softc *sc)
|
|||||||
tp = sc->sc_u.u_tty.tp;
|
tp = sc->sc_u.u_tty.tp;
|
||||||
tp->t_pps = NULL;
|
tp->t_pps = NULL;
|
||||||
ttygone(tp);
|
ttygone(tp);
|
||||||
ithread_remove_handler(sc->sc_softih);
|
intr_event_remove_handler(sc->sc_softih);
|
||||||
ttyfree(tp);
|
ttyfree(tp);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
|
@ -57,7 +57,7 @@
|
|||||||
|
|
||||||
#define MAX_STRAY_LOG 5
|
#define MAX_STRAY_LOG 5
|
||||||
|
|
||||||
typedef void (*mask_fn)(uintptr_t vector);
|
typedef void (*mask_fn)(void *);
|
||||||
|
|
||||||
static int intrcnt_index;
|
static int intrcnt_index;
|
||||||
static struct intsrc *interrupt_sources[NUM_IO_INTS];
|
static struct intsrc *interrupt_sources[NUM_IO_INTS];
|
||||||
@ -81,15 +81,14 @@ intr_register_source(struct intsrc *isrc)
|
|||||||
vector = isrc->is_pic->pic_vector(isrc);
|
vector = isrc->is_pic->pic_vector(isrc);
|
||||||
if (interrupt_sources[vector] != NULL)
|
if (interrupt_sources[vector] != NULL)
|
||||||
return (EEXIST);
|
return (EEXIST);
|
||||||
error = ithread_create(&isrc->is_ithread, (uintptr_t)isrc, 0,
|
error = intr_event_create(&isrc->is_event, isrc, 0,
|
||||||
(mask_fn)isrc->is_pic->pic_disable_source,
|
|
||||||
(mask_fn)isrc->is_pic->pic_enable_source, "irq%d:", vector);
|
(mask_fn)isrc->is_pic->pic_enable_source, "irq%d:", vector);
|
||||||
if (error)
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
mtx_lock_spin(&intr_table_lock);
|
mtx_lock_spin(&intr_table_lock);
|
||||||
if (interrupt_sources[vector] != NULL) {
|
if (interrupt_sources[vector] != NULL) {
|
||||||
mtx_unlock_spin(&intr_table_lock);
|
mtx_unlock_spin(&intr_table_lock);
|
||||||
ithread_destroy(isrc->is_ithread);
|
intr_event_destroy(isrc->is_event);
|
||||||
return (EEXIST);
|
return (EEXIST);
|
||||||
}
|
}
|
||||||
intrcnt_register(isrc);
|
intrcnt_register(isrc);
|
||||||
@ -115,8 +114,8 @@ intr_add_handler(const char *name, int vector, driver_intr_t handler,
|
|||||||
isrc = intr_lookup_source(vector);
|
isrc = intr_lookup_source(vector);
|
||||||
if (isrc == NULL)
|
if (isrc == NULL)
|
||||||
return (EINVAL);
|
return (EINVAL);
|
||||||
error = ithread_add_handler(isrc->is_ithread, name, handler, arg,
|
error = intr_event_add_handler(isrc->is_event, name, handler, arg,
|
||||||
ithread_priority(flags), flags, cookiep);
|
intr_priority(flags), flags, cookiep);
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
intrcnt_updatename(isrc);
|
intrcnt_updatename(isrc);
|
||||||
isrc->is_pic->pic_enable_intr(isrc);
|
isrc->is_pic->pic_enable_intr(isrc);
|
||||||
@ -130,7 +129,7 @@ intr_remove_handler(void *cookie)
|
|||||||
{
|
{
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = ithread_remove_handler(cookie);
|
error = intr_event_remove_handler(cookie);
|
||||||
#ifdef XXX
|
#ifdef XXX
|
||||||
if (error == 0)
|
if (error == 0)
|
||||||
intrcnt_updatename(/* XXX */);
|
intrcnt_updatename(/* XXX */);
|
||||||
@ -153,12 +152,11 @@ void
|
|||||||
intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
||||||
{
|
{
|
||||||
struct thread *td;
|
struct thread *td;
|
||||||
struct ithd *it;
|
struct intr_event *ie;
|
||||||
struct intrhand *ih;
|
struct intr_handler *ih;
|
||||||
int error, vector;
|
int error, vector, thread;
|
||||||
|
|
||||||
td = curthread;
|
td = curthread;
|
||||||
td->td_intr_nesting_level++;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We count software interrupts when we process them. The
|
* We count software interrupts when we process them. The
|
||||||
@ -169,11 +167,7 @@ intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
|||||||
(*isrc->is_count)++;
|
(*isrc->is_count)++;
|
||||||
PCPU_LAZY_INC(cnt.v_intr);
|
PCPU_LAZY_INC(cnt.v_intr);
|
||||||
|
|
||||||
it = isrc->is_ithread;
|
ie = isrc->is_event;
|
||||||
if (it == NULL)
|
|
||||||
ih = NULL;
|
|
||||||
else
|
|
||||||
ih = TAILQ_FIRST(&it->it_handlers);
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* XXX: We assume that IRQ 0 is only used for the ISA timer
|
* XXX: We assume that IRQ 0 is only used for the ISA timer
|
||||||
@ -183,40 +177,12 @@ intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
|||||||
if (vector == 0)
|
if (vector == 0)
|
||||||
clkintr_pending = 1;
|
clkintr_pending = 1;
|
||||||
|
|
||||||
if (ih != NULL && ih->ih_flags & IH_FAST) {
|
/*
|
||||||
/*
|
* For stray interrupts, mask and EOI the source, bump the
|
||||||
* Execute fast interrupt handlers directly.
|
* stray count, and log the condition.
|
||||||
* To support clock handlers, if a handler registers
|
*/
|
||||||
* with a NULL argument, then we pass it a pointer to
|
if (ie == NULL || TAILQ_EMPTY(&ie->ie_handlers)) {
|
||||||
* a trapframe as its argument.
|
|
||||||
*/
|
|
||||||
critical_enter();
|
|
||||||
TAILQ_FOREACH(ih, &it->it_handlers, ih_next) {
|
|
||||||
MPASS(ih->ih_flags & IH_FAST);
|
|
||||||
CTR3(KTR_INTR, "%s: executing handler %p(%p)",
|
|
||||||
__func__, ih->ih_handler,
|
|
||||||
ih->ih_argument == NULL ? iframe :
|
|
||||||
ih->ih_argument);
|
|
||||||
if (ih->ih_argument == NULL)
|
|
||||||
ih->ih_handler(iframe);
|
|
||||||
else
|
|
||||||
ih->ih_handler(ih->ih_argument);
|
|
||||||
}
|
|
||||||
isrc->is_pic->pic_eoi_source(isrc);
|
|
||||||
error = 0;
|
|
||||||
critical_exit();
|
|
||||||
} else {
|
|
||||||
/*
|
|
||||||
* For stray and threaded interrupts, we mask and EOI the
|
|
||||||
* source.
|
|
||||||
*/
|
|
||||||
isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
|
isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
|
||||||
if (ih == NULL)
|
|
||||||
error = EINVAL;
|
|
||||||
else
|
|
||||||
error = ithread_schedule(it);
|
|
||||||
}
|
|
||||||
if (error == EINVAL) {
|
|
||||||
(*isrc->is_straycount)++;
|
(*isrc->is_straycount)++;
|
||||||
if (*isrc->is_straycount < MAX_STRAY_LOG)
|
if (*isrc->is_straycount < MAX_STRAY_LOG)
|
||||||
log(LOG_ERR, "stray irq%d\n", vector);
|
log(LOG_ERR, "stray irq%d\n", vector);
|
||||||
@ -225,6 +191,46 @@ intr_execute_handlers(struct intsrc *isrc, struct intrframe *iframe)
|
|||||||
"too many stray irq %d's: not logging anymore\n",
|
"too many stray irq %d's: not logging anymore\n",
|
||||||
vector);
|
vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Execute fast interrupt handlers directly.
|
||||||
|
* To support clock handlers, if a handler registers
|
||||||
|
* with a NULL argument, then we pass it a pointer to
|
||||||
|
* an intrframe as its argument.
|
||||||
|
*/
|
||||||
|
td->td_intr_nesting_level++;
|
||||||
|
thread = 0;
|
||||||
|
critical_enter();
|
||||||
|
TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
|
||||||
|
if (!(ih->ih_flags & IH_FAST)) {
|
||||||
|
thread = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__,
|
||||||
|
ih->ih_handler, ih->ih_argument == NULL ? iframe :
|
||||||
|
ih->ih_argument, ih->ih_name);
|
||||||
|
if (ih->ih_argument == NULL)
|
||||||
|
ih->ih_handler(iframe);
|
||||||
|
else
|
||||||
|
ih->ih_handler(ih->ih_argument);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If there are any threaded handlers that need to run,
|
||||||
|
* mask the source as well as sending it an EOI. Otherwise,
|
||||||
|
* just send it an EOI but leave it unmasked.
|
||||||
|
*/
|
||||||
|
if (thread)
|
||||||
|
isrc->is_pic->pic_disable_source(isrc, PIC_EOI);
|
||||||
|
else
|
||||||
|
isrc->is_pic->pic_eoi_source(isrc);
|
||||||
|
critical_exit();
|
||||||
|
|
||||||
|
/* Schedule the ithread if needed. */
|
||||||
|
if (thread) {
|
||||||
|
error = intr_event_schedule_thread(ie);
|
||||||
|
KASSERT(error == 0, ("bad stray interrupt"));
|
||||||
|
}
|
||||||
td->td_intr_nesting_level--;
|
td->td_intr_nesting_level--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -266,7 +272,7 @@ static void
|
|||||||
intrcnt_updatename(struct intsrc *is)
|
intrcnt_updatename(struct intsrc *is)
|
||||||
{
|
{
|
||||||
|
|
||||||
intrcnt_setname(is->is_ithread->it_td->td_proc->p_comm, is->is_index);
|
intrcnt_setname(is->is_event->ie_fullname, is->is_index);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
@ -275,7 +281,7 @@ intrcnt_register(struct intsrc *is)
|
|||||||
char straystr[MAXCOMLEN + 1];
|
char straystr[MAXCOMLEN + 1];
|
||||||
|
|
||||||
/* mtx_assert(&intr_table_lock, MA_OWNED); */
|
/* mtx_assert(&intr_table_lock, MA_OWNED); */
|
||||||
KASSERT(is->is_ithread != NULL, ("%s: isrc with no ithread", __func__));
|
KASSERT(is->is_event != NULL, ("%s: isrc with no event", __func__));
|
||||||
is->is_index = intrcnt_index;
|
is->is_index = intrcnt_index;
|
||||||
intrcnt_index += 2;
|
intrcnt_index += 2;
|
||||||
snprintf(straystr, MAXCOMLEN + 1, "stray irq%d",
|
snprintf(straystr, MAXCOMLEN + 1, "stray irq%d",
|
||||||
@ -325,6 +331,6 @@ DB_SHOW_COMMAND(irqs, db_show_irqs)
|
|||||||
db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
|
db_setup_paging(db_simple_pager, &quit, db_lines_per_page);
|
||||||
for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++)
|
for (i = 0; i < NUM_IO_INTS && !quit; i++, isrc++)
|
||||||
if (*isrc != NULL)
|
if (*isrc != NULL)
|
||||||
db_dump_ithread((*isrc)->is_ithread, verbose);
|
db_dump_intr_event((*isrc)->is_event, verbose);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -75,7 +75,7 @@ enum {
|
|||||||
*/
|
*/
|
||||||
struct intsrc {
|
struct intsrc {
|
||||||
struct pic *is_pic;
|
struct pic *is_pic;
|
||||||
struct ithd *is_ithread;
|
struct intr_event *is_event;
|
||||||
u_long *is_count;
|
u_long *is_count;
|
||||||
u_long *is_straycount;
|
u_long *is_straycount;
|
||||||
u_int is_index;
|
u_int is_index;
|
||||||
|
@ -535,10 +535,10 @@ atpic_handle_intr(struct intrframe iframe)
|
|||||||
isrc = &atintrs[iframe.if_vec].at_intsrc;
|
isrc = &atintrs[iframe.if_vec].at_intsrc;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we don't have an ithread, see if this is a spurious
|
* If we don't have an event, see if this is a spurious
|
||||||
* interrupt.
|
* interrupt.
|
||||||
*/
|
*/
|
||||||
if (isrc->is_ithread == NULL &&
|
if (isrc->is_event == NULL &&
|
||||||
(iframe.if_vec == 7 || iframe.if_vec == 15)) {
|
(iframe.if_vec == 7 || iframe.if_vec == 15)) {
|
||||||
int port, isr;
|
int port, isr;
|
||||||
|
|
||||||
|
@ -254,7 +254,7 @@ interrupt(u_int64_t vector, struct trapframe *tf)
|
|||||||
#define IA64_HARDWARE_IRQ_BASE 0x20
|
#define IA64_HARDWARE_IRQ_BASE 0x20
|
||||||
|
|
||||||
struct ia64_intr {
|
struct ia64_intr {
|
||||||
struct ithd *ithd; /* interrupt thread */
|
struct intr_event *event; /* interrupt event */
|
||||||
volatile long *cntp; /* interrupt counter */
|
volatile long *cntp; /* interrupt counter */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -268,7 +268,7 @@ static void
|
|||||||
ithds_init(void *dummy)
|
ithds_init(void *dummy)
|
||||||
{
|
{
|
||||||
|
|
||||||
mtx_init(&ia64_intrs_lock, "ithread table lock", NULL, MTX_SPIN);
|
mtx_init(&ia64_intrs_lock, "intr table", NULL, MTX_SPIN);
|
||||||
}
|
}
|
||||||
SYSINIT(ithds_init, SI_SUB_INTR, SI_ORDER_SECOND, ithds_init, NULL);
|
SYSINIT(ithds_init, SI_SUB_INTR, SI_ORDER_SECOND, ithds_init, NULL);
|
||||||
|
|
||||||
@ -291,7 +291,7 @@ ia64_setup_intr(const char *name, int irq, driver_intr_t handler, void *arg,
|
|||||||
{
|
{
|
||||||
struct ia64_intr *i;
|
struct ia64_intr *i;
|
||||||
int errcode;
|
int errcode;
|
||||||
int vector = irq + IA64_HARDWARE_IRQ_BASE;
|
intptr_t vector = irq + IA64_HARDWARE_IRQ_BASE;
|
||||||
char *intrname;
|
char *intrname;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -321,8 +321,8 @@ ia64_setup_intr(const char *name, int irq, driver_intr_t handler, void *arg,
|
|||||||
memset(intrname, ' ', INTRNAME_LEN - 1);
|
memset(intrname, ' ', INTRNAME_LEN - 1);
|
||||||
bcopy(name, intrname, strlen(name));
|
bcopy(name, intrname, strlen(name));
|
||||||
}
|
}
|
||||||
errcode = ithread_create(&i->ithd, vector, 0, 0,
|
errcode = intr_event_create(&i->event, (void *)vector, 0,
|
||||||
ia64_send_eoi, "intr:");
|
(void (*)(void *))ia64_send_eoi, "intr:");
|
||||||
if (errcode) {
|
if (errcode) {
|
||||||
free(i, M_DEVBUF);
|
free(i, M_DEVBUF);
|
||||||
return errcode;
|
return errcode;
|
||||||
@ -334,8 +334,8 @@ ia64_setup_intr(const char *name, int irq, driver_intr_t handler, void *arg,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Second, add this handler. */
|
/* Second, add this handler. */
|
||||||
errcode = ithread_add_handler(i->ithd, name, handler, arg,
|
errcode = intr_event_add_handler(i->event, name, handler, arg,
|
||||||
ithread_priority(flags), flags, cookiep);
|
intr_priority(flags), flags, cookiep);
|
||||||
if (errcode)
|
if (errcode)
|
||||||
return errcode;
|
return errcode;
|
||||||
|
|
||||||
@ -346,53 +346,60 @@ int
|
|||||||
ia64_teardown_intr(void *cookie)
|
ia64_teardown_intr(void *cookie)
|
||||||
{
|
{
|
||||||
|
|
||||||
return (ithread_remove_handler(cookie));
|
return (intr_event_remove_handler(cookie));
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
ia64_dispatch_intr(void *frame, unsigned long vector)
|
ia64_dispatch_intr(void *frame, unsigned long vector)
|
||||||
{
|
{
|
||||||
struct ia64_intr *i;
|
struct ia64_intr *i;
|
||||||
struct ithd *ithd; /* our interrupt thread */
|
struct intr_event *ie; /* our interrupt event */
|
||||||
struct intrhand *ih;
|
struct intr_handler *ih;
|
||||||
int error;
|
int error, thread;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Find the interrupt thread for this vector.
|
* Find the interrupt thread for this vector.
|
||||||
*/
|
*/
|
||||||
i = ia64_intrs[vector];
|
i = ia64_intrs[vector];
|
||||||
if (i == NULL)
|
if (i == NULL)
|
||||||
return; /* no ithread for this vector */
|
return; /* no event for this vector */
|
||||||
|
|
||||||
if (i->cntp)
|
if (i->cntp)
|
||||||
atomic_add_long(i->cntp, 1);
|
atomic_add_long(i->cntp, 1);
|
||||||
|
|
||||||
ithd = i->ithd;
|
ie = i->event;
|
||||||
KASSERT(ithd != NULL, ("interrupt vector without a thread"));
|
KASSERT(ie != NULL, ("interrupt vector without an event"));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* As an optimization, if an ithread has no handlers, don't
|
* As an optimization, if an event has no handlers, don't
|
||||||
* schedule it to run.
|
* schedule it to run.
|
||||||
*/
|
*/
|
||||||
if (TAILQ_EMPTY(&ithd->it_handlers))
|
if (TAILQ_EMPTY(&ie->ie_handlers))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Handle a fast interrupt if there is no actual thread for this
|
* Execute all fast interrupt handlers directly without Giant. Note
|
||||||
* interrupt by calling the handler directly without Giant. Note
|
|
||||||
* that this means that any fast interrupt handler must be MP safe.
|
* that this means that any fast interrupt handler must be MP safe.
|
||||||
*/
|
*/
|
||||||
ih = TAILQ_FIRST(&ithd->it_handlers);
|
thread = 0;
|
||||||
if ((ih->ih_flags & IH_FAST) != 0) {
|
critical_enter();
|
||||||
critical_enter();
|
TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
|
||||||
|
if (!(ih->ih_flags & IH_FAST)) {
|
||||||
|
thread = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
CTR4(KTR_INTR, "%s: exec %p(%p) for %s", __func__,
|
||||||
|
ih->ih_handler, ih->ih_argument, ih->ih_name);
|
||||||
ih->ih_handler(ih->ih_argument);
|
ih->ih_handler(ih->ih_argument);
|
||||||
ia64_send_eoi(vector);
|
|
||||||
critical_exit();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
critical_exit();
|
||||||
|
|
||||||
error = ithread_schedule(ithd);
|
if (thread) {
|
||||||
KASSERT(error == 0, ("got an impossible stray interrupt"));
|
error = intr_event_schedule_thread(ie);
|
||||||
|
KASSERT(error == 0, ("got an impossible stray interrupt"));
|
||||||
|
} else
|
||||||
|
ia64_send_eoi(vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DDB
|
#ifdef DDB
|
||||||
|
@ -439,7 +439,8 @@ statclock(frame)
|
|||||||
* so that we know how much of its real time was spent
|
* so that we know how much of its real time was spent
|
||||||
* in ``non-process'' (i.e., interrupt) work.
|
* in ``non-process'' (i.e., interrupt) work.
|
||||||
*/
|
*/
|
||||||
if ((td->td_ithd != NULL) || td->td_intr_nesting_level >= 2) {
|
if ((td->td_pflags & TDP_ITHREAD) ||
|
||||||
|
td->td_intr_nesting_level >= 2) {
|
||||||
p->p_rux.rux_iticks++;
|
p->p_rux.rux_iticks++;
|
||||||
cp_time[CP_INTR]++;
|
cp_time[CP_INTR]++;
|
||||||
} else {
|
} else {
|
||||||
@ -447,7 +448,7 @@ statclock(frame)
|
|||||||
thread_statclock(0);
|
thread_statclock(0);
|
||||||
td->td_sticks++;
|
td->td_sticks++;
|
||||||
p->p_rux.rux_sticks++;
|
p->p_rux.rux_sticks++;
|
||||||
if (p != PCPU_GET(idlethread)->td_proc)
|
if (td != PCPU_GET(idlethread))
|
||||||
cp_time[CP_SYS]++;
|
cp_time[CP_SYS]++;
|
||||||
else
|
else
|
||||||
cp_time[CP_IDLE]++;
|
cp_time[CP_IDLE]++;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -376,7 +376,6 @@ static struct witness_order_list_entry order_lists[] = {
|
|||||||
{ "ng_worklist", &lock_class_mtx_spin },
|
{ "ng_worklist", &lock_class_mtx_spin },
|
||||||
{ "taskqueue_fast", &lock_class_mtx_spin },
|
{ "taskqueue_fast", &lock_class_mtx_spin },
|
||||||
{ "intr table", &lock_class_mtx_spin },
|
{ "intr table", &lock_class_mtx_spin },
|
||||||
{ "ithread table lock", &lock_class_mtx_spin },
|
|
||||||
{ "sleepq chain", &lock_class_mtx_spin },
|
{ "sleepq chain", &lock_class_mtx_spin },
|
||||||
{ "sched lock", &lock_class_mtx_spin },
|
{ "sched lock", &lock_class_mtx_spin },
|
||||||
{ "turnstile chain", &lock_class_mtx_spin },
|
{ "turnstile chain", &lock_class_mtx_spin },
|
||||||
|
@ -30,12 +30,12 @@
|
|||||||
|
|
||||||
typedef void ih_func_t(void *);
|
typedef void ih_func_t(void *);
|
||||||
|
|
||||||
struct ithd;
|
struct intr_event;
|
||||||
|
|
||||||
struct intr_handler {
|
struct ppc_intr_handler {
|
||||||
ih_func_t *ih_func;
|
ih_func_t *ih_func;
|
||||||
void *ih_arg;
|
void *ih_arg;
|
||||||
struct ithd *ih_ithd;
|
struct intr_event *ih_event;
|
||||||
u_int ih_irq;
|
u_int ih_irq;
|
||||||
u_int ih_flags;
|
u_int ih_flags;
|
||||||
u_int ih_index;
|
u_int ih_index;
|
||||||
|
@ -85,7 +85,7 @@ MALLOC_DEFINE(M_INTR, "intr", "interrupt handler data");
|
|||||||
static int intr_initialized = 0;
|
static int intr_initialized = 0;
|
||||||
|
|
||||||
static u_int intr_nirq;
|
static u_int intr_nirq;
|
||||||
static struct intr_handler *intr_handlers;
|
static struct ppc_intr_handler *intr_handlers;
|
||||||
|
|
||||||
static struct mtx intr_table_lock;
|
static struct mtx intr_table_lock;
|
||||||
|
|
||||||
@ -100,7 +100,7 @@ static void (*irq_enable)(uintptr_t);
|
|||||||
static void (*irq_disable)(uintptr_t);
|
static void (*irq_disable)(uintptr_t);
|
||||||
|
|
||||||
static void intrcnt_setname(const char *name, int index);
|
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
|
static void
|
||||||
intrcnt_setname(const char *name, int index)
|
intrcnt_setname(const char *name, int index)
|
||||||
@ -110,18 +110,18 @@ intrcnt_setname(const char *name, int index)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void
|
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
|
static void
|
||||||
intrcnt_register(struct intr_handler *ih)
|
intrcnt_register(struct ppc_intr_handler *ih)
|
||||||
{
|
{
|
||||||
char straystr[MAXCOMLEN + 1];
|
char straystr[MAXCOMLEN + 1];
|
||||||
|
|
||||||
KASSERT(ih->ih_ithd != NULL,
|
KASSERT(ih->ih_event != NULL,
|
||||||
("%s: intr_handler with no ithread", __func__));
|
("%s: ppc_intr_handler with no event", __func__));
|
||||||
|
|
||||||
ih->ih_index = intrcnt_index;
|
ih->ih_index = intrcnt_index;
|
||||||
intrcnt_index += 2;
|
intrcnt_index += 2;
|
||||||
@ -145,7 +145,7 @@ intr_init(void (*handler)(void), int nirq, void (*irq_e)(uintptr_t),
|
|||||||
intr_initialized++;
|
intr_initialized++;
|
||||||
|
|
||||||
intr_nirq = nirq;
|
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);
|
M_NOWAIT|M_ZERO);
|
||||||
if (intr_handlers == NULL)
|
if (intr_handlers == NULL)
|
||||||
panic("intr_init: unable to allocate interrupt handler array");
|
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_enable = irq_e;
|
||||||
irq_disable = irq_d;
|
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
|
void
|
||||||
@ -195,10 +195,10 @@ int
|
|||||||
inthand_add(const char *name, u_int irq, void (*handler)(void *), void *arg,
|
inthand_add(const char *name, u_int irq, void (*handler)(void *), void *arg,
|
||||||
int flags, void **cookiep)
|
int flags, void **cookiep)
|
||||||
{
|
{
|
||||||
struct intr_handler *ih;
|
struct ppc_intr_handler *ih;
|
||||||
struct ithd *ithd, *orphan;
|
struct intr_event *event, *orphan;
|
||||||
int error = 0;
|
int error = 0;
|
||||||
int created_ithd = 0;
|
int created_event = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Work around a race where more than one CPU may be registering
|
* 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];
|
ih = &intr_handlers[irq];
|
||||||
mtx_lock_spin(&intr_table_lock);
|
mtx_lock_spin(&intr_table_lock);
|
||||||
ithd = ih->ih_ithd;
|
event = ih->ih_event;
|
||||||
mtx_unlock_spin(&intr_table_lock);
|
mtx_unlock_spin(&intr_table_lock);
|
||||||
if (ithd == NULL) {
|
if (event == NULL) {
|
||||||
error = ithread_create(&ithd, irq, 0, irq_disable,
|
error = intr_event_create(&event, (void *)irq, 0,
|
||||||
irq_enable, "irq%d:", irq);
|
(void (*)(void *))irq_enable, "irq%d:", irq);
|
||||||
if (error)
|
if (error)
|
||||||
return (error);
|
return (error);
|
||||||
|
|
||||||
mtx_lock_spin(&intr_table_lock);
|
mtx_lock_spin(&intr_table_lock);
|
||||||
|
|
||||||
if (ih->ih_ithd == NULL) {
|
if (ih->ih_event == NULL) {
|
||||||
ih->ih_ithd = ithd;
|
ih->ih_event = event;
|
||||||
created_ithd++;
|
created_event++;
|
||||||
mtx_unlock_spin(&intr_table_lock);
|
mtx_unlock_spin(&intr_table_lock);
|
||||||
} else {
|
} else {
|
||||||
orphan = ithd;
|
orphan = event;
|
||||||
ithd = ih->ih_ithd;
|
event = ih->ih_event;
|
||||||
mtx_unlock_spin(&intr_table_lock);
|
mtx_unlock_spin(&intr_table_lock);
|
||||||
ithread_destroy(orphan);
|
intr_event_destroy(orphan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
error = ithread_add_handler(ithd, name, handler, arg,
|
/* XXX: Should probably fix support for multiple FAST. */
|
||||||
ithread_priority(flags), flags, cookiep);
|
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) {
|
if ((flags & INTR_FAST) == 0 || error) {
|
||||||
intr_setup(irq, sched_ithd, ih, flags);
|
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
|
int
|
||||||
inthand_remove(u_int irq, void *cookie)
|
inthand_remove(u_int irq, void *cookie)
|
||||||
{
|
{
|
||||||
struct intr_handler *ih;
|
struct ppc_intr_handler *ih;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = ithread_remove_handler(cookie);
|
error = intr_event_remove_handler(cookie);
|
||||||
|
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
ih = &intr_handlers[irq];
|
ih = &intr_handlers[irq];
|
||||||
|
|
||||||
mtx_lock_spin(&intr_table_lock);
|
mtx_lock_spin(&intr_table_lock);
|
||||||
|
|
||||||
if (ih->ih_ithd == NULL) {
|
if (ih->ih_event == NULL) {
|
||||||
intr_setup(irq, intr_stray_handler, ih, 0);
|
intr_setup(irq, intr_stray_handler, ih, 0);
|
||||||
} else {
|
} else {
|
||||||
intr_setup(irq, sched_ithd, ih, 0);
|
intr_setup(irq, sched_ithd, ih, 0);
|
||||||
@ -286,9 +289,9 @@ intr_handle(u_int irq)
|
|||||||
static void
|
static void
|
||||||
intr_stray_handler(void *cookie)
|
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) {
|
if (*intr_handlers[ih->ih_irq].ih_straycount < MAX_STRAY_LOG) {
|
||||||
printf("stray irq %d\n", ih->ih_irq);
|
printf("stray irq %d\n", ih->ih_irq);
|
||||||
@ -303,12 +306,12 @@ intr_stray_handler(void *cookie)
|
|||||||
static void
|
static void
|
||||||
sched_ithd(void *cookie)
|
sched_ithd(void *cookie)
|
||||||
{
|
{
|
||||||
struct intr_handler *ih;
|
struct ppc_intr_handler *ih;
|
||||||
int error;
|
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)
|
if (error == EINVAL)
|
||||||
intr_stray_handler(ih);
|
intr_stray_handler(ih);
|
||||||
|
@ -67,7 +67,7 @@ struct intr_request {
|
|||||||
struct intr_vector {
|
struct intr_vector {
|
||||||
iv_func_t *iv_func;
|
iv_func_t *iv_func;
|
||||||
void *iv_arg;
|
void *iv_arg;
|
||||||
struct ithd *iv_ithd;
|
struct intr_event *iv_event;
|
||||||
u_int iv_pri;
|
u_int iv_pri;
|
||||||
u_int iv_vec;
|
u_int iv_vec;
|
||||||
};
|
};
|
||||||
|
@ -227,38 +227,44 @@ void
|
|||||||
intr_init2()
|
intr_init2()
|
||||||
{
|
{
|
||||||
|
|
||||||
mtx_init(&intr_table_lock, "ithread table lock", NULL, MTX_SPIN);
|
mtx_init(&intr_table_lock, "intr table", NULL, MTX_SPIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
intr_execute_handlers(void *cookie)
|
intr_execute_handlers(void *cookie)
|
||||||
{
|
{
|
||||||
struct intr_vector *iv;
|
struct intr_vector *iv;
|
||||||
struct ithd *ithd;
|
struct intr_event *ie;
|
||||||
struct intrhand *ih;
|
struct intr_handler *ih;
|
||||||
int error;
|
int error, thread;
|
||||||
|
|
||||||
iv = cookie;
|
iv = cookie;
|
||||||
ithd = iv->iv_ithd;
|
ie = iv->iv_event;
|
||||||
|
if (ie == NULL) {
|
||||||
if (ithd == NULL)
|
intr_stray_vector(iv);
|
||||||
ih = NULL;
|
|
||||||
else
|
|
||||||
ih = TAILQ_FIRST(&ithd->it_handlers);
|
|
||||||
if (ih != NULL && ih->ih_flags & IH_FAST) {
|
|
||||||
/* Execute fast interrupt handlers directly. */
|
|
||||||
TAILQ_FOREACH(ih, &ithd->it_handlers, ih_next) {
|
|
||||||
MPASS(ih->ih_flags & IH_FAST &&
|
|
||||||
ih->ih_argument != NULL);
|
|
||||||
CTR3(KTR_INTR, "%s: executing handler %p(%p)",
|
|
||||||
__func__, ih->ih_handler, ih->ih_argument);
|
|
||||||
ih->ih_handler(ih->ih_argument);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Execute fast interrupt handlers directly. */
|
||||||
|
thread = 0;
|
||||||
|
TAILQ_FOREACH(ih, &ie->ie_handlers, ih_next) {
|
||||||
|
if (!(ih->ih_flags & IH_FAST)) {
|
||||||
|
thread = 1;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
MPASS(ih->ih_flags & IH_FAST && ih->ih_argument != NULL);
|
||||||
|
CTR3(KTR_INTR, "%s: executing handler %p(%p)", __func__,
|
||||||
|
ih->ih_handler, ih->ih_argument);
|
||||||
|
ih->ih_handler(ih->ih_argument);
|
||||||
|
}
|
||||||
|
|
||||||
/* Schedule a heavyweight interrupt process. */
|
/* Schedule a heavyweight interrupt process. */
|
||||||
error = ithread_schedule(ithd);
|
if (thread)
|
||||||
|
error = intr_event_schedule_thread(ie);
|
||||||
|
else if (TAILQ_EMPTY(&ie->ie_handlers))
|
||||||
|
error = EINVAL;
|
||||||
|
else
|
||||||
|
error = 0;
|
||||||
if (error == EINVAL)
|
if (error == EINVAL)
|
||||||
intr_stray_vector(iv);
|
intr_stray_vector(iv);
|
||||||
}
|
}
|
||||||
@ -268,8 +274,8 @@ inthand_add(const char *name, int vec, void (*handler)(void *), void *arg,
|
|||||||
int flags, void **cookiep)
|
int flags, void **cookiep)
|
||||||
{
|
{
|
||||||
struct intr_vector *iv;
|
struct intr_vector *iv;
|
||||||
struct ithd *ithd; /* descriptor for the IRQ */
|
struct intr_event *ie; /* descriptor for the IRQ */
|
||||||
struct ithd *orphan;
|
struct intr_event *orphan;
|
||||||
int errcode;
|
int errcode;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -278,27 +284,27 @@ inthand_add(const char *name, int vec, void (*handler)(void *), void *arg,
|
|||||||
*/
|
*/
|
||||||
iv = &intr_vectors[vec];
|
iv = &intr_vectors[vec];
|
||||||
mtx_lock_spin(&intr_table_lock);
|
mtx_lock_spin(&intr_table_lock);
|
||||||
ithd = iv->iv_ithd;
|
ie = iv->iv_event;
|
||||||
mtx_unlock_spin(&intr_table_lock);
|
mtx_unlock_spin(&intr_table_lock);
|
||||||
if (ithd == NULL) {
|
if (ie == NULL) {
|
||||||
errcode = ithread_create(&ithd, vec, 0, NULL, NULL, "vec%d:",
|
errcode = intr_event_create(&ie, (void *)(intptr_t)vec, 0, NULL,
|
||||||
vec);
|
"vec%d:", vec);
|
||||||
if (errcode)
|
if (errcode)
|
||||||
return (errcode);
|
return (errcode);
|
||||||
mtx_lock_spin(&intr_table_lock);
|
mtx_lock_spin(&intr_table_lock);
|
||||||
if (iv->iv_ithd == NULL) {
|
if (iv->iv_event == NULL) {
|
||||||
iv->iv_ithd = ithd;
|
iv->iv_event = ie;
|
||||||
mtx_unlock_spin(&intr_table_lock);
|
mtx_unlock_spin(&intr_table_lock);
|
||||||
} else {
|
} else {
|
||||||
orphan = ithd;
|
orphan = ie;
|
||||||
ithd = iv->iv_ithd;
|
ie = iv->iv_event;
|
||||||
mtx_unlock_spin(&intr_table_lock);
|
mtx_unlock_spin(&intr_table_lock);
|
||||||
ithread_destroy(orphan);
|
intr_event_destroy(orphan);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
errcode = ithread_add_handler(ithd, name, handler, arg,
|
errcode = intr_event_add_handler(ie, name, handler, arg,
|
||||||
ithread_priority(flags), flags, cookiep);
|
intr_priority(flags), flags, cookiep);
|
||||||
if (errcode)
|
if (errcode)
|
||||||
return (errcode);
|
return (errcode);
|
||||||
|
|
||||||
@ -307,7 +313,7 @@ inthand_add(const char *name, int vec, void (*handler)(void *), void *arg,
|
|||||||
|
|
||||||
intr_stray_count[vec] = 0;
|
intr_stray_count[vec] = 0;
|
||||||
|
|
||||||
intrcnt_updatename(vec, ithd->it_td->td_proc->p_comm, 0);
|
intrcnt_updatename(vec, ie->ie_fullname, 0);
|
||||||
|
|
||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
@ -318,15 +324,16 @@ inthand_remove(int vec, void *cookie)
|
|||||||
struct intr_vector *iv;
|
struct intr_vector *iv;
|
||||||
int error;
|
int error;
|
||||||
|
|
||||||
error = ithread_remove_handler(cookie);
|
error = intr_event_remove_handler(cookie);
|
||||||
if (error == 0) {
|
if (error == 0) {
|
||||||
/*
|
/*
|
||||||
* XXX: maybe this should be done regardless of whether
|
* XXX: maybe this should be done regardless of whether
|
||||||
* ithread_remove_handler() succeeded?
|
* intr_event_remove_handler() succeeded?
|
||||||
|
* XXX: aren't the PIL's backwards below?
|
||||||
*/
|
*/
|
||||||
iv = &intr_vectors[vec];
|
iv = &intr_vectors[vec];
|
||||||
mtx_lock_spin(&intr_table_lock);
|
mtx_lock_spin(&intr_table_lock);
|
||||||
if (iv->iv_ithd == NULL)
|
if (iv->iv_event == NULL)
|
||||||
intr_setup(PIL_ITHREAD, intr_fast, vec,
|
intr_setup(PIL_ITHREAD, intr_fast, vec,
|
||||||
intr_stray_vector, iv);
|
intr_stray_vector, iv);
|
||||||
else
|
else
|
||||||
|
@ -32,20 +32,23 @@
|
|||||||
#include <sys/_lock.h>
|
#include <sys/_lock.h>
|
||||||
#include <sys/_mutex.h>
|
#include <sys/_mutex.h>
|
||||||
|
|
||||||
|
struct intr_event;
|
||||||
|
struct intr_thread;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Describe a hardware interrupt handler.
|
* Describe a hardware interrupt handler.
|
||||||
*
|
*
|
||||||
* Multiple interrupt handlers for a specific vector can be chained
|
* Multiple interrupt handlers for a specific event can be chained
|
||||||
* together.
|
* together.
|
||||||
*/
|
*/
|
||||||
struct intrhand {
|
struct intr_handler {
|
||||||
driver_intr_t *ih_handler; /* Handler function. */
|
driver_intr_t *ih_handler; /* Handler function. */
|
||||||
void *ih_argument; /* Argument to pass to handler. */
|
void *ih_argument; /* Argument to pass to handler. */
|
||||||
int ih_flags;
|
int ih_flags;
|
||||||
const char *ih_name; /* Name of handler. */
|
const char *ih_name; /* Name of handler. */
|
||||||
struct ithd *ih_ithread; /* Ithread we are connected to. */
|
struct intr_event *ih_event; /* Event we are connected to. */
|
||||||
int ih_need; /* Needs service. */
|
int ih_need; /* Needs service. */
|
||||||
TAILQ_ENTRY(intrhand) ih_next; /* Next handler for this vector. */
|
TAILQ_ENTRY(intr_handler) ih_next; /* Next handler for this event. */
|
||||||
u_char ih_pri; /* Priority of this handler. */
|
u_char ih_pri; /* Priority of this handler. */
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -57,29 +60,26 @@ struct intrhand {
|
|||||||
#define IH_MPSAFE 0x80000000 /* Handler does not need Giant. */
|
#define IH_MPSAFE 0x80000000 /* Handler does not need Giant. */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Describe an interrupt thread. There is one of these per interrupt vector.
|
* Describe an interrupt event. An event holds a list of handlers.
|
||||||
* Note that this actually describes an interrupt source. There may or may
|
|
||||||
* not be an actual kernel thread attached to a given source.
|
|
||||||
*/
|
*/
|
||||||
struct ithd {
|
struct intr_event {
|
||||||
struct mtx it_lock;
|
TAILQ_ENTRY(intr_event) ie_list;
|
||||||
struct thread *it_td; /* Interrupt process. */
|
TAILQ_HEAD(, intr_handler) ie_handlers; /* Interrupt handlers. */
|
||||||
LIST_ENTRY(ithd) it_list; /* All interrupt threads. */
|
char ie_name[MAXCOMLEN]; /* Individual event name. */
|
||||||
TAILQ_HEAD(, intrhand) it_handlers; /* Interrupt handlers. */
|
char ie_fullname[MAXCOMLEN];
|
||||||
struct ithd *it_interrupted; /* Who we interrupted. */
|
struct mtx ie_lock;
|
||||||
void (*it_disable)(uintptr_t); /* Enable interrupt source. */
|
void *ie_source; /* Cookie used by MD code. */
|
||||||
void (*it_enable)(uintptr_t); /* Disable interrupt source. */
|
struct intr_thread *ie_thread; /* Thread we are connected to. */
|
||||||
void *it_md; /* Hook for MD interrupt code. */
|
void (*ie_enable)(void *);
|
||||||
int it_flags; /* Interrupt-specific flags. */
|
int ie_flags;
|
||||||
int it_need; /* Needs service. */
|
int ie_count; /* Loop counter. */
|
||||||
uintptr_t it_vector;
|
int ie_warned; /* Warned about interrupt storm. */
|
||||||
char it_name[MAXCOMLEN + 1];
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/* Interrupt thread flags kept in it_flags */
|
/* Interrupt event flags kept in ie_flags. */
|
||||||
#define IT_SOFT 0x000001 /* Software interrupt. */
|
#define IE_SOFT 0x000001 /* Software interrupt. */
|
||||||
#define IT_ENTROPY 0x000002 /* Interrupt is an entropy source. */
|
#define IE_ENTROPY 0x000002 /* Interrupt is an entropy source. */
|
||||||
#define IT_DEAD 0x000004 /* Thread is waiting to exit. */
|
#define IE_ADDING_THREAD 0x000004 /* Currently building an ithread. */
|
||||||
|
|
||||||
/* Flags to pass to sched_swi. */
|
/* Flags to pass to sched_swi. */
|
||||||
#define SWI_DELAY 0x2
|
#define SWI_DELAY 0x2
|
||||||
@ -97,8 +97,8 @@ struct ithd {
|
|||||||
#define SWI_TQ 6
|
#define SWI_TQ 6
|
||||||
#define SWI_TQ_GIANT 6
|
#define SWI_TQ_GIANT 6
|
||||||
|
|
||||||
extern struct ithd *tty_ithd;
|
extern struct intr_event *tty_intr_event;
|
||||||
extern struct ithd *clk_ithd;
|
extern struct intr_event *clk_intr_event;
|
||||||
extern void *softclock_ih;
|
extern void *softclock_ih;
|
||||||
extern void *vm_ih;
|
extern void *vm_ih;
|
||||||
|
|
||||||
@ -109,19 +109,19 @@ extern u_long intrcnt[]; /* counts for for each device and stray */
|
|||||||
extern char intrnames[]; /* string table containing device names */
|
extern char intrnames[]; /* string table containing device names */
|
||||||
|
|
||||||
#ifdef DDB
|
#ifdef DDB
|
||||||
void db_dump_ithread(struct ithd *ithd, int handlers);
|
void db_dump_intr_event(struct intr_event *ie, int handlers);
|
||||||
#endif
|
#endif
|
||||||
int ithread_create(struct ithd **ithread, uintptr_t vector, int flags,
|
u_char intr_priority(enum intr_type flags);
|
||||||
void (*disable)(uintptr_t), void (*enable)(uintptr_t),
|
int intr_event_add_handler(struct intr_event *ie, const char *name,
|
||||||
const char *fmt, ...) __printflike(6, 7);
|
|
||||||
int ithread_destroy(struct ithd *ithread);
|
|
||||||
u_char ithread_priority(enum intr_type flags);
|
|
||||||
int ithread_add_handler(struct ithd *ithread, const char *name,
|
|
||||||
driver_intr_t handler, void *arg, u_char pri, enum intr_type flags,
|
driver_intr_t handler, void *arg, u_char pri, enum intr_type flags,
|
||||||
void **cookiep);
|
void **cookiep);
|
||||||
int ithread_remove_handler(void *cookie);
|
int intr_event_create(struct intr_event **event, void *source,
|
||||||
int ithread_schedule(struct ithd *ithread);
|
int flags, void (*enable)(void *), const char *fmt, ...)
|
||||||
int swi_add(struct ithd **ithdp, const char *name,
|
__printflike(5, 6);
|
||||||
|
int intr_event_destroy(struct intr_event *ie);
|
||||||
|
int intr_event_remove_handler(void *cookie);
|
||||||
|
int intr_event_schedule_thread(struct intr_event *ie);
|
||||||
|
int swi_add(struct intr_event **eventp, const char *name,
|
||||||
driver_intr_t handler, void *arg, int pri, enum intr_type flags,
|
driver_intr_t handler, void *arg, int pri, enum intr_type flags,
|
||||||
void **cookiep);
|
void **cookiep);
|
||||||
void swi_sched(void *cookie, int flags);
|
void swi_sched(void *cookie, int flags);
|
||||||
|
@ -150,7 +150,6 @@ struct pargs {
|
|||||||
* either lock is sufficient for read access, but both locks must be held
|
* either lock is sufficient for read access, but both locks must be held
|
||||||
* for write access.
|
* for write access.
|
||||||
*/
|
*/
|
||||||
struct ithd;
|
|
||||||
struct kg_sched;
|
struct kg_sched;
|
||||||
struct nlminfo;
|
struct nlminfo;
|
||||||
struct kaioinfo;
|
struct kaioinfo;
|
||||||
@ -270,7 +269,6 @@ struct thread {
|
|||||||
volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */
|
volatile u_char td_owepreempt; /* (k*) Preempt on last critical_exit */
|
||||||
short td_locks; /* (k) DEBUG: lockmgr count of locks. */
|
short td_locks; /* (k) DEBUG: lockmgr count of locks. */
|
||||||
struct turnstile *td_blocked; /* (j) Lock process is blocked on. */
|
struct turnstile *td_blocked; /* (j) Lock process is blocked on. */
|
||||||
struct ithd *td_ithd; /* (b) For interrupt threads only. */
|
|
||||||
const char *td_lockname; /* (j) Name of lock blocked on. */
|
const char *td_lockname; /* (j) Name of lock blocked on. */
|
||||||
LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */
|
LIST_HEAD(, turnstile) td_contested; /* (q) Contested locks. */
|
||||||
struct lock_list_entry *td_sleeplocks; /* (k) Held sleep locks. */
|
struct lock_list_entry *td_sleeplocks; /* (k) Held sleep locks. */
|
||||||
@ -372,7 +370,7 @@ struct thread {
|
|||||||
#define TDP_SA 0x00000080 /* A scheduler activation based thread. */
|
#define TDP_SA 0x00000080 /* A scheduler activation based thread. */
|
||||||
#define TDP_NOSLEEPING 0x00000100 /* Thread is not allowed to sleep on a sq. */
|
#define TDP_NOSLEEPING 0x00000100 /* Thread is not allowed to sleep on a sq. */
|
||||||
#define TDP_OWEUPC 0x00000200 /* Call addupc() at next AST. */
|
#define TDP_OWEUPC 0x00000200 /* Call addupc() at next AST. */
|
||||||
#define TDP_UNUSED10 0x00000400 /* --available -- */
|
#define TDP_ITHREAD 0x00000400 /* Thread is an interrupt thread. */
|
||||||
#define TDP_CAN_UNBIND 0x00000800 /* Only temporarily bound. */
|
#define TDP_CAN_UNBIND 0x00000800 /* Only temporarily bound. */
|
||||||
#define TDP_SCHED1 0x00001000 /* Reserved for scheduler private use */
|
#define TDP_SCHED1 0x00001000 /* Reserved for scheduler private use */
|
||||||
#define TDP_SCHED2 0x00002000 /* Reserved for scheduler private use */
|
#define TDP_SCHED2 0x00002000 /* Reserved for scheduler private use */
|
||||||
|
Loading…
Reference in New Issue
Block a user