Skip to content

Commit 38c090b

Browse files
pierregondoissforshee
authored andcommitted
NVIDIA: VR: SAUCE: cpufreq: Remove driver default policy->min/max init
Prior to [1], drivers were setting policy->min/max and the value was used as a QoS constraint. After that change, the values were only temporarily used: cpufreq_set_policy() ultimately overriding them through: cpufreq_policy_online() \-cpufreq_init_policy() \-cpufreq_set_policy() \-/* Set policy->min/max */ This patch reinstate the initial behaviour. This will allow drivers to request min/max QoS frequencies if desired. For instance, the cppc driver advertises a lowest non-linear frequency, which should be used as a min QoS value. To avoid having drivers setting policy->min/max to default values which are considered as QoS values (i.e. the reason why [1] was introduced), remove the initialization of policy->min/max in .init() callbacks wherever the policy->min/max values are identical to the policy->cpuinfo.min/max_freq. Indeed, the previous patch ("cpufreq: Set default policy->min/max values for all drivers") makes this initialization redundant. The only drivers where these values are different are: - gx-suspmod.c (min) - cppc-cpufreq.c (min) - longrun.c [1] commit 521223d ("cpufreq: Fix initialization of min and max frequency QoS requests") Signed-off-by: Pierre Gondois <pierre.gondois@arm.com> (backported from https://lore.kernel.org/lkml/20260511135538.522653-4-pierre.gondois@arm.com/) [sforshee: adjustments to amd-pstate for missing max_freq caching patch] Signed-off-by: Seth Forshee <sforshee@nvidia.com>
1 parent 8def73f commit 38c090b

10 files changed

Lines changed: 25 additions & 42 deletions

File tree

drivers/cpufreq/amd-pstate.c

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,12 +1001,10 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
10011001

10021002
perf = READ_ONCE(cpudata->perf);
10031003

1004-
policy->cpuinfo.min_freq = policy->min = perf_to_freq(perf,
1005-
cpudata->nominal_freq,
1006-
perf.lowest_perf);
1007-
policy->cpuinfo.max_freq = policy->max = perf_to_freq(perf,
1008-
cpudata->nominal_freq,
1009-
perf.highest_perf);
1004+
policy->cpuinfo.min_freq = perf_to_freq(perf, cpudata->nominal_freq,
1005+
perf.lowest_perf);
1006+
policy->cpuinfo.max_freq = perf_to_freq(perf, cpudata->nominal_freq,
1007+
perf.highest_perf);
10101008

10111009
ret = amd_pstate_cppc_enable(policy);
10121010
if (ret)
@@ -1490,12 +1488,10 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
14901488

14911489
perf = READ_ONCE(cpudata->perf);
14921490

1493-
policy->cpuinfo.min_freq = policy->min = perf_to_freq(perf,
1494-
cpudata->nominal_freq,
1495-
perf.lowest_perf);
1496-
policy->cpuinfo.max_freq = policy->max = perf_to_freq(perf,
1497-
cpudata->nominal_freq,
1498-
perf.highest_perf);
1491+
policy->cpuinfo.min_freq = perf_to_freq(perf, cpudata->nominal_freq,
1492+
perf.lowest_perf);
1493+
policy->cpuinfo.max_freq = perf_to_freq(perf, cpudata->nominal_freq,
1494+
perf.highest_perf);
14991495
policy->driver_data = cpudata;
15001496

15011497
ret = amd_pstate_cppc_enable(policy);

drivers/cpufreq/cppc_cpufreq.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,16 +640,15 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy)
640640
* Section 8.4.7.1.1.5 of ACPI 6.1 spec)
641641
*/
642642
policy->min = cppc_perf_to_khz(caps, caps->lowest_nonlinear_perf);
643-
policy->max = cppc_perf_to_khz(caps, policy->boost_enabled ?
644-
caps->highest_perf : caps->nominal_perf);
645643

646644
/*
647645
* Set cpuinfo.min_freq to Lowest to make the full range of performance
648646
* available if userspace wants to use any perf between lowest & lowest
649647
* nonlinear perf
650648
*/
651649
policy->cpuinfo.min_freq = cppc_perf_to_khz(caps, caps->lowest_perf);
652-
policy->cpuinfo.max_freq = policy->max;
650+
policy->cpuinfo.max_freq = cppc_perf_to_khz(caps, policy->boost_enabled ?
651+
caps->highest_perf : caps->nominal_perf);
653652

654653
policy->transition_delay_us = cppc_cpufreq_get_transition_delay_us(cpu);
655654
policy->shared_type = cpu_data->shared_type;

drivers/cpufreq/cpufreq-nforce2.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@ static int nforce2_cpu_init(struct cpufreq_policy *policy)
355355
min_fsb = NFORCE2_MIN_FSB;
356356

357357
/* cpuinfo and default policy values */
358-
policy->min = policy->cpuinfo.min_freq = min_fsb * fid * 100;
359-
policy->max = policy->cpuinfo.max_freq = max_fsb * fid * 100;
358+
policy->cpuinfo.min_freq = min_fsb * fid * 100;
359+
policy->cpuinfo.max_freq = max_fsb * fid * 100;
360360

361361
return 0;
362362
}

drivers/cpufreq/freq_table.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,16 +49,15 @@ int cpufreq_frequency_table_cpuinfo(struct cpufreq_policy *policy)
4949
max_freq = freq;
5050
}
5151

52-
policy->min = policy->cpuinfo.min_freq = min_freq;
53-
policy->max = max_freq;
52+
policy->cpuinfo.min_freq = min_freq;
5453
/*
5554
* If the driver has set its own cpuinfo.max_freq above max_freq, leave
5655
* it as is.
5756
*/
5857
if (policy->cpuinfo.max_freq < max_freq)
59-
policy->max = policy->cpuinfo.max_freq = max_freq;
58+
policy->cpuinfo.max_freq = max_freq;
6059

61-
if (policy->min == ~0)
60+
if (min_freq == ~0)
6261
return -EINVAL;
6362
else
6463
return 0;

drivers/cpufreq/gx-suspmod.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ static int cpufreq_gx_cpu_init(struct cpufreq_policy *policy)
421421
policy->min = maxfreq / max_duration;
422422
else
423423
policy->min = maxfreq / POLICY_MIN_DIV;
424-
policy->max = maxfreq;
424+
425425
policy->cpuinfo.min_freq = maxfreq / max_duration;
426426
policy->cpuinfo.max_freq = maxfreq;
427427

drivers/cpufreq/intel_pstate.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3080,9 +3080,6 @@ static int __intel_pstate_cpu_init(struct cpufreq_policy *policy)
30803080
policy->cpuinfo.max_freq = READ_ONCE(global.no_turbo) ?
30813081
cpu->pstate.max_freq : cpu->pstate.turbo_freq;
30823082

3083-
policy->min = policy->cpuinfo.min_freq;
3084-
policy->max = policy->cpuinfo.max_freq;
3085-
30863083
intel_pstate_init_acpi_perf_limits(policy);
30873084

30883085
policy->fast_switch_possible = true;

drivers/cpufreq/pcc-cpufreq.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -551,13 +551,11 @@ static int pcc_cpufreq_cpu_init(struct cpufreq_policy *policy)
551551
goto out;
552552
}
553553

554-
policy->max = policy->cpuinfo.max_freq =
555-
ioread32(&pcch_hdr->nominal) * 1000;
556-
policy->min = policy->cpuinfo.min_freq =
557-
ioread32(&pcch_hdr->minimum_frequency) * 1000;
554+
policy->cpuinfo.max_freq = ioread32(&pcch_hdr->nominal) * 1000;
555+
policy->cpuinfo.min_freq = ioread32(&pcch_hdr->minimum_frequency) * 1000;
558556

559-
pr_debug("init: policy->max is %d, policy->min is %d\n",
560-
policy->max, policy->min);
557+
pr_debug("init: max_freq is %d, min_freq is %d\n",
558+
policy->cpuinfo.max_freq, policy->cpuinfo.min_freq);
561559
out:
562560
return result;
563561
}

drivers/cpufreq/pxa3xx-cpufreq.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -185,9 +185,8 @@ static int pxa3xx_cpufreq_init(struct cpufreq_policy *policy)
185185
int ret = -EINVAL;
186186

187187
/* set default policy and cpuinfo */
188-
policy->min = policy->cpuinfo.min_freq = 104000;
189-
policy->max = policy->cpuinfo.max_freq =
190-
(cpu_is_pxa320()) ? 806000 : 624000;
188+
policy->cpuinfo.min_freq = 104000;
189+
policy->cpuinfo.max_freq = (cpu_is_pxa320()) ? 806000 : 624000;
191190
policy->cpuinfo.transition_latency = 1000; /* FIXME: 1 ms, assumed */
192191

193192
if (cpu_is_pxa300() || cpu_is_pxa310())

drivers/cpufreq/sh-cpufreq.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,10 +124,8 @@ static int sh_cpufreq_cpu_init(struct cpufreq_policy *policy)
124124
dev_notice(dev, "no frequency table found, falling back "
125125
"to rate rounding.\n");
126126

127-
policy->min = policy->cpuinfo.min_freq =
128-
(clk_round_rate(cpuclk, 1) + 500) / 1000;
129-
policy->max = policy->cpuinfo.max_freq =
130-
(clk_round_rate(cpuclk, ~0UL) + 500) / 1000;
127+
policy->cpuinfo.min_freq = (clk_round_rate(cpuclk, 1) + 500) / 1000;
128+
policy->cpuinfo.max_freq = (clk_round_rate(cpuclk, ~0UL) + 500) / 1000;
131129
}
132130

133131
return 0;

drivers/cpufreq/virtual-cpufreq.c

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,7 @@ static int virt_cpufreq_get_freq_info(struct cpufreq_policy *policy)
164164
policy->cpuinfo.min_freq = 1;
165165
policy->cpuinfo.max_freq = virt_cpufreq_get_perftbl_entry(policy->cpu, 0);
166166

167-
policy->min = policy->cpuinfo.min_freq;
168-
policy->max = policy->cpuinfo.max_freq;
169-
170-
policy->cur = policy->max;
167+
policy->cur = policy->cpuinfo.max_freq;
171168
return 0;
172169
}
173170

0 commit comments

Comments
 (0)