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

Commit 634bfdaa authored by Lina Iyer's avatar Lina Iyer Committed by Gerrit - the friendly Code Review server
Browse files

drivers: cpuidle: lpm-levels: respect CPU bias



Avoid waking up early from deep sleep modes by looking up to scheduler
to know if the CPU was busy in the past. If the past was within the
hysteresis then choose a shallowest sleep mode.

Change-Id: Ide119c6f8c948cf595facf0d5f03b10889e8f773
Signed-off-by: default avatarLina Iyer <ilina@codeaurora.org>
parent 271e314b
Loading
Loading
Loading
Loading
+18 −0
Original line number Original line Diff line number Diff line
@@ -55,6 +55,7 @@
#define SCLK_HZ (32768)
#define SCLK_HZ (32768)
#define PSCI_POWER_STATE(reset) (reset << 30)
#define PSCI_POWER_STATE(reset) (reset << 30)
#define PSCI_AFFINITY_LEVEL(lvl) ((lvl & 0x3) << 24)
#define PSCI_AFFINITY_LEVEL(lvl) ((lvl & 0x3) << 24)
#define BIAS_HYST (5 * NSEC_PER_MSEC)


enum {
enum {
	MSM_LPM_LVL_DBG_SUSPEND_LIMITS = BIT(0),
	MSM_LPM_LVL_DBG_SUSPEND_LIMITS = BIT(0),
@@ -572,6 +573,17 @@ static void clear_predict_history(void)


static void update_history(struct cpuidle_device *dev, int idx);
static void update_history(struct cpuidle_device *dev, int idx);


static inline bool is_cpu_biased(int cpu)
{
	u64 now = sched_clock();
	u64 last = sched_get_cpu_last_busy_time(cpu);

	if (!last)
		return false;

	return (now - last) < BIAS_HYST;
}

static int cpu_power_select(struct cpuidle_device *dev,
static int cpu_power_select(struct cpuidle_device *dev,
		struct lpm_cpu *cpu)
		struct lpm_cpu *cpu)
{
{
@@ -596,6 +608,11 @@ static int cpu_power_select(struct cpuidle_device *dev,


	next_event_us = (uint32_t)(ktime_to_us(get_next_event_time(dev->cpu)));
	next_event_us = (uint32_t)(ktime_to_us(get_next_event_time(dev->cpu)));


	if (is_cpu_biased(dev->cpu)) {
		best_level = 0;
		goto done_select;
	}

	for (i = 0; i < cpu->nlevels; i++) {
	for (i = 0; i < cpu->nlevels; i++) {
		struct lpm_cpu_level *level = &cpu->levels[i];
		struct lpm_cpu_level *level = &cpu->levels[i];
		struct power_params *pwr_params = &level->pwr;
		struct power_params *pwr_params = &level->pwr;
@@ -674,6 +691,7 @@ static int cpu_power_select(struct cpuidle_device *dev,
			histtimer_start(htime);
			histtimer_start(htime);
	}
	}


done_select:
	trace_cpu_power_select(best_level, sleep_us, latency_us, next_event_us);
	trace_cpu_power_select(best_level, sleep_us, latency_us, next_event_us);


	trace_cpu_pred_select(idx_restrict_time ? 2 : (predicted ? 1 : 0),
	trace_cpu_pred_select(idx_restrict_time ? 2 : (predicted ? 1 : 0),