From: "Eric W. Biederman" The current implementation of create_irq() is a hack but it is the current hack that msi.c uses, and unfortunately the ``generic'' apic msi ops depend on this hack. Thus we are stuck this hack of assuming irq == vector until the depencencies in the generic msi code are removed. Signed-off-by: Eric W. Biederman Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Benjamin Herrenschmidt Cc: Rajesh Shah Cc: Andi Kleen Cc: "Protasevich, Natalie" Cc: "Luck, Tony" DESC genirq-i386-irq-dynamic-irq-support-fix EDESC From: "Eric W. Biederman" Rajesh Shah writes: > On Tue, Jun 20, 2006 at 04:24:35PM -0600, Eric W. Biederman wrote: >> >> The primary aim of this patch is to remove maintenances problems caused >> by the irq infrastructure. The two big issues I address are an >> artificially small cap on the number of irqs, and that MSI assumes >> vector == irq. My primary focus is on x86_64 but I have touched >> other architectures where necessary to keep them from breaking. >> > The MSI portions of this patchset is similar to the MSI cleanup > I was working on. I'll drop my patchkit and instead comment on > the relevant patches in this kit. > > I got a couple of minor compile errors on i386 (kernel/io_apic.c). > I fixed them up by hand and the resulting kernel booted and > worked with MSI in the limited testing I've done so far. Somewhere in the final round of cleanups I missed these two one liners. This is what it takes to fix the i386 build. Cc: Ingo Molnar Cc: Thomas Gleixner Cc: Benjamin Herrenschmidt Cc: Rajesh Shah Cc: Andi Kleen Cc: "Protasevich, Natalie" Cc: "Luck, Tony" Signed-off-by: Andrew Morton --- arch/i386/kernel/io_apic.c | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff -puN arch/i386/kernel/io_apic.c~genirq-i386-irq-dynamic-irq-support arch/i386/kernel/io_apic.c --- a/arch/i386/kernel/io_apic.c~genirq-i386-irq-dynamic-irq-support +++ a/arch/i386/kernel/io_apic.c @@ -2496,6 +2496,54 @@ static int __init ioapic_init_sysfs(void device_initcall(ioapic_init_sysfs); +#ifdef CONFIG_PCI_MSI +/* + * Dynamic irq allocate and deallocation for MSI + */ +int create_irq(void) +{ + /* Hack of the day: irq == vector. + * + * Ultimately this will be be more general, + * and not depend on the irq to vector identity mapping. + * But this version is needed until msi.c can cope with + * the more general form. + */ + int irq, vector; + unsigned long flags; + vector = assign_irq_vector(AUTO_ASSIGN); + irq = vector; + + if (vector >= 0) { + struct irq_desc *desc; + + spin_lock_irqsave(&vector_lock, flags); + vector_irq[vector] = irq; + irq_vector[irq] = vector; + spin_unlock_irqrestore(&vector_lock, flags); + + set_intr_gate(vector, interrupt[irq]); + + dynamic_irq_init(irq); + } + return irq; +} + +void destroy_irq(unsigned int irq) +{ + unsigned long flags; + unsigned int vector; + + dynamic_irq_cleanup(irq); + + spin_lock_irqsave(&vector_lock, flags); + vector = irq_vector[irq]; + vector_irq[vector] = -1; + irq_vector[irq] = 0; + spin_unlock_irqrestore(&vector_lock, flags); +} +#endif /* CONFIG_PCI_MSI */ + /* -------------------------------------------------------------------------- ACPI-based IOAPIC Configuration -------------------------------------------------------------------------- */ _