From c05377299bc802d38d8e9134ef8c313a3b58c8fc Mon Sep 17 00:00:00 2001 From: Harshdeep Dhatt Date: Tue, 9 Jul 2019 19:35:49 -0600 Subject: [PATCH] devfreq: Use devfreq_update_stats for gpu governors This is the recommended way of using the devfreq api from within governors. The devfreq_update_stats() will utilize the devfreq.last_status to get the target device status so we no longer need to declare a local variable to get the target status. Change-Id: I5d80e39468e3eb90e55dcb0a813cb846a65ee8a5 Signed-off-by: Harshdeep Dhatt --- drivers/devfreq/governor_gpubw_mon.c | 14 +++++++------- drivers/devfreq/governor_msm_adreno_tz.c | 22 +++++++++++----------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/drivers/devfreq/governor_gpubw_mon.c b/drivers/devfreq/governor_gpubw_mon.c index e3087a73a4ca..c07f6a118351 100644 --- a/drivers/devfreq/governor_gpubw_mon.c +++ b/drivers/devfreq/governor_gpubw_mon.c @@ -53,7 +53,7 @@ static int devfreq_gpubw_get_target(struct devfreq *df, (df->profile), struct msm_busmon_extended_profile, profile); - struct devfreq_dev_status stats; + struct devfreq_dev_status *stats = &df->last_status; struct xstats b; int result; int level = 0; @@ -73,18 +73,18 @@ static int devfreq_gpubw_get_target(struct devfreq *df, if (priv == NULL) return 0; - stats.private_data = &b; + stats->private_data = &b; - result = df->profile->get_dev_status(df->dev.parent, &stats); + result = devfreq_update_stats(df); - *freq = stats.current_frequency; + *freq = stats->current_frequency; - priv->bus.total_time += stats.total_time; - priv->bus.gpu_time += stats.busy_time; + priv->bus.total_time += stats->total_time; + priv->bus.gpu_time += stats->busy_time; priv->bus.ram_time += b.ram_time; priv->bus.ram_wait += b.ram_wait; - level = devfreq_get_freq_level(df, stats.current_frequency); + level = devfreq_get_freq_level(df, stats->current_frequency); if (priv->bus.total_time < LONG_FLOOR) return result; diff --git a/drivers/devfreq/governor_msm_adreno_tz.c b/drivers/devfreq/governor_msm_adreno_tz.c index 8b6c942fa49d..ae4bfc2ffe4b 100644 --- a/drivers/devfreq/governor_msm_adreno_tz.c +++ b/drivers/devfreq/governor_msm_adreno_tz.c @@ -361,42 +361,42 @@ static int tz_get_target_freq(struct devfreq *devfreq, unsigned long *freq) { int result = 0; struct devfreq_msm_adreno_tz_data *priv = devfreq->data; - struct devfreq_dev_status stats; + struct devfreq_dev_status *stats = &devfreq->last_status; int val, level = 0; unsigned int scm_data[4]; int context_count = 0; /* keeps stats.private_data == NULL */ - result = devfreq->profile->get_dev_status(devfreq->dev.parent, &stats); + result = devfreq_update_stats(devfreq); if (result) { pr_err(TAG "get_status failed %d\n", result); return result; } - *freq = stats.current_frequency; - priv->bin.total_time += stats.total_time; - priv->bin.busy_time += stats.busy_time; + *freq = stats->current_frequency; + priv->bin.total_time += stats->total_time; + priv->bin.busy_time += stats->busy_time; - if (stats.private_data) - context_count = *((int *)stats.private_data); + if (stats->private_data) + context_count = *((int *)stats->private_data); /* Update the GPU load statistics */ - compute_work_load(&stats, priv, devfreq); + compute_work_load(stats, priv, devfreq); /* * Do not waste CPU cycles running this algorithm if * the GPU just started, or if less than FLOOR time * has passed since the last run or the gpu hasn't been * busier than MIN_BUSY. */ - if ((stats.total_time == 0) || + if ((stats->total_time == 0) || (priv->bin.total_time < FLOOR) || (unsigned int) priv->bin.busy_time < MIN_BUSY) { return 0; } - level = devfreq_get_freq_level(devfreq, stats.current_frequency); + level = devfreq_get_freq_level(devfreq, stats->current_frequency); if (level < 0) { - pr_err(TAG "bad freq %ld\n", stats.current_frequency); + pr_err(TAG "bad freq %ld\n", stats->current_frequency); return level; }