Skip to content

Commit c941530

Browse files
committed
Merge: Update intel_idle to upstream v6.15
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/6660 JIRA: https://issues.redhat.com/browse/RHEL-85522 JIRA: https://issues.redhat.com/browse/RHEL-45063 Signed-off-by: David Arcari <darcari@redhat.com> Approved-by: Tony Camuso <tcamuso@redhat.com> Approved-by: Lenny Szubowicz <lszubowi@redhat.com> Approved-by: Steve Best <sbest@redhat.com> Approved-by: Mark Langsdorf <mlangsdo@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: Augusto Caringi <acaringi@redhat.com>
2 parents c82044a + d0c965e commit c941530

File tree

12 files changed

+138
-73
lines changed

12 files changed

+138
-73
lines changed

Documentation/admin-guide/pm/intel_idle.rst

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -192,11 +192,19 @@ even if they have been enumerated (see :ref:`cpu-pm-qos` in
192192
Documentation/admin-guide/pm/cpuidle.rst).
193193
Setting ``max_cstate`` to 0 causes the ``intel_idle`` initialization to fail.
194194

195-
The ``no_acpi`` and ``use_acpi`` module parameters (recognized by ``intel_idle``
196-
if the kernel has been configured with ACPI support) can be set to make the
197-
driver ignore the system's ACPI tables entirely or use them for all of the
198-
recognized processor models, respectively (they both are unset by default and
199-
``use_acpi`` has no effect if ``no_acpi`` is set).
195+
The ``no_acpi``, ``use_acpi`` and ``no_native`` module parameters are
196+
recognized by ``intel_idle`` if the kernel has been configured with ACPI
197+
support. In the case that ACPI is not configured these flags have no impact
198+
on functionality.
199+
200+
``no_acpi`` - Do not use ACPI at all. Only native mode is available, no
201+
ACPI mode.
202+
203+
``use_acpi`` - No-op in ACPI mode, the driver will consult ACPI tables for
204+
C-states on/off status in native mode.
205+
206+
``no_native`` - Work only in ACPI mode, no native mode available (ignore
207+
all custom tables).
200208

201209
The value of the ``states_off`` module parameter (0 by default) represents a
202210
list of idle states to be disabled by default in the form of a bitmask.

arch/x86/include/asm/smp.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,7 @@ void wbinvd_on_cpu(int cpu);
119119
int wbinvd_on_all_cpus(void);
120120

121121
void smp_kick_mwait_play_dead(void);
122+
void __noreturn mwait_play_dead(unsigned int eax_hint);
122123

123124
void native_smp_send_reschedule(int cpu);
124125
void native_send_call_func_ipi(const struct cpumask *mask);
@@ -169,6 +170,8 @@ static inline struct cpumask *cpu_llc_shared_mask(int cpu)
169170
{
170171
return (struct cpumask *)cpumask_of(0);
171172
}
173+
174+
static inline void __noreturn mwait_play_dead(unsigned int eax_hint) { BUG(); }
172175
#endif /* CONFIG_SMP */
173176

174177
#ifdef CONFIG_DEBUG_NMI_SELFTEST

arch/x86/kernel/acpi/cstate.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include <acpi/processor.h>
1616
#include <asm/mwait.h>
1717
#include <asm/special_insns.h>
18+
#include <asm/smp.h>
1819

1920
/*
2021
* Initialize bm_flags based on the CPU cache properties
@@ -204,6 +205,16 @@ int acpi_processor_ffh_cstate_probe(unsigned int cpu,
204205
}
205206
EXPORT_SYMBOL_GPL(acpi_processor_ffh_cstate_probe);
206207

208+
void __noreturn acpi_processor_ffh_play_dead(struct acpi_processor_cx *cx)
209+
{
210+
unsigned int cpu = smp_processor_id();
211+
struct cstate_entry *percpu_entry;
212+
213+
percpu_entry = per_cpu_ptr(cpu_cstate_entry, cpu);
214+
mwait_play_dead(percpu_entry->states[cx->index].eax);
215+
}
216+
EXPORT_SYMBOL_GPL(acpi_processor_ffh_play_dead);
217+
207218
void __cpuidle acpi_processor_ffh_cstate_enter(struct acpi_processor_cx *cx)
208219
{
209220
unsigned int cpu = smp_processor_id();

arch/x86/kernel/hpet.c

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -927,9 +927,6 @@ static bool __init mwait_pc10_supported(void)
927927
if (!cpu_feature_enabled(X86_FEATURE_MWAIT))
928928
return false;
929929

930-
if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
931-
return false;
932-
933930
cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &mwait_substates);
934931

935932
return (ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED) &&

arch/x86/kernel/smpboot.c

Lines changed: 47 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1282,49 +1282,9 @@ void play_dead_common(void)
12821282
local_irq_disable();
12831283
}
12841284

1285-
/*
1286-
* We need to flush the caches before going to sleep, lest we have
1287-
* dirty data in our caches when we come back up.
1288-
*/
1289-
static inline void mwait_play_dead(void)
1285+
void __noreturn mwait_play_dead(unsigned int eax_hint)
12901286
{
12911287
struct mwait_cpu_dead *md = this_cpu_ptr(&mwait_cpu_dead);
1292-
unsigned int eax, ebx, ecx, edx;
1293-
unsigned int highest_cstate = 0;
1294-
unsigned int highest_subcstate = 0;
1295-
int i;
1296-
1297-
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
1298-
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
1299-
return;
1300-
if (!this_cpu_has(X86_FEATURE_MWAIT))
1301-
return;
1302-
if (!this_cpu_has(X86_FEATURE_CLFLUSH))
1303-
return;
1304-
if (__this_cpu_read(cpu_info.cpuid_level) < CPUID_MWAIT_LEAF)
1305-
return;
1306-
1307-
eax = CPUID_MWAIT_LEAF;
1308-
ecx = 0;
1309-
native_cpuid(&eax, &ebx, &ecx, &edx);
1310-
1311-
/*
1312-
* eax will be 0 if EDX enumeration is not valid.
1313-
* Initialized below to cstate, sub_cstate value when EDX is valid.
1314-
*/
1315-
if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED)) {
1316-
eax = 0;
1317-
} else {
1318-
edx >>= MWAIT_SUBSTATE_SIZE;
1319-
for (i = 0; i < 7 && edx; i++, edx >>= MWAIT_SUBSTATE_SIZE) {
1320-
if (edx & MWAIT_SUBSTATE_MASK) {
1321-
highest_cstate = i;
1322-
highest_subcstate = edx & MWAIT_SUBSTATE_MASK;
1323-
}
1324-
}
1325-
eax = (highest_cstate << MWAIT_SUBSTATE_SIZE) |
1326-
(highest_subcstate - 1);
1327-
}
13281288

13291289
/* Set up state for the kexec() hack below */
13301290
md->status = CPUDEAD_MWAIT_WAIT;
@@ -1345,7 +1305,7 @@ static inline void mwait_play_dead(void)
13451305
mb();
13461306
__monitor(md, 0, 0);
13471307
mb();
1348-
__mwait(eax, 0);
1308+
__mwait(eax_hint, 0);
13491309

13501310
if (READ_ONCE(md->control) == CPUDEAD_MWAIT_KEXEC_HLT) {
13511311
/*
@@ -1368,6 +1328,50 @@ static inline void mwait_play_dead(void)
13681328
}
13691329
}
13701330

1331+
/*
1332+
* We need to flush the caches before going to sleep, lest we have
1333+
* dirty data in our caches when we come back up.
1334+
*/
1335+
static inline void mwait_play_dead_cpuid_hint(void)
1336+
{
1337+
unsigned int eax, ebx, ecx, edx;
1338+
unsigned int highest_cstate = 0;
1339+
unsigned int highest_subcstate = 0;
1340+
int i;
1341+
1342+
if (boot_cpu_data.x86_vendor == X86_VENDOR_AMD ||
1343+
boot_cpu_data.x86_vendor == X86_VENDOR_HYGON)
1344+
return;
1345+
if (!this_cpu_has(X86_FEATURE_MWAIT))
1346+
return;
1347+
if (!this_cpu_has(X86_FEATURE_CLFLUSH))
1348+
return;
1349+
1350+
eax = CPUID_MWAIT_LEAF;
1351+
ecx = 0;
1352+
native_cpuid(&eax, &ebx, &ecx, &edx);
1353+
1354+
/*
1355+
* eax will be 0 if EDX enumeration is not valid.
1356+
* Initialized below to cstate, sub_cstate value when EDX is valid.
1357+
*/
1358+
if (!(ecx & CPUID5_ECX_EXTENSIONS_SUPPORTED)) {
1359+
eax = 0;
1360+
} else {
1361+
edx >>= MWAIT_SUBSTATE_SIZE;
1362+
for (i = 0; i < 7 && edx; i++, edx >>= MWAIT_SUBSTATE_SIZE) {
1363+
if (edx & MWAIT_SUBSTATE_MASK) {
1364+
highest_cstate = i;
1365+
highest_subcstate = edx & MWAIT_SUBSTATE_MASK;
1366+
}
1367+
}
1368+
eax = (highest_cstate << MWAIT_SUBSTATE_SIZE) |
1369+
(highest_subcstate - 1);
1370+
}
1371+
1372+
mwait_play_dead(eax);
1373+
}
1374+
13711375
/*
13721376
* Kick all "offline" CPUs out of mwait on kexec(). See comment in
13731377
* mwait_play_dead().
@@ -1418,7 +1422,7 @@ void native_play_dead(void)
14181422
play_dead_common();
14191423
tboot_shutdown(TB_SHUTDOWN_WFS);
14201424

1421-
mwait_play_dead();
1425+
mwait_play_dead_cpuid_hint();
14221426
if (cpuidle_play_dead())
14231427
hlt_play_dead();
14241428
}

drivers/acpi/acpi_pad.c

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ static void power_saving_mwait_init(void)
4242

4343
if (!boot_cpu_has(X86_FEATURE_MWAIT))
4444
return;
45-
if (boot_cpu_data.cpuid_level < CPUID_MWAIT_LEAF)
46-
return;
4745

4846
cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx);
4947

drivers/acpi/processor_idle.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -578,7 +578,7 @@ static void __cpuidle acpi_idle_do_entry(struct acpi_processor_cx *cx)
578578
* @dev: the target CPU
579579
* @index: the index of suggested state
580580
*/
581-
static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
581+
static void acpi_idle_play_dead(struct cpuidle_device *dev, int index)
582582
{
583583
struct acpi_processor_cx *cx = per_cpu(acpi_cstate[index], dev->cpu);
584584

@@ -590,12 +590,11 @@ static int acpi_idle_play_dead(struct cpuidle_device *dev, int index)
590590
raw_safe_halt();
591591
else if (cx->entry_method == ACPI_CSTATE_SYSTEMIO) {
592592
io_idle(cx->address);
593+
} else if (cx->entry_method == ACPI_CSTATE_FFH) {
594+
acpi_processor_ffh_play_dead(cx);
593595
} else
594-
return -ENODEV;
596+
return;
595597
}
596-
597-
/* Never reached */
598-
return 0;
599598
}
600599

601600
static __always_inline bool acpi_idle_fallback_to_c1(struct acpi_processor *pr)

drivers/cpuidle/cpuidle.c

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,11 +69,15 @@ int cpuidle_play_dead(void)
6969
if (!drv)
7070
return -ENODEV;
7171

72-
/* Find lowest-power state that supports long-term idle */
73-
for (i = drv->state_count - 1; i >= 0; i--)
72+
for (i = drv->state_count - 1; i >= 0; i--) {
7473
if (drv->states[i].enter_dead)
75-
return drv->states[i].enter_dead(dev, i);
74+
drv->states[i].enter_dead(dev, i);
75+
}
7676

77+
/*
78+
* If :enter_dead() is successful, it will never return, so reaching
79+
* here means that all of them failed above or were not present.
80+
*/
7781
return -ENODEV;
7882
}
7983

0 commit comments

Comments
 (0)