diff options
author | Yazen Ghannam <Yazen.Ghannam@amd.com> | 2016-09-12 03:59:35 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2016-09-13 09:23:11 -0400 |
commit | 87a6d4091bd795b43d684bfc87253e04a263af1c (patch) | |
tree | 722d37c55f4c24c8fb6cd70289ca7514a9b9f368 | |
parent | 5896820e0aa32572ad03b30563c539655b6c6375 (diff) |
x86/mce/AMD: Update sysfs bank names for SMCA systems
Define a bank's sysfs filename based on its IP type and InstanceId.
Credits go to Aravind for:
* The general idea and proto- get_name().
* Defining smca_umc_block_names[] and buf_mcatype[].
Signed-off-by: Yazen Ghannam <Yazen.Ghannam@amd.com>
Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Aravind Gopalakrishnan <aravindksg.lkml@gmail.com>
Link: http://lkml.kernel.org/r/1473193490-3291-2-git-send-email-Yazen.Ghannam@amd.com
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
-rw-r--r-- | arch/x86/kernel/cpu/mcheck/mce_amd.c | 49 |
1 files changed, 47 insertions, 2 deletions
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index 3b74b62d0808..0f9d0786bc97 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/cpu.h> | 21 | #include <linux/cpu.h> |
22 | #include <linux/smp.h> | 22 | #include <linux/smp.h> |
23 | #include <linux/string.h> | ||
23 | 24 | ||
24 | #include <asm/amd_nb.h> | 25 | #include <asm/amd_nb.h> |
25 | #include <asm/apic.h> | 26 | #include <asm/apic.h> |
@@ -63,6 +64,11 @@ static const char * const th_names[] = { | |||
63 | "execution_unit", | 64 | "execution_unit", |
64 | }; | 65 | }; |
65 | 66 | ||
67 | static const char * const smca_umc_block_names[] = { | ||
68 | "dram_ecc", | ||
69 | "misc_umc" | ||
70 | }; | ||
71 | |||
66 | struct smca_bank_name smca_bank_names[] = { | 72 | struct smca_bank_name smca_bank_names[] = { |
67 | [SMCA_LS] = { "load_store", "Load Store Unit" }, | 73 | [SMCA_LS] = { "load_store", "Load Store Unit" }, |
68 | [SMCA_IF] = { "insn_fetch", "Instruction Fetch Unit" }, | 74 | [SMCA_IF] = { "insn_fetch", "Instruction Fetch Unit" }, |
@@ -113,6 +119,17 @@ static struct smca_hwid_mcatype smca_hwid_mcatypes[] = { | |||
113 | struct smca_bank_info smca_banks[MAX_NR_BANKS]; | 119 | struct smca_bank_info smca_banks[MAX_NR_BANKS]; |
114 | EXPORT_SYMBOL_GPL(smca_banks); | 120 | EXPORT_SYMBOL_GPL(smca_banks); |
115 | 121 | ||
122 | /* | ||
123 | * In SMCA enabled processors, we can have multiple banks for a given IP type. | ||
124 | * So to define a unique name for each bank, we use a temp c-string to append | ||
125 | * the MCA_IPID[InstanceId] to type's name in get_name(). | ||
126 | * | ||
127 | * InstanceId is 32 bits which is 8 characters. Make sure MAX_MCATYPE_NAME_LEN | ||
128 | * is greater than 8 plus 1 (for underscore) plus length of longest type name. | ||
129 | */ | ||
130 | #define MAX_MCATYPE_NAME_LEN 30 | ||
131 | static char buf_mcatype[MAX_MCATYPE_NAME_LEN]; | ||
132 | |||
116 | static DEFINE_PER_CPU(struct threshold_bank **, threshold_banks); | 133 | static DEFINE_PER_CPU(struct threshold_bank **, threshold_banks); |
117 | static DEFINE_PER_CPU(unsigned int, bank_map); /* see which banks are on */ | 134 | static DEFINE_PER_CPU(unsigned int, bank_map); /* see which banks are on */ |
118 | 135 | ||
@@ -769,6 +786,34 @@ static struct kobj_type threshold_ktype = { | |||
769 | .default_attrs = default_attrs, | 786 | .default_attrs = default_attrs, |
770 | }; | 787 | }; |
771 | 788 | ||
789 | static const char *get_name(unsigned int bank, struct threshold_block *b) | ||
790 | { | ||
791 | unsigned int bank_type; | ||
792 | |||
793 | if (!mce_flags.smca) { | ||
794 | if (b && bank == 4) | ||
795 | return bank4_names(b); | ||
796 | |||
797 | return th_names[bank]; | ||
798 | } | ||
799 | |||
800 | if (!smca_banks[bank].type) | ||
801 | return NULL; | ||
802 | |||
803 | bank_type = smca_banks[bank].type->bank_type; | ||
804 | |||
805 | if (b && bank_type == SMCA_UMC) { | ||
806 | if (b->block < ARRAY_SIZE(smca_umc_block_names)) | ||
807 | return smca_umc_block_names[b->block]; | ||
808 | return NULL; | ||
809 | } | ||
810 | |||
811 | snprintf(buf_mcatype, MAX_MCATYPE_NAME_LEN, | ||
812 | "%s_%x", smca_bank_names[bank_type].name, | ||
813 | smca_banks[bank].type_instance); | ||
814 | return buf_mcatype; | ||
815 | } | ||
816 | |||
772 | static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank, | 817 | static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank, |
773 | unsigned int block, u32 address) | 818 | unsigned int block, u32 address) |
774 | { | 819 | { |
@@ -823,7 +868,7 @@ static int allocate_threshold_blocks(unsigned int cpu, unsigned int bank, | |||
823 | 868 | ||
824 | err = kobject_init_and_add(&b->kobj, &threshold_ktype, | 869 | err = kobject_init_and_add(&b->kobj, &threshold_ktype, |
825 | per_cpu(threshold_banks, cpu)[bank]->kobj, | 870 | per_cpu(threshold_banks, cpu)[bank]->kobj, |
826 | (bank == 4 ? bank4_names(b) : th_names[bank])); | 871 | get_name(bank, b)); |
827 | if (err) | 872 | if (err) |
828 | goto out_free; | 873 | goto out_free; |
829 | recurse: | 874 | recurse: |
@@ -878,7 +923,7 @@ static int threshold_create_bank(unsigned int cpu, unsigned int bank) | |||
878 | struct device *dev = per_cpu(mce_device, cpu); | 923 | struct device *dev = per_cpu(mce_device, cpu); |
879 | struct amd_northbridge *nb = NULL; | 924 | struct amd_northbridge *nb = NULL; |
880 | struct threshold_bank *b = NULL; | 925 | struct threshold_bank *b = NULL; |
881 | const char *name = th_names[bank]; | 926 | const char *name = get_name(bank, NULL); |
882 | int err = 0; | 927 | int err = 0; |
883 | 928 | ||
884 | if (is_shared_bank(bank)) { | 929 | if (is_shared_bank(bank)) { |