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

Commit a671226a authored by Maulik Shah's avatar Maulik Shah
Browse files

drivers: cpuidle: Minimize round off errors in wake up time



Current implementation adds more delay in wake up time programmed
due to round off errors. Minimize round off errors in calculation.

Change-Id: Iddb19c6dae79c999de9fae444f0c64aac0500f42
Signed-off-by: default avatarMaulik Shah <mkshah@codeaurora.org>
parent 726d5dfb
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
/* Copyright (c) 2012-2016, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -653,6 +653,8 @@ static int cluster_configure(struct lpm_cluster *cluster, int idx,
	if (level->notify_rpm) {
		struct cpumask nextcpu, *cpumask;
		uint64_t us;
		uint64_t sec;
		uint64_t nsec;

		us = get_cluster_sleep_time(cluster, &nextcpu, from_idle);
		cpumask = level->disable_dynamic_routing ? NULL : &nextcpu;
@@ -663,8 +665,17 @@ static int cluster_configure(struct lpm_cluster *cluster, int idx,
			goto failed_set_mode;
		}

		us = (us + 1) * 1000;
		do_div(us, NSEC_PER_SEC/SCLK_HZ);
		us = us + 1;
		sec = us;
		do_div(sec, USEC_PER_SEC);
		nsec = us - sec * USEC_PER_SEC;

		sec = sec * SCLK_HZ;
		if (nsec > 0) {
			nsec = nsec * NSEC_PER_USEC;
			do_div(nsec, NSEC_PER_SEC/SCLK_HZ);
		}
		us = sec + nsec;
		msm_mpm_enter_sleep(us, from_idle, cpumask);

		if (cluster->no_saw_devices && !use_psci)