aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/acpi/numa.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/acpi/numa.c')
-rw-r--r--drivers/acpi/numa.c64
1 files changed, 62 insertions, 2 deletions
diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c
index 64b98e82feb7..4d622981f61a 100644
--- a/drivers/acpi/numa.c
+++ b/drivers/acpi/numa.c
@@ -23,7 +23,6 @@
23 * 23 *
24 */ 24 */
25#include <linux/module.h> 25#include <linux/module.h>
26#include <linux/config.h>
27#include <linux/init.h> 26#include <linux/init.h>
28#include <linux/kernel.h> 27#include <linux/kernel.h>
29#include <linux/types.h> 28#include <linux/types.h>
@@ -36,12 +35,60 @@
36#define _COMPONENT ACPI_NUMA 35#define _COMPONENT ACPI_NUMA
37ACPI_MODULE_NAME("numa") 36ACPI_MODULE_NAME("numa")
38 37
38static nodemask_t nodes_found_map = NODE_MASK_NONE;
39#define PXM_INVAL -1
40#define NID_INVAL -1
41
42/* maps to convert between proximity domain and logical node ID */
43int __cpuinitdata pxm_to_node_map[MAX_PXM_DOMAINS]
44 = { [0 ... MAX_PXM_DOMAINS - 1] = NID_INVAL };
45int __cpuinitdata node_to_pxm_map[MAX_NUMNODES]
46 = { [0 ... MAX_NUMNODES - 1] = PXM_INVAL };
47
39extern int __init acpi_table_parse_madt_family(enum acpi_table_id id, 48extern int __init acpi_table_parse_madt_family(enum acpi_table_id id,
40 unsigned long madt_size, 49 unsigned long madt_size,
41 int entry_id, 50 int entry_id,
42 acpi_madt_entry_handler handler, 51 acpi_madt_entry_handler handler,
43 unsigned int max_entries); 52 unsigned int max_entries);
44 53
54int __cpuinit pxm_to_node(int pxm)
55{
56 if (pxm < 0)
57 return NID_INVAL;
58 return pxm_to_node_map[pxm];
59}
60
61int __cpuinit node_to_pxm(int node)
62{
63 if (node < 0)
64 return PXM_INVAL;
65 return node_to_pxm_map[node];
66}
67
68int __cpuinit acpi_map_pxm_to_node(int pxm)
69{
70 int node = pxm_to_node_map[pxm];
71
72 if (node < 0){
73 if (nodes_weight(nodes_found_map) >= MAX_NUMNODES)
74 return NID_INVAL;
75 node = first_unset_node(nodes_found_map);
76 pxm_to_node_map[pxm] = node;
77 node_to_pxm_map[node] = pxm;
78 node_set(node, nodes_found_map);
79 }
80
81 return node;
82}
83
84void __cpuinit acpi_unmap_pxm_to_node(int node)
85{
86 int pxm = node_to_pxm_map[node];
87 pxm_to_node_map[pxm] = NID_INVAL;
88 node_to_pxm_map[node] = PXM_INVAL;
89 node_clear(node, nodes_found_map);
90}
91
45void __init acpi_table_print_srat_entry(acpi_table_entry_header * header) 92void __init acpi_table_print_srat_entry(acpi_table_entry_header * header)
46{ 93{
47 94
@@ -206,5 +253,18 @@ int acpi_get_pxm(acpi_handle h)
206 } while (ACPI_SUCCESS(status)); 253 } while (ACPI_SUCCESS(status));
207 return -1; 254 return -1;
208} 255}
209
210EXPORT_SYMBOL(acpi_get_pxm); 256EXPORT_SYMBOL(acpi_get_pxm);
257
258int acpi_get_node(acpi_handle *handle)
259{
260 int pxm, node = -1;
261
262 ACPI_FUNCTION_TRACE("acpi_get_node");
263
264 pxm = acpi_get_pxm(handle);
265 if (pxm >= 0)
266 node = acpi_map_pxm_to_node(pxm);
267
268 return_VALUE(node);
269}
270EXPORT_SYMBOL(acpi_get_node);