From 64999249d5fecc79805fd799bdf71bc5b554efc1 Mon Sep 17 00:00:00 2001 From: Jeson Gao Date: Mon, 6 Dec 2021 19:06:48 +0800 Subject: [PATCH] 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 Change-Id: If9c53a9669eec8e2821d837cfa3c660a9cfbf934 --- drivers/android/vendor_hooks.c | 1 + drivers/thermal/gov_power_allocator.c | 11 ++++++++--- include/trace/hooks/thermal.h | 4 ++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index bb2f17f9a32f..3714a17963d9 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -377,3 +377,4 @@ EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_sound_usb_support_cpu_suspend); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_snd_compr_use_pause_in_drain); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_modify_thermal_request_freq); EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_modify_thermal_target_freq); +EXPORT_TRACEPOINT_SYMBOL_GPL(android_vh_enable_thermal_power_throttle); diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index ab0be26f0816..fee3a301e902 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -14,6 +14,8 @@ #define CREATE_TRACE_POINTS #include +#undef CREATE_TRACE_POINTS +#include #include "thermal_core.h" @@ -607,6 +609,7 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip) int ret; int switch_on_temp, control_temp; struct power_allocator_params *params = tz->governor_data; + int enable = 1; /* * We get called for every trip point but we only need to do @@ -615,9 +618,11 @@ static int power_allocator_throttle(struct thermal_zone_device *tz, int trip) if (trip != params->trip_max_desired_temperature) return 0; - ret = tz->ops->get_trip_temp(tz, params->trip_switch_on, - &switch_on_temp); - if (!ret && (tz->temperature < switch_on_temp)) { + trace_android_vh_enable_thermal_power_throttle(&enable); + if (enable) + ret = tz->ops->get_trip_temp(tz, params->trip_switch_on, + &switch_on_temp); + if (!enable || (!ret && (tz->temperature < switch_on_temp))) { tz->passive = 0; reset_pid_controller(params); allow_maximum_power(tz); diff --git a/include/trace/hooks/thermal.h b/include/trace/hooks/thermal.h index 97be2675f3b8..3de589459b36 100644 --- a/include/trace/hooks/thermal.h +++ b/include/trace/hooks/thermal.h @@ -27,6 +27,10 @@ DECLARE_HOOK(android_vh_modify_thermal_target_freq, TP_PROTO(struct cpufreq_policy *policy, unsigned int *target_freq), TP_ARGS(policy, target_freq)); +DECLARE_HOOK(android_vh_enable_thermal_power_throttle, + TP_PROTO(int *enable), + TP_ARGS(enable)); + #endif /* _TRACE_HOOK_THERMAL_H */ /* This part must be outside protection */ #include