From dd28c3597989cfe0981e0436e188b8b5ae9de108 Mon Sep 17 00:00:00 2001 From: dlwlrma123 Date: Sat, 27 Nov 2021 10:21:13 +0800 Subject: [PATCH] adreno_tz: Adjust GPU target frequency calculation * based from [1], here we finetune the logic by adding a min_busy condition so that we will only upscale when FLOOR is exceeded (for power consumption). * ratio: by increasing initial load + the quotient of the 120(max refresh)/60 ratio, so that this will definitely act as boost (which is needed for HFR/heavy load situations). * 90hz ratio is used for conditions below FLOOR value [1]: https://github.com/KasaOS/KASA_Surya/commit/24c14876d80d091fa183a76fbd4f3a64402e6048 Change-Id: I98be2f909b63e5fb3426a74ddb5f0412ecbc5a00 Signed-off-by: dlwlrma123 Signed-off-by: Richard Raya --- drivers/devfreq/governor_msm_adreno_tz.c | 38 ++++++++---------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/drivers/devfreq/governor_msm_adreno_tz.c b/drivers/devfreq/governor_msm_adreno_tz.c index fb85cacdea96..a5e97c8b3c35 100644 --- a/drivers/devfreq/governor_msm_adreno_tz.c +++ b/drivers/devfreq/governor_msm_adreno_tz.c @@ -21,7 +21,6 @@ #include #include #include -#include #include #include "governor.h" @@ -30,18 +29,13 @@ static DEFINE_SPINLOCK(tz_lock); * FLOOR is 5msec to capture up to 3 re-draws * per frame for 60fps content. */ -#define FLOOR 5000 +#define FLOOR 3350 /* * MIN_BUSY is 1 msec for the sample to be sent */ #define MIN_BUSY 1000 #define MAX_TZ_VERSION 0 -/* - * CEILING is 50msec, larger than any standard - * frame length, but less than the idle timer. - */ -#define CEILING 50000 #define TZ_RESET_ID 0x3 #define TZ_UPDATE_ID 0x4 #define TZ_INIT_ID 0x6 @@ -346,7 +340,12 @@ static int tz_get_target_freq(struct devfreq *devfreq, unsigned long *freq) *freq = stats.current_frequency; priv->bin.total_time += stats.total_time; - priv->bin.busy_time += stats.busy_time; + + if ((unsigned int)(priv->bin.busy_time + stats.busy_time) >= FLOOR) { + priv->bin.busy_time += stats.busy_time * 4; + } else { + priv->bin.busy_time += stats.busy_time * 4 / 2; + } if (stats.private_data) context_count = *((int *)stats.private_data); @@ -371,23 +370,12 @@ static int tz_get_target_freq(struct devfreq *devfreq, unsigned long *freq) return level; } - /* - * If there is an extended block of busy processing, - * increase frequency. Otherwise run the normal algorithm. - */ - if (!priv->disable_busy_time_burst && - priv->bin.busy_time > CEILING) { - val = -1 * level; - } else { - unsigned int refresh_rate = dsi_panel_get_refresh_rate(); - - scm_data[0] = level; - scm_data[1] = priv->bin.total_time; - scm_data[2] = priv->bin.busy_time * refresh_rate / 30; - scm_data[3] = context_count; - __secure_tz_update_entry3(scm_data, sizeof(scm_data), - &val, sizeof(val), priv); - } + scm_data[0] = level; + scm_data[1] = priv->bin.total_time; + scm_data[2] = priv->bin.busy_time; + scm_data[3] = context_count; + __secure_tz_update_entry3(scm_data, sizeof(scm_data), + &val, sizeof(val), priv); priv->bin.total_time = 0; priv->bin.busy_time = 0;