blob: 34874c398b445735cf94b8bf0ac505798607eae7 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
2 * This file contains work-arounds for x86 and x86_64 platform bugs.
3 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07004#include <linux/pci.h>
5#include <linux/irq.h>
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +01006#include <asm/pci-direct.h>
7#include <asm/genapic.h>
8#include <asm/cpu.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07009
10#if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010011static void __devinit verify_quirk_intel_irqbalance(struct pci_dev *dev)
12{
Andi Kleen16d279d2006-12-09 21:33:35 +010013 u8 config, rev;
14 u32 word;
15
16 /* BIOS may enable hardware IRQ balancing for
17 * E7520/E7320/E7525(revision ID 0x9 and below)
18 * based platforms.
19 * For those platforms, make sure that the genapic is set to 'flat'
20 */
21 pci_read_config_byte(dev, PCI_CLASS_REVISION, &rev);
22 if (rev > 0x9)
23 return;
24
25 /* enable access to config space*/
26 pci_read_config_byte(dev, 0xf4, &config);
27 pci_write_config_byte(dev, 0xf4, config|0x2);
28
29 /* read xTPR register */
30 raw_pci_ops->read(0, 0, 0x40, 0x4c, 2, &word);
31
32 if (!(word & (1 << 13))) {
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010033#ifdef CONFIG_X86_64
Andi Kleen16d279d2006-12-09 21:33:35 +010034 if (genapic != &apic_flat)
35 panic("APIC mode must be flat on this system\n");
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010036#elif defined(CONFIG_X86_GENERICARCH)
Andi Kleen16d279d2006-12-09 21:33:35 +010037 if (genapic != &apic_default)
38 panic("APIC mode must be default(flat) on this system. Use apic=default\n");
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010039#endif
Andi Kleen16d279d2006-12-09 21:33:35 +010040 }
41
42 /* put back the original value for config space*/
43 if (!(config & 0x2))
44 pci_write_config_byte(dev, 0xf4, config);
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010045}
Linus Torvalds1da177e2005-04-16 15:20:36 -070046
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010047void __init quirk_intel_irqbalance(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070048{
49 u8 config, rev;
50 u32 word;
51
52 /* BIOS may enable hardware IRQ balancing for
53 * E7520/E7320/E7525(revision ID 0x9 and below)
54 * based platforms.
55 * Disable SW irqbalance/affinity on those platforms.
56 */
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010057 rev = read_pci_config_byte(0, 0, 0, PCI_CLASS_REVISION);
Linus Torvalds1da177e2005-04-16 15:20:36 -070058 if (rev > 0x9)
59 return;
60
61 printk(KERN_INFO "Intel E7520/7320/7525 detected.");
62
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010063 /* enable access to config space */
64 config = read_pci_config_byte(0, 0, 0, 0xf4);
65 write_pci_config_byte(0, 0, 0, 0xf4, config|0x2);
Linus Torvalds1da177e2005-04-16 15:20:36 -070066
67 /* read xTPR register */
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010068 word = read_pci_config_16(0, 0, 0x40, 0x4c);
Linus Torvalds1da177e2005-04-16 15:20:36 -070069
70 if (!(word & (1 << 13))) {
71 printk(KERN_INFO "Disabling irq balancing and affinity\n");
72#ifdef CONFIG_IRQBALANCE
73 irqbalance_disable("");
74#endif
75 noirqdebug_setup("");
76#ifdef CONFIG_PROC_FS
77 no_irq_affinity = 1;
78#endif
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010079#ifdef CONFIG_HOTPLUG_CPU
80 printk(KERN_INFO "Disabling cpu hotplug control\n");
81 enable_cpu_hotplug = 0;
82#endif
83#ifdef CONFIG_X86_64
84 /* force the genapic selection to flat mode so that
85 * interrupts can be redirected to more than one CPU.
86 */
87 genapic_force = &apic_flat;
88#endif
Linus Torvalds1da177e2005-04-16 15:20:36 -070089 }
90
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010091 /* put back the original value for config space */
Alan Coxda9bb1d2006-01-18 17:44:13 -080092 if (!(config & 0x2))
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010093 write_pci_config_byte(0, 0, 0, 0xf4, config);
Linus Torvalds1da177e2005-04-16 15:20:36 -070094}
Siddha, Suresh Bb0d0a4b2006-12-07 02:14:10 +010095DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, verify_quirk_intel_irqbalance);
96DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, verify_quirk_intel_irqbalance);
97DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, verify_quirk_intel_irqbalance);
98
Linus Torvalds1da177e2005-04-16 15:20:36 -070099#endif