diff options
author | David Miller <davem@davemloft.net> | 2013-10-03 17:24:51 -0400 |
---|---|---|
committer | Grant Likely <grant.likely@linaro.org> | 2013-10-15 15:09:10 -0400 |
commit | d1cb9d1af0bc11b7450a6032f43935c746609418 (patch) | |
tree | 061b56dbd9e656730262445b373bacd399c0678e /arch | |
parent | 444c91e5720cb5b825356e32c67c2c5184d1c09a (diff) |
of: Make cpu node handling more portable.
Use for_each_node_by_type() to iterate all cpu nodes in the
system.
Provide and overridable function arch_find_n_match_cpu_physical_id,
which sees if the given device node matches 'cpu' and if so sets
'*thread' when non-NULL to the cpu thread number within the core.
The default implementation behaves the same as the existing code.
Add a sparc64 implementation.
Signed-off-by: David S. Miller <davem@davemloft.net>
Tested-by: Sudeep KarkadaNagesha <Sudeep.KarkadaNagesha@arm.com>
Signed-off-by: Grant Likely <grant.likely@linaro.org>
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc/kernel/prom_64.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/arch/sparc/kernel/prom_64.c b/arch/sparc/kernel/prom_64.c index d397d7fc5c28..6b39125eb927 100644 --- a/arch/sparc/kernel/prom_64.c +++ b/arch/sparc/kernel/prom_64.c | |||
@@ -373,6 +373,59 @@ static const char *get_mid_prop(void) | |||
373 | return (tlb_type == spitfire ? "upa-portid" : "portid"); | 373 | return (tlb_type == spitfire ? "upa-portid" : "portid"); |
374 | } | 374 | } |
375 | 375 | ||
376 | bool arch_find_n_match_cpu_physical_id(struct device_node *cpun, | ||
377 | int cpu, unsigned int *thread) | ||
378 | { | ||
379 | const char *mid_prop = get_mid_prop(); | ||
380 | int this_cpu_id; | ||
381 | |||
382 | /* On hypervisor based platforms we interrogate the 'reg' | ||
383 | * property. On everything else we look for a 'upa-portis', | ||
384 | * 'portid', or 'cpuid' property. | ||
385 | */ | ||
386 | |||
387 | if (tlb_type == hypervisor) { | ||
388 | struct property *prop = of_find_property(cpun, "reg", NULL); | ||
389 | u32 *regs; | ||
390 | |||
391 | if (!prop) { | ||
392 | pr_warn("CPU node missing reg property\n"); | ||
393 | return false; | ||
394 | } | ||
395 | regs = prop->value; | ||
396 | this_cpu_id = regs[0] & 0x0fffffff; | ||
397 | } else { | ||
398 | this_cpu_id = of_getintprop_default(cpun, mid_prop, -1); | ||
399 | |||
400 | if (this_cpu_id < 0) { | ||
401 | mid_prop = "cpuid"; | ||
402 | this_cpu_id = of_getintprop_default(cpun, mid_prop, -1); | ||
403 | } | ||
404 | if (this_cpu_id < 0) { | ||
405 | pr_warn("CPU node missing cpu ID property\n"); | ||
406 | return false; | ||
407 | } | ||
408 | } | ||
409 | if (this_cpu_id == cpu) { | ||
410 | if (thread) { | ||
411 | int proc_id = cpu_data(cpu).proc_id; | ||
412 | |||
413 | /* On sparc64, the cpu thread information is obtained | ||
414 | * either from OBP or the machine description. We've | ||
415 | * actually probed this information already long before | ||
416 | * this interface gets called so instead of interrogating | ||
417 | * both the OF node and the MDESC again, just use what | ||
418 | * we discovered already. | ||
419 | */ | ||
420 | if (proc_id < 0) | ||
421 | proc_id = 0; | ||
422 | *thread = proc_id; | ||
423 | } | ||
424 | return true; | ||
425 | } | ||
426 | return false; | ||
427 | } | ||
428 | |||
376 | static void *of_iterate_over_cpus(void *(*func)(struct device_node *, int, int), int arg) | 429 | static void *of_iterate_over_cpus(void *(*func)(struct device_node *, int, int), int arg) |
377 | { | 430 | { |
378 | struct device_node *dp; | 431 | struct device_node *dp; |