1 #include "amd64_edac.h"
4 * store error injection section value which refers to one of 4 16-byte sections
5 * within a 64-byte cacheline
9 static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci,
10 const char *data, size_t count)
12 struct amd64_pvt *pvt = mci->pvt_info;
16 ret = strict_strtoul(data, 10, &value);
18 pvt->injection.section = (u32) value;
25 * store error injection word value which refers to one of 9 16-bit word of the
26 * 16-byte (128-bit + ECC bits) section
30 static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci,
31 const char *data, size_t count)
33 struct amd64_pvt *pvt = mci->pvt_info;
37 ret = strict_strtoul(data, 10, &value);
40 value = (value <= 8) ? value : 0;
41 pvt->injection.word = (u32) value;
49 * store 16 bit error injection vector which enables injecting errors to the
50 * corresponding bit within the error injection word above. When used during a
51 * DRAM ECC read, it holds the contents of the of the DRAM ECC bits.
53 static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci,
54 const char *data, size_t count)
56 struct amd64_pvt *pvt = mci->pvt_info;
60 ret = strict_strtoul(data, 16, &value);
63 pvt->injection.bit_map = (u32) value & 0xFFFF;
71 * Do a DRAM ECC read. Assemble staged values in the pvt area, format into
72 * fields needed by the injection registers and read the NB Array Data Port.
74 static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
75 const char *data, size_t count)
77 struct amd64_pvt *pvt = mci->pvt_info;
79 u32 section, word_bits;
82 ret = strict_strtoul(data, 10, &value);
85 /* Form value to choose 16-byte section of cacheline */
86 section = F10_NB_ARRAY_DRAM_ECC |
87 SET_NB_ARRAY_ADDRESS(pvt->injection.section);
88 pci_write_config_dword(pvt->misc_f3_ctl,
89 F10_NB_ARRAY_ADDR, section);
91 word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection.word,
92 pvt->injection.bit_map);
94 /* Issue 'word' and 'bit' along with the READ request */
95 pci_write_config_dword(pvt->misc_f3_ctl,
96 F10_NB_ARRAY_DATA, word_bits);
98 debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
106 * Do a DRAM ECC write. Assemble staged values in the pvt area and format into
107 * fields needed by the injection registers.
109 static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci,
110 const char *data, size_t count)
112 struct amd64_pvt *pvt = mci->pvt_info;
114 u32 section, word_bits;
117 ret = strict_strtoul(data, 10, &value);
118 if (ret != -EINVAL) {
120 /* Form value to choose 16-byte section of cacheline */
121 section = F10_NB_ARRAY_DRAM_ECC |
122 SET_NB_ARRAY_ADDRESS(pvt->injection.section);
123 pci_write_config_dword(pvt->misc_f3_ctl,
124 F10_NB_ARRAY_ADDR, section);
126 word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection.word,
127 pvt->injection.bit_map);
129 /* Issue 'word' and 'bit' along with the READ request */
130 pci_write_config_dword(pvt->misc_f3_ctl,
131 F10_NB_ARRAY_DATA, word_bits);
133 debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
141 * update NUM_INJ_ATTRS in case you add new members
143 struct mcidev_sysfs_attribute amd64_inj_attrs[] = {
147 .name = "inject_section",
148 .mode = (S_IRUGO | S_IWUSR)
151 .store = amd64_inject_section_store,
155 .name = "inject_word",
156 .mode = (S_IRUGO | S_IWUSR)
159 .store = amd64_inject_word_store,
163 .name = "inject_ecc_vector",
164 .mode = (S_IRUGO | S_IWUSR)
167 .store = amd64_inject_ecc_vector_store,
171 .name = "inject_write",
172 .mode = (S_IRUGO | S_IWUSR)
175 .store = amd64_inject_write_store,
179 .name = "inject_read",
180 .mode = (S_IRUGO | S_IWUSR)
183 .store = amd64_inject_read_store,