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]: 24c14876d8

Change-Id: I98be2f909b63e5fb3426a74ddb5f0412ecbc5a00
Signed-off-by: dlwlrma123 <alexfinhart@gmail.com>
Signed-off-by: Richard Raya <rdxzv.dev@gmail.com>
This commit is contained in:
dlwlrma123 2021-11-27 10:21:13 +08:00 committed by Richard Raya
parent 730ec39514
commit dd28c35979

View File

@ -21,7 +21,6 @@
#include <linux/mm.h>
#include <linux/msm_adreno_devfreq.h>
#include <asm/cacheflush.h>
#include <drm/drm_refresh_rate.h>
#include <soc/qcom/scm.h>
#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[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;