x86/apic: replace gsi_end with semiclosed gsi_next
PATCH 1/1 x86/apic: replace gsi_end with semiclosed gsi_next
In the current code gsi_end is inclusive, when gsi_end = 0, it is unclear whether there are 0 gsis or the next available one is 0. By using semiclosed gsi_next variable, we can avoid many +1 kind of corrections and fix a bug in the SFI code where gsi for the firsrt IOAPIC starts with 1 instead of 0.
http://lkml.org/lkml/2010/6/7/394
Signed-off-by Jacob Pan <[email protected]>
--- arch/x86/include/asm/io_apic.h | 4 ++-- arch/x86/kernel/acpi/boot.c | 8 ++++---- arch/x86/kernel/apic/io_apic.c | 12 ++++++------ arch/x86/kernel/mpparse.c | 2 +- arch/x86/kernel/sfi.c | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-)
arch/x86/include/asm/io_apic.h +2 -2
@@ -183,7 +183,7 @@ struct mp_ioapic_gsi{u32 gsi_end; };extern struct mp_ioapic_gsi mp_gsi_routing[]; -extern u32 gsi_end; +extern u32 gsi_next;int mp_find_ioapic (u32 gsi);int mp_find_ioapic_pin (int ioapic,u32 gsi);void __init mp_register_ioapic (int id,u32 address,u32 gsi_base);
@@ -197,7 +197,7 @@ static const int timer_through_8259 = 0;static inline void ioapic_init_mappings (void ) { }static inline void ioapic_insert_resources (void ) { }static inline void probe_nr_irqs_gsi (void ) { } -#define gsi_end (NR_IRQS_LEGACY - 1) +#define gsi_next NR_IRQS_LEGACYstatic inline int mp_find_ioapic (u32 gsi) {return 0 ; }struct io_apic_irq_attr ;
arch/x86/kernel/acpi/boot.c +4 -4
@@ -118,7 +118,7 @@ static unsigned int gsi_to_irq(unsigned int gsi)if (gsi >=NR_IRQS_LEGACY ) irq = gsi;else - irq = gsi_end +1 + gsi; + irq = gsi_next + gsi;return irq; }
@@ -129,10 +129,10 @@ static u32 irq_to_gsi(int irq)if (irq <NR_IRQS_LEGACY ) gsi = isa_irq_to_gsi[irq]; -else if (irq <= gsi_end) +else if (irq < gsi_next) gsi = irq; -else if (irq <= (gsi_end +NR_IRQS_LEGACY )) - gsi = irq - gsi_end; +else if (irq < (gsi_next +NR_IRQS_LEGACY )) + gsi = irq - gsi_next +1 ;else gsi =0xffffffff ;
arch/x86/kernel/apic/io_apic.c +6 -6
@@ -89,8 +89,8 @@ int nr_ioapics;/* IO APIC gsi routing info */ struct mp_ioapic_gsi mp_gsi_routing[MAX_IO_APICS ]; -/* The last gsi number used */ -u32 gsi_end; +/* The next gsi number to be used */ +u32 gsi_next;/* MP IRQ source entries */ struct mpc_intsrc mp_irqs[MAX_IRQ_SOURCES ];
@@ -1035,7 +1035,7 @@ static int pin_2_irq(int idx, int apic, int pin)if (gsi >=NR_IRQS_LEGACY ) irq = gsi;else - irq = gsi_end +1 + gsi; + irq = gsi_next + gsi; }#ifdef CONFIG_X86_32
@@ -3853,7 +3853,7 @@ void __init probe_nr_irqs_gsi(void) {int nr; - nr = gsi_end +1 +NR_IRQS_LEGACY ; + nr = gsi_next +NR_IRQS_LEGACY ;if (nr > nr_irqs_gsi) nr_irqs_gsi = nr;
@@ -4294,8 +4294,8 @@ void __init mp_register_ioapic(int id, u32 address, u32 gsi_base)*/ nr_ioapic_registers[idx] = entries; -if (mp_gsi_routing[idx].gsi_end > gsi_end) - gsi_end = mp_gsi_routing[idx].gsi_end; +if (mp_gsi_routing[idx].gsi_end >= gsi_next) + gsi_next = mp_gsi_routing[idx].gsi_end +1 ; printk(KERN_INFO "IOAPIC[%d]: apic_id %d, version %d, address 0x%x, " "GSI %d-%d\n", idx, mp_ioapics[idx].apicid,
arch/x86/kernel/mpparse.c +1 -1
@@ -123,7 +123,7 @@ static void __init MP_ioapic_info(struct mpc_ioapic *m)printk (KERN_INFO "I/O APIC #%d Version %d at 0x%X.\n" , m->apicid, m->apicver, m->apicaddr); -mp_register_ioapic (m->apicid, m->apicaddr, gsi_end +1 ); +mp_register_ioapic (m->apicid, m->apicaddr, gsi_next); }static void print_MP_intsrc_info (struct mpc_intsrc *m)
arch/x86/kernel/sfi.c +1 -1
@@ -93,7 +93,7 @@ static int __init sfi_parse_ioapic(struct sfi_table_header *table) pentry = (struct sfi_apic_table_entry *)sb->pentry;for (i =0 ; i < num; i++) { -mp_register_ioapic (i, pentry->phys_addr, gsi_end +1 ); +mp_register_ioapic (i, pentry->phys_addr, gsi_next); pentry++; }
Signature · 1 line
1.6.3.3