aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64/kernel/io_apic.c
diff options
context:
space:
mode:
authorJan Beulich <jbeulich@novell.com>2006-06-26 07:56:43 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-06-26 13:48:15 -0400
commit0a1ad60d7a7eb433095bc1b2c8b475f3f278f61d (patch)
treeb7f0efd5d2afb879b8ff9bfbc44c6ea94b3e7a89 /arch/x86_64/kernel/io_apic.c
parenta32073bffc656ca4bde6002b6cf7c1a8e0e22712 (diff)
[PATCH] x86_64: serialize assign_irq_vector() use of static variables
Since assign_irq_vector() can be called at runtime, its access of static variables should be protected by a lock. Signed-off-by: Jan Beulich <jbeulich@novell.com> Signed-off-by: Andi Kleen <ak@suse.de> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64/kernel/io_apic.c')
-rw-r--r--arch/x86_64/kernel/io_apic.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 9cc7031b715..062b10daeba 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -56,6 +56,7 @@ int timer_over_8254 __initdata = 0;
56static struct { int pin, apic; } ioapic_i8259 = { -1, -1 }; 56static struct { int pin, apic; } ioapic_i8259 = { -1, -1 };
57 57
58static DEFINE_SPINLOCK(ioapic_lock); 58static DEFINE_SPINLOCK(ioapic_lock);
59static DEFINE_SPINLOCK(vector_lock);
59 60
60/* 61/*
61 * # of IRQ routing registers 62 * # of IRQ routing registers
@@ -834,10 +835,16 @@ u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 };
834int assign_irq_vector(int irq) 835int assign_irq_vector(int irq)
835{ 836{
836 static int current_vector = FIRST_DEVICE_VECTOR, offset = 0; 837 static int current_vector = FIRST_DEVICE_VECTOR, offset = 0;
838 int vector;
837 839
838 BUG_ON(irq != AUTO_ASSIGN && (unsigned)irq >= NR_IRQ_VECTORS); 840 BUG_ON(irq != AUTO_ASSIGN && (unsigned)irq >= NR_IRQ_VECTORS);
839 if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0) 841
842 spin_lock(&vector_lock);
843
844 if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0) {
845 spin_unlock(&vector_lock);
840 return IO_APIC_VECTOR(irq); 846 return IO_APIC_VECTOR(irq);
847 }
841next: 848next:
842 current_vector += 8; 849 current_vector += 8;
843 if (current_vector == IA32_SYSCALL_VECTOR) 850 if (current_vector == IA32_SYSCALL_VECTOR)
@@ -849,11 +856,14 @@ next:
849 current_vector = FIRST_DEVICE_VECTOR + offset; 856 current_vector = FIRST_DEVICE_VECTOR + offset;
850 } 857 }
851 858
852 vector_irq[current_vector] = irq; 859 vector = current_vector;
860 vector_irq[vector] = irq;
853 if (irq != AUTO_ASSIGN) 861 if (irq != AUTO_ASSIGN)
854 IO_APIC_VECTOR(irq) = current_vector; 862 IO_APIC_VECTOR(irq) = vector;
863
864 spin_unlock(&vector_lock);
855 865
856 return current_vector; 866 return vector;
857} 867}
858 868
859extern void (*interrupt[NR_IRQS])(void); 869extern void (*interrupt[NR_IRQS])(void);