Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c62a901e authored by Prerna Singh's avatar Prerna Singh Committed by Gerrit - the friendly Code Review server
Browse files

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: default avatarPrerna Singh <quic_prersing@quicinc.com>
parent 06426824
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -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;
}