From e3a72785daf6fba453eafb39f348494c76d00b0a Mon Sep 17 00:00:00 2001 From: Di Shen Date: Wed, 28 Jun 2023 13:45:02 +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 Signed-off-by: Di Shen Change-Id: If9c53a9669eec8e2821d837cfa3c660a9cfbf934 (cherry picked from commit 64999249d5fecc79805fd799bdf71bc5b554efc1) --- drivers/android/vendor_hooks.c | 1 + drivers/thermal/gov_power_allocator.c | 5 ++++- include/trace/hooks/thermal.h | 4 ++++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/drivers/android/vendor_hooks.c b/drivers/android/vendor_hooks.c index 37aa4bba1726..badd371e142d 100644 --- a/drivers/android/vendor_hooks.c +++ b/drivers/android/vendor_hooks.c @@ -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); diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index 5471c9091f5f..b851d7cf0968 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -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); diff --git a/include/trace/hooks/thermal.h b/include/trace/hooks/thermal.h index dd42f1d6766a..3e928aa1920d 100644 --- a/include/trace/hooks/thermal.h +++ b/include/trace/hooks/thermal.h @@ -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