aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/i386/kernel/io_apic.c9
-rw-r--r--arch/x86_64/kernel/io_apic.c7
2 files changed, 9 insertions, 7 deletions
diff --git a/arch/i386/kernel/io_apic.c b/arch/i386/kernel/io_apic.c
index 61317f4be444..72ae414e4d49 100644
--- a/arch/i386/kernel/io_apic.c
+++ b/arch/i386/kernel/io_apic.c
@@ -1163,14 +1163,15 @@ u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 };
1163int assign_irq_vector(int irq) 1163int assign_irq_vector(int irq)
1164{ 1164{
1165 static int current_vector = FIRST_DEVICE_VECTOR, offset = 0; 1165 static int current_vector = FIRST_DEVICE_VECTOR, offset = 0;
1166 unsigned long flags;
1166 int vector; 1167 int vector;
1167 1168
1168 BUG_ON(irq != AUTO_ASSIGN && (unsigned)irq >= NR_IRQ_VECTORS); 1169 BUG_ON(irq != AUTO_ASSIGN && (unsigned)irq >= NR_IRQ_VECTORS);
1169 1170
1170 spin_lock(&vector_lock); 1171 spin_lock_irqsave(&vector_lock, flags);
1171 1172
1172 if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0) { 1173 if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0) {
1173 spin_unlock(&vector_lock); 1174 spin_unlock_irqrestore(&vector_lock, flags);
1174 return IO_APIC_VECTOR(irq); 1175 return IO_APIC_VECTOR(irq);
1175 } 1176 }
1176next: 1177next:
@@ -1181,7 +1182,7 @@ next:
1181 if (current_vector >= FIRST_SYSTEM_VECTOR) { 1182 if (current_vector >= FIRST_SYSTEM_VECTOR) {
1182 offset++; 1183 offset++;
1183 if (!(offset%8)) { 1184 if (!(offset%8)) {
1184 spin_unlock(&vector_lock); 1185 spin_unlock_irqrestore(&vector_lock, flags);
1185 return -ENOSPC; 1186 return -ENOSPC;
1186 } 1187 }
1187 current_vector = FIRST_DEVICE_VECTOR + offset; 1188 current_vector = FIRST_DEVICE_VECTOR + offset;
@@ -1192,7 +1193,7 @@ next:
1192 if (irq != AUTO_ASSIGN) 1193 if (irq != AUTO_ASSIGN)
1193 IO_APIC_VECTOR(irq) = vector; 1194 IO_APIC_VECTOR(irq) = vector;
1194 1195
1195 spin_unlock(&vector_lock); 1196 spin_unlock_irqrestore(&vector_lock, flags);
1196 1197
1197 return vector; 1198 return vector;
1198} 1199}
diff --git a/arch/x86_64/kernel/io_apic.c b/arch/x86_64/kernel/io_apic.c
index 38a3ff30bde1..519cd4e6f9e7 100644
--- a/arch/x86_64/kernel/io_apic.c
+++ b/arch/x86_64/kernel/io_apic.c
@@ -836,14 +836,15 @@ u8 irq_vector[NR_IRQ_VECTORS] __read_mostly = { FIRST_DEVICE_VECTOR , 0 };
836int assign_irq_vector(int irq) 836int assign_irq_vector(int irq)
837{ 837{
838 static int current_vector = FIRST_DEVICE_VECTOR, offset = 0; 838 static int current_vector = FIRST_DEVICE_VECTOR, offset = 0;
839 unsigned long flags;
839 int vector; 840 int vector;
840 841
841 BUG_ON(irq != AUTO_ASSIGN && (unsigned)irq >= NR_IRQ_VECTORS); 842 BUG_ON(irq != AUTO_ASSIGN && (unsigned)irq >= NR_IRQ_VECTORS);
842 843
843 spin_lock(&vector_lock); 844 spin_lock_irqsave(&vector_lock, flags);
844 845
845 if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0) { 846 if (irq != AUTO_ASSIGN && IO_APIC_VECTOR(irq) > 0) {
846 spin_unlock(&vector_lock); 847 spin_unlock_irqrestore(&vector_lock, flags);
847 return IO_APIC_VECTOR(irq); 848 return IO_APIC_VECTOR(irq);
848 } 849 }
849next: 850next:
@@ -862,7 +863,7 @@ next:
862 if (irq != AUTO_ASSIGN) 863 if (irq != AUTO_ASSIGN)
863 IO_APIC_VECTOR(irq) = vector; 864 IO_APIC_VECTOR(irq) = vector;
864 865
865 spin_unlock(&vector_lock); 866 spin_unlock_irqrestore(&vector_lock, flags);
866 867
867 return vector; 868 return vector;
868} 869}