summaryrefslogtreecommitdiff
path: root/arch/powerpc/kernel
diff options
context:
space:
mode:
authorOliver O'Halloran <oohall@gmail.com>2017-06-29 17:12:53 +1000
committerMichael Ellerman <mpe@ellerman.id.au>2017-08-31 14:26:50 +1000
commite3d8b67e2c60dcd35661d34df249f20d20463f0c (patch)
tree86fe1701ebde845efae026d512b4a9abba944b0b /arch/powerpc/kernel
parent197267d0356004a31c4d6b6336598f5dff3301e1 (diff)
powerpc/smp: Use cpu_to_chip_id() to find core siblings
When building the CPU scheduler topology the kernel uses the ibm,chipid property from the devicetree to group logical CPUs. Currently the DT search for this property is open-coded in smp.c and this functionality is a duplication of what's in cpu_to_chip_id() already. This patch removes the existing search in favor of that. It's worth mentioning that the semantics of the search are different in cpu_to_chip_id(). When there is no ibm,chipid in the CPUs node it will also search /cpus and / for the property, but this should not effect the output topology. Signed-off-by: Oliver O'Halloran <oohall@gmail.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Diffstat (limited to 'arch/powerpc/kernel')
-rw-r--r--arch/powerpc/kernel/smp.c37
1 files changed, 11 insertions, 26 deletions
diff --git a/arch/powerpc/kernel/smp.c b/arch/powerpc/kernel/smp.c
index 8d3320562c70..bf31f0874949 100644
--- a/arch/powerpc/kernel/smp.c
+++ b/arch/powerpc/kernel/smp.c
@@ -830,19 +830,11 @@ EXPORT_SYMBOL_GPL(cpu_first_thread_of_core);
static void traverse_siblings_chip_id(int cpu, bool add, int chipid)
{
- const struct cpumask *mask;
- struct device_node *np;
- int i, plen;
- const __be32 *prop;
+ const struct cpumask *mask = add ? cpu_online_mask : cpu_present_mask;
+ int i;
- mask = add ? cpu_online_mask : cpu_present_mask;
for_each_cpu(i, mask) {
- np = of_get_cpu_node(i, NULL);
- if (!np)
- continue;
- prop = of_get_property(np, "ibm,chip-id", &plen);
- if (prop && plen == sizeof(int) &&
- of_read_number(prop, 1) == chipid) {
+ if (cpu_to_chip_id(i) == chipid) {
if (add) {
cpumask_set_cpu(cpu, cpu_core_mask(i));
cpumask_set_cpu(i, cpu_core_mask(cpu));
@@ -851,7 +843,6 @@ static void traverse_siblings_chip_id(int cpu, bool add, int chipid)
cpumask_clear_cpu(i, cpu_core_mask(cpu));
}
}
- of_node_put(np);
}
}
@@ -881,21 +872,15 @@ static void traverse_core_siblings(int cpu, bool add)
{
struct device_node *l2_cache, *np;
const struct cpumask *mask;
- int i, chip, plen;
- const __be32 *prop;
+ int chip_id;
+ int i;
- /* First see if we have ibm,chip-id properties in cpu nodes */
- np = of_get_cpu_node(cpu, NULL);
- if (np) {
- chip = -1;
- prop = of_get_property(np, "ibm,chip-id", &plen);
- if (prop && plen == sizeof(int))
- chip = of_read_number(prop, 1);
- of_node_put(np);
- if (chip >= 0) {
- traverse_siblings_chip_id(cpu, add, chip);
- return;
- }
+ /* threads that share a chip-id are considered siblings */
+ chip_id = cpu_to_chip_id(cpu);
+
+ if (chip_id >= 0) {
+ traverse_siblings_chip_id(cpu, add, chip_id);
+ return;
}
l2_cache = cpu_to_l2cache(cpu);