From c62a901eab7ea94b81f89bf12a18d68a8b70bdbd Mon Sep 17 00:00:00 2001 From: Prerna Singh Date: Tue, 28 Mar 2023 16:25:59 +0530 Subject: [PATCH] qcom: cpufreq-hw: Use the topology coreid for offset Use the topology_core_id() API to calculate the offset of the CPU cores. This will help to correctly calculate the offset in case of CPU with fused cores. Change-Id: I78992edc3a646b8062e8bdd80f4c72e8c97387ec Signed-off-by: Prerna Singh --- drivers/cpufreq/qcom-cpufreq-hw.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/drivers/cpufreq/qcom-cpufreq-hw.c b/drivers/cpufreq/qcom-cpufreq-hw.c index 98f9456f8697..14c0c0401176 100644 --- a/drivers/cpufreq/qcom-cpufreq-hw.c +++ b/drivers/cpufreq/qcom-cpufreq-hw.c @@ -17,6 +17,7 @@ #include #include #include +#include #define CREATE_TRACE_POINTS #include @@ -33,8 +34,8 @@ #define LIMITS_POLLING_DELAY_MS 10 #define MAX_ROW 2 -#define CYCLE_CNTR_OFFSET(c, m, acc_count) \ - (acc_count ? ((c - cpumask_first(m) + 1) * 4) : 0) +#define CYCLE_CNTR_OFFSET(core_id, m, acc_count) \ + (acc_count ? ((core_id + 1) * 4) : 0) enum { REG_ENABLE, @@ -214,7 +215,7 @@ static u64 qcom_cpufreq_get_cpu_cycle_counter(int cpu) cpu_counter = &qcom_cpufreq_counter[cpu]; spin_lock_irqsave(&cpu_counter->lock, flags); - offset = CYCLE_CNTR_OFFSET(cpu, policy->related_cpus, + offset = CYCLE_CNTR_OFFSET(topology_core_id(cpu), policy->related_cpus, accumulative_counter); val = readl_relaxed_no_log(policy->driver_data + offsets[REG_CYCLE_CNTR] + offset); @@ -232,6 +233,8 @@ static u64 qcom_cpufreq_get_cpu_cycle_counter(int cpu) cycle_counter_ret = cpu_counter->total_cycle_counter; spin_unlock_irqrestore(&cpu_counter->lock, flags); + pr_debug("CPU %u, core-id 0x%x, offset %u\n", cpu, topology_core_id(cpu), offset); + return cycle_counter_ret; }