static void ithread_handler(void *arg);
static void ithread_emergency(void *arg);
static void report_stray_interrupt(int intr, struct intr_info *info);
-static void int_moveto_destcpu(int *, int *, int);
+static void int_moveto_destcpu(int *, int);
static void int_moveto_origcpu(int, int);
int intr_info_size = NELEM(intr_info_ary);
{
if (intr < FIRST_SOFTINT || intr >= MAX_INTS)
panic("register_swi: bad intr %d", intr);
- return(register_int(intr, handler, arg, name, serializer, 0));
+ return(register_int(intr, handler, arg, name, serializer, 0, 0));
}
void *
{
if (intr < FIRST_SOFTINT || intr >= MAX_INTS)
panic("register_swi: bad intr %d", intr);
- return(register_int(intr, handler, arg, name, serializer, INTR_MPSAFE));
+ return(register_int(intr, handler, arg, name, serializer, INTR_MPSAFE, 0));
}
void *
register_int(int intr, inthand2_t *handler, void *arg, const char *name,
- struct lwkt_serialize *serializer, int intr_flags)
+ struct lwkt_serialize *serializer, int intr_flags, int cpuid)
{
struct intr_info *info;
struct intrec **list;
intrec_t rec;
- int orig_cpuid, cpuid;
+ int orig_cpuid;
+
+ KKASSERT(cpuid >= 0 && cpuid < ncpus);
if (intr < 0 || intr >= MAX_INTS)
panic("register_int: bad intr %d", intr);
(emergency_intr_enable ? emergency_intr_freq : 1));
}
- int_moveto_destcpu(&orig_cpuid, &cpuid, intr);
+ int_moveto_destcpu(&orig_cpuid, cpuid);
/*
* Create an interrupt thread if necessary, leave it in an unscheduled
* state.
- *
- * Put it on cpu 0 for now, other work is pending related to this.
*/
if (info->i_state == ISTATE_NOTHREAD) {
info->i_state = ISTATE_NORMAL;
lwkt_create(ithread_handler, (void *)(intptr_t)intr, NULL,
- &info->i_thread, TDF_STOPREQ | TDF_INTTHREAD, 0,
+ &info->i_thread, TDF_STOPREQ | TDF_INTTHREAD, cpuid,
"ithread %d", intr);
if (intr >= FIRST_SOFTINT)
lwkt_setpri(&info->i_thread, TDPRI_SOFT_NORM);
void
unregister_swi(void *id)
{
- unregister_int(id);
+ unregister_int(id, 0);
}
void
-unregister_int(void *id)
+unregister_int(void *id, int cpuid)
{
struct intr_info *info;
struct intrec **list;
intrec_t rec;
- int intr, orig_cpuid, cpuid;
+ int intr, orig_cpuid;
+
+ KKASSERT(cpuid >= 0 && cpuid < ncpus);
intr = ((intrec_t)id)->intr;
info = &intr_info_ary[intr];
- int_moveto_destcpu(&orig_cpuid, &cpuid, intr);
+ int_moveto_destcpu(&orig_cpuid, cpuid);
/*
* Remove the interrupt descriptor, adjust the descriptor count,
NULL, 0, sysctl_intrcnt_all, "", "Interrupt Counts");
static void
-int_moveto_destcpu(int *orig_cpuid0, int *cpuid0, int intr)
+int_moveto_destcpu(int *orig_cpuid0, int cpuid)
{
- int orig_cpuid = mycpuid, cpuid;
- char envpath[32];
-
- cpuid = orig_cpuid;
- ksnprintf(envpath, sizeof(envpath), "hw.irq.%d.dest", intr);
- kgetenv_int(envpath, &cpuid);
- if (cpuid >= ncpus)
- cpuid = orig_cpuid;
+ int orig_cpuid = mycpuid;
if (cpuid != orig_cpuid)
lwkt_migratecpu(cpuid);
*orig_cpuid0 = orig_cpuid;
- *cpuid0 = cpuid;
}
static void
#include <sys/kernel.h>
#include <sys/machintr.h>
#include <sys/systm.h>
+#include <sys/thread2.h>
#include "acpi_sdt.h"
#include "acpi_sdt_var.h"
{
const struct acpi_sci_mode *mode;
+ KKASSERT(mycpuid == 0);
+
if (acpi_sci_irq < 0)
return;
sci_desc = register_int(acpi_sci_irq,
acpi_sci_dummy_intr, NULL, "sci", NULL,
INTR_EXCL | INTR_CLOCK |
- INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY);
+ INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY, 0);
DELAY(100 * 1000);
- unregister_int(sci_desc);
+ unregister_int(sci_desc, 0);
if (get_interrupt_counter(acpi_sci_irq) - last_cnt < 20) {
acpi_sci_trig = mode->sci_trig;
*/
*cookiep = register_int(irq->r_start, (inthand2_t *)ihand, arg,
device_get_nameunit(child), serializer,
- icflags);
+ icflags, rman_get_cpuid(irq));
if (*cookiep == NULL)
error = EINVAL;
return (error);
nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
{
if (ih) {
- unregister_int(ih);
+ unregister_int(ih, rman_get_cpuid(r));
return (0);
}
return(-1);
void *clkdesc = NULL;
int irq = 0, mixed_mode = 0, error;
+ KKASSERT(mycpuid == 0);
callout_init(&sysbeepstop_ch);
if (!selected && i8254_intr_disable)
NULL,
INTR_EXCL | INTR_CLOCK |
INTR_NOPOLL | INTR_MPSAFE |
- INTR_NOENTROPY);
+ INTR_NOENTROPY, 0);
} else {
register_int(0, clkintr, NULL, "clk", NULL,
INTR_EXCL | INTR_CLOCK |
INTR_NOPOLL | INTR_MPSAFE |
- INTR_NOENTROPY);
+ INTR_NOENTROPY, 0);
}
/* Initialize RTC. */
} else {
kprintf("IOAPIC: warning 8254 is not connected "
"to the correct pin, try mixed mode\n");
- unregister_int(clkdesc);
+ unregister_int(clkdesc, 0);
goto mixed_mode_setup;
}
}
#include <sys/kernel.h>
#include <sys/machintr.h>
#include <sys/systm.h>
+#include <sys/thread2.h>
#include "acpi_sdt.h"
#include "acpi_sdt_var.h"
{
const struct acpi_sci_mode *mode;
+ KKASSERT(mycpuid == 0);
+
if (acpi_sci_irq < 0)
return;
sci_desc = register_int(acpi_sci_irq,
acpi_sci_dummy_intr, NULL, "sci", NULL,
INTR_EXCL | INTR_CLOCK |
- INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY);
+ INTR_NOPOLL | INTR_MPSAFE | INTR_NOENTROPY, 0);
DELAY(100 * 1000);
- unregister_int(sci_desc);
+ unregister_int(sci_desc, 0);
if (get_interrupt_counter(acpi_sci_irq) - last_cnt < 20) {
acpi_sci_trig = mode->sci_trig;
void *clkdesc = NULL;
int irq = 0, mixed_mode = 0, error;
+ KKASSERT(mycpuid == 0);
callout_init_mp(&sysbeepstop_ch);
if (!selected && i8254_intr_disable)
NULL,
INTR_EXCL | INTR_CLOCK |
INTR_NOPOLL | INTR_MPSAFE |
- INTR_NOENTROPY);
+ INTR_NOENTROPY, 0);
} else {
register_int(0, clkintr, NULL, "clk", NULL,
INTR_EXCL | INTR_CLOCK |
INTR_NOPOLL | INTR_MPSAFE |
- INTR_NOENTROPY);
+ INTR_NOENTROPY, 0);
}
/* Initialize RTC. */
} else {
kprintf("IOAPIC: warning 8254 is not connected "
"to the correct pin, try mixed mode\n");
- unregister_int(clkdesc);
+ unregister_int(clkdesc, 0);
goto mixed_mode_setup;
}
}
*/
*cookiep = register_int(irq->r_start, (inthand2_t *)ihand, arg,
device_get_nameunit(child), serializer,
- icflags);
+ icflags, rman_get_cpuid(irq));
if (*cookiep == NULL)
error = EINVAL;
return (error);
nexus_teardown_intr(device_t dev, device_t child, struct resource *r, void *ih)
{
if (ih) {
- unregister_int(ih);
+ unregister_int(ih, rman_get_cpuid(r));
return (0);
}
return(-1);
* We have to do this here rather then in early boot to be able
* to use the interrupt subsystem.
*/
- register_int(3, vconswinch_intr, NULL, "swinch", NULL, INTR_MPSAFE);
+ register_int(3, vconswinch_intr, NULL, "swinch", NULL, INTR_MPSAFE, 0);
bzero(&sa, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_handler = vconswinchsig;
cotd->pintr = pthread_self();
cotd->intr_id = register_int(1, (void *)thr_intr, cotd, name, NULL,
- INTR_MPSAFE);
+ INTR_MPSAFE, 0);
/*
* The vkernel's cpu_disable_intr() masks signals. We don't want
cothread_t cotd;
if ((cotd = *cotdp) != NULL) {
- unregister_int(cotd->intr_id);
+ unregister_int(cotd->intr_id, 0);
crit_enter();
pthread_join(cotd->pthr, NULL);
crit_exit();
struct kqueue_info *info;
struct kevent kev;
- if (VIntr1 == NULL)
+ if (VIntr1 == NULL) {
VIntr1 = register_int(1, kqueue_intr, NULL, "kqueue", NULL,
- INTR_MPSAFE);
+ INTR_MPSAFE, 0);
+ }
info = kmalloc(sizeof(*info), M_DEVBUF, M_ZERO|M_INTWAIT);
info->func = func;
{
struct kqueue_info *info;
- if (VIntr1 == NULL)
- VIntr1 = register_int(1, kqueue_intr, NULL, "kqueue", NULL, 0);
+ if (VIntr1 == NULL) {
+ VIntr1 = register_int(1, kqueue_intr, NULL, "kqueue", NULL,
+ 0, 0);
+ }
info = kmalloc(sizeof(*info), M_DEVBUF, M_ZERO|M_INTWAIT);
info->func = func;
sa.sa_handler = shutdownsig;
sigaction(SIGTERM, &sa, NULL);
- register_int(2, shutdown_intr, NULL, "shutdown", NULL, INTR_MPSAFE);
+ register_int(2, shutdown_intr, NULL, "shutdown", NULL, INTR_MPSAFE, 0);
}
static
* We have to do this here rather then in early boot to be able
* to use the interrupt subsystem.
*/
- register_int(3, vconswinch_intr, NULL, "swinch", NULL, INTR_MPSAFE);
+ register_int(3, vconswinch_intr, NULL, "swinch", NULL, INTR_MPSAFE, 0);
bzero(&sa, sizeof(sa));
sigemptyset(&sa.sa_mask);
sa.sa_handler = vconswinchsig;
cotd->pintr = pthread_self();
cotd->intr_id = register_int(1, (void *)thr_intr, cotd, name, NULL,
- INTR_MPSAFE);
+ INTR_MPSAFE, 0);
/*
* The vkernel's cpu_disable_intr() masks signals. We don't want
cothread_t cotd;
if ((cotd = *cotdp) != NULL) {
- unregister_int(cotd->intr_id);
+ unregister_int(cotd->intr_id, 0);
crit_enter();
pthread_join(cotd->pthr, NULL);
crit_exit();
struct kqueue_info *info;
struct kevent kev;
- if (VIntr1 == NULL)
+ if (VIntr1 == NULL) {
VIntr1 = register_int(1, kqueue_intr, NULL, "kqueue", NULL,
- INTR_MPSAFE);
+ INTR_MPSAFE, 0);
+ }
info = kmalloc(sizeof(*info), M_DEVBUF, M_ZERO|M_INTWAIT);
info->func = func;
{
struct kqueue_info *info;
- if (VIntr1 == NULL)
+ if (VIntr1 == NULL) {
VIntr1 = register_int(1, kqueue_intr, NULL, "kqueue", NULL,
- INTR_MPSAFE);
+ INTR_MPSAFE, 0);
+ }
info = kmalloc(sizeof(*info), M_DEVBUF, M_ZERO|M_INTWAIT);
info->func = func;
sa.sa_handler = shutdownsig;
sigaction(SIGTERM, &sa, NULL);
- register_int(2, shutdown_intr, NULL, "shutdown", NULL, INTR_MPSAFE);
+ register_int(2, shutdown_intr, NULL, "shutdown", NULL, INTR_MPSAFE, 0);
}
static
struct lwkt_serialize *serializer);
void *register_int(int intr, inthand2_t *handler, void *arg,
const char *name,
- struct lwkt_serialize *serializer, int flags);
+ struct lwkt_serialize *serializer, int flags,
+ int cpuid);
long get_interrupt_counter(int intr);
int count_registered_ints(int intr);
const char *get_registered_name(int intr);
void swi_setpriority(int intr, int pri);
void unregister_swi(void *id);
-void unregister_int(void *id);
+void unregister_int(void *id, int cpuid);
void register_randintr(int intr);
void unregister_randintr(int intr);
int next_registered_randintr(int intr);