From 602c233f65a04c2cb2ac37f38c80aa02320ea0b6 Mon Sep 17 00:00:00 2001 From: Di Shen Date: Thu, 31 Mar 2022 16:20:18 +0800 Subject: [PATCH] ANDROID: thermal: Add a flag for vendor hook enable_thermal_power_throt- tle MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Taking in account of SoC's surface temperature, we have to use more str- ict temperature control to make IPA can monitor and mitigate temperature control earlier and faster. It means power budget will be overridden wi- th a more strict one(user power budget). So add an override flag. It is not the same as "enable" flag. Originally, whether the IPA turns on or not depends on whether the temperature exceeds switch_on_temp,the- refore add "enable" flag. About enable flag: true: enable IPA control when temperature >= swtich_on_temp false: disable IPA control when temperature < switch_on_temp Now in order not to affect the original logic, add flag "override". About override flag: true: power budget is overridden by user power budget, and then thermal power throttle takes action even if temperature < switch_on_temp. false: power budget is not overridden, there's no other thermal requirm- ent. Normal temperature control. Bug: 209386157 Signed-off-by: Di Shen Change-Id: Ia9bbded636809d89d90a330df302391a5f4b3f5a --- drivers/thermal/gov_power_allocator.c | 18 +++++++++++++++--- include/trace/hooks/thermal.h | 4 ++-- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/drivers/thermal/gov_power_allocator.c b/drivers/thermal/gov_power_allocator.c index ae9042c7f7b0..1f47321ee769 100644 --- a/drivers/thermal/gov_power_allocator.c +++ b/drivers/thermal/gov_power_allocator.c @@ -714,7 +714,8 @@ 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; - int enable = 1; + bool enable = true; + bool override = false; /* * We get called for every trip point but we only need to do @@ -723,11 +724,22 @@ 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); + /* + * Enable or disable IPA control by temperature and user power budget. + * About enable: + * true: enable IPA control when temperature >= swtich_on_temp. + * false: disable IPA control when temperature < switch_on_temp. + * About override: + * true: power budget is overridden by user power budget. + * false: power budget is not overridden, there's no other thermal + * requirement. + */ + trace_android_vh_enable_thermal_power_throttle(&enable, &override); if (enable) ret = tz->ops->get_trip_temp(tz, params->trip_switch_on, &switch_on_temp); - if (!enable || (!ret && (tz->temperature < switch_on_temp))) { + if (!enable || (!ret && (tz->temperature < switch_on_temp) && + !override)) { 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 31127ee42718..1539adb571e2 100644 --- a/include/trace/hooks/thermal.h +++ b/include/trace/hooks/thermal.h @@ -27,8 +27,8 @@ DECLARE_HOOK(android_vh_thermal_unregister, TP_ARGS(policy)); DECLARE_HOOK(android_vh_enable_thermal_power_throttle, - TP_PROTO(int *enable), - TP_ARGS(enable)); + TP_PROTO(bool *enable, bool *override), + TP_ARGS(enable, override)); DECLARE_HOOK(android_vh_thermal_power_cap, TP_PROTO(u32 *power_range),