Skip to content

Commit ad46e8f

Browse files
committed
Merge tag 'pm-6.12-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm
Pull power management fix from Rafael Wysocki: "Fix idle states enumeration in the intel_idle driver on platforms supporting multiple flavors of the C6 idle state (Artem Bityutskiy)" * tag 'pm-6.12-rc1-2' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: intel_idle: fix ACPI _CST matching for newer Xeon platforms
2 parents 12cc524 + 4c411cc commit ad46e8f

File tree

1 file changed

+29
-8
lines changed

1 file changed

+29
-8
lines changed

drivers/idle/intel_idle.c

+29-8
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ static unsigned int mwait_substates __initdata;
120120
*/
121121
#define CPUIDLE_FLAG_INIT_XSTATE BIT(17)
122122

123+
/*
124+
* Ignore the sub-state when matching mwait hints between the ACPI _CST and
125+
* custom tables.
126+
*/
127+
#define CPUIDLE_FLAG_PARTIAL_HINT_MATCH BIT(18)
128+
123129
/*
124130
* MWAIT takes an 8-bit "hint" in EAX "suggesting"
125131
* the C-state (top nibble) and sub-state (bottom nibble)
@@ -1043,7 +1049,8 @@ static struct cpuidle_state gnr_cstates[] __initdata = {
10431049
.name = "C6",
10441050
.desc = "MWAIT 0x20",
10451051
.flags = MWAIT2flg(0x20) | CPUIDLE_FLAG_TLB_FLUSHED |
1046-
CPUIDLE_FLAG_INIT_XSTATE,
1052+
CPUIDLE_FLAG_INIT_XSTATE |
1053+
CPUIDLE_FLAG_PARTIAL_HINT_MATCH,
10471054
.exit_latency = 170,
10481055
.target_residency = 650,
10491056
.enter = &intel_idle,
@@ -1052,7 +1059,8 @@ static struct cpuidle_state gnr_cstates[] __initdata = {
10521059
.name = "C6P",
10531060
.desc = "MWAIT 0x21",
10541061
.flags = MWAIT2flg(0x21) | CPUIDLE_FLAG_TLB_FLUSHED |
1055-
CPUIDLE_FLAG_INIT_XSTATE,
1062+
CPUIDLE_FLAG_INIT_XSTATE |
1063+
CPUIDLE_FLAG_PARTIAL_HINT_MATCH,
10561064
.exit_latency = 210,
10571065
.target_residency = 1000,
10581066
.enter = &intel_idle,
@@ -1354,15 +1362,17 @@ static struct cpuidle_state srf_cstates[] __initdata = {
13541362
{
13551363
.name = "C6S",
13561364
.desc = "MWAIT 0x22",
1357-
.flags = MWAIT2flg(0x22) | CPUIDLE_FLAG_TLB_FLUSHED,
1365+
.flags = MWAIT2flg(0x22) | CPUIDLE_FLAG_TLB_FLUSHED |
1366+
CPUIDLE_FLAG_PARTIAL_HINT_MATCH,
13581367
.exit_latency = 270,
13591368
.target_residency = 700,
13601369
.enter = &intel_idle,
13611370
.enter_s2idle = intel_idle_s2idle, },
13621371
{
13631372
.name = "C6SP",
13641373
.desc = "MWAIT 0x23",
1365-
.flags = MWAIT2flg(0x23) | CPUIDLE_FLAG_TLB_FLUSHED,
1374+
.flags = MWAIT2flg(0x23) | CPUIDLE_FLAG_TLB_FLUSHED |
1375+
CPUIDLE_FLAG_PARTIAL_HINT_MATCH,
13661376
.exit_latency = 310,
13671377
.target_residency = 900,
13681378
.enter = &intel_idle,
@@ -1744,7 +1754,7 @@ static void __init intel_idle_init_cstates_acpi(struct cpuidle_driver *drv)
17441754
}
17451755
}
17461756

1747-
static bool __init intel_idle_off_by_default(u32 mwait_hint)
1757+
static bool __init intel_idle_off_by_default(unsigned int flags, u32 mwait_hint)
17481758
{
17491759
int cstate, limit;
17501760

@@ -1761,7 +1771,15 @@ static bool __init intel_idle_off_by_default(u32 mwait_hint)
17611771
* the interesting states are ACPI_CSTATE_FFH.
17621772
*/
17631773
for (cstate = 1; cstate < limit; cstate++) {
1764-
if (acpi_state_table.states[cstate].address == mwait_hint)
1774+
u32 acpi_hint = acpi_state_table.states[cstate].address;
1775+
u32 table_hint = mwait_hint;
1776+
1777+
if (flags & CPUIDLE_FLAG_PARTIAL_HINT_MATCH) {
1778+
acpi_hint &= ~MWAIT_SUBSTATE_MASK;
1779+
table_hint &= ~MWAIT_SUBSTATE_MASK;
1780+
}
1781+
1782+
if (acpi_hint == table_hint)
17651783
return false;
17661784
}
17671785
return true;
@@ -1771,7 +1789,10 @@ static bool __init intel_idle_off_by_default(u32 mwait_hint)
17711789

17721790
static inline bool intel_idle_acpi_cst_extract(void) { return false; }
17731791
static inline void intel_idle_init_cstates_acpi(struct cpuidle_driver *drv) { }
1774-
static inline bool intel_idle_off_by_default(u32 mwait_hint) { return false; }
1792+
static inline bool intel_idle_off_by_default(unsigned int flags, u32 mwait_hint)
1793+
{
1794+
return false;
1795+
}
17751796
#endif /* !CONFIG_ACPI_PROCESSOR_CSTATE */
17761797

17771798
/**
@@ -2098,7 +2119,7 @@ static void __init intel_idle_init_cstates_icpu(struct cpuidle_driver *drv)
20982119

20992120
if ((disabled_states_mask & BIT(drv->state_count)) ||
21002121
((icpu->use_acpi || force_use_acpi) &&
2101-
intel_idle_off_by_default(mwait_hint) &&
2122+
intel_idle_off_by_default(state->flags, mwait_hint) &&
21022123
!(state->flags & CPUIDLE_FLAG_ALWAYS_ENABLE)))
21032124
state->flags |= CPUIDLE_FLAG_OFF;
21042125

0 commit comments

Comments
 (0)