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

Commit b4a0c3d1 authored by Lina Iyer's avatar Lina Iyer
Browse files

drivers: cpuidle: lpm-levels: Fix KW issues with idle state idx < 0



Idle state calculcations will need to return the state chosen as an
integer. The state chosen is used as a index into the array and as such
cannot be negative value. Do not return negative errors from the
calculations. By default, the state returned wil be zero.

Change-Id: Idb18e933f385cf868fe99fa6a2783f6b8e84c196
Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
parent 9b5c8a26
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -568,7 +568,7 @@ static void update_history(struct cpuidle_device *dev, int idx);
static int cpu_power_select(struct cpuidle_device *dev,
		struct lpm_cpu *cpu)
{
	int best_level = -1;
	int best_level = 0;
	uint32_t latency_us = pm_qos_request_for_cpu(PM_QOS_CPU_DMA_LATENCY,
							dev->cpu);
	s64 sleep_us = ktime_to_us(tick_nohz_get_sleep_length());
@@ -582,9 +582,6 @@ static int cpu_power_select(struct cpuidle_device *dev,
	uint32_t *min_residency = get_per_cpu_min_residency(dev->cpu);
	uint32_t *max_residency = get_per_cpu_max_residency(dev->cpu);

	if (!cpu)
		return -EINVAL;

	if (sleep_disabled || sleep_us < 0)
		return 0;

@@ -1293,17 +1290,11 @@ static int lpm_cpuidle_select(struct cpuidle_driver *drv,
		struct cpuidle_device *dev)
{
	struct lpm_cpu *cpu = per_cpu(cpu_lpm, dev->cpu);
	int idx;

	if (!cpu)
		return 0;

	idx = cpu_power_select(dev, cpu);

	if (idx < 0)
		return 0;

	return idx;
	return cpu_power_select(dev, cpu);
}

static void update_history(struct cpuidle_device *dev, int idx)
@@ -1358,7 +1349,7 @@ static int lpm_cpuidle_enter(struct cpuidle_device *dev,
	trace_cpu_idle_enter(idx);
	lpm_stats_cpu_enter(idx, start_time);

	if (need_resched() || (idx < 0))
	if (need_resched())
		goto exit;

	success = psci_enter_sleep(cpu, idx, true);