quirks.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /*
  2. * This file contains work-arounds for x86 and x86_64 platform bugs.
  3. */
  4. #include <linux/pci.h>
  5. #include <linux/irq.h>
  6. #include <asm/pci-direct.h>
  7. #include <asm/genapic.h>
  8. #include <asm/cpu.h>
  9. #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
  10. static void __devinit verify_quirk_intel_irqbalance(struct pci_dev *dev)
  11. {
  12. u8 config, rev;
  13. u32 word;
  14. /* BIOS may enable hardware IRQ balancing for
  15. * E7520/E7320/E7525(revision ID 0x9 and below)
  16. * based platforms.
  17. * For those platforms, make sure that the genapic is set to 'flat'
  18. */
  19. pci_read_config_byte(dev, PCI_CLASS_REVISION, &rev);
  20. if (rev > 0x9)
  21. return;
  22. /* enable access to config space*/
  23. pci_read_config_byte(dev, 0xf4, &config);
  24. pci_write_config_byte(dev, 0xf4, config|0x2);
  25. /* read xTPR register */
  26. raw_pci_ops->read(0, 0, 0x40, 0x4c, 2, &word);
  27. if (!(word & (1 << 13))) {
  28. #ifdef CONFIG_X86_64
  29. if (genapic != &apic_flat)
  30. panic("APIC mode must be flat on this system\n");
  31. #elif defined(CONFIG_X86_GENERICARCH)
  32. if (genapic != &apic_default)
  33. panic("APIC mode must be default(flat) on this system. Use apic=default\n");
  34. #endif
  35. }
  36. /* put back the original value for config space*/
  37. if (!(config & 0x2))
  38. pci_write_config_byte(dev, 0xf4, config);
  39. }
  40. void __init quirk_intel_irqbalance(void)
  41. {
  42. u8 config, rev;
  43. u32 word;
  44. /* BIOS may enable hardware IRQ balancing for
  45. * E7520/E7320/E7525(revision ID 0x9 and below)
  46. * based platforms.
  47. * Disable SW irqbalance/affinity on those platforms.
  48. */
  49. rev = read_pci_config_byte(0, 0, 0, PCI_CLASS_REVISION);
  50. if (rev > 0x9)
  51. return;
  52. printk(KERN_INFO "Intel E7520/7320/7525 detected.");
  53. /* enable access to config space */
  54. config = read_pci_config_byte(0, 0, 0, 0xf4);
  55. write_pci_config_byte(0, 0, 0, 0xf4, config|0x2);
  56. /* read xTPR register */
  57. word = read_pci_config_16(0, 0, 0x40, 0x4c);
  58. if (!(word & (1 << 13))) {
  59. printk(KERN_INFO "Disabling irq balancing and affinity\n");
  60. #ifdef CONFIG_IRQBALANCE
  61. irqbalance_disable("");
  62. #endif
  63. noirqdebug_setup("");
  64. #ifdef CONFIG_PROC_FS
  65. no_irq_affinity = 1;
  66. #endif
  67. #ifdef CONFIG_HOTPLUG_CPU
  68. printk(KERN_INFO "Disabling cpu hotplug control\n");
  69. enable_cpu_hotplug = 0;
  70. #endif
  71. #ifdef CONFIG_X86_64
  72. /* force the genapic selection to flat mode so that
  73. * interrupts can be redirected to more than one CPU.
  74. */
  75. genapic_force = &apic_flat;
  76. #endif
  77. }
  78. /* put back the original value for config space */
  79. if (!(config & 0x2))
  80. write_pci_config_byte(0, 0, 0, 0xf4, config);
  81. }
  82. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH, verify_quirk_intel_irqbalance);
  83. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH, verify_quirk_intel_irqbalance);
  84. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH, verify_quirk_intel_irqbalance);
  85. #endif