Skip to content

Commit 2ddb8a3

Browse files
Perry Yuanrafaeljw
authored andcommitted
cpufreq: amd-pstate: Bail out if min/max/nominal_freq is 0
The amd-pstate driver cannot work when the min_freq, nominal_freq or the max_freq is zero. When this happens it is prudent to error out early on rather than waiting failing at the time of the governor initialization. Acked-by: Huang Rui <[email protected]> Reviewed-by: Gautham R. Shenoy <[email protected]> Tested-by: Dhananjay Ugwekar <[email protected]> Signed-off-by: Perry Yuan <[email protected]> Signed-off-by: Rafael J. Wysocki <[email protected]>
1 parent 3cbbe88 commit 2ddb8a3

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

drivers/cpufreq/amd-pstate.c

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -839,9 +839,11 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy)
839839
nominal_freq = READ_ONCE(cpudata->nominal_freq);
840840
lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq);
841841

842-
if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) {
843-
dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n",
844-
min_freq, max_freq);
842+
if (min_freq <= 0 || max_freq <= 0 ||
843+
nominal_freq <= 0 || min_freq > max_freq) {
844+
dev_err(dev,
845+
"min_freq(%d) or max_freq(%d) or nominal_freq (%d) value is incorrect, check _CPC in ACPI tables\n",
846+
min_freq, max_freq, nominal_freq);
845847
ret = -EINVAL;
846848
goto free_cpudata1;
847849
}
@@ -1299,9 +1301,11 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy)
12991301
max_freq = READ_ONCE(cpudata->max_freq);
13001302
nominal_freq = READ_ONCE(cpudata->nominal_freq);
13011303
lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq);
1302-
if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) {
1303-
dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n",
1304-
min_freq, max_freq);
1304+
if (min_freq <= 0 || max_freq <= 0 ||
1305+
nominal_freq <= 0 || min_freq > max_freq) {
1306+
dev_err(dev,
1307+
"min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect, check _CPC in ACPI tables\n",
1308+
min_freq, max_freq, nominal_freq);
13051309
ret = -EINVAL;
13061310
goto free_cpudata1;
13071311
}

0 commit comments

Comments
 (0)