i386, x86_64: fix the irqbalance quirk for E7520/E7320/E7525 - V2
cover i386, x86_64: fix the irqbalance quirk for E7520/E7320/E7525 - V2
Mechanism of selecting physical mode in genapic when cpu hotplug is enabled on x86_64, broke the quirk(quirk_intel_irqbalance()) introduced for working around the transposing interrupt message errata in E7520/E7320/E7525 (revision ID 0x9 and below. errata #23 in
http://download.intel.com/design/chipsets/specupdt/30304203.pdf).
This errata requires the mode to be in logical flat, so that interrupts can be directed to more than one cpu(and thus use hardware IRQ balancing enabled by BIOS on these platforms).
Following four patches fixes this by moving the quirk to early quirk and forcing the x86_64 genapic selection to logical flat on these platforms.
Thanks to Shaohua for pointing out the breakage.
Changes in V2:
- Fix compilation breakages
- ifdef and variable name cleanups
PATCH 1/4 i386: add write_pci_config_byte() to direct PCI access routines
Add write_pci_config_byte() to direct PCI access routines
---
arch/i386/pci/early.c +7 -0
@@ -45,6 +45,13 @@ void write_pci_config(u8 bus, u8 slot, uoutl (val,0xcfc ); } +void write_pci_config_byte (u8 bus,u8 slot,u8 func,u8 offset,u8 val) +{ +PDprintk ("%x writing to %x: %x\n" , slot, offset, val); +outl (0x80000000 | (bus<<16 ) | (slot<<11 ) | (func<<8 ) | offset,0xcf8 ); +outb (val,0xcfc ); +} +int early_pci_allowed (void ) { return (pci_probe & (PCI_PROBE_CONF1|PCI_PROBE_NOEARLY)) ==
include/asm-x86_64/pci-direct.h +1 -0
@@ -10,6 +10,7 @@ extern u32 read_pci_config(u8 bus, u8 slextern u8 read_pci_config_byte (u8 bus,u8 slot,u8 func,u8 offset);extern u16 read_pci_config_16 (u8 bus,u8 slot,u8 func,u8 offset);extern void write_pci_config (u8 bus,u8 slot,u8 func,u8 offset,u32 val); +extern void write_pci_config_byte (u8 bus,u8 slot,u8 func,u8 offset,u8 val);extern int early_pci_allowed (void );
PATCH 2/4 i386: introduce the mechanism of disabling cpu hotplug control
In reply to Siddha, Suresh BAdd 'enable_cpu_hotplug' flag and when cleared, the hotplug control file ("online") will not be added under /sys/devices/system/cpu/cpuX/
Next patch doing PCI quirks will use this.
---
arch/i386/kernel/topology.c +5 -1
@@ -40,14 +40,18 @@ int arch_register_cpu(int num)* restrictions and assumptions in kernel. This basically * doesnt add a control file, one cannot attempt to offline * BSP. +* +* Also certain PCI quirks require not to enable hotplug control +* for all CPU's. */ -if (!num) +if (!num || !enable_cpu_hotplug) cpu_devices[num].cpu.no_control =1 ;return register_cpu (&cpu_devices[num].cpu, num); }#ifdef CONFIG_HOTPLUG_CPU +int enable_cpu_hotplug =1 ;void arch_unregister_cpu (int num) {return unregister_cpu (&cpu_devices[num].cpu);
include/asm-i386/cpu.h +3 -0
@@ -13,6 +13,9 @@ struct i386_cpu {extern int arch_register_cpu (int num);#ifdef CONFIG_HOTPLUG_CPU extern void arch_unregister_cpu (int ); +extern int enable_cpu_hotplug; +#else +#define enable_cpu_hotplug 0#endif DECLARE_PER_CPU (int, cpu_state);
PATCH 3/4 x86_64: add genapic_force
In reply to Siddha, Suresh BAdd genapic_force. Used by the next Intel quirks patch.
---
arch/x86_64/kernel/genapic.c +8 -1
@@ -33,7 +33,7 @@ extern struct genapic apic_flat;extern struct genapic apic_physflat;struct genapic *genapic = &apic_flat; - +struct genapic *genapic_force;/* * Check the APIC IDs in bios_cpu_apicid and choose the APIC mode.
@@ -46,6 +46,13 @@ void __init clustered_apic_check(void)u8 cluster_cnt[NUM_APIC_CLUSTERS ];int max_apic =0 ; +/* genapic selection can be forced because of certain quirks. +*/ +if (genapic_force) { + genapic = genapic_force; + goto print; + } +#if defined(CONFIG_ACPI )/* * Some x86_64 machines use physical APIC mode regardless of how many
include/asm-x86_64/genapic.h +1 -1
@@ -30,6 +30,6 @@ struct genapic { }; -extern struct genapic *genapic; +extern struct genapic *genapic, *genapic_force, apic_flat;#endif
PATCH 4/4 fix the irqbalance quirk for E7320/E7520/E7525
In reply to Siddha, Suresh BMove the irqbalance quirks for E7320/E7520/E7525(Errata 23 in
http://download.intel.com/design/chipsets/specupdt/30304203.pdf) to early quirks.
And add a PCI quirk for these platforms to check(which happens very late during the boot) if the APIC routing is indeed set to default flat mode.
This fixes the breakage(in x86_64) of this quirk due to cpu hotplug which selects physical mode instead of the logical flat(as needed for this errata workaround).
---
arch/i386/kernel/acpi/earlyquirk.c +21 -0
@@ -10,6 +10,7 @@ #include <linux/acpi.h>#include <asm/pci-direct.h> #include <asm/acpi.h> #include <asm/apic.h> +#include <asm/irq.h> #ifdef CONFIG_ACPI
@@ -43,6 +44,24 @@ #endifreturn 0 ; } +static void check_intel (void ) +{ +u16 vendor, device; + + vendor =read_pci_config_16 (0 ,0 ,0 ,PCI_VENDOR_ID ); + +if (vendor !=PCI_VENDOR_ID_INTEL ) +return ; + + device =read_pci_config_16 (0 ,0 ,0 ,PCI_DEVICE_ID ); +#ifdef CONFIG_SMP +if (device ==PCI_DEVICE_ID_INTEL_E7320_MCH || + device ==PCI_DEVICE_ID_INTEL_E7520_MCH || + device ==PCI_DEVICE_ID_INTEL_E7525_MCH ) +quirk_intel_irqbalance (); +#endif +} +void __init check_acpi_pci (void ) {int num, slot, func;
@@ -54,6 +73,8 @@ void __init check_acpi_pci(void)if (!early_pci_allowed ())return ; +check_intel (); +/* Poor man's PCI discovery */ for (num =0 ; num <32 ; num++) {for (slot =0 ; slot <32 ; slot++) {
arch/i386/kernel/quirks.c +35 -11
76 lines not on this page · raw message
arch/i386/kernel/smpboot.c +7 -0
@@ -52,6 +52,7 @@ #include <asm/tlbflush.h>#include <asm/desc.h> #include <asm/arch_hooks.h> #include <asm/nmi.h> +#include <asm/genapic.h> #include <mach_apic.h> #include <mach_wakecpu.h>
@@ -1461,6 +1462,12 @@ #endifcpu_set (cpu, smp_commenced_mask);while (!cpu_isset (cpu, cpu_online_map))cpu_relax (); + +#ifdef CONFIG_X86_GENERICARCH +if (num_online_cpus () >8 && genapic == &apic_default) +panic ("Default flat APIC routing can't be used with > 8 cpus\n" ); +#endif +return 0 ; }
arch/x86_64/kernel/early-quirks.c +13 -0
@@ -68,6 +68,18 @@ static void ati_bugs(void) } } +static void intel_bugs (void ) +{ +u16 device =read_pci_config_16 (0 ,0 ,0 ,PCI_DEVICE_ID ); + +#ifdef CONFIG_SMP +if (device ==PCI_DEVICE_ID_INTEL_E7320_MCH || + device ==PCI_DEVICE_ID_INTEL_E7520_MCH || + device ==PCI_DEVICE_ID_INTEL_E7525_MCH ) +quirk_intel_irqbalance (); +#endif +} +struct chipset {u16 vendor;void (*f)(void );
@@ -77,6 +89,7 @@ static struct chipset early_qrk[] = { { PCI_VENDOR_ID_NVIDIA, nvidia_bugs }, { PCI_VENDOR_ID_VIA, via_bugs }, { PCI_VENDOR_ID_ATI, ati_bugs }, + { PCI_VENDOR_ID_INTEL, intel_bugs}, {} };
arch/x86_64/kernel/smpboot.c +8 -0
@@ -60,6 +60,7 @@ #include <asm/nmi.h>#include <asm/irq.h> #include <asm/hw_irq.h> #include <asm/numa.h> +#include <asm/genapic.h> /* Number of siblings per CPU package */ int smp_num_siblings =1 ;
@@ -1167,6 +1168,13 @@ int __cpuinit __cpu_up(unsigned int cpu)while (!cpu_isset (cpu, cpu_online_map))cpu_relax (); + +if (num_online_cpus () >8 && genapic == &apic_flat) { +printk (KERN_WARNING +"flat APIC routing can't be used with > 8 cpus\n" ); +BUG (); + } + err =0 ;return err;
include/asm-i386/genapic.h +1 -1
@@ -122,6 +122,6 @@ #define APIC_INIT(aname, aprobe) { \APICFUNC (phys_pkg_id) \ } -extern struct genapic *genapic; +extern struct genapic *genapic, apic_default;#endif
include/asm-i386/irq.h +2 -0
@@ -37,6 +37,8 @@ #ifdef CONFIG_IRQBALANCEextern int irqbalance_disable (char *str);#endif +extern void quirk_intel_irqbalance (void ); +#ifdef CONFIG_HOTPLUG_CPU extern void fixup_irqs (cpumask_t map);#endif
include/asm-x86_64/proto.h +1 -0
@@ -88,6 +88,7 @@ extern void syscall32_cpu_init(void);extern void setup_node_bootmem (int nodeid,unsigned long start,unsigned long end);extern void early_quirks (void ); +extern void quirk_intel_irqbalance (void );extern void check_efer (void );extern int unhandled_signal (struct task_struct *tsk,int sig);
Quoted 9 lines · Suresh B
Mechanism of selecting physical mode in genapic when cpu hotplug is enabled on
x86_64, broke the quirk(quirk_intel_irqbalance()) introduced for working around the transposing interrupt message errata in E7520/E7320/E7525 (revision ID0x9and below. errata #23 in
http://download.intel.com/design/chipsets/specupdt/30304203.pdf).This errata requires the mode to be in logical flat, so that interrupts can be directed to more than one cpu(and thus use hardware IRQ balancing enabled by BIOS on these platforms).
Fine by me. But can you fix the compilation issues Andrew found and resend please?
-Andi