Commit 92ce5c07 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

cpuidle: teo: Reorder candidate state index checks



Since constraint_idx may be 0, the candidate state index may change to 0
after assigning constraint_idx to it, so first check if it is greater
than constraint_idx (and update it if so) and then check it against 0.

Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: default avatarChristian Loehle <christian.loehle@arm.com>
Tested-by: default avatarAboorva Devarajan <aboorvad@linux.ibm.com>
Tested-by: default avatarChristian Loehle <christian.loehle@arm.com>
Link: https://patch.msgid.link/1907276.tdWV9SEqCh@rjwysocki.net
parent 425b7536
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -428,6 +428,14 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
				break;
		}
	}

	/*
	 * If there is a latency constraint, it may be necessary to select an
	 * idle state shallower than the current candidate one.
	 */
	if (idx > constraint_idx)
		idx = constraint_idx;

	if (!idx && prev_intercept_idx) {
		/*
		 * We have to query the sleep length here otherwise we don't
@@ -438,13 +446,6 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
		goto out_tick;
	}

	/*
	 * If there is a latency constraint, it may be necessary to select an
	 * idle state shallower than the current candidate one.
	 */
	if (idx > constraint_idx)
		idx = constraint_idx;

	/*
	 * Skip the timers check if state 0 is the current candidate one,
	 * because an immediate non-timer wakeup is expected in that case.