Message ID | 884cab991815707eb10b720e6f72978cbb5e54f6.1710836407.git.perry.yuan@amd.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers | show |
Series | AMD Pstate Fixes And Enhancements | expand |
Hello Perry, On Tue, Mar 19, 2024 at 04:28:40PM +0800, Perry Yuan wrote: > 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. > This patch looks good to me. Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com> > Signed-off-by: Perry Yuan <perry.yuan@amd.com> > --- > drivers/cpufreq/amd-pstate.c | 16 ++++++++++------ > 1 file changed, 10 insertions(+), 6 deletions(-) > > diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c > index 132330b4942f..6708c436e1a2 100644 > --- a/drivers/cpufreq/amd-pstate.c > +++ b/drivers/cpufreq/amd-pstate.c > @@ -839,9 +839,11 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) > nominal_freq = READ_ONCE(cpudata->nominal_freq); > lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); > > - if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { > - dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", > - min_freq, max_freq); > + if (min_freq <= 0 || max_freq <= 0 || > + nominal_freq <= 0 || min_freq > max_freq) { > + dev_err(dev, > + "min_freq(%d) or max_freq(%d) or nominal_freq (%d) value is incorrect\n", > + min_freq, max_freq, nominal_freq); > ret = -EINVAL; > goto free_cpudata1; > } > @@ -1299,9 +1301,11 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) > max_freq = READ_ONCE(cpudata->max_freq); > nominal_freq = READ_ONCE(cpudata->nominal_freq); > lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); > - if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { > - dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", > - min_freq, max_freq); > + if (min_freq <= 0 || max_freq <= 0 || > + nominal_freq <= 0 || min_freq > max_freq) { > + dev_err(dev, > + "min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n", > + min_freq, max_freq, nominal_freq); > ret = -EINVAL; > goto free_cpudata1; > } > -- > 2.34.1 > -- Thanks and Regards gautham.
diff --git a/drivers/cpufreq/amd-pstate.c b/drivers/cpufreq/amd-pstate.c index 132330b4942f..6708c436e1a2 100644 --- a/drivers/cpufreq/amd-pstate.c +++ b/drivers/cpufreq/amd-pstate.c @@ -839,9 +839,11 @@ static int amd_pstate_cpu_init(struct cpufreq_policy *policy) nominal_freq = READ_ONCE(cpudata->nominal_freq); lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); - if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { - dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", - min_freq, max_freq); + if (min_freq <= 0 || max_freq <= 0 || + nominal_freq <= 0 || min_freq > max_freq) { + dev_err(dev, + "min_freq(%d) or max_freq(%d) or nominal_freq (%d) value is incorrect\n", + min_freq, max_freq, nominal_freq); ret = -EINVAL; goto free_cpudata1; } @@ -1299,9 +1301,11 @@ static int amd_pstate_epp_cpu_init(struct cpufreq_policy *policy) max_freq = READ_ONCE(cpudata->max_freq); nominal_freq = READ_ONCE(cpudata->nominal_freq); lowest_nonlinear_freq = READ_ONCE(cpudata->lowest_nonlinear_freq); - if (min_freq < 0 || max_freq < 0 || min_freq > max_freq) { - dev_err(dev, "min_freq(%d) or max_freq(%d) value is incorrect\n", - min_freq, max_freq); + if (min_freq <= 0 || max_freq <= 0 || + nominal_freq <= 0 || min_freq > max_freq) { + dev_err(dev, + "min_freq(%d) or max_freq(%d) or nominal_freq(%d) value is incorrect\n", + min_freq, max_freq, nominal_freq); ret = -EINVAL; goto free_cpudata1; }
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. Signed-off-by: Perry Yuan <perry.yuan@amd.com> --- drivers/cpufreq/amd-pstate.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-)