Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c0537729 authored by Harshdeep Dhatt's avatar Harshdeep Dhatt
Browse files

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: default avatarHarshdeep Dhatt <hdhatt@codeaurora.org>
parent 7eaf07a0
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -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;
+11 −11
Original line number Diff line number Diff line
@@ -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;
	}