Skip to content

Commit bb404db

Browse files
Kapileshwar SinghEduardo Valentin
authored andcommitted
thermal: power_allocator: Use temperature reading from tz
All thermal governors use the temperature value stored in struct thermal_zone_device. thermal_zone_device->temperature power_allocator governor should not deviate from this and use the same. Cc: Javi Merino <javi.merino@arm.com> Cc: Eduardo Valentin <edubezval@gmail.com> Cc: Daniel Kurtz <djkurtz@chromium.org> Cc: Zhang Rui <rui.zhang@intel.com> Cc: Dmitry Torokhov <dmitry.torokhov@gmail.com> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Andrea Arcangeli <aarcange@redhat.com> Acked-by: Javi Merino <javi.merino@arm.com> Reported-by: Sugumar Natarajan <sugumar.natarajan@arm.com> Signed-off-by: Kapileshwar Singh <kapileshwar.singh@arm.com> Signed-off-by: Eduardo Valentin <edubezval@gmail.com>
1 parent 20f0af7 commit bb404db

1 file changed

Lines changed: 7 additions & 17 deletions

File tree

drivers/thermal/power_allocator.c

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,6 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
174174
/**
175175
* pid_controller() - PID controller
176176
* @tz: thermal zone we are operating in
177-
* @current_temp: the current temperature in millicelsius
178177
* @control_temp: the target temperature in millicelsius
179178
* @max_allocatable_power: maximum allocatable power for this thermal zone
180179
*
@@ -191,7 +190,6 @@ static void estimate_pid_constants(struct thermal_zone_device *tz,
191190
* Return: The power budget for the next period.
192191
*/
193192
static u32 pid_controller(struct thermal_zone_device *tz,
194-
int current_temp,
195193
int control_temp,
196194
u32 max_allocatable_power)
197195
{
@@ -211,7 +209,7 @@ static u32 pid_controller(struct thermal_zone_device *tz,
211209
true);
212210
}
213211

214-
err = control_temp - current_temp;
212+
err = control_temp - tz->temperature;
215213
err = int_to_frac(err);
216214

217215
/* Calculate the proportional term */
@@ -332,7 +330,6 @@ static void divvy_up_power(u32 *req_power, u32 *max_power, int num_actors,
332330
}
333331

334332
static int allocate_power(struct thermal_zone_device *tz,
335-
int current_temp,
336333
int control_temp)
337334
{
338335
struct thermal_instance *instance;
@@ -418,8 +415,7 @@ static int allocate_power(struct thermal_zone_device *tz,
418415
i++;
419416
}
420417

421-
power_range = pid_controller(tz, current_temp, control_temp,
422-
max_allocatable_power);
418+
power_range = pid_controller(tz, control_temp, max_allocatable_power);
423419

424420
divvy_up_power(weighted_req_power, max_power, num_actors,
425421
total_weighted_req_power, power_range, granted_power,
@@ -444,8 +440,8 @@ static int allocate_power(struct thermal_zone_device *tz,
444440
trace_thermal_power_allocator(tz, req_power, total_req_power,
445441
granted_power, total_granted_power,
446442
num_actors, power_range,
447-
max_allocatable_power, current_temp,
448-
control_temp - current_temp);
443+
max_allocatable_power, tz->temperature,
444+
control_temp - tz->temperature);
449445

450446
kfree(req_power);
451447
unlock:
@@ -612,7 +608,7 @@ static void power_allocator_unbind(struct thermal_zone_device *tz)
612608
static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
613609
{
614610
int ret;
615-
int switch_on_temp, control_temp, current_temp;
611+
int switch_on_temp, control_temp;
616612
struct power_allocator_params *params = tz->governor_data;
617613

618614
/*
@@ -622,15 +618,9 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
622618
if (trip != params->trip_max_desired_temperature)
623619
return 0;
624620

625-
ret = thermal_zone_get_temp(tz, &current_temp);
626-
if (ret) {
627-
dev_warn(&tz->device, "Failed to get temperature: %d\n", ret);
628-
return ret;
629-
}
630-
631621
ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
632622
&switch_on_temp);
633-
if (!ret && (current_temp < switch_on_temp)) {
623+
if (!ret && (tz->temperature < switch_on_temp)) {
634624
tz->passive = 0;
635625
reset_pid_controller(params);
636626
allow_maximum_power(tz);
@@ -648,7 +638,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
648638
return ret;
649639
}
650640

651-
return allocate_power(tz, current_temp, control_temp);
641+
return allocate_power(tz, control_temp);
652642
}
653643

654644
static struct thermal_governor thermal_gov_power_allocator = {

0 commit comments

Comments
 (0)