Move ...mce/therm_throt.c to drivers/thermal/
Subsystems (3)
Borislav Petkov
maintainerv2 cover Move ...mce/therm_throt.c to drivers/thermal/
From: Borislav Petkov <[email protected]>
Hi,
here's v2 which addresses peterz's comments to patch 2.
@thermal folks, lemme know if you have any objections otherwise I'll route this through the tip tree.
Thx.
Changelog:
==========
v1:
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 | 29 ++++++++++++++
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, 70 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 v2 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
@@ -2178,7 +2178,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
[tip: ras/core] x86/mce: Get rid of mcheck_intel_therm_init()
The following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: b4e530ac40f25dbf07cbd37796bfcef3ec86fba8 Gitweb: https://git.kernel.org/tip/b4e530ac40f25dbf07cbd37796bfcef3ec86fba8 Author: Borislav Petkov <[email protected]> AuthorDate: Thu, 07 Jan 2021 13:23:34 +01:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Fri, 29 Jan 2021 17:33:05 +01:00
x86/mce: Get rid of mcheck_intel_therm_init()
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
@@ -2189,7 +2189,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 ;
Borislav Petkov
maintainerPATCH v2 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.
Have thermal_set_handler() check the build-time assigned default handler stub was the one used before therm_throt assigns a new one.
---
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 | 29 +++++++++++++++++++
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, 67 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 +29 -0
@@ -374,3 +374,32 @@ 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) { +WARN_ON (smp_thermal_vector != unexpected_thermal_interrupt); + smp_thermal_vector = handler; + }else { + smp_thermal_vector = 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 (); +} +#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
Zhang Rui
reviewerRe: [PATCH v2 2/2] thermal: Move therm_throt there from x86/mce
Hi, Borislav,
Thanks for the patch. CC Srinivas.
Quoted 5 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
This functionality has nothing to do with MCE, move it to the thermal framework and untangle it from MCE.
Agreed.
just one question,
there are many overlaps between this kernel thermal throttling code and the x86_pkg_temp_thermal driver, is it possible to combine these two pieces of code altogether?
thanks,
rui
Quoted 302 lines
Have
thermal_set_handler()check the build-time assigned default handler
stub was the one used beforetherm_throtassigns a new one.Requested-by Peter Zijlstra <[email protected]>Signed-off-by Borislav Petkov <[email protected]>--- 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 | 29 +++++++++++++++++++ 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, 67 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
-0@@ -1158,10 +1158,6 @@ config X86_MCE_INJECT If you don't know what a machine check is and you don't dokernel
arch/x86/Kconfig +0
-4QA 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_VM86arch/x86/include/asm/irq.h +0
-0@@ -53,4 +53,8 @@ void arch_trigger_cpumask_backtrace(const structcpumask *mask, #define arch_trigger_cpumask_backtrace
arch_trigger_cpumask_backtrace
#endifarch/x86/include/asm/irq.h +4
-0+#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.oarch/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 +9
-0@@ -374,3 +374,32 @@ 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;arch/x86/kernel/irq.c +5
-0+ +void thermal_set_handler (void (*handler)(void )) +{ +if (handler) { + WARN_ON(smp_thermal_vector !=
unexpected_thermal_interrupt);arch/x86/kernel/irq.c +15
-0+ smp_thermal_vector = handler; + }else { + smp_thermal_vector = 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 (); +} +#endif drivers/thermal/intel/Kconfig +0
-0@@ -8,6 +8,10 @@ config INTEL_POWERCLAMP enforce idle time which results in more package C-stateresidency. The
drivers/thermal/intel/Kconfig +4
-0user 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_VECTORdrivers/thermal/intel/Makefile +0
-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.odrivers/thermal/intel/Makefile +1
-0+obj-$(CONFIG_X86_THERMAL_VECTOR) += therm_throt.odrivers/thermal/intel/therm_throt.c renamed from arch/x86/kernel/cpu/mce/therm_throt.c +2
-21@@ -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){
drivers/thermal/intel/therm_throt.c renamed from arch/x86/kernel/cpu/mce/therm_throt.c +1
-1@@ -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
Borislav Petkov
maintainerRe: [PATCH v2 2/2] thermal: Move therm_throt there from x86/mce
Quoted 1 line · Zhang Rui
Agreed.
Ok I'll queue the stuff in tip if there are no objections. It is a lot easier this way...
Quoted 4 lines
just one question,
there are many overlaps between this kernel thermal throttling code and thex86_pkg_temp_thermaldriver, is it possible to combine these two pieces of code altogether?
You've CCed the right guy - I think Srinivas should be able to answer that question.
Thx.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v2 2/2] thermal: Move therm_throt there from x86/mce
In reply to Zhang RuiHi All,
Quoted 4 lines · Zhang Rui
Hi, Borislav,
Thanks for the patch. CC Srinivas.
Thanks for adding me.
Quoted 7 lines · Borislav Petkov
Quoted 6 lines
From: Borislav Petkov <[email protected]>
This functionality has nothing to do with MCE, move it to the thermal(unfortunately)
framework and untangle it from MCE.
Agreed.
But I have a question on how we should handle some new features.
Although interrupt handled in this code is called "Thermal interrupt", this interrupt is also used for notification for some other power /energy efficiency optimization events via IA32_THERM_STATUS and IA32_PACKAGE_THERM_STATUS.
For example (From SDM):IA32_PACKAGE_THERM_STATUS
Bit 26: Hardware Feedback Interface Structure Change Status
Can the handler, processing architectural features via thermal interrupt, reside in arch/x86 folder or need to be drivers/thermal/intel?
Quoted 7 lines
Agreed.
just one question,
there are many overlaps between this kernel thermal throttling code and
thex86_pkg_temp_thermaldriver, is it possible to combine these two pieces of code altogether?
May not be a good idea as the events are not just for temperature notifications.
Thanks,
Srinivas
Quoted 311 lines
thanks,
ruiQuoted 306 lines
Have
thermal_set_handler()check the build-time assigned default handler
stub was the one used beforetherm_throtassigns a new one.Requested-by Peter Zijlstra <[email protected]>Signed-off-by Borislav Petkov <[email protected]>--- 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 | 29 +++++++++++++++++++ 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, 67 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
-0@@ -1158,10 +1158,6 @@ config X86_MCE_INJECT If you don't know what a machine check is and you don't dokernel
arch/x86/Kconfig +0
-4QA 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_VM86arch/x86/include/asm/irq.h +0
-0@@ -53,4 +53,8 @@ void arch_trigger_cpumask_backtrace(const structcpumask *mask, #define arch_trigger_cpumask_backtrace
arch_trigger_cpumask_backtrace
#endifarch/x86/include/asm/irq.h +4
-0+#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.oarch/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 ();arch/x86/kernel/cpu/mce/intel.c +0
-0intel_ppin_init (c);arch/x86/kernel/irq.c +9
-0@@ -374,3 +374,32 @@ 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;arch/x86/kernel/irq.c +5
-0+ +void thermal_set_handler (void (*handler)(void )) +{ +if (handler) { + WARN_ON(smp_thermal_vector !=
unexpected_thermal_interrupt);arch/x86/kernel/irq.c +15
-0+ smp_thermal_vector = handler; + }else { + smp_thermal_vector = 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 (); +} +#endif drivers/thermal/intel/Kconfig +0
-0@@ -8,6 +8,10 @@ config INTEL_POWERCLAMP enforce idle time which results in more package C-stateresidency. The
drivers/thermal/intel/Kconfig +4
-0user 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_VECTORdrivers/thermal/intel/Makefile +0
-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.odrivers/thermal/intel/Makefile +1
-0+obj-$(CONFIG_X86_THERMAL_VECTOR) += therm_throt.odrivers/thermal/intel/therm_throt.c renamed from arch/x86/kernel/cpu/mce/therm_throt.c +2
-21@@ -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){drivers/thermal/intel/therm_throt.c renamed from arch/x86/kernel/cpu/mce/therm_throt.c +1
-1@@ -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
Borislav Petkov
maintainerRe: [PATCH v2 2/2] thermal: Move therm_throt there from x86/mce
Quoted 3 lines · Srinivas Pandruvada
Can the handler, processing architectural features via thermal interrupt, reside in
arch/x86folder or need to bedrivers/thermal/intel?
Look at...
Quoted 6 lines
Quoted 6 lines
drivers/thermal/intel/therm_throt.c void intel_init_thermal(struct cpuinfo_x86 *c) · line 702
Quoted 6 lines
drivers/thermal/intel/therm_throt.c renamed from arch/x86/kernel/cpu/mce/therm_throt.c +1
-1@@ -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);
... here. ^
This should answer your question.
Signature · 4 lines
Regards/Gruss,
Boris.
https://people.kernel.org/tglx/notes-about-netiquetteRe: [PATCH v2 2/2] thermal: Move therm_throt there from x86/mce
Quoted 13 lines · Borislav Petkov
Quoted 3 lines · Srinivas Pandruvada
Can the handler, processing architectural features via thermal interrupt, reside in
arch/x86folder or need to bedrivers/thermal/intel?Look at...
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
(quoted diff) +0
-0@@ -718,7 +699,7 @@ void intel_init_thermal(struct cpuinfo_x86 *c) | PACKAGE_THERM_INT_HIGH_ENABLE), h); }
Quoted 6 lines
Quoted 2 lines
Quoted 2 lines
drivers/thermal/intel/therm_throt.c void intel_init_thermal(struct cpuinfo_x86 *c) · line 702
Quoted 2 lines
drivers/thermal/intel/therm_throt.c renamed from arch/x86/kernel/cpu/mce/therm_throt.c +1
-1- smp_thermal_vector = intel_thermal_interrupt; +thermal_set_handler (intel_thermal_interrupt);... here. ^
This should answer your question.
Thanks for the answer.
-Srinivas
Re: [PATCH v2 2/2] thermal: Move therm_throt there from x86/mce
In reply to Borislav PetkovQuoted 11 lines · Borislav Petkov
From: Borislav Petkov <[email protected]>
This functionality has nothing to do with MCE, move it to the thermal framework and untangle it from MCE.
Have
thermal_set_handler()check the build-time assigned default handler
stub was the one used beforetherm_throtassigns a new one.Requested-by Peter Zijlstra <[email protected]>Signed-off-by Borislav Petkov <[email protected]>
thanks,
rui
Quoted 295 lines
--- 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 | 29 +++++++++++++++++++ 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, 67 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
-0@@ -1158,10 +1158,6 @@ config X86_MCE_INJECT If you don't know what a machine check is and you don't dokernel
arch/x86/Kconfig +0
-4QA 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_VM86arch/x86/include/asm/irq.h +0
-0@@ -53,4 +53,8 @@ void arch_trigger_cpumask_backtrace(const structcpumask *mask, #define arch_trigger_cpumask_backtrace
arch_trigger_cpumask_backtrace
#endifarch/x86/include/asm/irq.h +4
-0+#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.oarch/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 +9
-0@@ -374,3 +374,32 @@ 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;arch/x86/kernel/irq.c +5
-0+ +void thermal_set_handler (void (*handler)(void )) +{ +if (handler) { + WARN_ON(smp_thermal_vector !=
unexpected_thermal_interrupt);arch/x86/kernel/irq.c +15
-0+ smp_thermal_vector = handler; + }else { + smp_thermal_vector = 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 (); +} +#endif drivers/thermal/intel/Kconfig +0
-0@@ -8,6 +8,10 @@ config INTEL_POWERCLAMP enforce idle time which results in more package C-stateresidency. The
drivers/thermal/intel/Kconfig +4
-0user 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_VECTORdrivers/thermal/intel/Makefile +0
-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.odrivers/thermal/intel/Makefile +1
-0+obj-$(CONFIG_X86_THERMAL_VECTOR) += therm_throt.odrivers/thermal/intel/therm_throt.c renamed from arch/x86/kernel/cpu/mce/therm_throt.c +2
-21@@ -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){
drivers/thermal/intel/therm_throt.c renamed from arch/x86/kernel/cpu/mce/therm_throt.c +1
-1@@ -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
[tip: ras/core] thermal: Move therm_throt there from x86/mce
In reply to Borislav PetkovThe following commit has been merged into the ras/core branch of tip:
The following commit has been merged into the ras/core branch of tip:
Commit-ID: 1dba8a9538f5164eb8874eed4c7d6799a3c64963 Gitweb: https://git.kernel.org/tip/1dba8a9538f5164eb8874eed4c7d6799a3c64963 Author: Borislav Petkov <[email protected]> AuthorDate: Thu, 07 Jan 2021 13:29:05 +01:00 Committer: Borislav Petkov <[email protected]> CommitterDate: Fri, 29 Jan 2021 17:47:26 +01:00
thermal: Move therm_throt there from x86/mce
This functionality has nothing to do with MCE, move it to the thermal framework and untangle it from MCE.
Have thermal_set_handler() check the build-time assigned default handler stub was the one used before therm_throt assigns a new one.
--- 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/cpu/mce/therm_throt.c | 731 +------------------ arch/x86/kernel/irq.c | 29 +- drivers/thermal/intel/Kconfig | 4 +- drivers/thermal/intel/Makefile | 1 +- drivers/thermal/intel/therm_throt.c | 712 ++++++++++++++++++- drivers/thermal/intel/x86_pkg_temp_thermal.c | 3 +- 13 files changed, 776 insertions(+), 755 deletions(-) create mode 100644 arch/x86/include/asm/thermal.h delete mode 100644 arch/x86/kernel/cpu/mce/therm_throt.c create mode 100644 drivers/thermal/intel/therm_throt.c
arch/x86/Kconfig +0 -4
@@ -1157,10 +1157,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
@@ -289,22 +289,6 @@ extern void (*mce_threshold_vector)(void);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/cpu/mce/therm_throt.c deleted +0 -731
731 lines not on this page · raw message
arch/x86/kernel/irq.c +29 -0
@@ -374,3 +374,32 @@ 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) { +WARN_ON (smp_thermal_vector != unexpected_thermal_interrupt); + smp_thermal_vector = handler; + }else { + smp_thermal_vector = 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 (); +} +#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 new file +712 -0
712 lines not on this page · raw message
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