diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2020-02-12 00:34:01 +0100 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2020-04-14 15:47:11 +0200 |
commit | c9bf318f77b3a78483e656e609d005c52aadc86d (patch) | |
tree | 475b6e6950ba1387736445e93c261621e2ab6513 /arch/x86/kernel/cpu/mce/amd.c | |
parent | ada018b15ccecbdb95df46db7121516edb906bf6 (diff) | |
download | linux-c9bf318f77b3a78483e656e609d005c52aadc86d.tar.bz2 |
x86/mce/amd: Init thresholding machinery only on relevant vendors
... and not unconditionally.
[ bp: Add a new vendor_flags bit for that. ]
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Signed-off-by: Borislav Petkov <bp@suse.de>
Link: https://lkml.kernel.org/r/20200403161943.1458-3-bp@alien8.de
Diffstat (limited to 'arch/x86/kernel/cpu/mce/amd.c')
-rw-r--r-- | arch/x86/kernel/cpu/mce/amd.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/arch/x86/kernel/cpu/mce/amd.c b/arch/x86/kernel/cpu/mce/amd.c index 477cf773cf1c..c3b3326ad4ac 100644 --- a/arch/x86/kernel/cpu/mce/amd.c +++ b/arch/x86/kernel/cpu/mce/amd.c @@ -1442,15 +1442,20 @@ free_out: int mce_threshold_remove_device(unsigned int cpu) { + struct threshold_bank **bp = this_cpu_read(threshold_banks); unsigned int bank; + if (!bp) + return 0; + for (bank = 0; bank < per_cpu(mce_num_banks, cpu); ++bank) { if (!(per_cpu(bank_map, cpu) & (1 << bank))) continue; threshold_remove_bank(cpu, bank); } - kfree(per_cpu(threshold_banks, cpu)); - per_cpu(threshold_banks, cpu) = NULL; + /* Clear the pointer before freeing the memory */ + this_cpu_write(threshold_banks, NULL); + kfree(bp); return 0; } @@ -1461,6 +1466,9 @@ int mce_threshold_create_device(unsigned int cpu) struct threshold_bank **bp; int err = 0; + if (!mce_flags.amd_threshold) + return 0; + bp = per_cpu(threshold_banks, cpu); if (bp) return 0; |