Skip to content

Commit a3cd6db

Browse files
lukaszluba-armrafaeljw
authored andcommitted
thermal: gov_power_allocator: Support new update callback of weights
When the thermal instance's weight is updated from the sysfs the governor update_tz() callback is triggered. Implement proper reaction to this event in the IPA, which would save CPU cycles spent in throttle(). This will speed-up the main throttle() IPA function and clean it up a bit. Signed-off-by: Lukasz Luba <lukasz.luba@arm.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
1 parent bfc57bd commit a3cd6db

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

drivers/thermal/gov_power_allocator.c

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ struct power_actor {
7777
* @trip_switch_on should be NULL.
7878
* @trip_max: last passive trip point of the thermal zone. The
7979
* temperature we are controlling for.
80+
* @total_weight: Sum of all thermal instances weights
8081
* @num_actors: number of cooling devices supporting IPA callbacks
8182
* @buffer_size: internal buffer size, to avoid runtime re-calculation
8283
* @power: buffer for all power actors internal power information
@@ -88,6 +89,7 @@ struct power_allocator_params {
8889
u32 sustainable_power;
8990
const struct thermal_trip *trip_switch_on;
9091
const struct thermal_trip *trip_max;
92+
int total_weight;
9193
unsigned int num_actors;
9294
unsigned int buffer_size;
9395
struct power_actor *power;
@@ -405,16 +407,11 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp)
405407
u32 total_granted_power = 0;
406408
u32 total_req_power = 0;
407409
u32 power_range, weight;
408-
int total_weight = 0;
409410
int i = 0, ret;
410411

411412
if (!num_actors)
412413
return -ENODEV;
413414

414-
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
415-
if (power_actor_is_valid(params, instance))
416-
total_weight += instance->weight;
417-
418415
/* Clean all buffers for new power estimations */
419416
memset(power, 0, params->buffer_size);
420417

@@ -430,7 +427,7 @@ static int allocate_power(struct thermal_zone_device *tz, int control_temp)
430427
if (ret)
431428
continue;
432429

433-
if (!total_weight)
430+
if (!params->total_weight)
434431
weight = 1 << FRAC_BITS;
435432
else
436433
weight = instance->weight;
@@ -651,6 +648,12 @@ static void power_allocator_update_tz(struct thermal_zone_device *tz,
651648

652649
allocate_actors_buffer(params, num_actors);
653650
break;
651+
case THERMAL_INSTANCE_WEIGHT_CHANGED:
652+
params->total_weight = 0;
653+
list_for_each_entry(instance, &tz->thermal_instances, tz_node)
654+
if (power_actor_is_valid(params, instance))
655+
params->total_weight += instance->weight;
656+
break;
654657
default:
655658
break;
656659
}

0 commit comments

Comments
 (0)