1 #include "amd64_edac.h"
3 static ssize_t amd64_inject_section_show(struct mem_ctl_info *mci, char *buf)
5 struct amd64_pvt *pvt = mci->pvt_info;
6 return sprintf(buf, "0x%x\n", pvt->injection.section);
10 * store error injection section value which refers to one of 4 16-byte sections
11 * within a 64-byte cacheline
15 static ssize_t amd64_inject_section_store(struct mem_ctl_info *mci,
16 const char *data, size_t count)
18 struct amd64_pvt *pvt = mci->pvt_info;
22 ret = strict_strtoul(data, 10, &value);
26 amd64_printk(KERN_WARNING,
27 "%s: invalid section 0x%lx\n",
32 pvt->injection.section = (u32) value;
38 static ssize_t amd64_inject_word_show(struct mem_ctl_info *mci, char *buf)
40 struct amd64_pvt *pvt = mci->pvt_info;
41 return sprintf(buf, "0x%x\n", pvt->injection.word);
45 * store error injection word value which refers to one of 9 16-bit word of the
46 * 16-byte (128-bit + ECC bits) section
50 static ssize_t amd64_inject_word_store(struct mem_ctl_info *mci,
51 const char *data, size_t count)
53 struct amd64_pvt *pvt = mci->pvt_info;
57 ret = strict_strtoul(data, 10, &value);
61 amd64_printk(KERN_WARNING,
62 "%s: invalid word 0x%lx\n",
67 pvt->injection.word = (u32) value;
73 static ssize_t amd64_inject_ecc_vector_show(struct mem_ctl_info *mci, char *buf)
75 struct amd64_pvt *pvt = mci->pvt_info;
76 return sprintf(buf, "0x%x\n", pvt->injection.bit_map);
80 * store 16 bit error injection vector which enables injecting errors to the
81 * corresponding bit within the error injection word above. When used during a
82 * DRAM ECC read, it holds the contents of the of the DRAM ECC bits.
84 static ssize_t amd64_inject_ecc_vector_store(struct mem_ctl_info *mci,
85 const char *data, size_t count)
87 struct amd64_pvt *pvt = mci->pvt_info;
91 ret = strict_strtoul(data, 16, &value);
94 if (value & 0xFFFF0000) {
95 amd64_printk(KERN_WARNING,
96 "%s: invalid EccVector: 0x%lx\n",
101 pvt->injection.bit_map = (u32) value;
108 * Do a DRAM ECC read. Assemble staged values in the pvt area, format into
109 * fields needed by the injection registers and read the NB Array Data Port.
111 static ssize_t amd64_inject_read_store(struct mem_ctl_info *mci,
112 const char *data, size_t count)
114 struct amd64_pvt *pvt = mci->pvt_info;
116 u32 section, word_bits;
119 ret = strict_strtoul(data, 10, &value);
120 if (ret != -EINVAL) {
122 /* Form value to choose 16-byte section of cacheline */
123 section = F10_NB_ARRAY_DRAM_ECC |
124 SET_NB_ARRAY_ADDRESS(pvt->injection.section);
125 pci_write_config_dword(pvt->misc_f3_ctl,
126 F10_NB_ARRAY_ADDR, section);
128 word_bits = SET_NB_DRAM_INJECTION_READ(pvt->injection.word,
129 pvt->injection.bit_map);
131 /* Issue 'word' and 'bit' along with the READ request */
132 pci_write_config_dword(pvt->misc_f3_ctl,
133 F10_NB_ARRAY_DATA, word_bits);
135 debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
143 * Do a DRAM ECC write. Assemble staged values in the pvt area and format into
144 * fields needed by the injection registers.
146 static ssize_t amd64_inject_write_store(struct mem_ctl_info *mci,
147 const char *data, size_t count)
149 struct amd64_pvt *pvt = mci->pvt_info;
151 u32 section, word_bits;
154 ret = strict_strtoul(data, 10, &value);
155 if (ret != -EINVAL) {
157 /* Form value to choose 16-byte section of cacheline */
158 section = F10_NB_ARRAY_DRAM_ECC |
159 SET_NB_ARRAY_ADDRESS(pvt->injection.section);
160 pci_write_config_dword(pvt->misc_f3_ctl,
161 F10_NB_ARRAY_ADDR, section);
163 word_bits = SET_NB_DRAM_INJECTION_WRITE(pvt->injection.word,
164 pvt->injection.bit_map);
166 /* Issue 'word' and 'bit' along with the READ request */
167 pci_write_config_dword(pvt->misc_f3_ctl,
168 F10_NB_ARRAY_DATA, word_bits);
170 debugf0("section=0x%x word_bits=0x%x\n", section, word_bits);
178 * update NUM_INJ_ATTRS in case you add new members
180 struct mcidev_sysfs_attribute amd64_inj_attrs[] = {
184 .name = "inject_section",
185 .mode = (S_IRUGO | S_IWUSR)
187 .show = amd64_inject_section_show,
188 .store = amd64_inject_section_store,
192 .name = "inject_word",
193 .mode = (S_IRUGO | S_IWUSR)
195 .show = amd64_inject_word_show,
196 .store = amd64_inject_word_store,
200 .name = "inject_ecc_vector",
201 .mode = (S_IRUGO | S_IWUSR)
203 .show = amd64_inject_ecc_vector_show,
204 .store = amd64_inject_ecc_vector_store,
208 .name = "inject_write",
209 .mode = (S_IRUGO | S_IWUSR)
212 .store = amd64_inject_write_store,
216 .name = "inject_read",
217 .mode = (S_IRUGO | S_IWUSR)
220 .store = amd64_inject_read_store,