@@ -44,6 +44,7 @@ extern bool numa_disabled(void);
extern void numa_set_distance(nodeid_t from, nodeid_t to,
unsigned int distance);
extern void numa_detect_cpu_node(unsigned int cpu);
+extern int numa_device_tree_init(const void *fdt);
#else
@@ -259,3 +259,33 @@ invalid_data:
numa_fw_bad();
return -EINVAL;
}
+
+static int __init fdt_scan_numa_nodes(const void *fdt, int node,
+ const char *uname, int depth,
+ unsigned int address_cells,
+ unsigned int size_cells, void *data)
+{
+ int len, ret = 0;
+ const void *prop;
+
+ prop = fdt_getprop(fdt, node, "device_type", &len);
+ if ( prop )
+ {
+ if ( strncmp(prop, "cpu", len) == 0 )
+ ret = fdt_parse_numa_cpu_node(fdt, node);
+ else if ( strncmp(prop, "memory", len) == 0 )
+ ret = fdt_parse_numa_memory_node(fdt, node, uname,
+ address_cells, size_cells);
+ }
+ else if ( fdt_node_check_compatible(fdt, node,
+ "numa-distance-map-v1") == 0 )
+ ret = fdt_parse_numa_distance_map_v1(fdt, node);
+
+ return ret;
+}
+
+/* Initialize NUMA from device tree */
+int __init numa_device_tree_init(const void *fdt)
+{
+ return device_tree_for_each_node(fdt, 0, fdt_scan_numa_nodes, NULL);
+}