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

Merge branch 'pm-cpuidle'

Merge cpuidle fixes for 5.18-rc5:

 - Make intel_idle enable C1E promotion on all CPUs when C1E is
   preferred to C1 (Artem Bityutskiy).

 - Make C6 optimization on Sapphire Rapids added recently work as
   expected if both C1E and C1 are "preferred" (Artem Bityutskiy).

* pm-cpuidle:
  intel_idle: Fix SPR C6 optimization
  intel_idle: Fix the 'preferred_cstates' module parameter
parents 0f03610b 7eac3bd3
Loading
Loading
Loading
Loading
+15 −12
Original line number Diff line number Diff line
@@ -69,7 +69,12 @@ static unsigned int preferred_states_mask;
static struct cpuidle_device __percpu *intel_idle_cpuidle_devices;

static unsigned long auto_demotion_disable_flags;
static bool disable_promotion_to_c1e;

static enum {
	C1E_PROMOTION_PRESERVE,
	C1E_PROMOTION_ENABLE,
	C1E_PROMOTION_DISABLE
} c1e_promotion = C1E_PROMOTION_PRESERVE;

struct idle_cpu {
	struct cpuidle_state *state_table;
@@ -1398,8 +1403,6 @@ static inline void intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) { }
static inline bool intel_idle_off_by_default(u32 mwait_hint) { return false; }
#endif /* !CONFIG_ACPI_PROCESSOR_CSTATE */

static void c1e_promotion_enable(void);

/**
 * ivt_idle_state_table_update - Tune the idle states table for Ivy Town.
 *
@@ -1578,17 +1581,14 @@ static void __init spr_idle_state_table_update(void)
	unsigned long long msr;

	/* Check if user prefers C1E over C1. */
	if (preferred_states_mask & BIT(2)) {
		if (preferred_states_mask & BIT(1))
			/* Both can't be enabled, stick to the defaults. */
			return;

	if ((preferred_states_mask & BIT(2)) &&
	    !(preferred_states_mask & BIT(1))) {
		/* Disable C1 and enable C1E. */
		spr_cstates[0].flags |= CPUIDLE_FLAG_UNUSABLE;
		spr_cstates[1].flags &= ~CPUIDLE_FLAG_UNUSABLE;

		/* Enable C1E using the "C1E promotion" bit. */
		c1e_promotion_enable();
		disable_promotion_to_c1e = false;
		c1e_promotion = C1E_PROMOTION_ENABLE;
	}

	/*
@@ -1754,7 +1754,9 @@ static int intel_idle_cpu_init(unsigned int cpu)
	if (auto_demotion_disable_flags)
		auto_demotion_disable();

	if (disable_promotion_to_c1e)
	if (c1e_promotion == C1E_PROMOTION_ENABLE)
		c1e_promotion_enable();
	else if (c1e_promotion == C1E_PROMOTION_DISABLE)
		c1e_promotion_disable();

	return 0;
@@ -1833,7 +1835,8 @@ static int __init intel_idle_init(void)
	if (icpu) {
		cpuidle_state_table = icpu->state_table;
		auto_demotion_disable_flags = icpu->auto_demotion_disable_flags;
		disable_promotion_to_c1e = icpu->disable_promotion_to_c1e;
		if (icpu->disable_promotion_to_c1e)
			c1e_promotion = C1E_PROMOTION_DISABLE;
		if (icpu->use_acpi || force_use_acpi)
			intel_idle_acpi_cst_extract();
	} else if (!intel_idle_acpi_cst_extract()) {