[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20231025192225.468228-3-lukasz.luba@arm.com>
Date: Wed, 25 Oct 2023 20:22:20 +0100
From: Lukasz Luba <lukasz.luba@....com>
To: linux-kernel@...r.kernel.org, daniel.lezcano@...aro.org,
rafael@...nel.org
Cc: linux-pm@...r.kernel.org, rui.zhang@...el.com, lukasz.luba@....com
Subject: [PATCH 2/7] thermal: gov_power_allocator: Setup trip points earlier
Setup the trip points at the beginning of the binding function. This
simplifies the code a bit and allows further cleaning. Add also the
check if the last passive trip point is found and fail binding if not.
Signed-off-by: Lukasz Luba <lukasz.luba@....com>
---
drivers/thermal/gov_power_allocator.c | 27 +++++++++++++++++----------
1 file changed, 17 insertions(+), 10 deletions(-)
diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index 97a8a6e4e1b0b..0dfc5b5ab5235 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -617,14 +617,24 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
int ret;
struct power_allocator_params *params;
- ret = check_power_actors(tz);
- if (ret)
- return ret;
-
params = kzalloc(sizeof(*params), GFP_KERNEL);
if (!params)
return -ENOMEM;
+ get_governor_trips(tz, params);
+ if (!params->trip_max) {
+ dev_warn(&tz->device, "power_allocator: missing trip_max\n");
+ kfree(params);
+ return -EINVAL;
+ }
+
+ ret = check_power_actors(tz);
+ if (ret) {
+ dev_warn(&tz->device, "power_allocator: binding failed\n");
+ kfree(params);
+ return ret;
+ }
+
if (!tz->tzp) {
tz->tzp = kzalloc(sizeof(*tz->tzp), GFP_KERNEL);
if (!tz->tzp) {
@@ -638,12 +648,9 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
if (!tz->tzp->sustainable_power)
dev_warn(&tz->device, "power_allocator: sustainable_power will be estimated\n");
- get_governor_trips(tz, params);
-
- if (params->trip_max)
- estimate_pid_constants(tz, tz->tzp->sustainable_power,
- params->trip_switch_on,
- params->trip_max->temperature);
+ estimate_pid_constants(tz, tz->tzp->sustainable_power,
+ params->trip_switch_on,
+ params->trip_max->temperature);
reset_pid_controller(params);
--
2.25.1
Powered by blists - more mailing lists