quirks.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  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/hpet.h>
  7. #if defined(CONFIG_X86_IO_APIC) && defined(CONFIG_SMP) && defined(CONFIG_PCI)
  8. static void quirk_intel_irqbalance(struct pci_dev *dev)
  9. {
  10. u8 config;
  11. u16 word;
  12. /* BIOS may enable hardware IRQ balancing for
  13. * E7520/E7320/E7525(revision ID 0x9 and below)
  14. * based platforms.
  15. * Disable SW irqbalance/affinity on those platforms.
  16. */
  17. if (dev->revision > 0x9)
  18. return;
  19. /* enable access to config space*/
  20. pci_read_config_byte(dev, 0xf4, &config);
  21. pci_write_config_byte(dev, 0xf4, config|0x2);
  22. /*
  23. * read xTPR register. We may not have a pci_dev for device 8
  24. * because it might be hidden until the above write.
  25. */
  26. pci_bus_read_config_word(dev->bus, PCI_DEVFN(8, 0), 0x4c, &word);
  27. if (!(word & (1 << 13))) {
  28. dev_info(&dev->dev, "Intel E7520/7320/7525 detected; "
  29. "disabling irq balancing and affinity\n");
  30. noirqdebug_setup("");
  31. #ifdef CONFIG_PROC_FS
  32. no_irq_affinity = 1;
  33. #endif
  34. }
  35. /* put back the original value for config space*/
  36. if (!(config & 0x2))
  37. pci_write_config_byte(dev, 0xf4, config);
  38. }
  39. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7320_MCH,
  40. quirk_intel_irqbalance);
  41. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7525_MCH,
  42. quirk_intel_irqbalance);
  43. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E7520_MCH,
  44. quirk_intel_irqbalance);
  45. #endif
  46. #if defined(CONFIG_HPET_TIMER)
  47. unsigned long force_hpet_address;
  48. static enum {
  49. NONE_FORCE_HPET_RESUME,
  50. OLD_ICH_FORCE_HPET_RESUME,
  51. ICH_FORCE_HPET_RESUME,
  52. VT8237_FORCE_HPET_RESUME,
  53. NVIDIA_FORCE_HPET_RESUME,
  54. ATI_FORCE_HPET_RESUME,
  55. } force_hpet_resume_type;
  56. static void __iomem *rcba_base;
  57. static void ich_force_hpet_resume(void)
  58. {
  59. u32 val;
  60. if (!force_hpet_address)
  61. return;
  62. BUG_ON(rcba_base == NULL);
  63. /* read the Function Disable register, dword mode only */
  64. val = readl(rcba_base + 0x3404);
  65. if (!(val & 0x80)) {
  66. /* HPET disabled in HPTC. Trying to enable */
  67. writel(val | 0x80, rcba_base + 0x3404);
  68. }
  69. val = readl(rcba_base + 0x3404);
  70. if (!(val & 0x80))
  71. BUG();
  72. else
  73. printk(KERN_DEBUG "Force enabled HPET at resume\n");
  74. return;
  75. }
  76. static void ich_force_enable_hpet(struct pci_dev *dev)
  77. {
  78. u32 val;
  79. u32 uninitialized_var(rcba);
  80. int err = 0;
  81. if (hpet_address || force_hpet_address)
  82. return;
  83. pci_read_config_dword(dev, 0xF0, &rcba);
  84. rcba &= 0xFFFFC000;
  85. if (rcba == 0) {
  86. dev_printk(KERN_DEBUG, &dev->dev, "RCBA disabled; "
  87. "cannot force enable HPET\n");
  88. return;
  89. }
  90. /* use bits 31:14, 16 kB aligned */
  91. rcba_base = ioremap_nocache(rcba, 0x4000);
  92. if (rcba_base == NULL) {
  93. dev_printk(KERN_DEBUG, &dev->dev, "ioremap failed; "
  94. "cannot force enable HPET\n");
  95. return;
  96. }
  97. /* read the Function Disable register, dword mode only */
  98. val = readl(rcba_base + 0x3404);
  99. if (val & 0x80) {
  100. /* HPET is enabled in HPTC. Just not reported by BIOS */
  101. val = val & 0x3;
  102. force_hpet_address = 0xFED00000 | (val << 12);
  103. dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
  104. "0x%lx\n", force_hpet_address);
  105. iounmap(rcba_base);
  106. return;
  107. }
  108. /* HPET disabled in HPTC. Trying to enable */
  109. writel(val | 0x80, rcba_base + 0x3404);
  110. val = readl(rcba_base + 0x3404);
  111. if (!(val & 0x80)) {
  112. err = 1;
  113. } else {
  114. val = val & 0x3;
  115. force_hpet_address = 0xFED00000 | (val << 12);
  116. }
  117. if (err) {
  118. force_hpet_address = 0;
  119. iounmap(rcba_base);
  120. dev_printk(KERN_DEBUG, &dev->dev,
  121. "Failed to force enable HPET\n");
  122. } else {
  123. force_hpet_resume_type = ICH_FORCE_HPET_RESUME;
  124. dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
  125. "0x%lx\n", force_hpet_address);
  126. }
  127. }
  128. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB2_0,
  129. ich_force_enable_hpet);
  130. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_0,
  131. ich_force_enable_hpet);
  132. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH6_1,
  133. ich_force_enable_hpet);
  134. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_0,
  135. ich_force_enable_hpet);
  136. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_1,
  137. ich_force_enable_hpet);
  138. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH7_31,
  139. ich_force_enable_hpet);
  140. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_1,
  141. ich_force_enable_hpet);
  142. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH8_4,
  143. ich_force_enable_hpet);
  144. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ICH9_7,
  145. ich_force_enable_hpet);
  146. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, 0x3a16, /* ICH10 */
  147. ich_force_enable_hpet);
  148. static struct pci_dev *cached_dev;
  149. static void hpet_print_force_info(void)
  150. {
  151. printk(KERN_INFO "HPET not enabled in BIOS. "
  152. "You might try hpet=force boot option\n");
  153. }
  154. static void old_ich_force_hpet_resume(void)
  155. {
  156. u32 val;
  157. u32 uninitialized_var(gen_cntl);
  158. if (!force_hpet_address || !cached_dev)
  159. return;
  160. pci_read_config_dword(cached_dev, 0xD0, &gen_cntl);
  161. gen_cntl &= (~(0x7 << 15));
  162. gen_cntl |= (0x4 << 15);
  163. pci_write_config_dword(cached_dev, 0xD0, gen_cntl);
  164. pci_read_config_dword(cached_dev, 0xD0, &gen_cntl);
  165. val = gen_cntl >> 15;
  166. val &= 0x7;
  167. if (val == 0x4)
  168. printk(KERN_DEBUG "Force enabled HPET at resume\n");
  169. else
  170. BUG();
  171. }
  172. static void old_ich_force_enable_hpet(struct pci_dev *dev)
  173. {
  174. u32 val;
  175. u32 uninitialized_var(gen_cntl);
  176. if (hpet_address || force_hpet_address)
  177. return;
  178. pci_read_config_dword(dev, 0xD0, &gen_cntl);
  179. /*
  180. * Bit 17 is HPET enable bit.
  181. * Bit 16:15 control the HPET base address.
  182. */
  183. val = gen_cntl >> 15;
  184. val &= 0x7;
  185. if (val & 0x4) {
  186. val &= 0x3;
  187. force_hpet_address = 0xFED00000 | (val << 12);
  188. dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx\n",
  189. force_hpet_address);
  190. return;
  191. }
  192. /*
  193. * HPET is disabled. Trying enabling at FED00000 and check
  194. * whether it sticks
  195. */
  196. gen_cntl &= (~(0x7 << 15));
  197. gen_cntl |= (0x4 << 15);
  198. pci_write_config_dword(dev, 0xD0, gen_cntl);
  199. pci_read_config_dword(dev, 0xD0, &gen_cntl);
  200. val = gen_cntl >> 15;
  201. val &= 0x7;
  202. if (val & 0x4) {
  203. /* HPET is enabled in HPTC. Just not reported by BIOS */
  204. val &= 0x3;
  205. force_hpet_address = 0xFED00000 | (val << 12);
  206. dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
  207. "0x%lx\n", force_hpet_address);
  208. cached_dev = dev;
  209. force_hpet_resume_type = OLD_ICH_FORCE_HPET_RESUME;
  210. return;
  211. }
  212. dev_printk(KERN_DEBUG, &dev->dev, "Failed to force enable HPET\n");
  213. }
  214. /*
  215. * Undocumented chipset features. Make sure that the user enforced
  216. * this.
  217. */
  218. static void old_ich_force_enable_hpet_user(struct pci_dev *dev)
  219. {
  220. if (hpet_force_user)
  221. old_ich_force_enable_hpet(dev);
  222. }
  223. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_ESB_1,
  224. old_ich_force_enable_hpet_user);
  225. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_0,
  226. old_ich_force_enable_hpet_user);
  227. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801CA_12,
  228. old_ich_force_enable_hpet_user);
  229. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_0,
  230. old_ich_force_enable_hpet_user);
  231. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801DB_12,
  232. old_ich_force_enable_hpet_user);
  233. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_0,
  234. old_ich_force_enable_hpet);
  235. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_82801EB_12,
  236. old_ich_force_enable_hpet);
  237. static void vt8237_force_hpet_resume(void)
  238. {
  239. u32 val;
  240. if (!force_hpet_address || !cached_dev)
  241. return;
  242. val = 0xfed00000 | 0x80;
  243. pci_write_config_dword(cached_dev, 0x68, val);
  244. pci_read_config_dword(cached_dev, 0x68, &val);
  245. if (val & 0x80)
  246. printk(KERN_DEBUG "Force enabled HPET at resume\n");
  247. else
  248. BUG();
  249. }
  250. static void vt8237_force_enable_hpet(struct pci_dev *dev)
  251. {
  252. u32 uninitialized_var(val);
  253. if (hpet_address || force_hpet_address)
  254. return;
  255. if (!hpet_force_user) {
  256. hpet_print_force_info();
  257. return;
  258. }
  259. pci_read_config_dword(dev, 0x68, &val);
  260. /*
  261. * Bit 7 is HPET enable bit.
  262. * Bit 31:10 is HPET base address (contrary to what datasheet claims)
  263. */
  264. if (val & 0x80) {
  265. force_hpet_address = (val & ~0x3ff);
  266. dev_printk(KERN_DEBUG, &dev->dev, "HPET at 0x%lx\n",
  267. force_hpet_address);
  268. return;
  269. }
  270. /*
  271. * HPET is disabled. Trying enabling at FED00000 and check
  272. * whether it sticks
  273. */
  274. val = 0xfed00000 | 0x80;
  275. pci_write_config_dword(dev, 0x68, val);
  276. pci_read_config_dword(dev, 0x68, &val);
  277. if (val & 0x80) {
  278. force_hpet_address = (val & ~0x3ff);
  279. dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
  280. "0x%lx\n", force_hpet_address);
  281. cached_dev = dev;
  282. force_hpet_resume_type = VT8237_FORCE_HPET_RESUME;
  283. return;
  284. }
  285. dev_printk(KERN_DEBUG, &dev->dev, "Failed to force enable HPET\n");
  286. }
  287. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8235,
  288. vt8237_force_enable_hpet);
  289. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_8237,
  290. vt8237_force_enable_hpet);
  291. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_CX700,
  292. vt8237_force_enable_hpet);
  293. static void ati_force_hpet_resume(void)
  294. {
  295. pci_write_config_dword(cached_dev, 0x14, 0xfed00000);
  296. printk(KERN_DEBUG "Force enabled HPET at resume\n");
  297. }
  298. static u32 ati_ixp4x0_rev(struct pci_dev *dev)
  299. {
  300. int err = 0;
  301. u32 d = 0;
  302. u8 b = 0;
  303. err = pci_read_config_byte(dev, 0xac, &b);
  304. b &= ~(1<<5);
  305. err |= pci_write_config_byte(dev, 0xac, b);
  306. err |= pci_read_config_dword(dev, 0x70, &d);
  307. d |= 1<<8;
  308. err |= pci_write_config_dword(dev, 0x70, d);
  309. err |= pci_read_config_dword(dev, 0x8, &d);
  310. d &= 0xff;
  311. dev_printk(KERN_DEBUG, &dev->dev, "SB4X0 revision 0x%x\n", d);
  312. WARN_ON_ONCE(err);
  313. return d;
  314. }
  315. static void ati_force_enable_hpet(struct pci_dev *dev)
  316. {
  317. u32 d, val;
  318. u8 b;
  319. if (hpet_address || force_hpet_address)
  320. return;
  321. if (!hpet_force_user) {
  322. hpet_print_force_info();
  323. return;
  324. }
  325. d = ati_ixp4x0_rev(dev);
  326. if (d < 0x82)
  327. return;
  328. /* base address */
  329. pci_write_config_dword(dev, 0x14, 0xfed00000);
  330. pci_read_config_dword(dev, 0x14, &val);
  331. /* enable interrupt */
  332. outb(0x72, 0xcd6); b = inb(0xcd7);
  333. b |= 0x1;
  334. outb(0x72, 0xcd6); outb(b, 0xcd7);
  335. outb(0x72, 0xcd6); b = inb(0xcd7);
  336. if (!(b & 0x1))
  337. return;
  338. pci_read_config_dword(dev, 0x64, &d);
  339. d |= (1<<10);
  340. pci_write_config_dword(dev, 0x64, d);
  341. pci_read_config_dword(dev, 0x64, &d);
  342. if (!(d & (1<<10)))
  343. return;
  344. force_hpet_address = val;
  345. force_hpet_resume_type = ATI_FORCE_HPET_RESUME;
  346. dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx\n",
  347. force_hpet_address);
  348. cached_dev = dev;
  349. }
  350. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_IXP400_SMBUS,
  351. ati_force_enable_hpet);
  352. /*
  353. * Undocumented chipset feature taken from LinuxBIOS.
  354. */
  355. static void nvidia_force_hpet_resume(void)
  356. {
  357. pci_write_config_dword(cached_dev, 0x44, 0xfed00001);
  358. printk(KERN_DEBUG "Force enabled HPET at resume\n");
  359. }
  360. static void nvidia_force_enable_hpet(struct pci_dev *dev)
  361. {
  362. u32 uninitialized_var(val);
  363. if (hpet_address || force_hpet_address)
  364. return;
  365. if (!hpet_force_user) {
  366. hpet_print_force_info();
  367. return;
  368. }
  369. pci_write_config_dword(dev, 0x44, 0xfed00001);
  370. pci_read_config_dword(dev, 0x44, &val);
  371. force_hpet_address = val & 0xfffffffe;
  372. force_hpet_resume_type = NVIDIA_FORCE_HPET_RESUME;
  373. dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at 0x%lx\n",
  374. force_hpet_address);
  375. cached_dev = dev;
  376. return;
  377. }
  378. /* ISA Bridges */
  379. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0050,
  380. nvidia_force_enable_hpet);
  381. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0051,
  382. nvidia_force_enable_hpet);
  383. /* LPC bridges */
  384. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0260,
  385. nvidia_force_enable_hpet);
  386. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0360,
  387. nvidia_force_enable_hpet);
  388. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0361,
  389. nvidia_force_enable_hpet);
  390. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0362,
  391. nvidia_force_enable_hpet);
  392. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0363,
  393. nvidia_force_enable_hpet);
  394. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0364,
  395. nvidia_force_enable_hpet);
  396. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0365,
  397. nvidia_force_enable_hpet);
  398. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0366,
  399. nvidia_force_enable_hpet);
  400. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_NVIDIA, 0x0367,
  401. nvidia_force_enable_hpet);
  402. void force_hpet_resume(void)
  403. {
  404. switch (force_hpet_resume_type) {
  405. case ICH_FORCE_HPET_RESUME:
  406. ich_force_hpet_resume();
  407. return;
  408. case OLD_ICH_FORCE_HPET_RESUME:
  409. old_ich_force_hpet_resume();
  410. return;
  411. case VT8237_FORCE_HPET_RESUME:
  412. vt8237_force_hpet_resume();
  413. return;
  414. case NVIDIA_FORCE_HPET_RESUME:
  415. nvidia_force_hpet_resume();
  416. return;
  417. case ATI_FORCE_HPET_RESUME:
  418. ati_force_hpet_resume();
  419. return;
  420. default:
  421. break;
  422. }
  423. }
  424. /*
  425. * According to the datasheet e6xx systems have the HPET hardwired to
  426. * 0xfed00000
  427. */
  428. static void e6xx_force_enable_hpet(struct pci_dev *dev)
  429. {
  430. if (hpet_address || force_hpet_address)
  431. return;
  432. force_hpet_address = 0xFED00000;
  433. force_hpet_resume_type = NONE_FORCE_HPET_RESUME;
  434. dev_printk(KERN_DEBUG, &dev->dev, "Force enabled HPET at "
  435. "0x%lx\n", force_hpet_address);
  436. return;
  437. }
  438. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_INTEL, PCI_DEVICE_ID_INTEL_E6XX_CU,
  439. e6xx_force_enable_hpet);
  440. /*
  441. * HPET MSI on some boards (ATI SB700/SB800) has side effect on
  442. * floppy DMA. Disable HPET MSI on such platforms.
  443. * See erratum #27 (Misinterpreted MSI Requests May Result in
  444. * Corrupted LPC DMA Data) in AMD Publication #46837,
  445. * "SB700 Family Product Errata", Rev. 1.0, March 2010.
  446. */
  447. static void force_disable_hpet_msi(struct pci_dev *unused)
  448. {
  449. hpet_msi_disable = true;
  450. }
  451. DECLARE_PCI_FIXUP_HEADER(PCI_VENDOR_ID_ATI, PCI_DEVICE_ID_ATI_SBX00_SMBUS,
  452. force_disable_hpet_msi);
  453. #endif
  454. #if defined(CONFIG_PCI) && defined(CONFIG_NUMA)
  455. /* Set correct numa_node information for AMD NB functions */
  456. static void quirk_amd_nb_node(struct pci_dev *dev)
  457. {
  458. struct pci_dev *nb_ht;
  459. unsigned int devfn;
  460. u32 node;
  461. u32 val;
  462. devfn = PCI_DEVFN(PCI_SLOT(dev->devfn), 0);
  463. nb_ht = pci_get_slot(dev->bus, devfn);
  464. if (!nb_ht)
  465. return;
  466. pci_read_config_dword(nb_ht, 0x60, &val);
  467. node = pcibus_to_node(dev->bus) | (val & 7);
  468. /*
  469. * Some hardware may return an invalid node ID,
  470. * so check it first:
  471. */
  472. if (node_online(node))
  473. set_dev_node(&dev->dev, node);
  474. pci_dev_put(nb_ht);
  475. }
  476. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB,
  477. quirk_amd_nb_node);
  478. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_ADDRMAP,
  479. quirk_amd_nb_node);
  480. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MEMCTL,
  481. quirk_amd_nb_node);
  482. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_K8_NB_MISC,
  483. quirk_amd_nb_node);
  484. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_HT,
  485. quirk_amd_nb_node);
  486. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MAP,
  487. quirk_amd_nb_node);
  488. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_DRAM,
  489. quirk_amd_nb_node);
  490. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_MISC,
  491. quirk_amd_nb_node);
  492. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_10H_NB_LINK,
  493. quirk_amd_nb_node);
  494. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F0,
  495. quirk_amd_nb_node);
  496. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F1,
  497. quirk_amd_nb_node);
  498. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F2,
  499. quirk_amd_nb_node);
  500. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F3,
  501. quirk_amd_nb_node);
  502. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F4,
  503. quirk_amd_nb_node);
  504. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_15H_NB_F5,
  505. quirk_amd_nb_node);
  506. #endif
  507. #ifdef CONFIG_PCI
  508. /*
  509. * Processor does not ensure DRAM scrub read/write sequence
  510. * is atomic wrt accesses to CC6 save state area. Therefore
  511. * if a concurrent scrub read/write access is to same address
  512. * the entry may appear as if it is not written. This quirk
  513. * applies to Fam16h models 00h-0Fh
  514. *
  515. * See "Revision Guide" for AMD F16h models 00h-0fh,
  516. * document 51810 rev. 3.04, Nov 2013
  517. */
  518. static void amd_disable_seq_and_redirect_scrub(struct pci_dev *dev)
  519. {
  520. u32 val;
  521. /*
  522. * Suggested workaround:
  523. * set D18F3x58[4:0] = 00h and set D18F3x5C[0] = 0b
  524. */
  525. pci_read_config_dword(dev, 0x58, &val);
  526. if (val & 0x1F) {
  527. val &= ~(0x1F);
  528. pci_write_config_dword(dev, 0x58, val);
  529. }
  530. pci_read_config_dword(dev, 0x5C, &val);
  531. if (val & BIT(0)) {
  532. val &= ~BIT(0);
  533. pci_write_config_dword(dev, 0x5c, val);
  534. }
  535. }
  536. DECLARE_PCI_FIXUP_FINAL(PCI_VENDOR_ID_AMD, PCI_DEVICE_ID_AMD_16H_NB_F3,
  537. amd_disable_seq_and_redirect_scrub);
  538. #endif