ANDROID: thermal: Add hook to enable/disable thermal power throttle

By default, thermal power throttle is always enable, but sometimes it
need to be disabled for a period of time, so add it to meet platform
thermal requirement.

Bug: 209386157

Signed-off-by: Jeson Gao <jeson.gao@unisoc.com>
Signed-off-by: Di Shen <di.shen@unisoc.com>
Change-Id: If9c53a9669eec8e2821d837cfa3c660a9cfbf934
(cherry picked from commit 64999249d5fecc79805fd799bdf71bc5b554efc1)
This commit is contained in:
Di Shen 2023-06-28 13:45:02 +08:00 committed by Treehugger Robot
parent 05ba0cb850
commit e3a72785da
3 changed files with 9 additions and 1 deletions

View File

@ -291,6 +291,7 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_thermal_register);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_thermal_unregister);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_get_thermal_zone_device);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_thermal_power_cap);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_power_throttle);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_reclaim_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_alloc_pages_failure_bypass);
EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_madvise_pageout_swap_entry);

View File

@ -704,6 +704,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
int switch_on_temp, control_temp;
struct power_allocator_params *params = tz->governor_data;
bool update;
bool enable = true;
lockdep_assert_held(&tz->lock);
@ -714,9 +715,11 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip)
if (trip != params->trip_max_desired_temperature)
return 0;
trace_android_vh_enable_thermal_power_throttle(&enable);
ret = tz->ops->get_trip_temp(tz, params->trip_switch_on,
&switch_on_temp);
if (!ret && (tz->temperature < switch_on_temp)) {
if ((!ret && (tz->temperature < switch_on_temp)) || !enable) {
update = (tz->last_temperature >= switch_on_temp);
tz->passive = 0;
reset_pid_controller(params);

View File

@ -48,6 +48,10 @@ DECLARE_HOOK(android_vh_thermal_power_cap,
TP_PROTO(u32 *power_range),
TP_ARGS(power_range));
DECLARE_HOOK(android_vh_enable_thermal_power_throttle,
TP_PROTO(bool *enable),
TP_ARGS(enable));
#endif /* _TRACE_HOOK_THERMAL_H */
/* This part must be outside protection */
#include <trace/define_trace.h>