Commit 4e6d4687 authored by Lukasz Luba's avatar Lukasz Luba Committed by Rafael J. Wysocki

thermal: gov_power_allocator: Rename trip_max_desired_temperature

Refactor the code and rename the last passive trip point field.

There is a comment describing the field properly. Use shorter field name
so as to allow to clarify the code.

This change is not expected to alter the general functionality.
Signed-off-by: default avatarLukasz Luba <lukasz.luba@arm.com>
[ rjw: Changelog edits ]
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 44844db9
...@@ -59,9 +59,8 @@ static inline s64 div_frac(s64 x, s64 y) ...@@ -59,9 +59,8 @@ static inline s64 div_frac(s64 x, s64 y)
* governor switches on when this trip point is crossed. * governor switches on when this trip point is crossed.
* If the thermal zone only has one passive trip point, * If the thermal zone only has one passive trip point,
* @trip_switch_on should be NULL. * @trip_switch_on should be NULL.
* @trip_max_desired_temperature: last passive trip point of the thermal * @trip_max: last passive trip point of the thermal zone. The
* zone. The temperature we are * temperature we are controlling for.
* controlling for.
*/ */
struct power_allocator_params { struct power_allocator_params {
bool allocated_tzp; bool allocated_tzp;
...@@ -69,7 +68,7 @@ struct power_allocator_params { ...@@ -69,7 +68,7 @@ struct power_allocator_params {
s32 prev_err; s32 prev_err;
u32 sustainable_power; u32 sustainable_power;
const struct thermal_trip *trip_switch_on; const struct thermal_trip *trip_switch_on;
const struct thermal_trip *trip_max_desired_temperature; const struct thermal_trip *trip_max;
}; };
/** /**
...@@ -93,7 +92,7 @@ static u32 estimate_sustainable_power(struct thermal_zone_device *tz) ...@@ -93,7 +92,7 @@ static u32 estimate_sustainable_power(struct thermal_zone_device *tz)
struct thermal_cooling_device *cdev = instance->cdev; struct thermal_cooling_device *cdev = instance->cdev;
u32 min_power; u32 min_power;
if (instance->trip != params->trip_max_desired_temperature) if (instance->trip != params->trip_max)
continue; continue;
if (!cdev_is_power_actor(cdev)) if (!cdev_is_power_actor(cdev))
...@@ -379,8 +378,7 @@ static int allocate_power(struct thermal_zone_device *tz, ...@@ -379,8 +378,7 @@ static int allocate_power(struct thermal_zone_device *tz,
{ {
struct thermal_instance *instance; struct thermal_instance *instance;
struct power_allocator_params *params = tz->governor_data; struct power_allocator_params *params = tz->governor_data;
const struct thermal_trip *trip_max_desired_temperature = const struct thermal_trip *trip_max = params->trip_max;
params->trip_max_desired_temperature;
u32 *req_power, *max_power, *granted_power, *extra_actor_power; u32 *req_power, *max_power, *granted_power, *extra_actor_power;
u32 *weighted_req_power; u32 *weighted_req_power;
u32 total_req_power, max_allocatable_power, total_weighted_req_power; u32 total_req_power, max_allocatable_power, total_weighted_req_power;
...@@ -390,7 +388,7 @@ static int allocate_power(struct thermal_zone_device *tz, ...@@ -390,7 +388,7 @@ static int allocate_power(struct thermal_zone_device *tz,
num_actors = 0; num_actors = 0;
total_weight = 0; total_weight = 0;
list_for_each_entry(instance, &tz->thermal_instances, tz_node) { list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if ((instance->trip == trip_max_desired_temperature) && if ((instance->trip == trip_max) &&
cdev_is_power_actor(instance->cdev)) { cdev_is_power_actor(instance->cdev)) {
num_actors++; num_actors++;
total_weight += instance->weight; total_weight += instance->weight;
...@@ -429,7 +427,7 @@ static int allocate_power(struct thermal_zone_device *tz, ...@@ -429,7 +427,7 @@ static int allocate_power(struct thermal_zone_device *tz,
int weight; int weight;
struct thermal_cooling_device *cdev = instance->cdev; struct thermal_cooling_device *cdev = instance->cdev;
if (instance->trip != trip_max_desired_temperature) if (instance->trip != trip_max)
continue; continue;
if (!cdev_is_power_actor(cdev)) if (!cdev_is_power_actor(cdev))
...@@ -465,7 +463,7 @@ static int allocate_power(struct thermal_zone_device *tz, ...@@ -465,7 +463,7 @@ static int allocate_power(struct thermal_zone_device *tz,
total_granted_power = 0; total_granted_power = 0;
i = 0; i = 0;
list_for_each_entry(instance, &tz->thermal_instances, tz_node) { list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
if (instance->trip != trip_max_desired_temperature) if (instance->trip != trip_max)
continue; continue;
if (!cdev_is_power_actor(instance->cdev)) if (!cdev_is_power_actor(instance->cdev))
...@@ -531,13 +529,13 @@ static void get_governor_trips(struct thermal_zone_device *tz, ...@@ -531,13 +529,13 @@ static void get_governor_trips(struct thermal_zone_device *tz,
if (last_passive) { if (last_passive) {
params->trip_switch_on = first_passive; params->trip_switch_on = first_passive;
params->trip_max_desired_temperature = last_passive; params->trip_max = last_passive;
} else if (first_passive) { } else if (first_passive) {
params->trip_switch_on = NULL; params->trip_switch_on = NULL;
params->trip_max_desired_temperature = first_passive; params->trip_max = first_passive;
} else { } else {
params->trip_switch_on = NULL; params->trip_switch_on = NULL;
params->trip_max_desired_temperature = last_active; params->trip_max = last_active;
} }
} }
...@@ -556,8 +554,8 @@ static void allow_maximum_power(struct thermal_zone_device *tz, bool update) ...@@ -556,8 +554,8 @@ static void allow_maximum_power(struct thermal_zone_device *tz, bool update)
list_for_each_entry(instance, &tz->thermal_instances, tz_node) { list_for_each_entry(instance, &tz->thermal_instances, tz_node) {
struct thermal_cooling_device *cdev = instance->cdev; struct thermal_cooling_device *cdev = instance->cdev;
if (instance->trip != params->trip_max_desired_temperature || if (instance->trip != params->trip_max ||
(!cdev_is_power_actor(instance->cdev))) !cdev_is_power_actor(instance->cdev))
continue; continue;
instance->target = 0; instance->target = 0;
...@@ -642,12 +640,10 @@ static int power_allocator_bind(struct thermal_zone_device *tz) ...@@ -642,12 +640,10 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
get_governor_trips(tz, params); get_governor_trips(tz, params);
if (params->trip_max_desired_temperature) { if (params->trip_max)
int temp = params->trip_max_desired_temperature->temperature;
estimate_pid_constants(tz, tz->tzp->sustainable_power, estimate_pid_constants(tz, tz->tzp->sustainable_power,
params->trip_switch_on, temp); params->trip_switch_on,
} params->trip_max->temperature);
reset_pid_controller(params); reset_pid_controller(params);
...@@ -688,7 +684,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, ...@@ -688,7 +684,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz,
* 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)
return 0; return 0;
trip = params->trip_switch_on; trip = params->trip_switch_on;
...@@ -702,7 +698,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, ...@@ -702,7 +698,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz,
tz->passive = 1; tz->passive = 1;
return allocate_power(tz, params->trip_max_desired_temperature->temperature); return allocate_power(tz, params->trip_max->temperature);
} }
static struct thermal_governor thermal_gov_power_allocator = { static struct thermal_governor thermal_gov_power_allocator = {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment