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

Commit 925b850c authored by Chris Redpath's avatar Chris Redpath
Browse files

ANDROID: sched/fair: Select correct capacity state for energy_diff



The util returned from group_max_util is not capped at the max util
present in the group, so it can be larger than the capacity stored in
the array. Ensure that when this happens, we always use the last entry
in the array to fetch energy from.

Tested with synthetics on Juno board.

Change-Id: I89fb52fb7e68fa3e682e308acc232596672d03f7
Signed-off-by: default avatarChris Redpath <chris.redpath@arm.com>
parent 6e9ad2f2
Loading
Loading
Loading
Loading
+8 −5
Original line number Diff line number Diff line
@@ -4712,17 +4712,20 @@ long group_norm_util(struct energy_env *eenv, struct sched_group *sg)
static int find_new_capacity(struct energy_env *eenv,
	const struct sched_group_energy * const sge)
{
	int idx;
	int idx, max_idx = sge->nr_cap_states - 1;
	unsigned long util = group_max_util(eenv);

	/* default is max_cap if we don't find a match */
	eenv->cap_idx = max_idx;

	for (idx = 0; idx < sge->nr_cap_states; idx++) {
		if (sge->cap_states[idx].cap >= util)
		if (sge->cap_states[idx].cap >= util) {
			eenv->cap_idx = idx;
			break;
		}
	}

	eenv->cap_idx = idx;

	return idx;
	return eenv->cap_idx;
}

static int group_idle_state(struct sched_group *sg)