android_kernel_xiaomi_sm8450/arch
Zhang Rui 8462805788 x86/apic: Always explicitly disarm TSC-deadline timer
commit ffd95846c6ec6cf1f93da411ea10d504036cab42 upstream.

New processors have become pickier about the local APIC timer state
before entering low power modes. These low power modes are used (for
example) when you close your laptop lid and suspend. If you put your
laptop in a bag and it is not in this low power mode, it is likely
to get quite toasty while it quickly sucks the battery dry.

The problem boils down to some CPUs' inability to power down until the
CPU recognizes that the local APIC timer is shut down. The current
kernel code works in one-shot and periodic modes but does not work for
deadline mode. Deadline mode has been the supported and preferred mode
on Intel CPUs for over a decade and uses an MSR to drive the timer
instead of an APIC register.

Disable the TSC Deadline timer in lapic_timer_shutdown() by writing to
MSR_IA32_TSC_DEADLINE when in TSC-deadline mode. Also avoid writing
to the initial-count register (APIC_TMICT) which is ignored in
TSC-deadline mode.

Note: The APIC_LVTT|=APIC_LVT_MASKED operation should theoretically be
enough to tell the hardware that the timer will not fire in any of the
timer modes. But mitigating AMD erratum 411[1] also requires clearing
out APIC_TMICT. Solely setting APIC_LVT_MASKED is also ineffective in
practice on Intel Lunar Lake systems, which is the motivation for this
change.

1. 411 Processor May Exit Message-Triggered C1E State Without an Interrupt if Local APIC Timer Reaches Zero - https://www.amd.com/content/dam/amd/en/documents/archived-tech-docs/revision-guides/41322_10h_Rev_Gd.pdf

Fixes: 279f146143 ("x86: apic: Use tsc deadline for oneshot when available")
Suggested-by: Dave Hansen <dave.hansen@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
Reviewed-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Tested-by: Todd Brandt <todd.e.brandt@intel.com>
Cc: stable@vger.kernel.org
Link: https://lore.kernel.org/all/20241015061522.25288-1-rui.zhang%40intel.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2024-10-22 15:39:29 +02:00
..
alpha alpha: remove __init annotation from exported page_is_ram() 2023-08-16 18:21:03 +02:00
arc ARC: [plat-hsdk]: Remove misplaced interrupt-cells property 2024-05-02 16:23:41 +02:00
arm ARM: versatile: fix OF node leak in CPUs prepare 2024-10-17 15:07:43 +02:00
arm64 arm64: probes: Fix simulate_ldr*_literal() 2024-10-22 15:39:24 +02:00
c6x c6x: add support for TIF_NOTIFY_SIGNAL 2023-01-04 11:39:21 +01:00
csky csky, hexagon: fix broken sys_sync_file_range 2024-07-05 09:12:54 +02:00
h8300 h8300: Fix build errors from do_exit() to make_task_dead() transition 2023-02-01 08:23:19 +01:00
hexagon hexagon: fix fadvise64_64 calling conventions 2024-07-05 09:12:54 +02:00
ia64 efi: ia64: move IA64-only declarations to new asm/efi.h header 2024-07-18 13:05:50 +02:00
m68k m68k: Fix kernel_clone_args.flags in m68k_clone() 2024-10-17 15:07:44 +02:00
microblaze microblaze: don't treat zero reserved memory regions as error 2024-10-17 15:07:35 +02:00
mips MIPS: cevt-r4k: Don't call get_c0_compare_int if timer irq is installed 2024-09-12 11:06:49 +02:00
nds32 exit: Add and use make_task_dead. 2023-02-01 08:23:19 +01:00
nios2 nios2: dts: Fix tse_mac "max-frame-size" property 2023-06-21 15:45:37 +02:00
openrisc openrisc: Call setup_memory() earlier in the init sequence 2024-09-04 13:17:38 +02:00
parisc parisc: Fix 64-bit userspace syscall path 2024-10-17 15:08:20 +02:00
powerpc powerpc/mm: Fix boot warning with hugepages and CONFIG_DEBUG_VIRTUAL 2024-10-17 15:07:31 +02:00
riscv riscv: define ILLEGAL_POINTER_VALUE for 64bit 2024-10-17 15:08:22 +02:00
s390 KVM: s390: Change virtual to physical address access in diag 0x258 handler 2024-10-22 15:39:25 +02:00
sh Revert "sh: Handle calling csum_partial with misaligned data" 2024-06-16 13:32:07 +02:00
sparc sparc64: Fix incorrect function signature and add prototype for prom_cif_init 2024-08-19 05:40:51 +02:00
um um: line: always fill *error_out in setup_one_line() 2024-09-12 11:06:48 +02:00
x86 x86/apic: Always explicitly disarm TSC-deadline timer 2024-10-22 15:39:29 +02:00
xtensa xtensa: boot/lib: fix function prototypes 2023-10-10 21:53:31 +02:00
.gitignore
Kconfig cpu: Re-enable CPU mitigations by default for !X86 architectures 2024-05-02 16:23:44 +02:00