k8-bus.c 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #include <linux/init.h>
  2. #include <linux/pci.h>
  3. #include <asm/mpspec.h>
  4. #include <linux/cpumask.h>
  5. #include <asm/k8.h>
  6. /*
  7. * This discovers the pcibus <-> node mapping on AMD K8.
  8. *
  9. * RED-PEN need to call this again on PCI hotplug
  10. * RED-PEN empty cpus get reported wrong
  11. */
  12. #define NODE_ID_REGISTER 0x60
  13. #define NODE_ID(dword) (dword & 0x07)
  14. #define LDT_BUS_NUMBER_REGISTER_0 0x94
  15. #define LDT_BUS_NUMBER_REGISTER_1 0xB4
  16. #define LDT_BUS_NUMBER_REGISTER_2 0xD4
  17. #define NR_LDT_BUS_NUMBER_REGISTERS 3
  18. #define SECONDARY_LDT_BUS_NUMBER(dword) ((dword >> 8) & 0xFF)
  19. #define SUBORDINATE_LDT_BUS_NUMBER(dword) ((dword >> 16) & 0xFF)
  20. /**
  21. * fill_mp_bus_to_cpumask()
  22. * fills the mp_bus_to_cpumask array based according to the LDT Bus Number
  23. * Registers found in the K8 northbridge
  24. */
  25. __init static int
  26. fill_mp_bus_to_cpumask(void)
  27. {
  28. int i, j, k;
  29. u32 ldtbus, nid;
  30. static int lbnr[3] = {
  31. LDT_BUS_NUMBER_REGISTER_0,
  32. LDT_BUS_NUMBER_REGISTER_1,
  33. LDT_BUS_NUMBER_REGISTER_2
  34. };
  35. cache_k8_northbridges();
  36. for (k = 0; k < num_k8_northbridges; k++) {
  37. struct pci_dev *nb_dev = k8_northbridges[k];
  38. pci_read_config_dword(nb_dev, NODE_ID_REGISTER, &nid);
  39. for (i = 0; i < NR_LDT_BUS_NUMBER_REGISTERS; i++) {
  40. pci_read_config_dword(nb_dev, lbnr[i], &ldtbus);
  41. /*
  42. * if there are no busses hanging off of the current
  43. * ldt link then both the secondary and subordinate
  44. * bus number fields are set to 0.
  45. *
  46. * RED-PEN
  47. * This is slightly broken because it assumes
  48. * HT node IDs == Linux node ids, which is not always
  49. * true. However it is probably mostly true.
  50. */
  51. if (!(SECONDARY_LDT_BUS_NUMBER(ldtbus) == 0
  52. && SUBORDINATE_LDT_BUS_NUMBER(ldtbus) == 0)) {
  53. for (j = SECONDARY_LDT_BUS_NUMBER(ldtbus);
  54. j <= SUBORDINATE_LDT_BUS_NUMBER(ldtbus);
  55. j++) {
  56. struct pci_bus *bus;
  57. long node = NODE_ID(nid);
  58. /* Algorithm a bit dumb, but
  59. it shouldn't matter here */
  60. bus = pci_find_bus(0, j);
  61. if (!bus)
  62. continue;
  63. if (!node_online(node))
  64. node = 0;
  65. bus->sysdata = (void *)node;
  66. }
  67. }
  68. }
  69. }
  70. return 0;
  71. }
  72. fs_initcall(fill_mp_bus_to_cpumask);