Move ...mce/therm_throt.c to drivers/thermal/
Subsystems (3)
Borislav Petkov
maintainercover Move ...mce/therm_throt.c to drivers/thermal/
From: Borislav Petkov <[email protected]>
Hi,
so this has come up a bunch of times in the past and PeterZ is right
- that thing doesn't have anything to do with the MCE glue so move it where it belongs.
Thx.
Borislav Petkov (2):
x86/mce: Get rid of mcheck_intel_therm_init()
thermal: Move therm_throt there from x86/mce
arch/x86/Kconfig | 4 --
arch/x86/include/asm/irq.h | 4 ++
arch/x86/include/asm/mce.h | 22 -----------
arch/x86/include/asm/thermal.h | 21 ++++++++++
arch/x86/kernel/cpu/intel.c | 3 ++
arch/x86/kernel/cpu/mce/Makefile | 2 -
arch/x86/kernel/cpu/mce/core.c | 1 -
arch/x86/kernel/cpu/mce/intel.c | 1 -
arch/x86/kernel/irq.c | 28 +++++++++++++
drivers/thermal/intel/Kconfig | 4 ++
drivers/thermal/intel/Makefile | 1 +
.../thermal/intel}/therm_throt.c | 39 +++----------------
drivers/thermal/intel/x86_pkg_temp_thermal.c | 3 +-
13 files changed, 69 insertions(+), 64 deletions(-)
create mode 100644 arch/x86/include/asm/thermal.h
rename {arch/x86/kernel/cpu/mce => drivers/thermal/intel}/therm_throt.c (96%)Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 1/2 x86/mce: Get rid of mcheck_intel_therm_init()
From: Borislav Petkov <[email protected]>
Move the APIC_LVTTHMR read which needs to happen on the BSP, to intel_init_thermal(). One less boot dependency.
No functional changes.
--- arch/x86/include/asm/mce.h | 6 ------ arch/x86/kernel/cpu/mce/core.c | 1 - arch/x86/kernel/cpu/mce/therm_throt.c | 14 +++----------- 3 files changed, 3 insertions(+), 18 deletions(-)
arch/x86/include/asm/mce.h +0 -6
@@ -304,12 +304,6 @@ extern int (*platform_thermal_package_notify)(__u64 msr_val);* callback has rate control */ extern bool (*platform_thermal_package_rate_control)(void ); -#ifdef CONFIG_X86_THERMAL_VECTOR -extern void mcheck_intel_therm_init (void ); -#else -static inline void mcheck_intel_therm_init (void ) { } -#endif -/* * Used by APEI to report memory error via /dev/mcelog */
arch/x86/kernel/cpu/mce/core.c +0 -1
@@ -2177,7 +2177,6 @@ __setup("mce", mcheck_enable);int __init mcheck_init (void ) { -mcheck_intel_therm_init ();mce_register_decode_chain (&early_nb);mce_register_decode_chain (&mce_uc_nb);mce_register_decode_chain (&mce_default_nb);
arch/x86/kernel/cpu/mce/therm_throt.c +3 -11
@@ -633,23 +633,15 @@ static int intel_thermal_supported(struct cpuinfo_x86 *c)return 1 ; } -void __init mcheck_intel_therm_init (void ) -{ -/* -* This function is only called on boot CPU. Save the init thermal -* LVT value on BSP and use that value to restore APs' thermal LVT -* entry BIOS programmed later -*/ -if (intel_thermal_supported (&boot_cpu_data)) - lvtthmr_init =apic_read (APIC_LVTTHMR ); -} -void intel_init_thermal (struct cpuinfo_x86 *c) {unsigned int cpu =smp_processor_id ();int tm2 =0 ;u32 l, h; +if ((c == &boot_cpu_data) &&intel_thermal_supported (c)) + lvtthmr_init =apic_read (APIC_LVTTHMR ); +if (!intel_thermal_supported (c))return ;
Signature · 1 line
2.29.2
Borislav Petkov
maintainerPATCH 2/2 thermal: Move therm_throt there from x86/mce
In reply to Borislav PetkovFrom: Borislav Petkov <[email protected]>
This functionality has nothing to do with MCE, move it to the thermal framework and untangle it from MCE.
---
arch/x86/Kconfig | 4 ---
arch/x86/include/asm/irq.h | 4 +++
arch/x86/include/asm/mce.h | 16 -----------
arch/x86/include/asm/thermal.h | 21 ++++++++++++++
arch/x86/kernel/cpu/intel.c | 3 ++
arch/x86/kernel/cpu/mce/Makefile | 2 --
arch/x86/kernel/cpu/mce/intel.c | 1 -
arch/x86/kernel/irq.c | 28 +++++++++++++++++++
drivers/thermal/intel/Kconfig | 4 +++
drivers/thermal/intel/Makefile | 1 +
.../thermal/intel}/therm_throt.c | 25 ++---------------
drivers/thermal/intel/x86_pkg_temp_thermal.c | 3 +-
12 files changed, 66 insertions(+), 46 deletions(-)
create mode 100644 arch/x86/include/asm/thermal.h
rename {arch/x86/kernel/cpu/mce => drivers/thermal/intel}/therm_throt.c (97%)arch/x86/Kconfig +0 -4
@@ -1158,10 +1158,6 @@ config X86_MCE_INJECT If you don't know what a machine check is and you don't do kernel QA it is safe to say n. -config X86_THERMAL_VECTOR - def_bool y - depends on X86_MCE_INTEL - source "arch/x86/events/Kconfig" config X86_LEGACY_VM86
arch/x86/include/asm/irq.h +4 -0
@@ -53,4 +53,8 @@ void arch_trigger_cpumask_backtrace(const struct cpumask *mask,#define arch_trigger_cpumask_backtrace arch_trigger_cpumask_backtrace#endif +#ifdef CONFIG_X86_THERMAL_VECTOR +void thermal_set_handler (void (*handler)(void )); +#endif +#endif /* _ASM_X86_IRQ_H */
arch/x86/include/asm/mce.h +0 -16
@@ -288,22 +288,6 @@ extern void (*mce_threshold_vector)(void);/* Deferred error interrupt handler */ extern void (*deferred_error_int_vector)(void ); -/* -* Thermal handler -*/ - -void intel_init_thermal (struct cpuinfo_x86 *c); - -/* Interrupt Handler for core thermal thresholds */ -extern int (*platform_thermal_notify)(__u64 msr_val); - -/* Interrupt Handler for package thermal thresholds */ -extern int (*platform_thermal_package_notify)(__u64 msr_val); - -/* Callback support of rate control, return true, if -* callback has rate control */ -extern bool (*platform_thermal_package_rate_control)(void ); -/* * Used by APEI to report memory error via /dev/mcelog */
arch/x86/include/asm/thermal.h new file +21 -0
@@ -0,0 +1,21 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +#ifndef _ASM_X86_THERMAL_H +#define _ASM_X86_THERMAL_H + +/* Interrupt Handler for package thermal thresholds */ +extern int (*platform_thermal_package_notify)(__u64 msr_val); + +/* Interrupt Handler for core thermal thresholds */ +extern int (*platform_thermal_notify)(__u64 msr_val); + +/* Callback support of rate control, return true, if +* callback has rate control */ +extern bool (*platform_thermal_package_rate_control)(void ); + +#ifdef CONFIG_X86_THERMAL_VECTOR +void intel_init_thermal (struct cpuinfo_x86 *c); +#else +static inline void intel_init_thermal (struct cpuinfo_x86 *c) { } +#endif + +#endif /* _ASM_X86_THERMAL_H */
arch/x86/kernel/cpu/intel.c +3 -0
@@ -24,6 +24,7 @@#include <asm/traps.h> #include <asm/resctrl.h> #include <asm/numa.h> +#include <asm/thermal.h> #ifdef CONFIG_X86_64 #include <linux/topology.h>
@@ -719,6 +720,8 @@ static void init_intel(struct cpuinfo_x86 *c)tsx_disable ();split_lock_init (); + +intel_init_thermal (c); }#ifdef CONFIG_X86_32
arch/x86/kernel/cpu/mce/Makefile +0 -2
@@ -9,8 +9,6 @@ obj-$(CONFIG_X86_MCE_THRESHOLD) += threshold.o mce-inject-y := inject.o obj-$(CONFIG_X86_MCE_INJECT) += mce-inject.o -obj-$(CONFIG_X86_THERMAL_VECTOR) += therm_throt.o - obj-$(CONFIG_ACPI_APEI) += apei.o obj-$(CONFIG_X86_MCELOG_LEGACY) += dev-mcelog.o
arch/x86/kernel/cpu/mce/intel.c +0 -1
@@ -531,7 +531,6 @@ static void intel_imc_init(struct cpuinfo_x86 *c)void mce_intel_feature_init (struct cpuinfo_x86 *c) { -intel_init_thermal (c);intel_init_cmci ();intel_init_lmce ();intel_ppin_init (c);
arch/x86/kernel/irq.c +28 -0
@@ -374,3 +374,31 @@ void fixup_irqs(void) } }#endif + +#ifdef CONFIG_X86_THERMAL_VECTOR +static void unexpected_thermal_interrupt (void ) +{ +pr_err ("CPU%d: Unexpected LVT thermal interrupt!\n" , +smp_processor_id ()); +} + +static void (*smp_thermal_vector)(void ) = unexpected_thermal_interrupt; + +void thermal_set_handler (void (*handler)(void )) +{ +if (handler) + smp_thermal_vector = handler; +else + smp_thermal_vector = unexpected_thermal_interrupt; +} +EXPORT_SYMBOL_GPL (thermal_set_handler); + +DEFINE_IDTENTRY_SYSVEC (sysvec_thermal) +{ +trace_thermal_apic_entry (THERMAL_APIC_VECTOR ); +inc_irq_stat (irq_thermal_count); +smp_thermal_vector (); +trace_thermal_apic_exit (THERMAL_APIC_VECTOR ); +ack_APIC_irq (); +} +#endif
drivers/thermal/intel/Kconfig +4 -0
@@ -8,6 +8,10 @@ config INTEL_POWERCLAMP enforce idle time which results in more package C-state residency. The user interface is exposed via generic thermal framework. +config X86_THERMAL_VECTOR + def_bool y + depends on X86 && CPU_SUP_INTEL && X86_LOCAL_APIC + config X86_PKG_TEMP_THERMAL tristate "X86 package temperature thermal driver" depends on X86_THERMAL_VECTOR
drivers/thermal/intel/Makefile +1 -0
@@ -10,3 +10,4 @@ obj-$(CONFIG_INTEL_QUARK_DTS_THERMAL) += intel_quark_dts_thermal.o obj-$(CONFIG_INT340X_THERMAL) += int340x_thermal/ obj-$(CONFIG_INTEL_BXT_PMIC_THERMAL) += intel_bxt_pmic_thermal.o obj-$(CONFIG_INTEL_PCH_THERMAL) += intel_pch_thermal.o +obj-$(CONFIG_X86_THERMAL_VECTOR) += therm_throt.o
drivers/thermal/intel/therm_throt.c renamed from arch/x86/kernel/cpu/mce/therm_throt.c +3 -22
@@ -26,13 +26,11 @@#include <linux/cpu.h> #include <asm/processor.h> +#include <asm/thermal.h> #include <asm/traps.h> #include <asm/apic.h> -#include <asm/mce.h> +#include <asm/irq.h> #include <asm/msr.h> -#include <asm/trace/irq_vectors.h> - -#include "internal.h" /* How long to wait between reporting thermal events */ #define CHECK_INTERVAL (300 * HZ)
@@ -606,23 +604,6 @@ static void intel_thermal_interrupt(void) } } -static void unexpected_thermal_interrupt (void ) -{ -pr_err ("CPU%d: Unexpected LVT thermal interrupt!\n" , -smp_processor_id ()); -} - -static void (*smp_thermal_vector)(void ) = unexpected_thermal_interrupt; - -DEFINE_IDTENTRY_SYSVEC (sysvec_thermal) -{ -trace_thermal_apic_entry (THERMAL_APIC_VECTOR ); -inc_irq_stat (irq_thermal_count); -smp_thermal_vector (); -trace_thermal_apic_exit (THERMAL_APIC_VECTOR ); -ack_APIC_irq (); -} -/* Thermal monitoring depends on APIC, ACPI and clock modulation */ static int intel_thermal_supported (struct cpuinfo_x86 *c) {
@@ -718,7 +699,7 @@ void intel_init_thermal(struct cpuinfo_x86 *c) | PACKAGE_THERM_INT_HIGH_ENABLE), h); } - smp_thermal_vector = intel_thermal_interrupt; +thermal_set_handler (intel_thermal_interrupt);rdmsr (MSR_IA32_MISC_ENABLE , l, h);wrmsr (MSR_IA32_MISC_ENABLE , l |MSR_IA32_MISC_ENABLE_TM1 , h);
drivers/thermal/intel/x86_pkg_temp_thermal.c +2 -1
@@ -17,8 +17,9 @@#include <linux/pm.h> #include <linux/thermal.h> #include <linux/debugfs.h> +#include <asm/cpu_device_id.h> -#include <asm/mce.h> +#include <asm/thermal.h> /* * Rate control delay: Idea is to introduce denounce effect
Signature · 1 line
2.29.2
Re: [PATCH 2/2] thermal: Move therm_throt there from x86/mce
arch/x86/kernel/irq.c void fixup_irqs(void)
Quoted 12 lines · Borislav Petkov
arch/x86/kernel/irq.c +12
-0+#ifdef CONFIG_X86_THERMAL_VECTOR +static void unexpected_thermal_interrupt (void ) +{ +pr_err ("CPU%d: Unexpected LVT thermal interrupt!\n" , +smp_processor_id ()); +} + +static void (*smp_thermal_vector)(void ) = unexpected_thermal_interrupt; + +void thermal_set_handler (void (*handler)(void )) +{ +if (handler) {
WARN_ON(smp_thermal_vector != unexpected_thermal_interrupt);
arch/x86/kernel/irq.c void fixup_irqs(void) · line 394
Quoted 5 lines
arch/x86/kernel/irq.c +5
-0+ smp_thermal_vector = handler; + }else + smp_thermal_vector = unexpected_thermal_interrupt; +} +EXPORT_SYMBOL_GPL (thermal_set_handler);
You really don't want multiple modules to touch that at the same time.
Quoted 9 lines
arch/x86/kernel/irq.c +9
-0+DEFINE_IDTENTRY_SYSVEC (sysvec_thermal) +{ +trace_thermal_apic_entry (THERMAL_APIC_VECTOR ); +inc_irq_stat (irq_thermal_count); +smp_thermal_vector (); +trace_thermal_apic_exit (THERMAL_APIC_VECTOR ); +ack_APIC_irq (); +} +#endif