Skip to content

Commit 7a8d578

Browse files
committed
Merge branch 'pm-cpuidle'
Merge cpuidle updates for 6.9-rc1: - Prevent the haltpoll cpuidle governor from shrinking guest poll_limit_ns below grow_start (Parshuram Sangle). - Avoid potential overflow in integer multiplication when computing cpuidle state parameters (C Cheng). - Adjust MWAIT hint target C-state computation in the ACPI cpuidle driver and in intel_idle to return a correct value for C0 (He Rongguang). * pm-cpuidle: cpuidle: ACPI/intel: fix MWAIT hint target C-state computation cpuidle: Avoid potential overflow in integer multiplication cpuidle: haltpoll: do not shrink guest poll_limit_ns below grow_start
2 parents 32b88f5 + 6b8e288 commit 7a8d578

File tree

4 files changed

+13
-6
lines changed

4 files changed

+13
-6
lines changed

arch/x86/kernel/acpi/cstate.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ static long acpi_processor_ffh_cstate_probe_cpu(void *_cx)
131131
cpuid(CPUID_MWAIT_LEAF, &eax, &ebx, &ecx, &edx);
132132

133133
/* Check whether this particular cx_type (in CST) is supported or not */
134-
cstate_type = ((cx->address >> MWAIT_SUBSTATE_SIZE) &
135-
MWAIT_CSTATE_MASK) + 1;
134+
cstate_type = (((cx->address >> MWAIT_SUBSTATE_SIZE) &
135+
MWAIT_CSTATE_MASK) + 1) & MWAIT_CSTATE_MASK;
136136
edx_part = edx >> (cstate_type * MWAIT_SUBSTATE_SIZE);
137137
num_cstate_subtype = edx_part & MWAIT_SUBSTATE_MASK;
138138

drivers/cpuidle/driver.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <linux/cpumask.h>
1717
#include <linux/tick.h>
1818
#include <linux/cpu.h>
19+
#include <linux/math64.h>
1920

2021
#include "cpuidle.h"
2122

@@ -187,7 +188,7 @@ static void __cpuidle_driver_init(struct cpuidle_driver *drv)
187188
s->target_residency = div_u64(s->target_residency_ns, NSEC_PER_USEC);
188189

189190
if (s->exit_latency > 0)
190-
s->exit_latency_ns = s->exit_latency * NSEC_PER_USEC;
191+
s->exit_latency_ns = mul_u32_u32(s->exit_latency, NSEC_PER_USEC);
191192
else if (s->exit_latency_ns < 0)
192193
s->exit_latency_ns = 0;
193194
else

drivers/cpuidle/governors/haltpoll.c

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,15 @@ static void adjust_poll_limit(struct cpuidle_device *dev, u64 block_ns)
9898
unsigned int shrink = guest_halt_poll_shrink;
9999

100100
val = dev->poll_limit_ns;
101-
if (shrink == 0)
101+
if (shrink == 0) {
102102
val = 0;
103-
else
103+
} else {
104104
val /= shrink;
105+
/* Reset value to 0 if shrunk below grow_start */
106+
if (val < guest_halt_poll_grow_start)
107+
val = 0;
108+
}
109+
105110
trace_guest_halt_poll_ns_shrink(val, dev->poll_limit_ns);
106111
dev->poll_limit_ns = val;
107112
}

drivers/idle/intel_idle.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1934,7 +1934,8 @@ static void __init spr_idle_state_table_update(void)
19341934

19351935
static bool __init intel_idle_verify_cstate(unsigned int mwait_hint)
19361936
{
1937-
unsigned int mwait_cstate = MWAIT_HINT2CSTATE(mwait_hint) + 1;
1937+
unsigned int mwait_cstate = (MWAIT_HINT2CSTATE(mwait_hint) + 1) &
1938+
MWAIT_CSTATE_MASK;
19381939
unsigned int num_substates = (mwait_substates >> mwait_cstate * 4) &
19391940
MWAIT_SUBSTATE_MASK;
19401941

0 commit comments

Comments
 (0)