[PATCH] x86/mce/amd: Fix inverted interrupt enablement during storm handling
Jasjeet Rangi <[email protected]>
| Newsgroups | org.kernel.vger.linux-edac,org.kernel.vger.stable |
|---|---|
| Message-ID | <[email protected]> |
mce_amd_handle_storm() currently does the opposite of what storm
handling needs: it enables threshold interrupts when a storm is detected
and disables them when the storm subsides.
In addition, machine_check_poll() -> clear_bank() -> amd_clear_bank() ->
amd_reset_thr_limit() will unconditionally enable threshold interrupts,
which undoes storm mode behavior.
Fix this by disabling interrupts when storm mode is entered and enabling
interrupts when storm mode is cleared. Also make amd_reset_thr_limit()
enable interrupts when the bank is not in storm mode and disable
interrupts when the bank is in storm mode.
Rename mce_handle_storm() parameter "on" to "in_storm_mode" to
disambiguate its meaning. This includes updating the Intel storm handler
parameter as well.
Fixes: 5c4663ed1eac ("x86/mce: Handle AMD threshold interrupt storms")
Cc: [email protected]
Signed-off-by: Jasjeet Rangi <[email protected]>
---
arch/x86/kernel/cpu/mce/amd.c | 9 ++++++---
arch/x86/kernel/cpu/mce/intel.c | 4 ++--
arch/x86/kernel/cpu/mce/internal.h | 8 ++++----
arch/x86/kernel/cpu/mce/threshold.c | 6 +++---
4 files changed, 15 insertions(+), 12 deletions(-)
diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c
index 83b04e02417d..fd8f7ce4f38b 100644
--- a/arch/x86/kernel/cpu/mce/amd.c
+++ b/arch/x86/kernel/cpu/mce/amd.c
@@ -842,14 +842,17 @@ static void amd_deferred_error_interrupt(void)
machine_check_poll(MCP_TIMESTAMP, &this_cpu_ptr(&mce_amd_data)->dfr_intr_banks);
}
-void mce_amd_handle_storm(unsigned int bank, bool on)
+void mce_amd_handle_storm(unsigned int bank, bool in_storm_mode)
{
- threshold_restart_bank(bank, on);
+ threshold_restart_bank(bank, !in_storm_mode);
}
static void amd_reset_thr_limit(unsigned int bank)
{
- threshold_restart_bank(bank, true);
+ struct mca_storm_desc *storm = this_cpu_ptr(&storm_desc);
+ bool intr_en = !storm->banks[bank].in_storm_mode;
+
+ threshold_restart_bank(bank, intr_en);
}
/*
diff --git a/arch/x86/kernel/cpu/mce/intel.c b/arch/x86/kernel/cpu/mce/intel.c
index 4655223ba560..3e3cbdc4fedd 100644
--- a/arch/x86/kernel/cpu/mce/intel.c
+++ b/arch/x86/kernel/cpu/mce/intel.c
@@ -147,9 +147,9 @@ static void cmci_set_threshold(int bank, int thresh)
raw_spin_unlock_irqrestore(&cmci_discover_lock, flags);
}
-void mce_intel_handle_storm(int bank, bool on)
+void mce_intel_handle_storm(int bank, bool in_storm_mode)
{
- if (on)
+ if (in_storm_mode)
cmci_set_threshold(bank, CMCI_STORM_THRESHOLD);
else
cmci_set_threshold(bank, cmci_threshold[bank]);
diff --git a/arch/x86/kernel/cpu/mce/internal.h b/arch/x86/kernel/cpu/mce/internal.h
index 85bb474f2f44..287ef4a8223a 100644
--- a/arch/x86/kernel/cpu/mce/internal.h
+++ b/arch/x86/kernel/cpu/mce/internal.h
@@ -41,7 +41,7 @@ struct dentry *mce_get_debugfs_dir(void);
extern mce_banks_t mce_banks_ce_disabled;
#ifdef CONFIG_X86_MCE_INTEL
-void mce_intel_handle_storm(int bank, bool on);
+void mce_intel_handle_storm(int bank, bool in_storm_mode);
void cmci_disable_bank(int bank);
void intel_init_cmci(void);
void intel_init_lmce(void);
@@ -49,7 +49,7 @@ void intel_clear_lmce(void);
bool intel_filter_mce(struct mce *m);
bool intel_mce_usable_address(struct mce *m);
#else
-static inline void mce_intel_handle_storm(int bank, bool on) { }
+static inline void mce_intel_handle_storm(int bank, bool in_storm_mode) { }
static inline void cmci_disable_bank(int bank) { }
static inline void intel_init_cmci(void) { }
static inline void intel_init_lmce(void) { }
@@ -270,7 +270,7 @@ void mce_prep_record_per_cpu(unsigned int cpu, struct mce *m);
#ifdef CONFIG_X86_MCE_AMD
void mce_threshold_create_device(unsigned int cpu);
void mce_threshold_remove_device(unsigned int cpu);
-void mce_amd_handle_storm(unsigned int bank, bool on);
+void mce_amd_handle_storm(unsigned int bank, bool in_storm_mode);
extern bool amd_filter_mce(struct mce *m);
bool amd_mce_usable_address(struct mce *m);
void amd_clear_bank(struct mce *m);
@@ -303,7 +303,7 @@ void smca_bsp_init(void);
#else
static inline void mce_threshold_create_device(unsigned int cpu) { }
static inline void mce_threshold_remove_device(unsigned int cpu) { }
-static inline void mce_amd_handle_storm(unsigned int bank, bool on) { }
+static inline void mce_amd_handle_storm(unsigned int bank, bool in_storm_mode) { }
static inline bool amd_filter_mce(struct mce *m) { return false; }
static inline bool amd_mce_usable_address(struct mce *m) { return false; }
static inline void amd_clear_bank(struct mce *m) { }
diff --git a/arch/x86/kernel/cpu/mce/threshold.c b/arch/x86/kernel/cpu/mce/threshold.c
index 22e4c916559f..14e4713adc53 100644
--- a/arch/x86/kernel/cpu/mce/threshold.c
+++ b/arch/x86/kernel/cpu/mce/threshold.c
@@ -70,14 +70,14 @@ void mce_set_storm_mode(bool storm)
__this_cpu_write(storm_desc.poll_mode, storm);
}
-static void mce_handle_storm(unsigned int bank, bool on)
+static void mce_handle_storm(unsigned int bank, bool in_storm_mode)
{
switch (boot_cpu_data.x86_vendor) {
case X86_VENDOR_INTEL:
- mce_intel_handle_storm(bank, on);
+ mce_intel_handle_storm(bank, in_storm_mode);
break;
case X86_VENDOR_AMD:
- mce_amd_handle_storm(bank, on);
+ mce_amd_handle_storm(bank, in_storm_mode);
break;
}
}
--
2.50.1