Commit e3d8b67e authored by Oliver O'Halloran's avatar Oliver O'Halloran Committed by Michael Ellerman

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: default avatarOliver O'Halloran <oohall@gmail.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
parent 197267d0
...@@ -830,19 +830,11 @@ EXPORT_SYMBOL_GPL(cpu_first_thread_of_core); ...@@ -830,19 +830,11 @@ EXPORT_SYMBOL_GPL(cpu_first_thread_of_core);
static void traverse_siblings_chip_id(int cpu, bool add, int chipid) static void traverse_siblings_chip_id(int cpu, bool add, int chipid)
{ {
const struct cpumask *mask; const struct cpumask *mask = add ? cpu_online_mask : cpu_present_mask;
struct device_node *np; int i;
int i, plen;
const __be32 *prop;
mask = add ? cpu_online_mask : cpu_present_mask;
for_each_cpu(i, mask) { for_each_cpu(i, mask) {
np = of_get_cpu_node(i, NULL); if (cpu_to_chip_id(i) == chipid) {
if (!np)
continue;
prop = of_get_property(np, "ibm,chip-id", &plen);
if (prop && plen == sizeof(int) &&
of_read_number(prop, 1) == chipid) {
if (add) { if (add) {
cpumask_set_cpu(cpu, cpu_core_mask(i)); cpumask_set_cpu(cpu, cpu_core_mask(i));
cpumask_set_cpu(i, cpu_core_mask(cpu)); cpumask_set_cpu(i, cpu_core_mask(cpu));
...@@ -851,7 +843,6 @@ static void traverse_siblings_chip_id(int cpu, bool add, int chipid) ...@@ -851,7 +843,6 @@ static void traverse_siblings_chip_id(int cpu, bool add, int chipid)
cpumask_clear_cpu(i, cpu_core_mask(cpu)); cpumask_clear_cpu(i, cpu_core_mask(cpu));
} }
} }
of_node_put(np);
} }
} }
...@@ -881,22 +872,16 @@ static void traverse_core_siblings(int cpu, bool add) ...@@ -881,22 +872,16 @@ static void traverse_core_siblings(int cpu, bool add)
{ {
struct device_node *l2_cache, *np; struct device_node *l2_cache, *np;
const struct cpumask *mask; const struct cpumask *mask;
int i, chip, plen; int chip_id;
const __be32 *prop; int i;
/* First see if we have ibm,chip-id properties in cpu nodes */ /* threads that share a chip-id are considered siblings */
np = of_get_cpu_node(cpu, NULL); chip_id = cpu_to_chip_id(cpu);
if (np) {
chip = -1; if (chip_id >= 0) {
prop = of_get_property(np, "ibm,chip-id", &plen); traverse_siblings_chip_id(cpu, add, chip_id);
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; return;
} }
}
l2_cache = cpu_to_l2cache(cpu); l2_cache = cpu_to_l2cache(cpu);
mask = add ? cpu_online_mask : cpu_present_mask; mask = add ? cpu_online_mask : cpu_present_mask;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment