x86: find nr_irqs_gsi with mp_ioapic_routing
PATCH 1/1 x86: find nr_irqs_gsi with mp_ioapic_routing
Impact: find right nr_irqs_gsi on some systems.
one system has gap between gsi.
[ 0.000000] ACPI: IOAPIC (id[0x04] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 4, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x05] address[0xfeafd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 5, version 0, address 0xfeafd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x06] address[0xfeafc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 6, version 0, address 0xfeafc000, GSI 56-62 ... [ 0.000000] nr_irqs_gsi: 38
so nr_irqs_gsi is not right. some irq for MSI will overwrite with io_apic.
need to get that with acpi_probe_gsi when acpi io_apic is used
--- arch/x86/include/asm/mpspec.h | 5 +++++ arch/x86/kernel/acpi/boot.c | 23 +++++++++++++++++++++++ arch/x86/kernel/io_apic.c | 20 +++++++++++++++----- 3 files changed, 43 insertions(+), 5 deletions(-)
arch/x86/include/asm/mpspec.h +5 -0
@@ -73,6 +73,7 @@ extern void mp_override_legacy_irq(u8 bu u32 gsi);extern void mp_config_acpi_legacy_irqs (void );extern int mp_register_gsi (u32 gsi,int edge_level,int active_high_low); +extern int acpi_probe_gsi (void );#ifdef CONFIG_X86_IO_APIC extern int mp_config_acpi_gsi (unsigned char number,unsigned int devfn,u8 pin,u32 gsi,int triggering,int polarity);
@@ -83,6 +84,10 @@ mp_config_acpi_gsi(unsigned char number, {return 0 ; } +static inline int acpi_probe_gsi (void ) +{ +return 0 ; +}#endif #endif /* CONFIG_ACPI */
arch/x86/kernel/acpi/boot.c +23 -0
@@ -944,6 +944,29 @@ void __init mp_register_ioapic(int id, u nr_ioapics++; } +int __init acpi_probe_gsi (void ) +{ +int idx; +int gsi; +int max_gsi =0 ; + +if (acpi_disabled) +return 0 ; + +if (!acpi_ioapic) +return 0 ; + + max_gsi =0 ; +for (idx =0 ; idx < nr_ioapics; idx++) { + gsi = mp_ioapic_routing[idx].gsi_end; + +if (gsi > max_gsi) + max_gsi = gsi; + } + +return max_gsi +1 ; +} +static void assign_to_mp_irq (struct mpc_intsrc *m,struct mpc_intsrc *mp_irq) {
arch/x86/kernel/io_apic.c +15 -5
@@ -3810,14 +3810,24 @@ int __init io_apic_get_redir_entries (invoid __init probe_nr_irqs_gsi (void ) { -int idx;int nr =0 ; -for (idx =0 ; idx < nr_ioapics; idx++) - nr +=io_apic_get_redir_entries (idx) +1 ; - -if (nr > nr_irqs_gsi) + nr =acpi_probe_gsi (); +if (nr > nr_irqs_gsi) { nr_irqs_gsi = nr; + }else { +/* for acpi=off or acpi is not compiled in */ +int idx; + + nr =0 ; +for (idx =0 ; idx < nr_ioapics; idx++) + nr +=io_apic_get_redir_entries (idx) +1 ; + +if (nr > nr_irqs_gsi) + nr_irqs_gsi = nr; + } + +printk (KERN_DEBUG "nr_irqs_gsi: %d\n" , nr_irqs_gsi); }#ifdef CONFIG_SPARSE_IRQ
PATCH 1/1 x86/irq: optimizing nr_irqs
Impact: more depend on cards to be used
depend on nr_irq_gsi more, and have a ratio for MSI
--- arch/x86/kernel/io_apic.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
arch/x86/kernel/io_apic.c +9 -6
@@ -3479,9 +3479,9 @@ int arch_setup_msi_irqs(struct pci_dev * sub_handle =0 ;list_for_each_entry (msidesc, &dev->msi_list, list) { irq =create_irq_nr (irq_want); - irq_want++;if (irq ==0 )return -1 ; + irq_want = irq +1 ;#ifdef CONFIG_INTR_REMAP if (!intr_remapping_enabled) goto no_ir;
@@ -3835,11 +3835,14 @@ int __init arch_probe_nr_irqs(void) {int nr; - nr = ((8 * nr_cpu_ids) > (32 * nr_ioapics) ? - (NR_VECTORS + (8 * nr_cpu_ids)) : - (NR_VECTORS + (32 * nr_ioapics))); - -if (nr < nr_irqs && nr > nr_irqs_gsi) + nr = nr_irqs_gsi +8 * nr_cpu_ids; +#if defined(CONFIG_PCI_MSI ) || defined(CONFIG_HT_IRQ ) +/* +* for MSI and HT dyn irq +*/ + nr += nr_irqs_gsi *16 ; +#endif +if (nr < (NR_VECTORS * nr_cpu_ids)) nr_irqs = nr;return 0 ;
Len Brown
reviewerQuoted 6 lines
Impact: find right
nr_irqs_gsion some systems.one system has gap between gsi.
Quoted 8 lines
[ 0.000000] ACPI: IOAPIC (id[0x04] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 4, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x05] address[0xfeafd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 5, version 0, address 0xfeafd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x06] address[0xfeafc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 6, version 0, address 0xfeafc000, GSI 56-62 ... [ 0.000000] nr_irqs_gsi: 38
I've never seen gaps in GSIs.
I've never seen IOAPICs with 7 redirection table entries.
This system looks quite broken even before the probe for nr_irqs_gsi. Do you have more information on it?
thanks,
-Len
--
Intel Open Source Technology Center
Quoted 14 lines · Len Brown
Quoted 5 lines
Impact: find right
nr_irqs_gsion some systems.one system has gap between gsi.
Quoted 8 lines
[ 0.000000] ACPI: IOAPIC (id[0x04] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 4, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x05] address[0xfeafd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 5, version 0, address 0xfeafd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x06] address[0xfeafc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 6, version 0, address 0xfeafc000, GSI 56-62 ... [ 0.000000] nr_irqs_gsi: 38
Quoted 5 lines
I've never seen gaps in GSIs.
I've never seen IOAPICs with 7 redirection table entries.This system looks quite broken even before the probe for
nr_irqs_gsi. Do you have more information on it?
it is one AMD based system from Sun. it has two hypertransport chains.
one: 8132 + ck804
one: io4
when 8 sockets are installed, will get
[ 0.000000] ACPI: IOAPIC (id[0x00] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 0, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x01] address[0xfdefd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 1, version 0, address 0xfdefd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x02] address[0xfdefc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 2, version 0, address 0xfdefc000, GSI 56-62 [ 0.000000] ACPI: IOAPIC (id[0x03] address[0xfeaff000] gsi_base[24]) [ 0.000000] IOAPIC[3]: apic_id 3, version 0, address 0xfeaff000, GSI 24-47
when 2 sockets are installed, only HT chains is used. will get
[ 0.000000] ACPI: IOAPIC (id[0x04] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 4, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x05] address[0xfeafd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 5, version 0, address 0xfeafd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x06] address[0xfeafc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 6, version 0, address 0xfeafc000, GSI 56-62
acpi madt ioapic-entries does include gsi_base field.
amd 8131: has 4 gsi
amd 8132: has 7 gsi, but only 3 can be used.
anyway that system is not broken, and it is quite solid.
this patch seems to be a 2.6.29 material.
YH
Len Brown
reviewerQuoted 44 lines
Quoted 14 lines
Quoted 5 lines
Impact: find right
nr_irqs_gsion some systems.one system has gap between gsi.
Quoted 8 lines
[ 0.000000] ACPI: IOAPIC (id[0x04] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 4, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x05] address[0xfeafd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 5, version 0, address 0xfeafd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x06] address[0xfeafc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 6, version 0, address 0xfeafc000, GSI 56-62 ... [ 0.000000] nr_irqs_gsi: 38Quoted 5 lines
I've never seen gaps in GSIs.
I've never seen IOAPICs with 7 redirection table entries.This system looks quite broken even before the probe for
nr_irqs_gsi. Do you have more information on it?it is one AMD based system from Sun. it has two hypertransport chains.
one: 8132 + ck804
one: io4when 8 sockets are installed, will get
[ 0.000000] ACPI: IOAPIC (id[0x00] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 0, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x01] address[0xfdefd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 1, version 0, address 0xfdefd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x02] address[0xfdefc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 2, version 0, address 0xfdefc000, GSI 56-62 [ 0.000000] ACPI: IOAPIC (id[0x03] address[0xfeaff000] gsi_base[24]) [ 0.000000] IOAPIC[3]: apic_id 3, version 0, address 0xfeaff000, GSI 24-47when 2 sockets are installed, only HT chains is used. will get
[ 0.000000] ACPI: IOAPIC (id[0x04] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 4, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x05] address[0xfeafd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 5, version 0, address 0xfeafd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x06] address[0xfeafc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 6, version 0, address 0xfeafc000, GSI 56-62
Quoted 6 lines
acpi madt ioapic-entries does include
gsi_basefield.amd 8131: has 4 gsi
amd 8132: has 7 gsi, but only 3 can be used.anyway that system is not broken, and it is quite solid.
I don't know if it violates the ACPI spec to have gaps in the GSI's, but it does violate my expectations when I read the spec -- so i guess that "unexpected" or "unconventional" may be a better word than "broken".
At the same time, "unexpected" and "unconventional" BIOS implementations cause things like "broken" OS -- thus the need for your patch:-)
Quoted 1 line
this patch seems to be a 2.6.29 material.
I agree.
thanks,
Len Brown, Intel Open Source Technology Center
PATCH 1/1 x86: use NR_IRQS_LEGACY to replace 16
In reply to Yinghai LuImpact: cleanup
also could kill platform_legacy_irq
--- arch/x86/include/asm/hw_irq.h | 4 +--- arch/x86/kernel/io_apic.c | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-)
arch/x86/include/asm/hw_irq.h +1 -3
@@ -25,8 +25,6 @@#include <asm/irq.h> #include <asm/sections.h> -#define platform_legacy_irq (irq) ((irq) < 16) -/* Interrupt handlers registered during init_IRQ */ extern void apic_timer_interrupt (void );extern void error_interrupt (void );
@@ -60,7 +58,7 @@ extern void make_8259A_irq(unsigned intextern void init_8259A (int aeoi);/* IOAPIC */ -#define IO_APIC_IRQ (x) (((x) >= 16) || ((1<<(x)) & io_apic_irqs)) +#define IO_APIC_IRQ (x) (((x) >= NR_IRQS_LEGACY) || ((1<<(x)) & io_apic_irqs))extern unsigned long io_apic_irqs;extern void init_VISWS_APIC_irqs (void );
arch/x86/kernel/io_apic.c +4 -4
@@ -3168,6 +3168,7 @@ static int __init ioapic_init_sysfs(voiddevice_initcall (ioapic_init_sysfs); +static int nr_irqs_gsi =NR_IRQS_LEGACY ;/* * Dynamic irq allocate and deallocation */
@@ -3182,11 +3183,11 @@ unsigned int create_irq_nr(unsigned intstruct irq_desc *desc_new =NULL ; irq =0 ; +if (irq_want < nr_irqs_gsi) + irq_want = nr_irqs_gsi; +spin_lock_irqsave (&vector_lock, flags);for (new = irq_want; new < nr_irqs; new++) { -if (platform_legacy_irq (new)) -continue ; - desc_new =irq_to_desc_alloc_cpu (new, cpu);if (!desc_new) {printk (KERN_INFO "can not get irq_desc for %d\n" , new);
@@ -3211,7 +3212,6 @@ unsigned int create_irq_nr(unsigned intreturn irq; } -static int nr_irqs_gsi =NR_IRQS_LEGACY ;int create_irq (void ) {unsigned int irq_want;
PATCH 1/1 x86/irq: optimizing nr_irqs -v2
In reply to Yinghai LuImpact: more depend on cards to be used
depend on nr_irq_gsi more, and have a ratio for MSI
v2: make nr_irqs shoule less than NR_VECTORS * nr_cpu_ids
aka if only one cpu, we only can support nr_irqs = NR_VECTORS
--- arch/x86/kernel/io_apic.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
arch/x86/kernel/io_apic.c +11 -5
@@ -3482,9 +3482,9 @@ int arch_setup_msi_irqs(struct pci_dev * sub_handle =0 ;list_for_each_entry (msidesc, &dev->msi_list, list) { irq =create_irq_nr (irq_want); - irq_want++;if (irq ==0 )return -1 ; + irq_want = irq +1 ;#ifdef CONFIG_INTR_REMAP if (!intr_remapping_enabled) goto no_ir;
@@ -3838,11 +3838,17 @@ int __init arch_probe_nr_irqs(void) {int nr; - nr = ((8 * nr_cpu_ids) > (32 * nr_ioapics) ? - (NR_VECTORS + (8 * nr_cpu_ids)) : - (NR_VECTORS + (32 * nr_ioapics))); +if (nr_irqs > (NR_VECTORS * nr_cpu_ids)) + nr_irqs =NR_VECTORS * nr_cpu_ids; -if (nr < nr_irqs && nr > nr_irqs_gsi) + nr = nr_irqs_gsi +8 * nr_cpu_ids; +#if defined(CONFIG_PCI_MSI ) || defined(CONFIG_HT_IRQ ) +/* +* for MSI and HT dyn irq +*/ + nr += nr_irqs_gsi *16 ; +#endif +if (nr < nr_irqs) nr_irqs = nr;return 0 ;
Ingo Molnar
AppliedQuoted 17 lines · Yinghai Lu
Impact: find right
nr_irqs_gsion some systems.one system has gap between gsi.
[ 0.000000] ACPI: IOAPIC (id[0x04] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 4, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x05] address[0xfeafd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 5, version 0, address 0xfeafd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x06] address[0xfeafc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 6, version 0, address 0xfeafc000, GSI 56-62 ... [ 0.000000] nr_irqs_gsi: 38so
nr_irqs_gsiis not right. some irq for MSI will overwrite withio_apic.need to get that with
acpi_probe_gsiwhen acpiio_apicis used
Quoted 7 lines
Signed-off-by Yinghai Lu <[email protected]>--- arch/x86/include/asm/mpspec.h | 5 +++++ arch/x86/kernel/acpi/boot.c | 23 +++++++++++++++++++++++ arch/x86/kernel/io_apic.c | 20 +++++++++++++++----- 3 files changed, 43 insertions(+), 5 deletions(-)
Applied to tip/x86/apic, thanks Yinghai!
Could you please send one against linus/master too please? (there's conflicts)
Ingo
Ingo Molnar
AppliedRe: [PATCH] x86/irq: optimizing nr_irqs -v2
In reply to Yinghai LuQuoted 5 lines · Yinghai Lu
Impact: more depend on cards to be used
depend on
nr_irq_gsimore, and have a ratio for MSI
Quoted 8 lines
v2: make
nr_irqsshoule less thanNR_VECTORS*nr_cpu_ids
aka if only one cpu, we only can supportnr_irqs=NR_VECTORSSigned-off-by Yinghai Lu <[email protected]>--- arch/x86/kernel/io_apic.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-)
Applied to tip/x86/apic, thanks Yinghai!
Ingo
Ingo Molnar
AppliedRe: [PATCH] x86: use NR_IRQS_LEGACY to replace 16
In reply to Yinghai LuQuoted 11 lines · Yinghai Lu
Impact: cleanup
also could kill
platform_legacy_irqSigned-off-by Yinghai Lu <[email protected]>--- arch/x86/include/asm/hw_irq.h | 4 +--- arch/x86/kernel/io_apic.c | 8 ++++---- 2 files changed, 5 insertions(+), 7 deletions(-)
Applied to tip/x86/apic, thanks Yinghai!
Ingo
PATCH 1/1 x86: find nr_irqs_gsi with mp_ioapic_routing v3
In reply to Ingo MolnarImpact: find right nr_irqs_gsi on some systems.
one system has gap between gsi.
[ 0.000000] ACPI: IOAPIC (id[0x04] address[0xfec00000] gsi_base[0]) [ 0.000000] IOAPIC[0]: apic_id 4, version 0, address 0xfec00000, GSI 0-23 [ 0.000000] ACPI: IOAPIC (id[0x05] address[0xfeafd000] gsi_base[48]) [ 0.000000] IOAPIC[1]: apic_id 5, version 0, address 0xfeafd000, GSI 48-54 [ 0.000000] ACPI: IOAPIC (id[0x06] address[0xfeafc000] gsi_base[56]) [ 0.000000] IOAPIC[2]: apic_id 6, version 0, address 0xfeafc000, GSI 56-62 ... [ 0.000000] nr_irqs_gsi: 38
so nr_irqs_gsi is not right. some irq for MSI will overwrite with io_apic.
need to get that with acpi_probe_gsi when acpi io_apic is used
v2: Ingo pointed out inline acpi_probe_gsi() should be with !CONFIG_ACPI
v3: against current upstream for 2.6.29, because it is 2.6.29 material
--- arch/x86/include/asm/mpspec.h | 6 ++++++ arch/x86/kernel/acpi/boot.c | 23 +++++++++++++++++++++++ arch/x86/kernel/io_apic.c | 20 +++++++++++++++----- 3 files changed, 44 insertions(+), 5 deletions(-)
arch/x86/include/asm/mpspec.h +6 -0
@@ -60,6 +60,7 @@ extern void mp_override_legacy_irq(u8 bu u32 gsi);extern void mp_config_acpi_legacy_irqs (void );extern int mp_register_gsi (u32 gsi,int edge_level,int active_high_low); +extern int acpi_probe_gsi (void );#ifdef CONFIG_X86_IO_APIC extern int mp_config_acpi_gsi (unsigned char number,unsigned int devfn,u8 pin,u32 gsi,int triggering,int polarity);
@@ -71,6 +72,11 @@ mp_config_acpi_gsi(unsigned char number,return 0 ; }#endif +#else /* !CONFIG_ACPI */ +static inline int acpi_probe_gsi (void ) +{ +return 0 ; +}#endif /* CONFIG_ACPI */ #define PHYSID_ARRAY_SIZE BITS_TO_LONGS(MAX_APICS)
arch/x86/kernel/io_apic.c +15 -5
@@ -3841,14 +3841,24 @@ int __init io_apic_get_redir_entries (invoid __init probe_nr_irqs_gsi (void ) { -int idx;int nr =0 ; -for (idx =0 ; idx < nr_ioapics; idx++) - nr +=io_apic_get_redir_entries (idx) +1 ; - -if (nr > nr_irqs_gsi) + nr =acpi_probe_gsi (); +if (nr > nr_irqs_gsi) { nr_irqs_gsi = nr; + }else { +/* for acpi=off or acpi is not compiled in */ +int idx; + + nr =0 ; +for (idx =0 ; idx < nr_ioapics; idx++) + nr +=io_apic_get_redir_entries (idx) +1 ; + +if (nr > nr_irqs_gsi) + nr_irqs_gsi = nr; + } + +printk (KERN_DEBUG "nr_irqs_gsi: %d\n" , nr_irqs_gsi); }/* --------------------------------------------------------------------------
arch/x86/kernel/acpi/boot.c +23 -0
@@ -973,6 +973,29 @@ void __init mp_register_ioapic(int id, u nr_ioapics++; } +int __init acpi_probe_gsi (void ) +{ +int idx; +int gsi; +int max_gsi =0 ; + +if (acpi_disabled) +return 0 ; + +if (!acpi_ioapic) +return 0 ; + + max_gsi =0 ; +for (idx =0 ; idx < nr_ioapics; idx++) { + gsi = mp_ioapic_routing[idx].gsi_end; + +if (gsi > max_gsi) + max_gsi = gsi; + } + +return max_gsi +1 ; +} +static void assign_to_mp_irq (struct mp_config_intsrc *m,struct mp_config_intsrc *mp_irq) {