]> pilppa.com Git - linux-2.6-omap-h63xx.git/commitdiff
powerpc: Make core id information available to userspace
authorNathan Lynch <ntl@pobox.com>
Sun, 27 Jul 2008 05:24:54 +0000 (15:24 +1000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Mon, 28 Jul 2008 06:30:52 +0000 (16:30 +1000)
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>
arch/powerpc/kernel/smp.c
include/asm-powerpc/smp.h
include/asm-powerpc/topology.h

index f7a2f81b5b7da784ce6eccfa01cc45a7f9f9e2f7..5337ca7bb649b02999258143947751109fe6c585 100644 (file)
@@ -380,6 +380,29 @@ int __cpuinit __cpu_up(unsigned int cpu)
        return 0;
 }
 
+/* Return the value of the reg property corresponding to the given
+ * logical cpu.
+ */
+int cpu_to_core_id(int cpu)
+{
+       struct device_node *np;
+       const int *reg;
+       int id = -1;
+
+       np = of_get_cpu_node(cpu, NULL);
+       if (!np)
+               goto out;
+
+       reg = of_get_property(np, "reg", NULL);
+       if (!reg)
+               goto out;
+
+       id = *reg;
+out:
+       of_node_put(np);
+       return id;
+}
+
 /* Must be called when no change can occur to cpu_present_map,
  * i.e. during cpu online or offline.
  */
index 32e910006250c9e104772bfd27aee0cbaa2ac833..4d28e1e4521b8c39992d327a4d0699d8f0df4ba2 100644 (file)
@@ -63,6 +63,7 @@ extern int smp_hw_index[];
 
 DECLARE_PER_CPU(cpumask_t, cpu_sibling_map);
 DECLARE_PER_CPU(cpumask_t, cpu_core_map);
+extern int cpu_to_core_id(int cpu);
 
 /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers.
  *
index f00e8e551738390e5fd82c0c933c6df3759dde66..c32da6f9799957a1ce3439b8f9e269bd887621f2 100644 (file)
@@ -109,6 +109,7 @@ static inline void sysfs_remove_device_from_node(struct sys_device *dev,
 
 #define topology_thread_siblings(cpu)  (per_cpu(cpu_sibling_map, cpu))
 #define topology_core_siblings(cpu)    (per_cpu(cpu_core_map, cpu))
+#define topology_core_id(cpu)          (cpu_to_core_id(cpu))
 #endif
 #endif