]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/mce/amd: Define threshold restart function for banks
authorYazen Ghannam <yazen.ghannam@amd.com>
Tue, 4 Nov 2025 14:55:43 +0000 (14:55 +0000)
committerBorislav Petkov (AMD) <bp@alien8.de>
Wed, 5 Nov 2025 21:38:31 +0000 (22:38 +0100)
Prepare for CMCI storm support by moving the common bank/block iterator code
to a helper function.

Include a parameter to switch the interrupt enable. This will be used by the
CMCI storm handling function.

Signed-off-by: Yazen Ghannam <yazen.ghannam@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Reviewed-by: Nikolay Borisov <nik.borisov@suse.com>
Link: https://lore.kernel.org/20251104-wip-mca-updates-v8-0-66c8eacf67b9@amd.com
arch/x86/kernel/cpu/mce/amd.c

index af2221bcba964e6d91ddf8ed19631f98a1b43b0d..940d1a03356913f95cb5411af7c7ff3519bf70a2 100644 (file)
@@ -471,6 +471,24 @@ static void threshold_restart_block(void *_tr)
        wrmsr(tr->b->address, lo, hi);
 }
 
+static void threshold_restart_bank(unsigned int bank, bool intr_en)
+{
+       struct threshold_bank **thr_banks = this_cpu_read(threshold_banks);
+       struct threshold_block *block, *tmp;
+       struct thresh_restart tr;
+
+       if (!thr_banks || !thr_banks[bank])
+               return;
+
+       memset(&tr, 0, sizeof(tr));
+
+       list_for_each_entry_safe(block, tmp, &thr_banks[bank]->miscj, miscj) {
+               tr.b = block;
+               tr.b->interrupt_enable = intr_en;
+               threshold_restart_block(&tr);
+       }
+}
+
 static void mce_threshold_block_init(struct threshold_block *b, int offset)
 {
        struct thresh_restart tr = {
@@ -814,24 +832,7 @@ static void amd_deferred_error_interrupt(void)
 
 static void amd_reset_thr_limit(unsigned int bank)
 {
-       struct threshold_bank **bp = this_cpu_read(threshold_banks);
-       struct threshold_block *block, *tmp;
-       struct thresh_restart tr;
-
-       /*
-        * Validate that the threshold bank has been initialized already. The
-        * handler is installed at boot time, but on a hotplug event the
-        * interrupt might fire before the data has been initialized.
-        */
-       if (!bp || !bp[bank])
-               return;
-
-       memset(&tr, 0, sizeof(tr));
-
-       list_for_each_entry_safe(block, tmp, &bp[bank]->miscj, miscj) {
-               tr.b = block;
-               threshold_restart_block(&tr);
-       }
+       threshold_restart_bank(bank, true);
 }
 
 /*