aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathan Lynch <ntl@pobox.com>2008-07-27 01:24:54 -0400
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>2008-07-28 02:30:52 -0400
commite9efed3b80a83e44b98fc626f3268ae072550b84 (patch)
treecbe7cc897dc112e2eb93f9bbded5aa3a8e6e0bf3
parent440a0857e32a05979fb01fc59ea454a723e80e4b (diff)
powerpc: Make core id information available to userspace
Existing Open Firmware practice is to report each processor core as a separate node in the device tree. Report the value of the "reg" OF property corresponding to a logical CPU's device node as the core_id attribute in /sys/devices/system/cpu/cpu*/topology/core_id. Signed-off-by: Nathan Lynch <ntl@pobox.com> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r--arch/powerpc/kernel/smp.c23
-rw-r--r--include/asm-powerpc/smp.h1
-rw-r--r--include/asm-powerpc/topology.h1
3 files changed, 25 insertions, 0 deletions
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index f7a2f81b5b7d..5337ca7bb649 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -380,6 +380,29 @@ int __cpuinit __cpu_up(unsigned int cpu)
380 return 0; 380 return 0;
381} 381}
382 382
383/* Return the value of the reg property corresponding to the given
384 * logical cpu.
385 */
386int cpu_to_core_id(int cpu)
387{
388 struct device_node *np;
389 const int *reg;
390 int id = -1;
391
392 np = of_get_cpu_node(cpu, NULL);
393 if (!np)
394 goto out;
395
396 reg = of_get_property(np, "reg", NULL);
397 if (!reg)
398 goto out;
399
400 id = *reg;
401out:
402 of_node_put(np);
403 return id;
404}
405
383/* Must be called when no change can occur to cpu_present_map, 406/* Must be called when no change can occur to cpu_present_map,
384 * i.e. during cpu online or offline. 407 * i.e. during cpu online or offline.
385 */ 408 */
diff --git a/include/asm-powerpc/smp.h b/include/asm-powerpc/smp.h
index 32e910006250..4d28e1e4521b 100644
--- a/include/asm-powerpc/smp.h
+++ b/include/asm-powerpc/smp.h
@@ -63,6 +63,7 @@ extern int smp_hw_index[];
63 63
64DECLARE_PER_CPU(cpumask_t, cpu_sibling_map); 64DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
65DECLARE_PER_CPU(cpumask_t, cpu_core_map); 65DECLARE_PER_CPU(cpumask_t, cpu_core_map);
66extern int cpu_to_core_id(int cpu);
66 67
67/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers. 68/* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
68 * 69 *
diff --git a/include/asm-powerpc/topology.h b/include/asm-powerpc/topology.h
index f00e8e551738..c32da6f97999 100644
--- a/include/asm-powerpc/topology.h
+++ b/include/asm-powerpc/topology.h
@@ -109,6 +109,7 @@ static inline void sysfs_remove_device_from_node(struct sys_device *dev,
109 109
110#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu)) 110#define topology_thread_siblings(cpu) (per_cpu(cpu_sibling_map, cpu))
111#define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu)) 111#define topology_core_siblings(cpu) (per_cpu(cpu_core_map, cpu))
112#define topology_core_id(cpu) (cpu_to_core_id(cpu))
112#endif 113#endif
113#endif 114#endif
114 115