diff options
author | Vasant Hegde <hegdevasant@linux.vnet.ibm.com> | 2013-08-12 08:05:57 -0400 |
---|---|---|
committer | Benjamin Herrenschmidt <benh@kernel.crashing.org> | 2013-08-14 01:33:17 -0400 |
commit | 15863ff3b8dae4cacd831ce10aa34992e9ababb0 (patch) | |
tree | b061c136ecd6204ce9084f4e4d4232b5404e8b39 | |
parent | 202127031a14f244c15ae4434993d36bd10a439c (diff) |
powerpc: Make chip-id information available to userspace
So far "/sys/devices/system/cpu/cpuX/topology/physical_package_id"
was always default (-1) on ppc64 architecture.
Now, some systems have an ibm,chip-id property in the cpu nodes in
the device tree. On these systems, we now use this information to
display physical_package_id.
Signed-off-by: Vasant Hegde <hegdevasant@linux.vnet.ibm.com>
Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
-rw-r--r-- | arch/powerpc/include/asm/smp.h | 1 | ||||
-rw-r--r-- | arch/powerpc/include/asm/topology.h | 1 | ||||
-rw-r--r-- | arch/powerpc/kernel/smp.c | 15 |
3 files changed, 17 insertions, 0 deletions
diff --git a/arch/powerpc/include/asm/smp.h b/arch/powerpc/include/asm/smp.h index 9a5e71b0aea4..98da78e0c2c0 100644 --- a/arch/powerpc/include/asm/smp.h +++ b/arch/powerpc/include/asm/smp.h | |||
@@ -112,6 +112,7 @@ static inline struct cpumask *cpu_core_mask(int cpu) | |||
112 | } | 112 | } |
113 | 113 | ||
114 | extern int cpu_to_core_id(int cpu); | 114 | extern int cpu_to_core_id(int cpu); |
115 | extern int cpu_to_chip_id(int cpu); | ||
115 | 116 | ||
116 | /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers. | 117 | /* Since OpenPIC has only 4 IPIs, we use slightly different message numbers. |
117 | * | 118 | * |
diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h index 161ab662843b..89e3ef2496ac 100644 --- a/arch/powerpc/include/asm/topology.h +++ b/arch/powerpc/include/asm/topology.h | |||
@@ -96,6 +96,7 @@ static inline int prrn_is_enabled(void) | |||
96 | #ifdef CONFIG_PPC64 | 96 | #ifdef CONFIG_PPC64 |
97 | #include <asm/smp.h> | 97 | #include <asm/smp.h> |
98 | 98 | ||
99 | #define topology_physical_package_id(cpu) (cpu_to_chip_id(cpu)) | ||
99 | #define topology_thread_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu)) | 100 | #define topology_thread_cpumask(cpu) (per_cpu(cpu_sibling_map, cpu)) |
100 | #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu)) | 101 | #define topology_core_cpumask(cpu) (per_cpu(cpu_core_map, cpu)) |
101 | #define topology_core_id(cpu) (cpu_to_core_id(cpu)) | 102 | #define topology_core_id(cpu) (cpu_to_core_id(cpu)) |
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c index 009900dd8f25..d9d8bb0f4454 100644 --- a/arch/powerpc/kernel/smp.c +++ b/arch/powerpc/kernel/smp.c | |||
@@ -596,6 +596,21 @@ out: | |||
596 | return id; | 596 | return id; |
597 | } | 597 | } |
598 | 598 | ||
599 | /* Return the value of the chip-id property corresponding | ||
600 | * to the given logical cpu. | ||
601 | */ | ||
602 | int cpu_to_chip_id(int cpu) | ||
603 | { | ||
604 | struct device_node *np; | ||
605 | |||
606 | np = of_get_cpu_node(cpu, NULL); | ||
607 | if (!np) | ||
608 | return -1; | ||
609 | |||
610 | of_node_put(np); | ||
611 | return of_get_ibm_chip_id(np); | ||
612 | } | ||
613 | |||
599 | /* Helper routines for cpu to core mapping */ | 614 | /* Helper routines for cpu to core mapping */ |
600 | int cpu_core_index_of_thread(int cpu) | 615 | int cpu_core_index_of_thread(int cpu) |
601 | { | 616 | { |