Re: [PATCH v1 2/2] PM: devfreq: handle invalid parameters gracefully in simpleondemand

From: Chanwoo Choi

Date: Sun Nov 23 2025 - 10:24:44 EST


25. 11. 18. 12:23에 Riwen Lu 이(가) 쓴 글:
> Instead of returning -EINVAL when upthreshold > 100 or upthreshold <
> downdifferential, fall back to default threshold values to ensure the
> governor continues functioning.
>
> Additionally, the validation is now scoped to the if (data) block,
> preventing unnecessary checks when no user data is provided, while the
> fallback mechanism ensures reliability with invalid configurations.
>
> Signed-off-by: Riwen Lu <luriwen@xxxxxxxxxx>
> ---
> drivers/devfreq/governor_simpleondemand.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/devfreq/governor_simpleondemand.c b/drivers/devfreq/governor_simpleondemand.c
> index b4d7be766f33..7205891d2ec6 100644
> --- a/drivers/devfreq/governor_simpleondemand.c
> +++ b/drivers/devfreq/governor_simpleondemand.c
> @@ -36,10 +36,15 @@ static int devfreq_simple_ondemand_func(struct devfreq *df,
> dfso_upthreshold = data->upthreshold;
> if (data->downdifferential)
> dfso_downdifferential = data->downdifferential;
> +
> + if (dfso_upthreshold > 100 ||
> + dfso_upthreshold < dfso_downdifferential) {
> + dfso_upthreshold = DFSO_UPTHRESHOLD;
> + dfso_downdifferential = DFSO_DOWNDIFFERENTIAL;
> + pr_debug("Invalid thresholds, using defaults: up = %u, down = %u\n",
> + dfso_upthreshold, dfso_downdifferential);
> + }
> }
> - if (dfso_upthreshold > 100 ||
> - dfso_upthreshold < dfso_downdifferential)
> - return -EINVAL;
>
> /* Assume MAX if it is going to be divided by zero */
> if (stat->total_time == 0) {

If there are wrong initialization of devfreq_simple_ondemand,
it should point out what is wrong because it makes some confusion if there are no error.


--
Best Regards,
Samsung Electronics
Chanwoo Choi