srat.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. /*
  2. * ACPI 3.0 based NUMA setup
  3. * Copyright 2004 Andi Kleen, SuSE Labs.
  4. *
  5. * Reads the ACPI SRAT table to figure out what memory belongs to which CPUs.
  6. *
  7. * Called from acpi_numa_init while reading the SRAT and SLIT tables.
  8. * Assumes all memory regions belonging to a single proximity domain
  9. * are in one chunk. Holes between them will be included in the node.
  10. */
  11. #include <linux/kernel.h>
  12. #include <linux/acpi.h>
  13. #include <linux/mmzone.h>
  14. #include <linux/bitmap.h>
  15. #include <linux/init.h>
  16. #include <linux/topology.h>
  17. #include <linux/mm.h>
  18. #include <asm/proto.h>
  19. #include <asm/numa.h>
  20. #include <asm/e820.h>
  21. #include <asm/apic.h>
  22. #include <asm/uv/uv.h>
  23. /* Callback for Proximity Domain -> x2APIC mapping */
  24. void __init
  25. acpi_numa_x2apic_affinity_init(struct acpi_srat_x2apic_cpu_affinity *pa)
  26. {
  27. int pxm, node;
  28. int apic_id;
  29. if (srat_disabled())
  30. return;
  31. if (pa->header.length < sizeof(struct acpi_srat_x2apic_cpu_affinity)) {
  32. bad_srat();
  33. return;
  34. }
  35. if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
  36. return;
  37. pxm = pa->proximity_domain;
  38. apic_id = pa->apic_id;
  39. if (!apic->apic_id_valid(apic_id)) {
  40. printk(KERN_INFO "SRAT: PXM %u -> X2APIC 0x%04x ignored\n",
  41. pxm, apic_id);
  42. return;
  43. }
  44. node = acpi_map_pxm_to_node(pxm);
  45. if (node < 0) {
  46. printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
  47. bad_srat();
  48. return;
  49. }
  50. if (apic_id >= MAX_LOCAL_APIC) {
  51. printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
  52. return;
  53. }
  54. set_apicid_to_node(apic_id, node);
  55. node_set(node, numa_nodes_parsed);
  56. printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%04x -> Node %u\n",
  57. pxm, apic_id, node);
  58. }
  59. /* Callback for Proximity Domain -> LAPIC mapping */
  60. void __init
  61. acpi_numa_processor_affinity_init(struct acpi_srat_cpu_affinity *pa)
  62. {
  63. int pxm, node;
  64. int apic_id;
  65. if (srat_disabled())
  66. return;
  67. if (pa->header.length != sizeof(struct acpi_srat_cpu_affinity)) {
  68. bad_srat();
  69. return;
  70. }
  71. if ((pa->flags & ACPI_SRAT_CPU_ENABLED) == 0)
  72. return;
  73. pxm = pa->proximity_domain_lo;
  74. if (acpi_srat_revision >= 2)
  75. pxm |= *((unsigned int*)pa->proximity_domain_hi) << 8;
  76. node = acpi_map_pxm_to_node(pxm);
  77. if (node < 0) {
  78. printk(KERN_ERR "SRAT: Too many proximity domains %x\n", pxm);
  79. bad_srat();
  80. return;
  81. }
  82. if (get_uv_system_type() >= UV_X2APIC)
  83. apic_id = (pa->apic_id << 8) | pa->local_sapic_eid;
  84. else
  85. apic_id = pa->apic_id;
  86. if (apic_id >= MAX_LOCAL_APIC) {
  87. printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u skipped apicid that is too big\n", pxm, apic_id, node);
  88. return;
  89. }
  90. set_apicid_to_node(apic_id, node);
  91. node_set(node, numa_nodes_parsed);
  92. printk(KERN_INFO "SRAT: PXM %u -> APIC 0x%02x -> Node %u\n",
  93. pxm, apic_id, node);
  94. }
  95. int __init x86_acpi_numa_init(void)
  96. {
  97. int ret;
  98. ret = acpi_numa_init();
  99. if (ret < 0)
  100. return ret;
  101. return srat_disabled() ? -EINVAL : 0;
  102. }