target/arm/arm-powerctl: Restrict to ARM cores
RFC PATCH 1/1 target/arm/arm-powerctl: Restrict to ARM cores
When running on a heterogeneous setup, the CPU_FOREACH() macro in arm_get_cpu_by_id() iterates on all vCPUs, regardless they are ARM or not. Check the CPU class type and skip the non-ARM instances.
--- target/arm/arm-powerctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
target/arm/arm-powerctl.c +4 -2
@@ -36,9 +36,11 @@ CPUState *arm_get_cpu_by_id(uint64_t id)DPRINTF ("cpu %" PRId64"\n" , id);CPU_FOREACH (cpu) { -ARMCPU *armcpu =ARM_CPU (cpu); +if (!object_class_dynamic_cast ((ObjectClass *)cpu->cc,TYPE_ARM_CPU )) { +continue ; + } -if (arm_cpu_mp_affinity (armcpu) == id) { +if (arm_cpu_mp_affinity ((ARMCPU *)cpu) == id) {return cpu; } }
Signature · 1 line
2.47.1
Quoted 7 lines · Philippe Mathieu-Daudé
When running on a heterogeneous setup, the
CPU_FOREACH()macro inarm_get_cpu_by_id()iterates on all vCPUs, regardless they are ARM or not. Check the CPU class type and skip the non-ARM instances.Signed-off-by Philippe Mathieu-Daudé <[email protected]>---
Quoted 21 lines
target/arm/arm-powerctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)target/arm/arm-powerctl.c +4
-2@@ -36,9 +36,11 @@ CPUState *arm_get_cpu_by_id(uint64_t id)DPRINTF ("cpu %" PRId64"\n" , id);CPU_FOREACH (cpu) { -ARMCPU *armcpu =ARM_CPU (cpu); +if (!object_class_dynamic_cast ((ObjectClass *)cpu->cc,TYPE_ARM_CPU )) { +continue ; + } -if (arm_cpu_mp_affinity (armcpu) == id) { +if (arm_cpu_mp_affinity ((ARMCPU *)cpu) == id) {return cpu; } }
Quoted 20 lines · Philippe Mathieu-Daudé
When running on a heterogeneous setup, the
CPU_FOREACH()macro inarm_get_cpu_by_id()iterates on all vCPUs, regardless they are ARM or not. Check the CPU class type and skip the non-ARM instances.Signed-off-by Philippe Mathieu-Daudé <[email protected]>--- target/arm/arm-powerctl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)target/arm/arm-powerctl.c +0
-1@@ -36,9 +36,11 @@ CPUState *arm_get_cpu_by_id(uint64_t id)DPRINTF ("cpu %" PRId64"\n" , id);CPU_FOREACH (cpu) { -ARMCPU *armcpu =ARM_CPU (cpu);
target/arm/arm-powerctl.c CPUState *arm_get_cpu_by_id(uint64_t id)
Quoted 10 lines
target/arm/arm-powerctl.c +4
-2+if (!object_class_dynamic_cast ((ObjectClass *)cpu->cc,TYPE_ARM_CPU )) { +continue ; + } -if (arm_cpu_mp_affinity (armcpu) == id) { +if (arm_cpu_mp_affinity ((ARMCPU *)cpu) == id) {return cpu; } } --
Makes sense -- the function is "get me a CPU with this MPIDR", so in a heterogenous system we can happily scan all the Arm CPUs (even if they're in some other SoC) and trust that the caller passed us a MPIDR that makes sense. (The callsites might need some work if we wanted to use those SoC models in a heterogenous setup where they're not the only SoC -- eg the imx6_src devices assume the CPUs in the SoC are numbered 0,1,2,3 -- but we don't need to do that now.)
thanks
-- PMM