summaryrefslogtreecommitdiffstats
path: root/sys/x86
diff options
context:
space:
mode:
Diffstat (limited to 'sys/x86')
-rw-r--r--sys/x86/x86/intr_machdep.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/sys/x86/x86/intr_machdep.c b/sys/x86/x86/intr_machdep.c
index 9a5e463..980da87 100644
--- a/sys/x86/x86/intr_machdep.c
+++ b/sys/x86/x86/intr_machdep.c
@@ -46,6 +46,7 @@
#include <sys/mutex.h>
#include <sys/proc.h>
#include <sys/smp.h>
+#include <sys/sx.h>
#include <sys/syslog.h>
#include <sys/systm.h>
#include <machine/clock.h>
@@ -73,7 +74,8 @@ typedef void (*mask_fn)(void *);
static int intrcnt_index;
static struct intsrc *interrupt_sources[NUM_IO_INTS];
-static struct mtx intr_table_lock;
+static struct sx intrsrc_lock;
+static struct mtx intrpic_lock;
static struct mtx intrcnt_lock;
static TAILQ_HEAD(pics_head, pic) pics;
@@ -117,14 +119,14 @@ intr_register_pic(struct pic *pic)
{
int error;
- mtx_lock(&intr_table_lock);
+ mtx_lock(&intrpic_lock);
if (intr_pic_registered(pic))
error = EBUSY;
else {
TAILQ_INSERT_TAIL(&pics, pic, pics);
error = 0;
}
- mtx_unlock(&intr_table_lock);
+ mtx_unlock(&intrpic_lock);
return (error);
}
@@ -148,16 +150,16 @@ intr_register_source(struct intsrc *isrc)
vector);
if (error)
return (error);
- mtx_lock(&intr_table_lock);
+ sx_xlock(&intrsrc_lock);
if (interrupt_sources[vector] != NULL) {
- mtx_unlock(&intr_table_lock);
+ sx_xunlock(&intrsrc_lock);
intr_event_destroy(isrc->is_event);
return (EEXIST);
}
intrcnt_register(isrc);
interrupt_sources[vector] = isrc;
isrc->is_handlers = 0;
- mtx_unlock(&intr_table_lock);
+ sx_xunlock(&intrsrc_lock);
return (0);
}
@@ -181,14 +183,14 @@ intr_add_handler(const char *name, int vector, driver_filter_t filter,
error = intr_event_add_handler(isrc->is_event, name, filter, handler,
arg, intr_priority(flags), flags, cookiep);
if (error == 0) {
- mtx_lock(&intr_table_lock);
+ sx_xlock(&intrsrc_lock);
intrcnt_updatename(isrc);
isrc->is_handlers++;
if (isrc->is_handlers == 1) {
isrc->is_pic->pic_enable_intr(isrc);
isrc->is_pic->pic_enable_source(isrc);
}
- mtx_unlock(&intr_table_lock);
+ sx_xunlock(&intrsrc_lock);
}
return (error);
}
@@ -202,14 +204,14 @@ intr_remove_handler(void *cookie)
isrc = intr_handler_source(cookie);
error = intr_event_remove_handler(cookie);
if (error == 0) {
- mtx_lock(&intr_table_lock);
+ sx_xlock(&intrsrc_lock);
isrc->is_handlers--;
if (isrc->is_handlers == 0) {
isrc->is_pic->pic_disable_source(isrc, PIC_NO_EOI);
isrc->is_pic->pic_disable_intr(isrc);
}
intrcnt_updatename(isrc);
- mtx_unlock(&intr_table_lock);
+ sx_xunlock(&intrsrc_lock);
}
return (error);
}
@@ -283,12 +285,12 @@ intr_resume(bool suspend_cancelled)
#ifndef DEV_ATPIC
atpic_reset();
#endif
- mtx_lock(&intr_table_lock);
+ mtx_lock(&intrpic_lock);
TAILQ_FOREACH(pic, &pics, pics) {
if (pic->pic_resume != NULL)
pic->pic_resume(pic, suspend_cancelled);
}
- mtx_unlock(&intr_table_lock);
+ mtx_unlock(&intrpic_lock);
}
void
@@ -296,12 +298,12 @@ intr_suspend(void)
{
struct pic *pic;
- mtx_lock(&intr_table_lock);
+ mtx_lock(&intrpic_lock);
TAILQ_FOREACH_REVERSE(pic, &pics, pics_head, pics) {
if (pic->pic_suspend != NULL)
pic->pic_suspend(pic);
}
- mtx_unlock(&intr_table_lock);
+ mtx_unlock(&intrpic_lock);
}
static int
@@ -317,9 +319,9 @@ intr_assign_cpu(void *arg, u_char cpu)
*/
if (assign_cpu && cpu != NOCPU) {
isrc = arg;
- mtx_lock(&intr_table_lock);
+ sx_xlock(&intrsrc_lock);
error = isrc->is_pic->pic_assign_cpu(isrc, cpu_apic_ids[cpu]);
- mtx_unlock(&intr_table_lock);
+ sx_xunlock(&intrsrc_lock);
} else
error = 0;
return (error);
@@ -379,7 +381,8 @@ intr_init(void *dummy __unused)
intrcnt_setname("???", 0);
intrcnt_index = 1;
TAILQ_INIT(&pics);
- mtx_init(&intr_table_lock, "intr sources", NULL, MTX_DEF);
+ mtx_init(&intrpic_lock, "intrpic", NULL, MTX_DEF);
+ sx_init(&intrsrc_lock, "intrsrc");
mtx_init(&intrcnt_lock, "intrcnt", NULL, MTX_SPIN);
}
SYSINIT(intr_init, SI_SUB_INTR, SI_ORDER_FIRST, intr_init, NULL);
@@ -527,7 +530,7 @@ intr_shuffle_irqs(void *arg __unused)
return;
/* Round-robin assign a CPU to each enabled source. */
- mtx_lock(&intr_table_lock);
+ sx_xlock(&intrsrc_lock);
assign_cpu = 1;
for (i = 0; i < NUM_IO_INTS; i++) {
isrc = interrupt_sources[i];
@@ -548,7 +551,7 @@ intr_shuffle_irqs(void *arg __unused)
}
}
- mtx_unlock(&intr_table_lock);
+ sx_xunlock(&intrsrc_lock);
}
SYSINIT(intr_shuffle_irqs, SI_SUB_SMP, SI_ORDER_SECOND, intr_shuffle_irqs,
NULL);
OpenPOWER on IntegriCloud