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_warn("%s: invalid section 0x%lx\n", __func__
, value
);
30 pvt
->injection
.section
= (u32
) value
;
36 static ssize_t
amd64_inject_word_show(struct mem_ctl_info
*mci
, char *buf
)
38 struct amd64_pvt
*pvt
= mci
->pvt_info
;
39 return sprintf(buf
, "0x%x\n", pvt
->injection
.word
);
43 * store error injection word value which refers to one of 9 16-bit word of the
44 * 16-byte (128-bit + ECC bits) section
48 static ssize_t
amd64_inject_word_store(struct mem_ctl_info
*mci
,
49 const char *data
, size_t count
)
51 struct amd64_pvt
*pvt
= mci
->pvt_info
;
55 ret
= strict_strtoul(data
, 10, &value
);
59 amd64_warn("%s: invalid word 0x%lx\n", __func__
, value
);
63 pvt
->injection
.word
= (u32
) value
;
69 static ssize_t
amd64_inject_ecc_vector_show(struct mem_ctl_info
*mci
, char *buf
)
71 struct amd64_pvt
*pvt
= mci
->pvt_info
;
72 return sprintf(buf
, "0x%x\n", pvt
->injection
.bit_map
);
76 * store 16 bit error injection vector which enables injecting errors to the
77 * corresponding bit within the error injection word above. When used during a
78 * DRAM ECC read, it holds the contents of the of the DRAM ECC bits.
80 static ssize_t
amd64_inject_ecc_vector_store(struct mem_ctl_info
*mci
,
81 const char *data
, size_t count
)
83 struct amd64_pvt
*pvt
= mci
->pvt_info
;
87 ret
= strict_strtoul(data
, 16, &value
);
90 if (value
& 0xFFFF0000) {
91 amd64_warn("%s: invalid EccVector: 0x%lx\n",
96 pvt
->injection
.bit_map
= (u32
) value
;
103 * Do a DRAM ECC read. Assemble staged values in the pvt area, format into
104 * fields needed by the injection registers and read the NB Array Data Port.
106 static ssize_t
amd64_inject_read_store(struct mem_ctl_info
*mci
,
107 const char *data
, size_t count
)
109 struct amd64_pvt
*pvt
= mci
->pvt_info
;
111 u32 section
, word_bits
;
114 ret
= strict_strtoul(data
, 10, &value
);
115 if (ret
!= -EINVAL
) {
117 /* Form value to choose 16-byte section of cacheline */
118 section
= F10_NB_ARRAY_DRAM_ECC
|
119 SET_NB_ARRAY_ADDRESS(pvt
->injection
.section
);
120 pci_write_config_dword(pvt
->F3
, F10_NB_ARRAY_ADDR
, section
);
122 word_bits
= SET_NB_DRAM_INJECTION_READ(pvt
->injection
.word
,
123 pvt
->injection
.bit_map
);
125 /* Issue 'word' and 'bit' along with the READ request */
126 pci_write_config_dword(pvt
->F3
, F10_NB_ARRAY_DATA
, word_bits
);
128 debugf0("section=0x%x word_bits=0x%x\n", section
, word_bits
);
136 * Do a DRAM ECC write. Assemble staged values in the pvt area and format into
137 * fields needed by the injection registers.
139 static ssize_t
amd64_inject_write_store(struct mem_ctl_info
*mci
,
140 const char *data
, size_t count
)
142 struct amd64_pvt
*pvt
= mci
->pvt_info
;
144 u32 section
, word_bits
;
147 ret
= strict_strtoul(data
, 10, &value
);
148 if (ret
!= -EINVAL
) {
150 /* Form value to choose 16-byte section of cacheline */
151 section
= F10_NB_ARRAY_DRAM_ECC
|
152 SET_NB_ARRAY_ADDRESS(pvt
->injection
.section
);
153 pci_write_config_dword(pvt
->F3
, F10_NB_ARRAY_ADDR
, section
);
155 word_bits
= SET_NB_DRAM_INJECTION_WRITE(pvt
->injection
.word
,
156 pvt
->injection
.bit_map
);
158 /* Issue 'word' and 'bit' along with the READ request */
159 pci_write_config_dword(pvt
->F3
, F10_NB_ARRAY_DATA
, word_bits
);
161 debugf0("section=0x%x word_bits=0x%x\n", section
, word_bits
);
169 * update NUM_INJ_ATTRS in case you add new members
171 struct mcidev_sysfs_attribute amd64_inj_attrs
[] = {
175 .name
= "inject_section",
176 .mode
= (S_IRUGO
| S_IWUSR
)
178 .show
= amd64_inject_section_show
,
179 .store
= amd64_inject_section_store
,
183 .name
= "inject_word",
184 .mode
= (S_IRUGO
| S_IWUSR
)
186 .show
= amd64_inject_word_show
,
187 .store
= amd64_inject_word_store
,
191 .name
= "inject_ecc_vector",
192 .mode
= (S_IRUGO
| S_IWUSR
)
194 .show
= amd64_inject_ecc_vector_show
,
195 .store
= amd64_inject_ecc_vector_store
,
199 .name
= "inject_write",
200 .mode
= (S_IRUGO
| S_IWUSR
)
203 .store
= amd64_inject_write_store
,
207 .name
= "inject_read",
208 .mode
= (S_IRUGO
| S_IWUSR
)
211 .store
= amd64_inject_read_store
,