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 <quic_prersing@quicinc.com>
This commit is contained in:
Prerna Singh 2023-03-28 16:25:59 +05:30 • committed by Gerrit - the friendly Code Review server
commit c62a901eab

View file

@ -17,6 +17,7 @@
#include <linux/pm_opp.h>
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/topology.h>
#define CREATE_TRACE_POINTS
#include <trace/events/dcvsh.h>
@ -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;
}