Commit fa35e868 authored by Srikar Dronamraju's avatar Srikar Dronamraju Committed by Michael Ellerman

powerpc/smp: Implement cpu_to_coregroup_id

Lookup the coregroup id from the associativity array.

If unable to detect the coregroup id, fallback on the core id.
This way, ensure sched_domain degenerates and an extra sched domain is
not created.

Ideally this function should have been implemented in
arch/powerpc/kernel/smp.c. However if its implemented in mm/numa.c, we
don't need to find the primary domain again.

If the device-tree mentions more than one coregroup, then kernel
implements only the last or the smallest coregroup, which currently
corresponds to the penultimate domain in the device-tree.
Signed-off-by: default avatarSrikar Dronamraju <srikar@linux.vnet.ibm.com>
Reviewed-by: default avatarGautham R. Shenoy <ego@linux.vnet.ibm.com>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20200810071834.92514-11-srikar@linux.vnet.ibm.com
parent 72730bfc
...@@ -1247,6 +1247,26 @@ int find_and_online_cpu_nid(int cpu) ...@@ -1247,6 +1247,26 @@ int find_and_online_cpu_nid(int cpu)
int cpu_to_coregroup_id(int cpu) int cpu_to_coregroup_id(int cpu)
{ {
__be32 associativity[VPHN_ASSOC_BUFSIZE] = {0};
int index;
if (cpu < 0 || cpu > nr_cpu_ids)
return -1;
if (!coregroup_enabled)
goto out;
if (!firmware_has_feature(FW_FEATURE_VPHN))
goto out;
if (vphn_get_associativity(cpu, associativity))
goto out;
index = of_read_number(associativity, 1);
if (index > min_common_depth + 1)
return of_read_number(&associativity[index - 1], 1);
out:
return cpu_to_core_id(cpu); return cpu_to_core_id(cpu);
} }
......
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