Signed-off-by: Jiang Liu <[email protected]>
---
 arch/x86/kernel/apic/io_apic.c |   29 ++++++++++++++++++++++-------
 1 file changed, 22 insertions(+), 7 deletions(-)

diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c
index bb013e4126c3..3b6e29d29903 100644
--- a/arch/x86/kernel/apic/io_apic.c
+++ b/arch/x86/kernel/apic/io_apic.c
@@ -117,6 +117,24 @@ struct mp_ioapic_gsi *mp_ioapic_gsi_routing(int ioapic_idx)
        return &ioapics[ioapic_idx].gsi_config;
 }
 
+static inline int mp_ioapic_pin_count(int ioapic)
+{
+       struct mp_ioapic_gsi *gsi_cfg = mp_ioapic_gsi_routing(ioapic);
+
+       return gsi_cfg->gsi_end - gsi_cfg->gsi_base + 1;
+}
+
+static inline u32 mp_pin_2_gsi(int ioapic, int pin)
+{
+       return mp_ioapic_gsi_routing(ioapic)->gsi_base + pin;
+}
+
+/* Initialize all legacy IRQs and all pins on the first IOAPIC at boot */
+static inline int mp_init_irq_at_boot(int ioapic, int irq)
+{
+       return ioapic == 0 || (irq >= 0 && irq < NR_IRQS_LEGACY);
+}
+
 int nr_ioapics;
 
 /* The one past the highest gsi number used */
@@ -1368,8 +1386,7 @@ static void __init __io_apic_setup_irqs(unsigned int 
ioapic_idx)
                        continue;
 
                irq = pin_2_irq(idx, ioapic_idx, pin);
-
-               if ((ioapic_idx > 0) && (irq > NR_IRQS_LEGACY))
+               if (!mp_init_irq_at_boot(ioapic_idx, irq))
                        continue;
 
                /*
@@ -1420,9 +1437,7 @@ void setup_IO_APIC_irq_extra(u32 gsi)
                return;
 
        irq = pin_2_irq(idx, ioapic_idx, pin);
-
-       /* Only handle the non legacy irqs on secondary ioapics */
-       if (ioapic_idx == 0 || irq < NR_IRQS_LEGACY)
+       if (mp_init_irq_at_boot(ioapic_idx, irq))
                return;
 
        set_io_apic_irq_attr(&attr, ioapic_idx, pin, irq_trigger(idx),
@@ -3536,9 +3551,9 @@ void __init setup_ioapic_dest(void)
                irq_entry = find_irq_entry(ioapic, pin, mp_INT);
                if (irq_entry == -1)
                        continue;
-               irq = pin_2_irq(irq_entry, ioapic, pin);
 
-               if ((ioapic > 0) && (irq > NR_IRQS_LEGACY))
+               irq = pin_2_irq(irq_entry, ioapic, pin);
+               if (!mp_init_irq_at_boot(ioapic, irq))
                        continue;
 
                idata = irq_get_irq_data(irq);
-- 
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Reply via email to