[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <25a5c859-357f-4e31-9b47-822d0c32ce70@kernel.org>
Date: Mon, 24 Nov 2025 00:24:40 +0900
From: Chanwoo Choi <chanwoo@...nel.org>
To: Riwen Lu <luriwen@...inos.cn>, myungjoo.ham@...sung.com,
kyungmin.park@...sung.com, cw00.choi@...sung.com
Cc: linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v1 2/2] PM: devfreq: handle invalid parameters gracefully
in simpleondemand
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@...inos.cn>
> ---
> 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
Powered by blists - more mailing lists