aboutsummaryrefslogtreecommitdiff
path: root/drivers/thermal/gov_power_allocator.c
diff options
context:
space:
mode:
authorGravatar Daniel Lezcano <daniel.lezcano@linaro.org> 2022-08-05 17:38:33 +0200
committerGravatar Daniel Lezcano <daniel.lezcano@linaro.org> 2022-08-17 14:09:39 +0200
commit670a5e356cb6dfc61b87b599eba483af6a3a99ad (patch)
tree5165d8ff45c1107d36c6cdcb5606cdf72aa82e8e /drivers/thermal/gov_power_allocator.c
parentthermal/governors: Group the thermal zone lock inside the throttle function (diff)
downloadlinux-670a5e356cb6dfc61b87b599eba483af6a3a99ad.tar.gz
linux-670a5e356cb6dfc61b87b599eba483af6a3a99ad.tar.bz2
linux-670a5e356cb6dfc61b87b599eba483af6a3a99ad.zip
thermal/core: Move the thermal zone lock out of the governors
All the governors throttling ops are taking/releasing the lock at the beginning and the end of the function. We can move the mutex to the throttling call site instead. Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20220805153834.2510142-4-daniel.lezcano@linaro.org
Diffstat (limited to 'drivers/thermal/gov_power_allocator.c')
-rw-r--r--drivers/thermal/gov_power_allocator.c16
1 files changed, 6 insertions, 10 deletions
diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c
index d3aca236e274..2d1aeaba38a8 100644
--- a/drivers/thermal/gov_power_allocator.c
+++ b/drivers/thermal/gov_power_allocator.c
@@ -697,19 +697,19 @@ static void power_allocator_unbind(struct thermal_zone_device *tz)
static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
{
- int ret = 0;
+ int ret;
int switch_on_temp, control_temp;
struct power_allocator_params *params = tz->governor_data;
bool update;
- mutex_lock(&tz->lock);
+ lockdep_assert_held(&tz->lock);
/*
* We get called for every trip point but we only need to do
* our calculations once
*/
if (trip != params->trip_max_desired_temperature)
- goto out;
+ return 0;
ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
&switch_on_temp);
@@ -718,7 +718,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
tz->passive = 0;
reset_pid_controller(params);
allow_maximum_power(tz, update);
- goto out;
+ return 0;
}
tz->passive = 1;
@@ -729,14 +729,10 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
dev_warn(&tz->device,
"Failed to get the maximum desired temperature: %d\n",
ret);
- goto out;
+ return ret;
}
- ret = allocate_power(tz, control_temp);
-
- mutex_unlock(&tz->lock);
-out:
- return ret;
+ return allocate_power(tz, control_temp);
}
static struct thermal_governor thermal_gov_power_allocator = {