Commit be5d5350 authored by Yinghai Lu's avatar Yinghai Lu Committed by Ingo Molnar

x86: MSI start irq numbering from nr_irqs_gsi

Impact: sanitize MSI irq number ordering from top-down to bottom-up

Increase new MSI IRQs starting from nr_irqs_gsi (which is somewhere below
256), instead of decreasing from NR_IRQS. (The latter method can result
in confusingly high IRQ numbers - if NR_CPUS is set to a high value and
NR_IRQS scales up to a high value.)
Signed-off-by: default avatarYinghai Lu <yinghai@kernel.org>
Signed-off-by: default avatarIngo Molnar <mingo@elte.hu>
parent 99d093d1
...@@ -188,7 +188,7 @@ extern void restore_IO_APIC_setup(void); ...@@ -188,7 +188,7 @@ extern void restore_IO_APIC_setup(void);
extern void reinit_intr_remapped_IO_APIC(int); extern void reinit_intr_remapped_IO_APIC(int);
#endif #endif
extern int probe_nr_irqs(void); extern void probe_nr_irqs_gsi(void);
#else /* !CONFIG_X86_IO_APIC */ #else /* !CONFIG_X86_IO_APIC */
#define io_apic_assign_pci_irqs 0 #define io_apic_assign_pci_irqs 0
......
...@@ -2973,7 +2973,7 @@ unsigned int create_irq_nr(unsigned int irq_want) ...@@ -2973,7 +2973,7 @@ unsigned int create_irq_nr(unsigned int irq_want)
irq = 0; irq = 0;
spin_lock_irqsave(&vector_lock, flags); spin_lock_irqsave(&vector_lock, flags);
for (new = irq_want; new > 0; new--) { for (new = irq_want; new < NR_IRQS; new++) {
if (platform_legacy_irq(new)) if (platform_legacy_irq(new))
continue; continue;
...@@ -3001,11 +3001,14 @@ unsigned int create_irq_nr(unsigned int irq_want) ...@@ -3001,11 +3001,14 @@ unsigned int create_irq_nr(unsigned int irq_want)
return irq; return irq;
} }
static int nr_irqs_gsi = NR_IRQS_LEGACY;
int create_irq(void) int create_irq(void)
{ {
unsigned int irq_want;
int irq; int irq;
irq = create_irq_nr(nr_irqs - 1); irq_want = nr_irqs_gsi;
irq = create_irq_nr(irq_want);
if (irq == 0) if (irq == 0)
irq = -1; irq = -1;
...@@ -3281,7 +3284,7 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc) ...@@ -3281,7 +3284,7 @@ int arch_setup_msi_irq(struct pci_dev *dev, struct msi_desc *msidesc)
int ret; int ret;
unsigned int irq_want; unsigned int irq_want;
irq_want = nr_irqs - 1; irq_want = nr_irqs_gsi;
irq = create_irq_nr(irq_want); irq = create_irq_nr(irq_want);
if (irq == 0) if (irq == 0)
return -1; return -1;
...@@ -3321,11 +3324,11 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) ...@@ -3321,11 +3324,11 @@ int arch_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
int index = 0; int index = 0;
#endif #endif
irq_want = nr_irqs - 1; irq_want = nr_irqs_gsi;
sub_handle = 0; sub_handle = 0;
list_for_each_entry(msidesc, &dev->msi_list, list) { list_for_each_entry(msidesc, &dev->msi_list, list) {
irq = create_irq_nr(irq_want); irq = create_irq_nr(irq_want);
irq_want--; irq_want++;
if (irq == 0) if (irq == 0)
return -1; return -1;
#ifdef CONFIG_INTR_REMAP #ifdef CONFIG_INTR_REMAP
...@@ -3674,9 +3677,16 @@ int __init io_apic_get_redir_entries (int ioapic) ...@@ -3674,9 +3677,16 @@ int __init io_apic_get_redir_entries (int ioapic)
return reg_01.bits.entries; return reg_01.bits.entries;
} }
int __init probe_nr_irqs(void) void __init probe_nr_irqs_gsi(void)
{ {
return NR_IRQS; 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_irqs_gsi = nr;
} }
/* -------------------------------------------------------------------------- /* --------------------------------------------------------------------------
......
...@@ -1082,7 +1082,7 @@ void __init setup_arch(char **cmdline_p) ...@@ -1082,7 +1082,7 @@ void __init setup_arch(char **cmdline_p)
ioapic_init_mappings(); ioapic_init_mappings();
/* need to wait for io_apic is mapped */ /* need to wait for io_apic is mapped */
nr_irqs = probe_nr_irqs(); probe_nr_irqs_gsi();
kvm_guest_init(); kvm_guest_init();
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment