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
This commit is contained in:
parent
63561fe36b
commit
670a5e356c
5 changed files with 11 additions and 19 deletions
|
@ -96,15 +96,13 @@ static int bang_bang_control(struct thermal_zone_device *tz, int trip)
|
||||||
{
|
{
|
||||||
struct thermal_instance *instance;
|
struct thermal_instance *instance;
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
thermal_zone_trip_update(tz, trip);
|
thermal_zone_trip_update(tz, trip);
|
||||||
|
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
|
||||||
thermal_cdev_update(instance->cdev);
|
thermal_cdev_update(instance->cdev);
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
int total_instance = 0;
|
int total_instance = 0;
|
||||||
int cur_trip_level = get_trip_level(tz);
|
int cur_trip_level = get_trip_level(tz);
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
|
||||||
if (instance->trip != trip)
|
if (instance->trip != trip)
|
||||||
|
@ -112,8 +112,6 @@ static int fair_share_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
mutex_unlock(&cdev->lock);
|
mutex_unlock(&cdev->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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)
|
static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
{
|
{
|
||||||
int ret = 0;
|
int ret;
|
||||||
int switch_on_temp, control_temp;
|
int switch_on_temp, control_temp;
|
||||||
struct power_allocator_params *params = tz->governor_data;
|
struct power_allocator_params *params = tz->governor_data;
|
||||||
bool update;
|
bool update;
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We get called for every trip point but we only need to do
|
* We get called for every trip point but we only need to do
|
||||||
* our calculations once
|
* our calculations once
|
||||||
*/
|
*/
|
||||||
if (trip != params->trip_max_desired_temperature)
|
if (trip != params->trip_max_desired_temperature)
|
||||||
goto out;
|
return 0;
|
||||||
|
|
||||||
ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
|
ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
|
||||||
&switch_on_temp);
|
&switch_on_temp);
|
||||||
|
@ -718,7 +718,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
tz->passive = 0;
|
tz->passive = 0;
|
||||||
reset_pid_controller(params);
|
reset_pid_controller(params);
|
||||||
allow_maximum_power(tz, update);
|
allow_maximum_power(tz, update);
|
||||||
goto out;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
tz->passive = 1;
|
tz->passive = 1;
|
||||||
|
@ -729,14 +729,10 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
dev_warn(&tz->device,
|
dev_warn(&tz->device,
|
||||||
"Failed to get the maximum desired temperature: %d\n",
|
"Failed to get the maximum desired temperature: %d\n",
|
||||||
ret);
|
ret);
|
||||||
goto out;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = allocate_power(tz, control_temp);
|
return allocate_power(tz, control_temp);
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
out:
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct thermal_governor thermal_gov_power_allocator = {
|
static struct thermal_governor thermal_gov_power_allocator = {
|
||||||
|
|
|
@ -160,15 +160,13 @@ static int step_wise_throttle(struct thermal_zone_device *tz, int trip)
|
||||||
{
|
{
|
||||||
struct thermal_instance *instance;
|
struct thermal_instance *instance;
|
||||||
|
|
||||||
mutex_lock(&tz->lock);
|
lockdep_assert_held(&tz->lock);
|
||||||
|
|
||||||
thermal_zone_trip_update(tz, trip);
|
thermal_zone_trip_update(tz, trip);
|
||||||
|
|
||||||
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
|
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
|
||||||
thermal_cdev_update(instance->cdev);
|
thermal_cdev_update(instance->cdev);
|
||||||
|
|
||||||
mutex_unlock(&tz->lock);
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -311,8 +311,10 @@ static void monitor_thermal_zone(struct thermal_zone_device *tz)
|
||||||
|
|
||||||
static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip)
|
static void handle_non_critical_trips(struct thermal_zone_device *tz, int trip)
|
||||||
{
|
{
|
||||||
|
mutex_lock(&tz->lock);
|
||||||
tz->governor ? tz->governor->throttle(tz, trip) :
|
tz->governor ? tz->governor->throttle(tz, trip) :
|
||||||
def_governor->throttle(tz, trip);
|
def_governor->throttle(tz, trip);
|
||||||
|
mutex_unlock(&tz->lock);
|
||||||
}
|
}
|
||||||
|
|
||||||
void thermal_zone_device_critical(struct thermal_zone_device *tz)
|
void thermal_zone_device_critical(struct thermal_zone_device *tz)
|
||||||
|
|
Loading…
Add table
Reference in a new issue