Skip to content

Commit d46c24f

Browse files
ConchuODgregkh
authored andcommitted
arm64: topology: move store_cpu_topology() to shared code
commit 456797d upstream. arm64's method of defining a default cpu topology requires only minimal changes to apply to RISC-V also. The current arm64 implementation exits early in a uniprocessor configuration by reading MPIDR & claiming that uniprocessor can rely on the default values. This is appears to be a hangover from prior to '3102bc0e6ac7 ("arm64: topology: Stop using MPIDR for topology information")', because the current code just assigns default values for multiprocessor systems. With the MPIDR references removed, store_cpu_topolgy() can be moved to the common arch_topology code. Reviewed-by: Sudeep Holla <sudeep.holla@arm.com> Acked-by: Catalin Marinas <catalin.marinas@arm.com> Reviewed-by: Atish Patra <atishp@rivosinc.com> Signed-off-by: Conor Dooley <conor.dooley@microchip.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent fcf0f6c commit d46c24f

File tree

2 files changed

+19
-40
lines changed

2 files changed

+19
-40
lines changed

arch/arm64/kernel/topology.c

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -22,46 +22,6 @@
2222
#include <asm/cputype.h>
2323
#include <asm/topology.h>
2424

25-
void store_cpu_topology(unsigned int cpuid)
26-
{
27-
struct cpu_topology *cpuid_topo = &cpu_topology[cpuid];
28-
u64 mpidr;
29-
30-
if (cpuid_topo->package_id != -1)
31-
goto topology_populated;
32-
33-
mpidr = read_cpuid_mpidr();
34-
35-
/* Uniprocessor systems can rely on default topology values */
36-
if (mpidr & MPIDR_UP_BITMASK)
37-
return;
38-
39-
/*
40-
* This would be the place to create cpu topology based on MPIDR.
41-
*
42-
* However, it cannot be trusted to depict the actual topology; some
43-
* pieces of the architecture enforce an artificial cap on Aff0 values
44-
* (e.g. GICv3's ICC_SGI1R_EL1 limits it to 15), leading to an
45-
* artificial cycling of Aff1, Aff2 and Aff3 values. IOW, these end up
46-
* having absolutely no relationship to the actual underlying system
47-
* topology, and cannot be reasonably used as core / package ID.
48-
*
49-
* If the MT bit is set, Aff0 *could* be used to define a thread ID, but
50-
* we still wouldn't be able to obtain a sane core ID. This means we
51-
* need to entirely ignore MPIDR for any topology deduction.
52-
*/
53-
cpuid_topo->thread_id = -1;
54-
cpuid_topo->core_id = cpuid;
55-
cpuid_topo->package_id = cpu_to_node(cpuid);
56-
57-
pr_debug("CPU%u: cluster %d core %d thread %d mpidr %#016llx\n",
58-
cpuid, cpuid_topo->package_id, cpuid_topo->core_id,
59-
cpuid_topo->thread_id, mpidr);
60-
61-
topology_populated:
62-
update_siblings_masks(cpuid);
63-
}
64-
6525
#ifdef CONFIG_ACPI
6626
static bool __init acpi_cpu_is_threaded(int cpu)
6727
{

drivers/base/arch_topology.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,4 +690,23 @@ void __init init_cpu_topology(void)
690690
else if (of_have_populated_dt() && parse_dt_topology())
691691
reset_cpu_topology();
692692
}
693+
694+
void store_cpu_topology(unsigned int cpuid)
695+
{
696+
struct cpu_topology *cpuid_topo = &cpu_topology[cpuid];
697+
698+
if (cpuid_topo->package_id != -1)
699+
goto topology_populated;
700+
701+
cpuid_topo->thread_id = -1;
702+
cpuid_topo->core_id = cpuid;
703+
cpuid_topo->package_id = cpu_to_node(cpuid);
704+
705+
pr_debug("CPU%u: package %d core %d thread %d\n",
706+
cpuid, cpuid_topo->package_id, cpuid_topo->core_id,
707+
cpuid_topo->thread_id);
708+
709+
topology_populated:
710+
update_siblings_masks(cpuid);
711+
}
693712
#endif

0 commit comments

Comments
 (0)