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: Taniya Das <quic_tdas@quicinc.com>
This commit is contained in:
Taniya Das 2023-01-16 16:58:42 +05:30 committed by Gerrit - the friendly Code Review server
parent 44f87a48ee
commit 2e2aba5773

View File

@ -19,6 +19,7 @@
#include <linux/sched.h>
#include <linux/slab.h>
#include <linux/qcom-cpufreq-hw.h>
#include <linux/topology.h>
#define CREATE_TRACE_POINTS
#include <trace/events/dcvsh.h>
@ -34,8 +35,8 @@
#define MAX_FN_SIZE 20
#define LIMITS_POLLING_DELAY_MS 4
#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,
@ -227,7 +228,7 @@ 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);
@ -245,6 +246,8 @@ 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;
}
EXPORT_SYMBOL_GPL(qcom_cpufreq_get_cpu_cycle_counter);