Updated MSI Patches
Subsystems (3)
Hi Jeff,
Thank you for your feedback on MSI patches based on kernel 2.6.0-test5. Below are the updated patches, which are based on kernel 2.6.0-test6 and include minor modification to reflect your input.
Thanks,
Long
---------------------------------------------------------
arch/i386/Kconfig +11 -0
@@ -1030,6 +1030,17 @@ depends on PCI && ((PCI_GODIRECT || PCI_GOANY) || X86_VISWS) default y +config PCI_USE_VECTOR + bool "PCI_USE_VECTOR" + default n + help + This replaces the current existing IRQ-based index interrupt scheme + with the vector-base index scheme. The advantages of vector base over IRQ base are listed below: + 1) Support MSI implementation. + 2) Support future IOxAPIC hotplug + + If you don't know what to do here, say N. + source "drivers/pci/Kconfig" config ISA
arch/i386/kernel/i8259.c +3 -1
@@ -419,8 +419,10 @@* us. (some of these will be overridden and become * 'special' SMP interrupts) */ -for (i =0 ; i <NR_IRQS ; i++) { +for (i =0 ; i < (NR_VECTORS -FIRST_EXTERNAL_VECTOR ); i++) {int vector =FIRST_EXTERNAL_VECTOR + i; +if (i >=NR_IRQS ) +break ;if (vector !=SYSCALL_VECTOR )set_intr_gate (vector, interrupt[i]); }
arch/i386/kernel/io_apic.c +121 -46
285 lines not on this page · raw message
arch/i386/kernel/mpparse.c +8 -4
@@ -1136,15 +1136,19 @@if ((1 <<bit) & mp_ioapic_routing[ioapic].pin_programmed[idx]) {printk (KERN_DEBUG "Pin %d-%d already programmed\n" , mp_ioapic_routing[ioapic].apic_id, ioapic_pin); - entry->irq = irq; +if (use_pci_vector () && !platform_legacy_irq (irq)) + irq =IO_APIC_VECTOR (irq); + entry->irq = irq;continue ; } mp_ioapic_routing[ioapic].pin_programmed[idx] |= (1 <<bit); -if (!io_apic_set_pci_routing (ioapic, ioapic_pin, irq, edge_level, active_high_low)) - entry->irq = irq; - +if (!io_apic_set_pci_routing (ioapic, ioapic_pin, irq, edge_level, active_high_low)) { +if (use_pci_vector () && !platform_legacy_irq (irq)) + irq =IO_APIC_VECTOR (irq); + entry->irq = irq; + } printk(KERN_DEBUG "%02x:%02x:%02x[%c] -> %d-%d -> IRQ %d\n", entry->id.segment, entry->id.bus, entry->id.device, ('A' + entry->pin),
arch/i386/pci/irq.c +4 -0
@@ -745,6 +745,10 @@ bridge->bus->number, PCI_SLOT(bridge->devfn), pin, irq); }if (irq >=0 ) { +if (use_pci_vector () && + !platform_legacy_irq (irq)) + irq =IO_APIC_VECTOR (irq); +printk (KERN_INFO "PCI->APIC IRQ transform: (B%d,I%d,P%d) -> %d\n" , dev->bus->number,PCI_SLOT (dev->devfn), pin, irq); dev->irq = irq;
include/asm-i386/hw_irq.h +1 -0
@@ -41,6 +41,7 @@ asmlinkage void error_interrupt(void); asmlinkage void spurious_interrupt(void); asmlinkage void thermal_interrupt(struct pt_regs); +#define platform_legacy_irq (irq) ((irq) < 16)#endif void mask_irq (unsigned int irq);
include/asm-i386/io_apic.h +40 -0
@@ -13,6 +13,46 @@#ifdef CONFIG_X86_IO_APIC +#ifdef CONFIG_PCI_USE_VECTOR +static inline int use_pci_vector (void ) {return 1 ;} +static inline void disable_edge_ioapic_vector (unsigned int vector) { } +static inline void mask_and_ack_level_ioapic_vector (unsigned int vector) { } +static inline void end_edge_ioapic_vector (unsigned int vector) { } +#define startup_level_ioapic startup_level_ioapic_vector +#define shutdown_level_ioapic mask_IO_APIC_vector +#define enable_level_ioapic unmask_IO_APIC_vector +#define disable_level_ioapic mask_IO_APIC_vector +#define mask_and_ack_level_ioapic mask_and_ack_level_ioapic_vector +#define end_level_ioapic end_level_ioapic_vector +#define set_ioapic_affinity set_ioapic_affinity_vector + +#define startup_edge_ioapic startup_edge_ioapic_vector +#define shutdown_edge_ioapic disable_edge_ioapic_vector +#define enable_edge_ioapic unmask_IO_APIC_vector +#define disable_edge_ioapic disable_edge_ioapic_vector +#define ack_edge_ioapic ack_edge_ioapic_vector +#define end_edge_ioapic end_edge_ioapic_vector +#else +static inline int use_pci_vector (void ) {return 0 ;} +static inline void disable_edge_ioapic_irq (unsigned int irq) { } +static inline void mask_and_ack_level_ioapic_irq (unsigned int irq) { } +static inline void end_edge_ioapic_irq (unsigned int irq) { } +#define startup_level_ioapic startup_level_ioapic_irq +#define shutdown_level_ioapic mask_IO_APIC_irq +#define enable_level_ioapic unmask_IO_APIC_irq +#define disable_level_ioapic mask_IO_APIC_irq +#define mask_and_ack_level_ioapic mask_and_ack_level_ioapic_irq +#define end_level_ioapic end_level_ioapic_irq +#define set_ioapic_affinity set_ioapic_affinity_irq + +#define startup_edge_ioapic startup_edge_ioapic_irq +#define shutdown_edge_ioapic disable_edge_ioapic_irq +#define enable_edge_ioapic unmask_IO_APIC_irq +#define disable_edge_ioapic disable_edge_ioapic_irq +#define ack_edge_ioapic ack_edge_ioapic_irq +#define end_edge_ioapic end_edge_ioapic_irq +#endif +#define APIC_MISMATCH_DEBUG #define IO_APIC_BASE (idx) \
include/asm-i386/mach-default/irq_vectors.h +10 -0
@@ -76,11 +76,21 @@* Since vectors 0x00-0x1f are used/reserved for the CPU, * the usable vector space is 0x20-0xff (224 vectors) */ +/* +* The maximum number of vectors supported by i386 processors +* is limited to 256. For processors other than i386, NR_VECTORS +* should be changed accordingly. +*/ +#define NR_VECTORS 256 +#ifdef CONFIG_PCI_USE_VECTOR +#define NR_IRQS FIRST_SYSTEM_VECTOR +#else #ifdef CONFIG_X86_IO_APIC #define NR_IRQS 224#else #define NR_IRQS 16#endif +#endif #define FPU_IRQ 13
arch/i386/Kconfig +7 -0
@@ -1032,6 +1032,7 @@ config PCI_USE_VECTOR bool "PCI_USE_VECTOR" + depends on X86_LOCAL_APIC default n help This replaces the current existing IRQ-based index interrupt scheme
@@ -1039,6 +1040,12 @@ 1) Support MSI implementation. 2) Support future IOxAPIC hotplug + Note that this enables MSI, Message Signaled Interrupt, on all + MSI capable device functions detected if users also install the + MSI patch. Message Signal Interrupt enables an MSI-capable + hardware device to send an inbound Memory Write on its PCI bus + instead of asserting IRQ signal on device IRQ pin. + If you don't know what to do here, say N. source "drivers/pci/Kconfig"
arch/i386/kernel/io_apic.c +5 -5
@@ -296,7 +296,7 @@extern cpumask_t irq_affinity[NR_IRQS ]; -static cpumask_t __cacheline_aligned pending_irq_balance_cpumask[NR_IRQS]; +cpumask_t __cacheline_aligned pending_irq_balance_cpumask[NR_IRQS];#define IRQBALANCE_CHECK_ARCH -999static int irqbalance_disabled =IRQBALANCE_CHECK_ARCH ;
@@ -1148,6 +1148,7 @@int irq_vector[NR_IRQS ] = {FIRST_DEVICE_VECTOR ,0 }; +#ifndef CONFIG_PCI_USE_VECTOR static int __init assign_irq_vector (int irq) {static int current_vector =FIRST_DEVICE_VECTOR , offset =0 ;
@@ -1164,14 +1165,13 @@ current_vector = FIRST_DEVICE_VECTOR + offset; } -#ifdef CONFIG_PCI_USE_VECTOR - vector_irq[current_vector] = irq; -#endif -IO_APIC_VECTOR (irq) = current_vector;return current_vector; } +#else +extern int assign_irq_vector (int irq); +#endif static struct hw_interrupt_type ioapic_level_type;static struct hw_interrupt_type ioapic_edge_type;
arch/i386/pci/irq.c +2 -0
@@ -680,8 +680,10 @@if ( dev2->irq && dev2->irq != irq && \ (!(pci_probe &PCI_USE_PIRQ_MASK ) || \ ((1 << dev2->irq) & mask)) ) { +#ifndef CONFIG_PCI_USE_VECTOR printk (KERN_INFO "IRQ routing conflict for %s, have irq %d, want irq %d\n" ,pci_name (dev2), dev2->irq, irq); +#endif continue ; } dev2->irq = irq;
Documentation/MSI-HOWTO.txt +321 -0
321 lines not on this page · raw message
drivers/acpi/pci_irq.c +1 -1
@@ -234,7 +234,7 @@PCI Interrupt Routing Support -------------------------------------------------------------------------- */ -static int +int acpi_pci_irq_lookup (struct pci_bus *bus,int device,int pin) {struct acpi_prt_entry *entry =NULL ;
drivers/pci/Makefile +1 -0
@@ -28,6 +28,7 @@ obj-$(CONFIG_SGI_IP27) += setup-irq.o obj-$(CONFIG_SGI_IP32) += setup-irq.o obj-$(CONFIG_X86_VISWS) += setup-irq.o +obj-$(CONFIG_PCI_USE_VECTOR) += msi.o # Cardbus & CompactPCI use setup-bus obj-$(CONFIG_HOTPLUG) += setup-bus.o
drivers/pci/msi.c +1061 -0
1,061 lines not on this page · raw message
drivers/pci/probe.c +1 -0
@@ -552,6 +552,7 @@struct pci_dev *dev; dev =pci_scan_device (bus, devfn); +pci_scan_msi_device (dev);if (func ==0 ) {if (!dev)break ;
drivers/pci/remove.c +2 -0
@@ -14,6 +14,8 @@ {int i; +msi_remove_pci_irq_vectors (dev); +for (i =0 ; i <PCI_NUM_RESOURCES ; i++) {struct resource *res = dev->resource + i;if (res->parent)
include/linux/pci.h +17 -0
@@ -36,6 +36,7 @@#define PCI_COMMAND_WAIT 0x80/* Enable address/data stepping */ #define PCI_COMMAND_SERR 0x100/* Enable SERR */ #define PCI_COMMAND_FAST_BACK 0x200/* Enable back-to-back writes */ +#define PCI_COMMAND_INTX_DISABLE 0x400/* INTx Emulation Disable */ #define PCI_STATUS 0x06/* 16 bits */ #define PCI_STATUS_CAP_LIST 0x10/* Support Capability List */
@@ -198,6 +199,8 @@#define PCI_CAP_ID_MSI 0x05/* Message Signalled Interrupts */ #define PCI_CAP_ID_CHSWP 0x06/* CompactPCI HotSwap */ #define PCI_CAP_ID_PCIX 0x07/* PCI-X */ +#define PCI_CAP_ID_EXP 0x10/* PCI Express */ +#define PCI_CAP_ID_MSIX 0x11/* MSI-X */ #define PCI_CAP_LIST_NEXT 1/* Next capability in the list */ #define PCI_CAP_FLAGS 2/* Capability defined flags (16 bits) */ #define PCI_CAP_SIZEOF 4
@@ -275,11 +278,13 @@#define PCI_MSI_FLAGS_QSIZE 0x70/* Message queue size configured */ #define PCI_MSI_FLAGS_QMASK 0x0e/* Maximum queue size available */ #define PCI_MSI_FLAGS_ENABLE 0x01/* MSI feature enabled */ +#define PCI_MSI_FLAGS_MASKBIT 0x100/* 64-bit mask bits allowed */ #define PCI_MSI_RFU 3/* Rest of capability flags */ #define PCI_MSI_ADDRESS_LO 4/* Lower 32 bits */ #define PCI_MSI_ADDRESS_HI 8/* Upper 32 bits (if PCI_MSI_FLAGS_64BIT set) */ #define PCI_MSI_DATA_32 8/* 16 bits of data for 32-bit devices */ #define PCI_MSI_DATA_64 12/* 16 bits of data for 64-bit devices */ +#define PCI_MSI_MASK_BIT 16/* Mask bits register */ /* CompactPCI Hotswap Register */
@@ -696,6 +701,18 @@extern struct pci_dev *isa_bridge;#endif +#ifndef CONFIG_PCI_USE_VECTOR +static inline void pci_scan_msi_device (struct pci_dev *dev) {} +static inline int pci_enable_msi (struct pci_dev *dev) {return -1 ;} +static inline void msi_remove_pci_irq_vectors (struct pci_dev *dev) {} +#else +extern void pci_scan_msi_device (struct pci_dev *dev); +extern int pci_enable_msi (struct pci_dev *dev); +extern void msi_remove_pci_irq_vectors (struct pci_dev *dev); +extern int msi_alloc_vectors (struct pci_dev * dev,int *vector,int nvec); +extern int msi_free_vectors (struct pci_dev * dev,int *vector,int nvec); +#endif +#endif /* CONFIG_PCI */ /* Include architecture-dependent settings and functions */
include/linux/pci_msi.h +193 -0
193 lines not on this page · raw message