From 5aa0e3f0355e445f9c826a7f58c3620b8c80e6d8 Mon Sep 17 00:00:00 2001 From: Ted Unangst Date: Sat, 6 Dec 2008 04:31:25 +0000 Subject: mpsafe intr_establish that doesn't get biglock, so that we may dream of the day when this is useful. mostly macro magic that does nothing. only actually useful on amd64 for now, compliments of art. --- sys/arch/amd64/amd64/intr.c | 45 ++++++++++++++++++++++------------ sys/arch/amd64/amd64/vector.S | 13 +--------- sys/arch/amd64/include/intr.h | 10 +++++--- sys/arch/amd64/include/pci_machdep.h | 11 ++++++--- sys/arch/arm/include/pci_machdep.h | 4 ++- sys/arch/hppa/include/pci_machdep.h | 4 ++- sys/arch/hppa64/include/pci_machdep.h | 4 ++- sys/arch/landisk/include/pci_machdep.h | 4 ++- sys/arch/sparc64/include/pci_machdep.h | 4 ++- 9 files changed, 59 insertions(+), 40 deletions(-) (limited to 'sys/arch') diff --git a/sys/arch/amd64/amd64/intr.c b/sys/arch/amd64/amd64/intr.c index 04969b9043b..1aec44f3fe4 100644 --- a/sys/arch/amd64/amd64/intr.c +++ b/sys/arch/amd64/amd64/intr.c @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.c,v 1.19 2008/10/22 19:53:31 kettenis Exp $ */ +/* $OpenBSD: intr.c,v 1.20 2008/12/06 04:31:24 tedu Exp $ */ /* $NetBSD: intr.c,v 1.3 2003/03/03 22:16:20 fvdl Exp $ */ /* @@ -79,6 +79,8 @@ struct pic softintr_pic = { NULL, }; +int intr_biglock_wrap(void *); + /* * Fill in default interrupt table (in case of spurious interrupt * during configuration of kernel), setup interrupt control unit @@ -353,13 +355,17 @@ found: void * intr_establish(int legacy_irq, struct pic *pic, int pin, int type, int level, - int (*handler)(void *), void *arg, char *what) + int (*handler)(void *), void *arg, char *what, int flags) { struct intrhand **p, *q, *ih; struct cpu_info *ci; int slot, error, idt_vec; struct intrsource *source; struct intrstub *stubp; + int mpsafe = 0; + + if (level >= IPL_SCHED || (flags & INTR_ESTABLISH_MPSAFE)) + mpsafe = 1; #ifdef DIAGNOSTIC if (legacy_irq != -1 && (legacy_irq < 0 || legacy_irq > 15)) @@ -444,6 +450,14 @@ intr_establish(int legacy_irq, struct pic *pic, int pin, int type, int level, ih->ih_pin = pin; ih->ih_cpu = ci; ih->ih_slot = slot; +#ifdef MULTIPROCESSOR + if (!mpsafe) { + ih->ih_wrapped_fun = handler; + ih->ih_wrapped_arg = arg; + ih->ih_fun = intr_biglock_wrap; + ih->ih_arg = ih; + } +#endif evcount_attach(&ih->ih_count, what, (void *)&ih->ih_pin, &evcount_intr); @@ -539,6 +553,19 @@ intr_disestablish(struct intrhand *ih) simple_unlock(&ci->ci_slock); } +int +intr_biglock_wrap(void *v) +{ + struct intrhand *ih = v; + int ret; + + __mp_lock(&kernel_lock); + ret = (*ih->ih_wrapped_fun)(ih->ih_wrapped_arg); + __mp_unlock(&kernel_lock); + + return (ret); +} + #define CONCAT(x,y) __CONCAT(x,y) /* @@ -623,20 +650,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) { diff --git a/sys/arch/amd64/amd64/vector.S b/sys/arch/amd64/amd64/vector.S index d79ee5da8e9..511af4d5ac4 100644 --- a/sys/arch/amd64/amd64/vector.S +++ b/sys/arch/amd64/amd64/vector.S @@ -1,4 +1,4 @@ -/* $OpenBSD: vector.S,v 1.14 2008/06/27 06:03:08 ray Exp $ */ +/* $OpenBSD: vector.S,v 1.15 2008/12/06 04:31:24 tedu Exp $ */ /* $NetBSD: vector.S,v 1.5 2004/06/28 09:13:11 fvdl Exp $ */ /* @@ -381,14 +381,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) @@ -429,7 +421,6 @@ IDTVEC(intr_/**/name/**/num) ;\ sti ;\ incl CPUVAR(IDEPTH) ;\ movq IS_HANDLERS(%r14),%rbx ;\ - LOCK_KERNEL ;\ 6: \ movl IH_LEVEL(%rbx),%r12d ;\ cmpl %r13d,%r12d ;\ @@ -447,14 +438,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 ;\ orl $(1 << num),CPUVAR(IPENDING) ;\ level_mask(num) ;\ diff --git a/sys/arch/amd64/include/intr.h b/sys/arch/amd64/include/intr.h index a376d42d2d4..740ffb0ec5d 100644 --- a/sys/arch/amd64/include/intr.h +++ b/sys/arch/amd64/include/intr.h @@ -1,4 +1,4 @@ -/* $OpenBSD: intr.h,v 1.13 2008/06/26 05:42:09 ray Exp $ */ +/* $OpenBSD: intr.h,v 1.14 2008/12/06 04:31:24 tedu Exp $ */ /* $NetBSD: intr.h,v 1.2 2003/05/04 22:01:56 fvdl Exp $ */ /*- @@ -91,6 +91,8 @@ struct intrsource { struct intrhand { int (*ih_fun)(void *); void *ih_arg; + int (*ih_wrapped_fun)(void *); + void *ih_wrapped_arg; int ih_level; struct intrhand *ih_next; int ih_pin; @@ -206,8 +208,10 @@ void intr_calculatemasks(struct cpu_info *); int intr_allocate_slot_cpu(struct cpu_info *, struct pic *, int, int *); int intr_allocate_slot(struct pic *, int, int, int, struct cpu_info **, int *, int *); + +#define INTR_ESTABLISH_MPSAFE 0x01 void *intr_establish(int, struct pic *, int, int, int, int (*)(void *), - void *, char *); + void *, char *, int); void intr_disestablish(struct intrhand *); void cpu_intr_init(struct cpu_info *); int intr_find_mpmapping(int bus, int pin, int *handle); @@ -219,8 +223,6 @@ int x86_fast_ipi(struct cpu_info *, int); void x86_broadcast_ipi(int); void x86_multicast_ipi(int, 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 *); diff --git a/sys/arch/amd64/include/pci_machdep.h b/sys/arch/amd64/include/pci_machdep.h index 60c95d80b23..cfd04020f47 100644 --- a/sys/arch/amd64/include/pci_machdep.h +++ b/sys/arch/amd64/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.6 2008/12/03 15:46:06 oga Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.7 2008/12/06 04:31:24 tedu Exp $ */ /* $NetBSD: pci_machdep.h,v 1.1 2003/02/26 21:26:11 fvdl Exp $ */ /* @@ -93,8 +93,13 @@ void pci_conf_write(pci_chipset_tag_t, pcitag_t, int, pcireg_t); int pci_intr_map(struct pci_attach_args *, pci_intr_handle_t *); const char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t); -void *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t, - int, int (*)(void *), void *, char *); + +void *pci_intr_establish_flags(pci_chipset_tag_t, pci_intr_handle_t, + int, int (*)(void *), void *, char *, int); +#define pci_intr_establish(t,h,l,f,a,w) \ + pci_intr_establish_flags(t,h,l,f,a,w,0) +#define pci_intr_establish_mpsafe(t,h,l,f,a,w) \ + pci_intr_establish_flags(t,h,l,f,a,w,INTR_ESTABLISH_MPSAFE) void pci_intr_disestablish(pci_chipset_tag_t, void *); void pci_decompose_tag(pci_chipset_tag_t, pcitag_t, int *, int *, int *); diff --git a/sys/arch/arm/include/pci_machdep.h b/sys/arch/arm/include/pci_machdep.h index 5e1638cdf1f..064864380b2 100644 --- a/sys/arch/arm/include/pci_machdep.h +++ b/sys/arch/arm/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.4 2005/09/20 00:54:16 brad Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.5 2008/12/06 04:31:24 tedu Exp $ */ /* $NetBSD: pci_machdep.h,v 1.2 2002/05/15 19:23:52 thorpej Exp $ */ /* @@ -93,5 +93,7 @@ struct arm32_pci_chipset { (*(c)->pc_intr_string)((c)->pc_intr_v, (ih)) #define pci_intr_establish(c, ih, l, h, a, n) \ (*(c)->pc_intr_establish)((c)->pc_intr_v, (ih), (l), (h), (a), (n)) +#define pci_intr_establish_mpsafe(c,h,l,f,a,w) \ + pci_intr_establish(c,h,l,f,a,w) #define pci_intr_disestablish(c, iv) \ (*(c)->pc_intr_disestablish)((c)->pc_intr_v, (iv)) diff --git a/sys/arch/hppa/include/pci_machdep.h b/sys/arch/hppa/include/pci_machdep.h index 2460c8229ad..ec3caa8eac5 100644 --- a/sys/arch/hppa/include/pci_machdep.h +++ b/sys/arch/hppa/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.1 2003/09/29 19:23:02 mickey Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.2 2008/12/06 04:31:24 tedu Exp $ */ /* * Copyright (c) 2003 Michael Shalayeff @@ -82,6 +82,8 @@ struct hppa_pci_chipset_tag { (*(c)->pc_intr_string)((c)->_cookie, (ih)) #define pci_intr_establish(c, ih, l, h, a, nm) \ (*(c)->pc_intr_establish)((c)->_cookie, (ih), (l), (h), (a), (nm)) +#define pci_intr_establish_mpsafe(c, ih, l, h, a, nm) \ + pci_intr_establish(c, ih, l, h, a, nm) #define pci_intr_disestablish(c, iv) \ (*(c)->pc_intr_disestablish)((c)->_cookie, (iv)) diff --git a/sys/arch/hppa64/include/pci_machdep.h b/sys/arch/hppa64/include/pci_machdep.h index 9e122ad90ab..2115d8e35ca 100644 --- a/sys/arch/hppa64/include/pci_machdep.h +++ b/sys/arch/hppa64/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.1 2005/04/01 10:40:48 mickey Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.2 2008/12/06 04:31:24 tedu Exp $ */ /* * Copyright (c) 2005 Michael Shalayeff @@ -73,6 +73,8 @@ struct hppa64_pci_chipset_tag { (*(c)->pc_intr_string)((c)->_cookie, (ih)) #define pci_intr_establish(c, ih, l, h, a, nm) \ (*(c)->pc_intr_establish)((c)->_cookie, (ih), (l), (h), (a), (nm)) +#define pci_intr_establish_mpsafe(c,h,l,f,a,w) \ + pci_intr_establish(c,h,l,f,a,w) #define pci_intr_disestablish(c, iv) \ (*(c)->pc_intr_disestablish)((c)->_cookie, (iv)) diff --git a/sys/arch/landisk/include/pci_machdep.h b/sys/arch/landisk/include/pci_machdep.h index 883a7d526c3..6da2e1c4470 100644 --- a/sys/arch/landisk/include/pci_machdep.h +++ b/sys/arch/landisk/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.1 2006/10/06 21:16:15 miod Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.2 2008/12/06 04:31:24 tedu Exp $ */ /* $NetBSD: pci_machdep.h,v 1.1 2006/09/01 21:26:18 uwe Exp $ */ /* @@ -77,5 +77,7 @@ void landisk_pci_conf_interrupt(void *v, int bus, int dev, int pin, landisk_pci_intr_string(v, ih) #define pci_intr_establish(v, ih, level, ih_fun, ih_arg, ih_name) \ landisk_pci_intr_establish(v, ih, level, ih_fun, ih_arg, ih_name) +#define pci_intr_establish_mpsafe(t,h,l,f,a,w) \ + pci_intr_establish(t,h,l,f,a,w) #define pci_intr_disestablish(v, cookie) \ landisk_pci_intr_disestablish(v, cookie) diff --git a/sys/arch/sparc64/include/pci_machdep.h b/sys/arch/sparc64/include/pci_machdep.h index f97af5807c9..aa845e04357 100644 --- a/sys/arch/sparc64/include/pci_machdep.h +++ b/sys/arch/sparc64/include/pci_machdep.h @@ -1,4 +1,4 @@ -/* $OpenBSD: pci_machdep.h,v 1.19 2008/01/19 11:13:43 kettenis Exp $ */ +/* $OpenBSD: pci_machdep.h,v 1.20 2008/12/06 04:31:24 tedu Exp $ */ /* $NetBSD: pci_machdep.h,v 1.7 2001/07/20 00:07:14 eeh Exp $ */ /* @@ -87,6 +87,8 @@ int pci_intr_line(pci_intr_handle_t); const char *pci_intr_string(pci_chipset_tag_t, pci_intr_handle_t); void *pci_intr_establish(pci_chipset_tag_t, pci_intr_handle_t, int, int (*)(void *), void *, char *); +#define pci_intr_establish_mpsafe(t,h,l,f,a,w) \ + pci_intr_establish(t,h,l,f,a,w) void pci_intr_disestablish(pci_chipset_tag_t, void *); int sparc64_pci_enumerate_bus(struct pci_softc *, -- cgit v1.2.3