Re: [PATCH v2] thermal: gov_power_allocator: Update total_weight on bind and cdev updates

From: Lukasz Luba
Date: Thu Feb 27 2025 - 09:38:18 EST




On 2/25/25 11:35, Rafael J. Wysocki wrote:
On Sat, Feb 22, 2025 at 4:20 AM Yu-Che Cheng <giver@xxxxxxxxxxxx> wrote:

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 we trigger an update via sysfs.

The bound cdev update will be triggered during thermal zone registration,
where each cooling device will be bound to the thermal zone one by one.

The power_allocator_bind can be called without 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: a3cd6db4cc2e ("thermal: gov_power_allocator: Support new update callback of weights")
Signed-off-by: Yu-Che Cheng <giver@xxxxxxxxxxxx>

Applied as 6.14-rc material with some minor edits in the changelog.

Lukasz, if you have any objections, please let me know.

My apologies for the delay. Thanks Rafael for taking this into your
tree.

No objections, thanks Yu-Che for the fix.

The code looks good and if it's not too late then:

Reviewed-by: Lukasz Luba <lukasz.luba@xxxxxxx>

Regards,
Lukasz