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

Commit ac457e74 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "drivers: cpuidle: lpm-levels: respect CPU bias"

parents 076dbf04 634bfdaa
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@
#define SCLK_HZ (32768)
#define PSCI_POWER_STATE(reset) (reset << 30)
#define PSCI_AFFINITY_LEVEL(lvl) ((lvl & 0x3) << 24)
#define BIAS_HYST (5 * NSEC_PER_MSEC)

enum {
	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 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,
		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)));

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

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

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

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