aboutsummaryrefslogtreecommitdiffstats
path: root/arch/powerpc/mm/numa.c
diff options
context:
space:
mode:
authorJeremy Kerr <jk@ozlabs.org>2006-05-01 15:16:12 -0400
committerLinus Torvalds <torvalds@g5.osdl.org>2006-05-01 21:17:46 -0400
commit953039c8df7beb2694814e20e2707a77d335a2e3 (patch)
tree8e8d6af92441d70074efc24f55cf5965ae28447a /arch/powerpc/mm/numa.c
parentbed120c64eb07b6838bb758109811484af8cebba (diff)
[PATCH] powerpc: Allow devices to register with numa topology
Change of_node_to_nid() to traverse the device tree, looking for a numa id. Cell uses this to assign ids to SPUs, which are children of the CPU node. Existing users of of_node_to_nid() are altered to use of_node_to_nid_single(), which doesn't do the traversal. Export an attach_sysdev_to_node() function, allowing system devices (eg. SPUs) to link themselves into the numa topology in sysfs. Signed-off-by: Arnd Bergmann <arnd.bergmann@de.ibm.com> Cc: Paul Mackerras <paulus@samba.org> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/powerpc/mm/numa.c')
-rw-r--r--arch/powerpc/mm/numa.c32
1 files changed, 27 insertions, 5 deletions
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 */
197static int of_node_to_nid(struct device_node *device) 197static 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 */
220int 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}
239EXPORT_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)
776ha_new_range: 798ha_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))