diff options
author | Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com> | 2015-05-27 15:03:34 -0400 |
---|---|---|
committer | Borislav Petkov <bp@suse.de> | 2015-06-03 10:18:22 -0400 |
commit | 685d46d72ba456569d739cc3ff43577f4001d52f (patch) | |
tree | e42e289d0baa778239c2f01536261633bd2a5848 /drivers/edac/mce_amd_inj.c | |
parent | e7f2ea1dbec30d607f0017706aa25b77477dd69c (diff) |
EDAC, mce_amd_inj: Read out number of MCE banks from the hardware
The number of banks for a given processor is encoded in
MSR_IA32_MCG_CAP[7:0]. So obtain the value from that MSR and use it for
sanity checking in inj_bank_set() instead of doing a family/model check.
Signed-off-by: Aravind Gopalakrishnan <Aravind.Gopalakrishnan@amd.com>
Cc: linux-edac <linux-edac@vger.kernel.org>
Cc: mchehab@osg.samsung.com
Link: http://lkml.kernel.org/r/1432753418-2985-3-git-send-email-Aravind.Gopalakrishnan@amd.com
Signed-off-by: Borislav Petkov <bp@suse.de>
Diffstat (limited to 'drivers/edac/mce_amd_inj.c')
-rw-r--r-- | drivers/edac/mce_amd_inj.c | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/drivers/edac/mce_amd_inj.c b/drivers/edac/mce_amd_inj.c index 7f3a97a5ad17..15f6aa18b2f8 100644 --- a/drivers/edac/mce_amd_inj.c +++ b/drivers/edac/mce_amd_inj.c | |||
@@ -25,6 +25,8 @@ | |||
25 | static struct mce i_mce; | 25 | static struct mce i_mce; |
26 | static struct dentry *dfs_inj; | 26 | static struct dentry *dfs_inj; |
27 | 27 | ||
28 | static u8 n_banks; | ||
29 | |||
28 | #define MCE_INJECT_SET(reg) \ | 30 | #define MCE_INJECT_SET(reg) \ |
29 | static int inj_##reg##_set(void *data, u64 val) \ | 31 | static int inj_##reg##_set(void *data, u64 val) \ |
30 | { \ | 32 | { \ |
@@ -174,11 +176,9 @@ static int inj_bank_set(void *data, u64 val) | |||
174 | { | 176 | { |
175 | struct mce *m = (struct mce *)data; | 177 | struct mce *m = (struct mce *)data; |
176 | 178 | ||
177 | if (val > 5) { | 179 | if (val >= n_banks) { |
178 | if (boot_cpu_data.x86 != 0x15 || val > 6) { | 180 | pr_err("Non-existent MCE bank: %llu\n", val); |
179 | pr_err("Non-existent MCE bank: %llu\n", val); | 181 | return -EINVAL; |
180 | return -EINVAL; | ||
181 | } | ||
182 | } | 182 | } |
183 | 183 | ||
184 | m->bank = val; | 184 | m->bank = val; |
@@ -207,6 +207,10 @@ static struct dfs_node { | |||
207 | static int __init init_mce_inject(void) | 207 | static int __init init_mce_inject(void) |
208 | { | 208 | { |
209 | int i; | 209 | int i; |
210 | u64 cap; | ||
211 | |||
212 | rdmsrl(MSR_IA32_MCG_CAP, cap); | ||
213 | n_banks = cap & MCG_BANKCNT_MASK; | ||
210 | 214 | ||
211 | dfs_inj = debugfs_create_dir("mce-inject", NULL); | 215 | dfs_inj = debugfs_create_dir("mce-inject", NULL); |
212 | if (!dfs_inj) | 216 | if (!dfs_inj) |