diff options
author | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2013-05-12 14:15:32 +0000 |
---|---|---|
committer | Alexandre Ratchov <ratchov@cvs.openbsd.org> | 2013-05-12 14:15:32 +0000 |
commit | 138c1e3d20b3cb194ac4b2084e169a352f435cf4 (patch) | |
tree | 5276bfce175e4099f4aa324f74da104ba2e455b0 /sys/arch/amd64 | |
parent | ff051aeeb25a82fbab57e6e17823414ce7c5ad60 (diff) |
Take the kernel lock and call the actual interrupt handler from a
single c function. This will hopefully make easier to stop taking
the kernel lock when running "mp safe" interrupt handlers.
help from ok kettenis
Diffstat (limited to 'sys/arch/amd64')
-rw-r--r-- | sys/arch/amd64/amd64/intr.c | 36 | ||||
-rw-r--r-- | sys/arch/amd64/amd64/vector.S | 20 | ||||
-rw-r--r-- | sys/arch/amd64/include/intr.h | 5 |
3 files changed, 27 insertions, 34 deletions
diff --git a/sys/arch/amd64/amd64/intr.c b/sys/arch/amd64/amd64/intr.c index a49d7828b58..6175d7de464 100644 --- a/sys/arch/amd64/amd64/intr.c +++ b/sys/arch/amd64/amd64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.32 2012/12/05 23:20:10 deraadt Exp $ */ +/* $OpenBSD: intr.c,v 1.33 2013/05/12 14:15:31 ratchov Exp $ */ /* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */ /* @@ -523,6 +523,26 @@ intr_disestablish(struct intrhand *ih) simple_unlock(&ci->ci_slock); } +int +intr_handler(struct intrframe *frame, struct intrhand *ih) +{ + int rc; +#ifdef MULTIPROCESSOR + int need_lock; + + need_lock = frame->if_ppl < IPL_SCHED; + + if (need_lock) + __mp_lock(&kernel_lock); +#endif + rc = (*ih->ih_fun)(ih->ih_arg ? ih->ih_arg : frame); +#ifdef MULTIPROCESSOR + if (need_lock) + __mp_unlock(&kernel_lock); +#endif + return rc; +} + #define CONCAT(x,y) __CONCAT(x,y) /* @@ -608,20 +628,6 @@ cpu_intr_init(struct cpu_info *ci) #ifdef MULTIPROCESSOR void -x86_intlock(struct intrframe iframe) -{ - if (iframe.if_ppl < IPL_SCHED) - __mp_lock(&kernel_lock); -} - -void -x86_intunlock(struct intrframe iframe) -{ - if (iframe.if_ppl < IPL_SCHED) - __mp_unlock(&kernel_lock); -} - -void x86_softintlock(void) { __mp_lock(&kernel_lock); diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S index c4ddc234f83..128620b00ae 100644 --- a/sys/arch/amd64/amd64/vector.S +++ b/sys/arch/amd64/amd64/vector.S @@ -1,4 +1,4 @@ -/* $OpenBSD: vector.S,v 1.32 2012/07/09 16:01:16 deraadt Exp $ */ +/* $OpenBSD: vector.S,v 1.33 2013/05/12 14:15:31 ratchov Exp $ */ /* $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $ */ /* @@ -423,13 +423,6 @@ IDTVEC(resume_lapic_ltimer) INTRFASTEXIT #endif /* NLAPIC > 0 */ -#ifdef MULTIPROCESSOR -#define LOCK_KERNEL movq %rsp, %rdi; call _C_LABEL(x86_intlock) -#define UNLOCK_KERNEL movq %rsp, %rdi; call _C_LABEL(x86_intunlock) -#else -#define LOCK_KERNEL -#define UNLOCK_KERNEL -#endif #define voidop(num) @@ -471,17 +464,14 @@ IDTVEC(intr_##name##num) ;\ sti ;\ incl CPUVAR(IDEPTH) ;\ movq IS_HANDLERS(%r14),%rbx ;\ - LOCK_KERNEL ;\ 6: \ movl IH_LEVEL(%rbx),%r12d ;\ cmpl %r13d,%r12d ;\ jle 7f ;\ - movq IH_ARG(%rbx),%rdi ;\ - testq %rdi, %rdi ;\ - jnz 8f ;\ + movl %r12d,CPUVAR(ILEVEL) ;\ + movq %rbx, %rsi ;\ movq %rsp, %rdi ;\ -8: movl %r12d,CPUVAR(ILEVEL) ;\ - call *IH_FUN(%rbx) /* call it */ ;\ + call _C_LABEL(intr_handler) /* call it */ ;\ orl %eax,%eax /* should it be counted? */ ;\ jz 4f /* no, skip it */ ;\ incq IH_COUNT(%rbx) /* count the intrs */ ;\ @@ -493,14 +483,12 @@ IDTVEC(intr_##name##num) ;\ testq %rbx,%rbx ;\ jnz 6b ;\ 5: \ - UNLOCK_KERNEL ;\ cli ;\ unmask(num) /* unmask it in hardware */ ;\ late_ack(num) ;\ sti ;\ jmp _C_LABEL(Xdoreti) /* lower spl and do ASTs */ ;\ 7: \ - UNLOCK_KERNEL ;\ cli ;\ movq $(1 << num),%rax ;\ orq %rax,CPUVAR(IPENDING) ;\ diff --git a/sys/arch/amd64/include/intr.h b/sys/arch/amd64/include/intr.h index fdb6d236b44..a4f6674f12e 100644 --- a/sys/arch/amd64/include/intr.h +++ b/sys/arch/amd64/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.23 2011/04/16 00:40:58 deraadt Exp $ */ +/* $OpenBSD: intr.h,v 1.24 2013/05/12 14:15:31 ratchov Exp $ */ /* $NetBSD: intr.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */ /*- @@ -204,6 +204,7 @@ int intr_allocate_slot(struct pic *, int, int, int, struct cpu_info **, int *, void *intr_establish(int, struct pic *, int, int, int, int (*)(void *), void *, const char *); void intr_disestablish(struct intrhand *); +int intr_handler(struct intrframe *, struct intrhand *); void cpu_intr_init(struct cpu_info *); int intr_find_mpmapping(int bus, int pin, int *handle); void intr_printconfig(void); @@ -213,8 +214,6 @@ int x86_send_ipi(struct cpu_info *, int); int x86_fast_ipi(struct cpu_info *, int); void x86_broadcast_ipi(int); void x86_ipi_handler(void); -void x86_intlock(struct intrframe); -void x86_intunlock(struct intrframe); void x86_softintlock(void); void x86_softintunlock(void); void x86_setperf_ipi(struct cpu_info *); |