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

Commit 6a669177 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: kgsl: Replace jiffy sampling with usec"

parents 13c375eb e46c9cf4
Loading
Loading
Loading
Loading
+17 −16
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ void kgsl_pwrscale_sleep(struct kgsl_device *device)
	BUG_ON(!mutex_is_locked(&device->mutex));
	if (!device->pwrscale.enabled)
		return;
	device->pwrscale.time = device->pwrscale.on_time = 0;
	device->pwrscale.on_time = 0;

	/* to call devfreq_suspend_device() from a kernel thread */
	queue_work(device->pwrscale.devfreq_wq,
@@ -61,26 +61,25 @@ EXPORT_SYMBOL(kgsl_pwrscale_sleep);
void kgsl_pwrscale_wake(struct kgsl_device *device)
{
	struct kgsl_power_stats stats;
	struct kgsl_pwrscale *psc = &device->pwrscale;
	BUG_ON(!mutex_is_locked(&device->mutex));

	if (!device->pwrscale.enabled)
		return;
	/* clear old stats before waking */
	memset(&device->pwrscale.accum_stats, 0,
		sizeof(device->pwrscale.accum_stats));
	memset(&psc->accum_stats, 0, sizeof(psc->accum_stats));
	memset(&last_xstats, 0, sizeof(last_xstats));

	/* and any hw activity from waking up*/
	device->ftbl->power_stats(device, &stats);

	device->pwrscale.time = ktime_to_us(ktime_get());
	psc->time = ktime_get();

	device->pwrscale.next_governor_call = jiffies +
			msecs_to_jiffies(KGSL_GOVERNOR_CALL_INTERVAL);
	psc->next_governor_call = ktime_add_us(psc->time,
			KGSL_GOVERNOR_CALL_INTERVAL);

	/* to call devfreq_resume_device() from a kernel thread */
	queue_work(device->pwrscale.devfreq_wq,
		&device->pwrscale.devfreq_resume_ws);
	queue_work(psc->devfreq_wq, &psc->devfreq_resume_ws);
}
EXPORT_SYMBOL(kgsl_pwrscale_wake);

@@ -133,16 +132,18 @@ EXPORT_SYMBOL(kgsl_pwrscale_update_stats);
 */
void kgsl_pwrscale_update(struct kgsl_device *device)
{
	ktime_t t;
	BUG_ON(!mutex_is_locked(&device->mutex));

	if (!device->pwrscale.enabled)
		return;

	if (time_before(jiffies, device->pwrscale.next_governor_call))
	t = ktime_get();
	if (ktime_compare(t, device->pwrscale.next_governor_call) < 0)
		return;

	device->pwrscale.next_governor_call = jiffies
			+ msecs_to_jiffies(KGSL_GOVERNOR_CALL_INTERVAL);
	device->pwrscale.next_governor_call = ktime_add_us(t,
			KGSL_GOVERNOR_CALL_INTERVAL);

	/* to call srcu_notifier_call_chain() from a kernel thread */
	if (device->state != KGSL_STATE_SLUMBER)
@@ -286,7 +287,7 @@ int kgsl_devfreq_get_dev_status(struct device *dev,
	struct kgsl_device *device = dev_get_drvdata(dev);
	struct kgsl_pwrctrl *pwrctrl;
	struct kgsl_pwrscale *pwrscale;
	s64 tmp;
	ktime_t tmp;

	if (device == NULL)
		return -ENODEV;
@@ -304,8 +305,8 @@ int kgsl_devfreq_get_dev_status(struct device *dev,
	 */
	kgsl_pwrscale_update_stats(device);

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

	stat->busy_time = pwrscale->accum_stats.busy_time;
@@ -606,8 +607,8 @@ int kgsl_pwrscale_init(struct device *dev, const char *governor)
	INIT_WORK(&pwrscale->devfreq_resume_ws, do_devfreq_resume);
	INIT_WORK(&pwrscale->devfreq_notify_ws, do_devfreq_notify);

	pwrscale->next_governor_call = jiffies +
			msecs_to_jiffies(KGSL_GOVERNOR_CALL_INTERVAL);
	pwrscale->next_governor_call = ktime_add_us(ktime_get(),
			KGSL_GOVERNOR_CALL_INTERVAL);

	return 0;
}
+4 −4
Original line number Diff line number Diff line
@@ -17,8 +17,8 @@
#include <linux/devfreq.h>
#include <linux/msm_adreno_devfreq.h>

/* devfreq governor call window in msec */
#define KGSL_GOVERNOR_CALL_INTERVAL 5
/* devfreq governor call window in usec */
#define KGSL_GOVERNOR_CALL_INTERVAL 10000

struct kgsl_power_stats {
	u64 busy_time;
@@ -34,14 +34,14 @@ struct kgsl_pwrscale {
	char last_governor[DEVFREQ_NAME_LEN];
	struct kgsl_power_stats accum_stats;
	bool enabled;
	s64 time;
	ktime_t time;
	s64 on_time;
	struct srcu_notifier_head nh;
	struct workqueue_struct *devfreq_wq;
	struct work_struct devfreq_suspend_ws;
	struct work_struct devfreq_resume_ws;
	struct work_struct devfreq_notify_ws;
	unsigned long next_governor_call;
	ktime_t next_governor_call;
};

int kgsl_pwrscale_init(struct device *dev, const char *governor);