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

Commit bc55c4fd authored by Abhilash Kumar's avatar Abhilash Kumar Committed by TARKZiM
Browse files

msm: kgsl: Update total time at right place for accurate GPU busy



For calculation of busy time and total time, KGSL relies on perf
counters and CPU clock. These can be a bit out of sync and may
give GPU busy greater than 100 percent. Updating time at the right
place will give more accurate total time and will avoid crossing
100% in GPU busy calculation.

Change-Id: I3cc702492325b9dc44ea2b705e4d9014d95abd33
Signed-off-by: default avatarAbhilash Kumar <krabhi@codeaurora.org>
parent 8761d1e7
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -510,7 +510,7 @@ int kgsl_devfreq_get_dev_status(struct device *dev,
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_pwrctrl *pwrctrl;
	struct kgsl_pwrctrl *pwrctrl;
	struct kgsl_pwrscale *pwrscale;
	struct kgsl_pwrscale *pwrscale;
	ktime_t tmp;
	ktime_t tmp1, tmp2;


	if (device == NULL)
	if (device == NULL)
		return -ENODEV;
		return -ENODEV;
@@ -521,6 +521,8 @@ int kgsl_devfreq_get_dev_status(struct device *dev,
	pwrctrl = &device->pwrctrl;
	pwrctrl = &device->pwrctrl;


	mutex_lock(&device->mutex);
	mutex_lock(&device->mutex);

	tmp1 = ktime_get();
	/*
	/*
	 * If the GPU clock is on grab the latest power counter
	 * If the GPU clock is on grab the latest power counter
	 * values.  Otherwise the most recent ACTIVE values will
	 * values.  Otherwise the most recent ACTIVE values will
@@ -528,9 +530,9 @@ int kgsl_devfreq_get_dev_status(struct device *dev,
	 */
	 */
	kgsl_pwrscale_update_stats(device);
	kgsl_pwrscale_update_stats(device);


	tmp = ktime_get();
	tmp2 = ktime_get();
	stat->total_time = ktime_us_delta(tmp, pwrscale->time);
	stat->total_time = ktime_us_delta(tmp2, pwrscale->time);
	pwrscale->time = tmp;
	pwrscale->time = tmp1;


	stat->busy_time = pwrscale->accum_stats.busy_time;
	stat->busy_time = pwrscale->accum_stats.busy_time;