diff options
-rw-r--r-- | arch/powerpc/kernel/sysfs.c | 18 | ||||
-rw-r--r-- | arch/powerpc/mm/numa.c | 32 | ||||
-rw-r--r-- | include/asm-powerpc/topology.h | 24 |
3 files changed, 69 insertions, 5 deletions
diff --git a/arch/powerpc/kernel/sysfs.c b/arch/powerpc/kernel/sysfs.c index ed737cacf92d..5bc2585c8036 100644 --- a/arch/powerpc/kernel/sysfs.c +++ b/arch/powerpc/kernel/sysfs.c | |||
@@ -322,13 +322,31 @@ static void register_nodes(void) | |||
322 | } | 322 | } |
323 | } | 323 | } |
324 | } | 324 | } |
325 | |||
326 | int sysfs_add_device_to_node(struct sys_device *dev, int nid) | ||
327 | { | ||
328 | struct node *node = &node_devices[nid]; | ||
329 | return sysfs_create_link(&node->sysdev.kobj, &dev->kobj, | ||
330 | kobject_name(&dev->kobj)); | ||
331 | } | ||
332 | |||
333 | void sysfs_remove_device_from_node(struct sys_device *dev, int nid) | ||
334 | { | ||
335 | struct node *node = &node_devices[nid]; | ||
336 | sysfs_remove_link(&node->sysdev.kobj, kobject_name(&dev->kobj)); | ||
337 | } | ||
338 | |||
325 | #else | 339 | #else |
326 | static void register_nodes(void) | 340 | static void register_nodes(void) |
327 | { | 341 | { |
328 | return; | 342 | return; |
329 | } | 343 | } |
344 | |||
330 | #endif | 345 | #endif |
331 | 346 | ||
347 | EXPORT_SYMBOL_GPL(sysfs_add_device_to_node); | ||
348 | EXPORT_SYMBOL_GPL(sysfs_remove_device_from_node); | ||
349 | |||
332 | /* Only valid if CPU is present. */ | 350 | /* Only valid if CPU is present. */ |
333 | static ssize_t show_physical_id(struct sys_device *dev, char *buf) | 351 | static ssize_t show_physical_id(struct sys_device *dev, char *buf) |
334 | { | 352 | { |
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 0a335f34974c..092355f37399 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
@@ -194,7 +194,7 @@ static int *of_get_associativity(struct device_node *dev) | |||
194 | /* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa | 194 | /* Returns nid in the range [0..MAX_NUMNODES-1], or -1 if no useful numa |
195 | * info is found. | 195 | * info is found. |
196 | */ | 196 | */ |
197 | static int of_node_to_nid(struct device_node *device) | 197 | static int of_node_to_nid_single(struct device_node *device) |
198 | { | 198 | { |
199 | int nid = -1; | 199 | int nid = -1; |
200 | unsigned int *tmp; | 200 | unsigned int *tmp; |
@@ -216,6 +216,28 @@ out: | |||
216 | return nid; | 216 | return nid; |
217 | } | 217 | } |
218 | 218 | ||
219 | /* Walk the device tree upwards, looking for an associativity id */ | ||
220 | int of_node_to_nid(struct device_node *device) | ||
221 | { | ||
222 | struct device_node *tmp; | ||
223 | int nid = -1; | ||
224 | |||
225 | of_node_get(device); | ||
226 | while (device) { | ||
227 | nid = of_node_to_nid_single(device); | ||
228 | if (nid != -1) | ||
229 | break; | ||
230 | |||
231 | tmp = device; | ||
232 | device = of_get_parent(tmp); | ||
233 | of_node_put(tmp); | ||
234 | } | ||
235 | of_node_put(device); | ||
236 | |||
237 | return nid; | ||
238 | } | ||
239 | EXPORT_SYMBOL_GPL(of_node_to_nid); | ||
240 | |||
219 | /* | 241 | /* |
220 | * In theory, the "ibm,associativity" property may contain multiple | 242 | * In theory, the "ibm,associativity" property may contain multiple |
221 | * associativity lists because a resource may be multiply connected | 243 | * associativity lists because a resource may be multiply connected |
@@ -300,7 +322,7 @@ static int __cpuinit numa_setup_cpu(unsigned long lcpu) | |||
300 | goto out; | 322 | goto out; |
301 | } | 323 | } |
302 | 324 | ||
303 | nid = of_node_to_nid(cpu); | 325 | nid = of_node_to_nid_single(cpu); |
304 | 326 | ||
305 | if (nid < 0 || !node_online(nid)) | 327 | if (nid < 0 || !node_online(nid)) |
306 | nid = any_online_node(NODE_MASK_ALL); | 328 | nid = any_online_node(NODE_MASK_ALL); |
@@ -393,7 +415,7 @@ static int __init parse_numa_properties(void) | |||
393 | 415 | ||
394 | cpu = find_cpu_node(i); | 416 | cpu = find_cpu_node(i); |
395 | BUG_ON(!cpu); | 417 | BUG_ON(!cpu); |
396 | nid = of_node_to_nid(cpu); | 418 | nid = of_node_to_nid_single(cpu); |
397 | of_node_put(cpu); | 419 | of_node_put(cpu); |
398 | 420 | ||
399 | /* | 421 | /* |
@@ -437,7 +459,7 @@ new_range: | |||
437 | * have associativity properties. If none, then | 459 | * have associativity properties. If none, then |
438 | * everything goes to default_nid. | 460 | * everything goes to default_nid. |
439 | */ | 461 | */ |
440 | nid = of_node_to_nid(memory); | 462 | nid = of_node_to_nid_single(memory); |
441 | if (nid < 0) | 463 | if (nid < 0) |
442 | nid = default_nid; | 464 | nid = default_nid; |
443 | node_set_online(nid); | 465 | node_set_online(nid); |
@@ -776,7 +798,7 @@ int hot_add_scn_to_nid(unsigned long scn_addr) | |||
776 | ha_new_range: | 798 | ha_new_range: |
777 | start = read_n_cells(n_mem_addr_cells, &memcell_buf); | 799 | start = read_n_cells(n_mem_addr_cells, &memcell_buf); |
778 | size = read_n_cells(n_mem_size_cells, &memcell_buf); | 800 | size = read_n_cells(n_mem_size_cells, &memcell_buf); |
779 | nid = of_node_to_nid(memory); | 801 | nid = of_node_to_nid_single(memory); |
780 | 802 | ||
781 | /* Domains not present at boot default to 0 */ | 803 | /* Domains not present at boot default to 0 */ |
782 | if (nid < 0 || !node_online(nid)) | 804 | if (nid < 0 || !node_online(nid)) |
diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h index 1e19cd00af25..87362a05542b 100644 --- a/include/asm-powerpc/topology.h +++ b/include/asm-powerpc/topology.h | |||
@@ -4,6 +4,9 @@ | |||
4 | 4 | ||
5 | #include <linux/config.h> | 5 | #include <linux/config.h> |
6 | 6 | ||
7 | struct sys_device; | ||
8 | struct device_node; | ||
9 | |||
7 | #ifdef CONFIG_NUMA | 10 | #ifdef CONFIG_NUMA |
8 | 11 | ||
9 | #include <asm/mmzone.h> | 12 | #include <asm/mmzone.h> |
@@ -27,6 +30,8 @@ static inline int node_to_first_cpu(int node) | |||
27 | return first_cpu(tmp); | 30 | return first_cpu(tmp); |
28 | } | 31 | } |
29 | 32 | ||
33 | int of_node_to_nid(struct device_node *device); | ||
34 | |||
30 | #define pcibus_to_node(node) (-1) | 35 | #define pcibus_to_node(node) (-1) |
31 | #define pcibus_to_cpumask(bus) (cpu_online_map) | 36 | #define pcibus_to_cpumask(bus) (cpu_online_map) |
32 | 37 | ||
@@ -57,10 +62,29 @@ static inline int node_to_first_cpu(int node) | |||
57 | 62 | ||
58 | extern void __init dump_numa_cpu_topology(void); | 63 | extern void __init dump_numa_cpu_topology(void); |
59 | 64 | ||
65 | extern int sysfs_add_device_to_node(struct sys_device *dev, int nid); | ||
66 | extern void sysfs_remove_device_from_node(struct sys_device *dev, int nid); | ||
67 | |||
60 | #else | 68 | #else |
61 | 69 | ||
70 | static inline int of_node_to_nid(struct device_node *device) | ||
71 | { | ||
72 | return 0; | ||
73 | } | ||
74 | |||
62 | static inline void dump_numa_cpu_topology(void) {} | 75 | static inline void dump_numa_cpu_topology(void) {} |
63 | 76 | ||
77 | static inline int sysfs_add_device_to_node(struct sys_device *dev, int nid) | ||
78 | { | ||
79 | return 0; | ||
80 | } | ||
81 | |||
82 | static inline void sysfs_remove_device_from_node(struct sys_device *dev, | ||
83 | int nid) | ||
84 | { | ||
85 | } | ||
86 | |||
87 | |||
64 | #include <asm-generic/topology.h> | 88 | #include <asm-generic/topology.h> |
65 | 89 | ||
66 | #endif /* CONFIG_NUMA */ | 90 | #endif /* CONFIG_NUMA */ |