UPSTREAM: thermal: gov_power_allocator: Update total_weight on bind and cdev updates
[ Upstream commit 0cde378a10c1cbfaa8dd2b89672d42f36c2809c3 ] params->total_weight is not initialized during bind and not updated when the bound cdev changes. The cooling device weight will not be used due to the uninitialized total_weight, until an update via sysfs is triggered. The bound cdevs are updated during thermal zone registration, where each cooling device will be bound to the thermal zone one by one, but power_allocator_bind() can be called without an additional cdev update when manually changing the policy of a thermal zone via sysfs. Add a new function to handle weight update logic, including updating total_weight, and call it when bind, weight changes, and cdev updates to ensure total_weight is always correct. Fixes:a3cd6db4cc("thermal: gov_power_allocator: Support new update callback of weights") Change-Id: I93a5c719c026c7db62f73445d9707ad4ef93b136 Signed-off-by: Yu-Che Cheng <giver@chromium.org> Link: https://patch.msgid.link/20250222-fix-power-allocator-weight-v2-1-a94de86b685a@chromium.org [ rjw: Changelog edits ] Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org> (cherry picked from commit27a144c3be) Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
committed by
Carlos Llamas
parent
86487fbac6
commit
58ac66754d
@@ -635,6 +635,22 @@ clean_state:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void power_allocator_update_weight(struct power_allocator_params *params)
|
||||
{
|
||||
const struct thermal_trip_desc *td;
|
||||
struct thermal_instance *instance;
|
||||
|
||||
if (!params->trip_max)
|
||||
return;
|
||||
|
||||
td = trip_to_trip_desc(params->trip_max);
|
||||
|
||||
params->total_weight = 0;
|
||||
list_for_each_entry(instance, &td->thermal_instances, trip_node)
|
||||
if (power_actor_is_valid(instance))
|
||||
params->total_weight += instance->weight;
|
||||
}
|
||||
|
||||
static void power_allocator_update_tz(struct thermal_zone_device *tz,
|
||||
enum thermal_notify_event reason)
|
||||
{
|
||||
@@ -650,16 +666,12 @@ static void power_allocator_update_tz(struct thermal_zone_device *tz,
|
||||
if (power_actor_is_valid(instance))
|
||||
num_actors++;
|
||||
|
||||
if (num_actors == params->num_actors)
|
||||
return;
|
||||
if (num_actors != params->num_actors)
|
||||
allocate_actors_buffer(params, num_actors);
|
||||
|
||||
allocate_actors_buffer(params, num_actors);
|
||||
break;
|
||||
fallthrough;
|
||||
case THERMAL_INSTANCE_WEIGHT_CHANGED:
|
||||
params->total_weight = 0;
|
||||
list_for_each_entry(instance, &td->thermal_instances, trip_node)
|
||||
if (power_actor_is_valid(instance))
|
||||
params->total_weight += instance->weight;
|
||||
power_allocator_update_weight(params);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@@ -725,6 +737,8 @@ static int power_allocator_bind(struct thermal_zone_device *tz)
|
||||
|
||||
tz->governor_data = params;
|
||||
|
||||
power_allocator_update_weight(params);
|
||||
|
||||
return 0;
|
||||
|
||||
free_params:
|
||||
|
||||
Reference in New Issue
Block a user