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

Commit 607d0082 authored by qctecmdr's avatar qctecmdr Committed by Gerrit - the friendly Code Review server
Browse files

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

parents ceb47a0e 763cf29b
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)) {
			/*