BACKPORT: FROMLIST: thermal/core/power_allocator: avoid thermal cdev can not be reset
Commit 0952177f ("thermal/core/power_allocator: Update once cooling devices when temp is low") adds a update flag to avoid the thermal event is triggered when there is no need, and thermal cdev would be update once when temperature is low. But when the trips are writable, and switch_on_temp is set to be a higher value, the cooling device state may not be reset to 0, because last_temperature is smaller than the switch_on_temp. For example: First: switch_on_temp=70 control_temp=85; Then userspace change the trip_temp: switch_on_temp=45 control_temp=55 cur_temp=54 Then userspace reset the trip_temp: switch_on_temp=70 control_temp=85 cur_temp=57 last_temp=54 At this time, the cooling device state should be reset to 0. However, because cur_temp(57) < switch_on_temp(70) last_temp(54) < switch_on_temp(70) ----> update = false, update is false, the cooling device state can not be reset. This patch adds a function thermal_cdev_needs_update() to renew the update flag value only when the trips are writable, so that thermal cdev->state can be reset after switch_on_temp changed from low to high. Fixes: 0952177f ("thermal/core/power_allocator: Update once cooling devices when temp is low") Signed-off-by:Di Shen <di.shen@unisoc.com> Reviewed-by:
Lukasz Luba <lukasz.luba@arm.com> Bug: 280955449 Link: https://lore.kernel.org/all/20230320095620.7480-1-di.shen@unisoc.com/ Link: https://lore.kernel.org/all/6055bc39-5c00-d12f-b5c3-fa21a9649d63@arm.com/ Change-Id: I4fc510da0cf16a10b3dc449db3c4cd12233d4e23 Signed-off-by:
Di Shen <di.shen@unisoc.com> [ resolved minor conflict in drivers/thermal/gov_power_allocator.c ]
Loading
Please sign in to comment