thermal: gov_bang_bang: Use governor_data to reduce overhead
authorRafael J. Wysocki <rafael.j.wysocki@intel.com>
Tue, 13 Aug 2024 14:29:11 +0000 (16:29 +0200)
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>
Fri, 16 Aug 2024 11:13:59 +0000 (13:13 +0200)
commit6e6f58a170ea98e44075b761f2da42a5aec47dfb
tree9737c20afa4430d792cd6028d15f8ed2a4e37b28
parent5f64b4a1ab1b0412446d42e1fc2964c2cdb60b27
thermal: gov_bang_bang: Use governor_data to reduce overhead

After running once, the for_each_trip_desc() loop in
bang_bang_manage() is pure needless overhead because it is not going to
make any changes unless a new cooling device has been bound to one of
the trips in the thermal zone or the system is resuming from sleep.

For this reason, make bang_bang_manage() set governor_data for the
thermal zone and check it upfront to decide whether or not it needs to
do anything.

However, governor_data needs to be reset in some cases to let
bang_bang_manage() know that it should walk the trips again, so add an
.update_tz() callback to the governor and make the core additionally
invoke it during system resume.

To avoid affecting the other users of that callback unnecessarily, add
a special notification reason for system resume, THERMAL_TZ_RESUME, and
also pass it to __thermal_zone_device_update() called during system
resume for consistency.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Peter Kästle <peter@piie.net>
Reviewed-by: Zhang Rui <rui.zhang@intel.com>
Cc: 6.10+ <stable@vger.kernel.org> # 6.10+
Link: https://patch.msgid.link/2285575.iZASKD2KPV@rjwysocki.net
drivers/thermal/gov_bang_bang.c
drivers/thermal/thermal_core.c
include/linux/thermal.h