From 3abe156a4edfe636a9409af8be5f2457e78b4eaf Mon Sep 17 00:00:00 2001 From: Ishan Shah Date: Fri, 11 Apr 2025 22:23:31 +0000 Subject: [PATCH] NVIDIA: SAUCE: cpufreq: tegra194: fix policy initialization Fix the policy-initialization scheme to correctly be dependent on cores sharing a clusterid or a clock-source via connected cluster-ids. This solves an issue where we floorsweep only one core in a cluster, causing logical IDs to fall out of order with physical IDs and so causing cores to be tied together incorrectly in the cpufreq framework. http://nvbugs/5213905 Signed-off-by: Ishan Shah Reviewed-by: Sumit Gupta Reviewed-by: Nathan Hartman Signed-off-by: Kartik Rajput Acked-by: Noah Wager Acked-by: Jacob Martin Signed-off-by: Noah Wager --- drivers/cpufreq/tegra194-cpufreq.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/drivers/cpufreq/tegra194-cpufreq.c b/drivers/cpufreq/tegra194-cpufreq.c index 0a87f28897d1..8e4b6295119c 100644 --- a/drivers/cpufreq/tegra194-cpufreq.c +++ b/drivers/cpufreq/tegra194-cpufreq.c @@ -620,17 +620,24 @@ static int tegra194_cpufreq_init(struct cpufreq_policy *policy) u32 clusterid = data->cpu_data[policy->cpu].clusterid; struct cpufreq_frequency_table *freq_table; struct cpufreq_frequency_table *bpmp_lut; - u32 start_cpu, cpu; + u32 cpu; int ret; if (clusterid >= data->soc->num_clusters || !data->bpmp_luts[clusterid]) return -EINVAL; - start_cpu = rounddown(policy->cpu, maxcpus_per_clock); - /* set same policy for all cpus in a cluster */ - for (cpu = start_cpu; cpu < (start_cpu + maxcpus_per_clock); cpu++) { - if (cpu_possible(cpu)) + /* Set same policy for all possible cpus in a clocking cluster */ + for_each_possible_cpu(cpu) { + if (data->cpu_data[cpu].clusterid == clusterid) { cpumask_set_cpu(cpu, policy->cpus); + } else if (data->soc->clusters_per_clk > 1) { + u32 policy_clk_id = clusterid / data->soc->clusters_per_clk; + u32 clk_id = data->cpu_data[cpu].clusterid / + data->soc->clusters_per_clk; + if (policy_clk_id == clk_id) { + cpumask_set_cpu(cpu, policy->cpus); + } + } } policy->cpuinfo.transition_latency = TEGRA_CPUFREQ_TRANSITION_LATENCY;