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

Commit 763cf29b authored by Maulik Shah's avatar Maulik Shah
Browse files

cpuidle: lpm-levels: Reorganize code to calculate next wakeup



Add new inline function to calculate next wakeup.

Change-Id: Iaa17563597cf794966cc0e89159a1d8b257fa6dd
Signed-off-by: default avatarMaulik Shah <mkshah@codeaurora.org>
parent bc904ccd
Loading
Loading
Loading
Loading
+17 −7
Original line number Diff line number Diff line
@@ -636,6 +636,21 @@ static inline bool lpm_disallowed(s64 sleep_us, int cpu, struct lpm_cpu *pm_cpu)
	return false;
}

static void calculate_next_wakeup(uint32_t *next_wakeup_us,
				  uint32_t next_event_us,
				  uint32_t lvl_latency_us,
				  s64 sleep_us)
{
	if (!next_event_us)
		return;

	if (next_event_us < lvl_latency_us)
		return;

	if (next_event_us < sleep_us)
		*next_wakeup_us = next_event_us - lvl_latency_us;
}

static int cpu_power_select(struct cpuidle_device *dev,
		struct lpm_cpu *cpu)
{
@@ -672,13 +687,8 @@ static int cpu_power_select(struct cpuidle_device *dev,
		if (latency_us < lvl_latency_us)
			break;

		if (next_event_us) {
			if (next_event_us < lvl_latency_us)
				break;

			if (next_event_us < sleep_us)
				next_wakeup_us = next_event_us - lvl_latency_us;
		}
		calculate_next_wakeup(&next_wakeup_us, next_event_us,
				      lvl_latency_us, sleep_us);

		if (!i && !cpu_isolated(dev->cpu)) {
			/*