aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYinghai Lu <yinghai@kernel.org>2012-09-17 22:22:31 -0700
committerYinghai Lu <yinghai@kernel.org>2012-09-17 22:22:31 -0700
commit042e24586030355e4d0118453cafba61eefac441 (patch)
tree23af39dc24945f02afa01688284bf174d24fa03e
parent1beaca1d77291fa4e5cf09d64e43bbc8d6340bb9 (diff)
downloadlinux-yinghai-042e24586030355e4d0118453cafba61eefac441.tar.gz
x86, irq: Make ioapics loop code skip blank slot
When multiple ioapics get added and removed, we could have blank slot in ioapics array. Add skip code in this case by check nr_registers. Signed-off-by: Yinghai Lu <yinghai@kernel.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: Ingo Molnar <mingo@redhat.com> Cc: "H. Peter Anvin" <hpa@zytor.com> Cc: Suresh Siddha <suresh.b.siddha@intel.com>
-rw-r--r--arch/x86/kernel/apic/io_apic.c29
1 files changed, 23 insertions, 6 deletions
diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index 3e5788a96fd74b..fddd31ad6c6d40 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -818,7 +818,8 @@ int save_ioapic_entries(void)
int err = 0;
for (apic = 0; apic < nr_ioapics; apic++) {
- if (!ioapics[apic].saved_registers) {
+ if (!ioapics[apic].saved_registers &&
+ ioapics[apic].nr_registers) {
err = -ENOMEM;
continue;
}
@@ -924,9 +925,12 @@ static int __init find_isa_irq_apic(int irq, int type)
if (i < mp_irq_entries) {
int ioapic_idx;
- for (ioapic_idx = 0; ioapic_idx < nr_ioapics; ioapic_idx++)
+ for (ioapic_idx = 0; ioapic_idx < nr_ioapics; ioapic_idx++) {
+ if (!ioapics[ioapic_idx].nr_registers)
+ continue;
if (mpc_ioapic_id(ioapic_idx) == mp_irqs[i].dstapic)
return ioapic_idx;
+ }
}
return -1;
@@ -1146,10 +1150,13 @@ int IO_APIC_get_PCI_irq_vector(int bus, int slot, int pin,
for (i = 0; i < mp_irq_entries; i++) {
int lbus = mp_irqs[i].srcbus;
- for (ioapic_idx = 0; ioapic_idx < nr_ioapics; ioapic_idx++)
+ for (ioapic_idx = 0; ioapic_idx < nr_ioapics; ioapic_idx++) {
+ if (!ioapics[ioapic_idx].nr_registers)
+ continue;
if (mpc_ioapic_id(ioapic_idx) == mp_irqs[i].dstapic ||
mp_irqs[i].dstapic == MP_APIC_ALL)
break;
+ }
if (!test_bit(lbus, mp_bus_not_pci) &&
!mp_irqs[i].irqtype &&
@@ -2134,6 +2141,9 @@ void __init setup_ioapic_ids_from_mpc_nocheck(void)
* Set the IOAPIC ID to the value stored in the MPC table.
*/
for (ioapic_idx = 0; ioapic_idx < nr_ioapics; ioapic_idx++) {
+ if (!ioapics[ioapic_idx].nr_registers)
+ continue;
+
/* Read the register 0 value */
raw_spin_lock_irqsave(&ioapic_lock, flags);
reg_00.raw = io_apic_read(ioapic_idx, 0);
@@ -3103,8 +3113,12 @@ static void ioapic_resume(void)
{
int ioapic_idx;
- for (ioapic_idx = nr_ioapics - 1; ioapic_idx >= 0; ioapic_idx--)
+ for (ioapic_idx = nr_ioapics - 1; ioapic_idx >= 0; ioapic_idx--) {
+ if (!ioapics[ioapic_idx].nr_registers)
+ continue;
+
resume_ioapic_id(ioapic_idx);
+ }
restore_ioapic_entries();
}
@@ -3946,8 +3960,11 @@ static int __mp_find_ioapic(u32 gsi, bool quiet)
/* Find the IOAPIC that manages this GSI. */
for (i = 0; i < nr_ioapics; i++) {
struct mp_ioapic_gsi *gsi_cfg = mp_ioapic_gsi_routing(i);
- if ((gsi >= gsi_cfg->gsi_base)
- && (gsi <= gsi_cfg->gsi_end))
+
+ if (!ioapics[i].nr_registers)
+ continue;
+
+ if ((gsi >= gsi_cfg->gsi_base) && (gsi <= gsi_cfg->gsi_end))
return i;
}