[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-Id: <20251118032339.2799230-2-luriwen@kylinos.cn>
Date: Tue, 18 Nov 2025 11:23:39 +0800
From: Riwen Lu <luriwen@...inos.cn>
To: myungjoo.ham@...sung.com,
kyungmin.park@...sung.com,
cw00.choi@...sung.com
Cc: linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org,
Riwen Lu <luriwen@...inos.cn>
Subject: [PATCH v1 2/2] PM: devfreq: handle invalid parameters gracefully in simpleondemand
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) {
--
2.25.1
Powered by blists - more mailing lists