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

Commit a95247f5 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 fec225ae
Loading
Loading
Loading
Loading
+13 −2
Original line number Diff line number Diff line
@@ -1123,6 +1123,8 @@ static int cluster_configure(struct lpm_cluster *cluster, int idx,
		struct cpumask nextcpu, *cpumask;
		uint64_t us;
		uint32_t pred_us;
		uint64_t sec;
		uint64_t nsec;

		us = get_cluster_sleep_time(cluster, &nextcpu,
						from_idle, &pred_us);
@@ -1134,11 +1136,20 @@ static int cluster_configure(struct lpm_cluster *cluster, int idx,
			goto failed_set_mode;
		}

		us = (us + 1) * 1000;
		clear_predict_history();
		clear_cl_predict_history();

		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);
	}