2 * Copyright 2018 Advanced Micro Devices, Inc.
4 * Permission is hereby granted, free of charge, to any person obtaining a
5 * copy of this software and associated documentation files (the "Software"),
6 * to deal in the Software without restriction, including without limitation
7 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8 * and/or sell copies of the Software, and to permit persons to whom the
9 * Software is furnished to do so, subject to the following conditions:
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20 * OTHER DEALINGS IN THE SOFTWARE.
27 #include <linux/debugfs.h>
28 #include <linux/list.h>
29 #include "ta_ras_if.h"
30 #include "amdgpu_ras_eeprom.h"
32 struct amdgpu_iv_entry;
34 #define AMDGPU_RAS_FLAG_INIT_BY_VBIOS (0x1 << 0)
36 enum amdgpu_ras_block {
37 AMDGPU_RAS_BLOCK__UMC = 0,
38 AMDGPU_RAS_BLOCK__SDMA,
39 AMDGPU_RAS_BLOCK__GFX,
40 AMDGPU_RAS_BLOCK__MMHUB,
41 AMDGPU_RAS_BLOCK__ATHUB,
42 AMDGPU_RAS_BLOCK__PCIE_BIF,
43 AMDGPU_RAS_BLOCK__HDP,
44 AMDGPU_RAS_BLOCK__XGMI_WAFL,
46 AMDGPU_RAS_BLOCK__SMN,
47 AMDGPU_RAS_BLOCK__SEM,
48 AMDGPU_RAS_BLOCK__MP0,
49 AMDGPU_RAS_BLOCK__MP1,
50 AMDGPU_RAS_BLOCK__FUSE,
51 AMDGPU_RAS_BLOCK__MCA,
52 AMDGPU_RAS_BLOCK__VCN,
53 AMDGPU_RAS_BLOCK__JPEG,
55 AMDGPU_RAS_BLOCK__LAST
58 enum amdgpu_ras_mca_block {
59 AMDGPU_RAS_MCA_BLOCK__MP0 = 0,
60 AMDGPU_RAS_MCA_BLOCK__MP1,
61 AMDGPU_RAS_MCA_BLOCK__MPIO,
62 AMDGPU_RAS_MCA_BLOCK__IOHC,
64 AMDGPU_RAS_MCA_BLOCK__LAST
67 #define AMDGPU_RAS_BLOCK_COUNT AMDGPU_RAS_BLOCK__LAST
68 #define AMDGPU_RAS_MCA_BLOCK_COUNT AMDGPU_RAS_MCA_BLOCK__LAST
69 #define AMDGPU_RAS_BLOCK_MASK ((1ULL << AMDGPU_RAS_BLOCK_COUNT) - 1)
71 enum amdgpu_ras_gfx_subblock {
73 AMDGPU_RAS_BLOCK__GFX_CPC_INDEX_START = 0,
74 AMDGPU_RAS_BLOCK__GFX_CPC_SCRATCH =
75 AMDGPU_RAS_BLOCK__GFX_CPC_INDEX_START,
76 AMDGPU_RAS_BLOCK__GFX_CPC_UCODE,
77 AMDGPU_RAS_BLOCK__GFX_DC_STATE_ME1,
78 AMDGPU_RAS_BLOCK__GFX_DC_CSINVOC_ME1,
79 AMDGPU_RAS_BLOCK__GFX_DC_RESTORE_ME1,
80 AMDGPU_RAS_BLOCK__GFX_DC_STATE_ME2,
81 AMDGPU_RAS_BLOCK__GFX_DC_CSINVOC_ME2,
82 AMDGPU_RAS_BLOCK__GFX_DC_RESTORE_ME2,
83 AMDGPU_RAS_BLOCK__GFX_CPC_INDEX_END =
84 AMDGPU_RAS_BLOCK__GFX_DC_RESTORE_ME2,
86 AMDGPU_RAS_BLOCK__GFX_CPF_INDEX_START,
87 AMDGPU_RAS_BLOCK__GFX_CPF_ROQ_ME2 =
88 AMDGPU_RAS_BLOCK__GFX_CPF_INDEX_START,
89 AMDGPU_RAS_BLOCK__GFX_CPF_ROQ_ME1,
90 AMDGPU_RAS_BLOCK__GFX_CPF_TAG,
91 AMDGPU_RAS_BLOCK__GFX_CPF_INDEX_END = AMDGPU_RAS_BLOCK__GFX_CPF_TAG,
93 AMDGPU_RAS_BLOCK__GFX_CPG_INDEX_START,
94 AMDGPU_RAS_BLOCK__GFX_CPG_DMA_ROQ =
95 AMDGPU_RAS_BLOCK__GFX_CPG_INDEX_START,
96 AMDGPU_RAS_BLOCK__GFX_CPG_DMA_TAG,
97 AMDGPU_RAS_BLOCK__GFX_CPG_TAG,
98 AMDGPU_RAS_BLOCK__GFX_CPG_INDEX_END = AMDGPU_RAS_BLOCK__GFX_CPG_TAG,
100 AMDGPU_RAS_BLOCK__GFX_GDS_INDEX_START,
101 AMDGPU_RAS_BLOCK__GFX_GDS_MEM = AMDGPU_RAS_BLOCK__GFX_GDS_INDEX_START,
102 AMDGPU_RAS_BLOCK__GFX_GDS_INPUT_QUEUE,
103 AMDGPU_RAS_BLOCK__GFX_GDS_OA_PHY_CMD_RAM_MEM,
104 AMDGPU_RAS_BLOCK__GFX_GDS_OA_PHY_DATA_RAM_MEM,
105 AMDGPU_RAS_BLOCK__GFX_GDS_OA_PIPE_MEM,
106 AMDGPU_RAS_BLOCK__GFX_GDS_INDEX_END =
107 AMDGPU_RAS_BLOCK__GFX_GDS_OA_PIPE_MEM,
109 AMDGPU_RAS_BLOCK__GFX_SPI_SR_MEM,
111 AMDGPU_RAS_BLOCK__GFX_SQ_INDEX_START,
112 AMDGPU_RAS_BLOCK__GFX_SQ_SGPR = AMDGPU_RAS_BLOCK__GFX_SQ_INDEX_START,
113 AMDGPU_RAS_BLOCK__GFX_SQ_LDS_D,
114 AMDGPU_RAS_BLOCK__GFX_SQ_LDS_I,
115 AMDGPU_RAS_BLOCK__GFX_SQ_VGPR,
116 AMDGPU_RAS_BLOCK__GFX_SQ_INDEX_END = AMDGPU_RAS_BLOCK__GFX_SQ_VGPR,
118 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX_START,
120 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX0_START =
121 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX_START,
122 AMDGPU_RAS_BLOCK__GFX_SQC_INST_UTCL1_LFIFO =
123 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX0_START,
124 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU0_WRITE_DATA_BUF,
125 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU0_UTCL1_LFIFO,
126 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU1_WRITE_DATA_BUF,
127 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU1_UTCL1_LFIFO,
128 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU2_WRITE_DATA_BUF,
129 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU2_UTCL1_LFIFO,
130 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX0_END =
131 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU2_UTCL1_LFIFO,
133 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX1_START,
134 AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_TAG_RAM =
135 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX1_START,
136 AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_UTCL1_MISS_FIFO,
137 AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_MISS_FIFO,
138 AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_BANK_RAM,
139 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_TAG_RAM,
140 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_HIT_FIFO,
141 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_MISS_FIFO,
142 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_DIRTY_BIT_RAM,
143 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_BANK_RAM,
144 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX1_END =
145 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_BANK_RAM,
147 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_START,
148 AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_TAG_RAM =
149 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_START,
150 AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_UTCL1_MISS_FIFO,
151 AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_MISS_FIFO,
152 AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_BANK_RAM,
153 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_TAG_RAM,
154 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_HIT_FIFO,
155 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_MISS_FIFO,
156 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_DIRTY_BIT_RAM,
157 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_BANK_RAM,
158 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_END =
159 AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_BANK_RAM,
160 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX_END =
161 AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_END,
163 AMDGPU_RAS_BLOCK__GFX_TA_INDEX_START,
164 AMDGPU_RAS_BLOCK__GFX_TA_FS_DFIFO =
165 AMDGPU_RAS_BLOCK__GFX_TA_INDEX_START,
166 AMDGPU_RAS_BLOCK__GFX_TA_FS_AFIFO,
167 AMDGPU_RAS_BLOCK__GFX_TA_FL_LFIFO,
168 AMDGPU_RAS_BLOCK__GFX_TA_FX_LFIFO,
169 AMDGPU_RAS_BLOCK__GFX_TA_FS_CFIFO,
170 AMDGPU_RAS_BLOCK__GFX_TA_INDEX_END = AMDGPU_RAS_BLOCK__GFX_TA_FS_CFIFO,
172 AMDGPU_RAS_BLOCK__GFX_TCA_INDEX_START,
173 AMDGPU_RAS_BLOCK__GFX_TCA_HOLE_FIFO =
174 AMDGPU_RAS_BLOCK__GFX_TCA_INDEX_START,
175 AMDGPU_RAS_BLOCK__GFX_TCA_REQ_FIFO,
176 AMDGPU_RAS_BLOCK__GFX_TCA_INDEX_END =
177 AMDGPU_RAS_BLOCK__GFX_TCA_REQ_FIFO,
178 /* TCC (5 sub-ranges) */
179 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX_START,
181 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX0_START =
182 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX_START,
183 AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA =
184 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX0_START,
185 AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_0_1,
186 AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_1_0,
187 AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_1_1,
188 AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DIRTY_BANK_0,
189 AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DIRTY_BANK_1,
190 AMDGPU_RAS_BLOCK__GFX_TCC_HIGH_RATE_TAG,
191 AMDGPU_RAS_BLOCK__GFX_TCC_LOW_RATE_TAG,
192 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX0_END =
193 AMDGPU_RAS_BLOCK__GFX_TCC_LOW_RATE_TAG,
195 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX1_START,
196 AMDGPU_RAS_BLOCK__GFX_TCC_IN_USE_DEC =
197 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX1_START,
198 AMDGPU_RAS_BLOCK__GFX_TCC_IN_USE_TRANSFER,
199 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX1_END =
200 AMDGPU_RAS_BLOCK__GFX_TCC_IN_USE_TRANSFER,
202 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX2_START,
203 AMDGPU_RAS_BLOCK__GFX_TCC_RETURN_DATA =
204 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX2_START,
205 AMDGPU_RAS_BLOCK__GFX_TCC_RETURN_CONTROL,
206 AMDGPU_RAS_BLOCK__GFX_TCC_UC_ATOMIC_FIFO,
207 AMDGPU_RAS_BLOCK__GFX_TCC_WRITE_RETURN,
208 AMDGPU_RAS_BLOCK__GFX_TCC_WRITE_CACHE_READ,
209 AMDGPU_RAS_BLOCK__GFX_TCC_SRC_FIFO,
210 AMDGPU_RAS_BLOCK__GFX_TCC_SRC_FIFO_NEXT_RAM,
211 AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_TAG_PROBE_FIFO,
212 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX2_END =
213 AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_TAG_PROBE_FIFO,
215 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX3_START,
216 AMDGPU_RAS_BLOCK__GFX_TCC_LATENCY_FIFO =
217 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX3_START,
218 AMDGPU_RAS_BLOCK__GFX_TCC_LATENCY_FIFO_NEXT_RAM,
219 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX3_END =
220 AMDGPU_RAS_BLOCK__GFX_TCC_LATENCY_FIFO_NEXT_RAM,
222 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_START,
223 AMDGPU_RAS_BLOCK__GFX_TCC_WRRET_TAG_WRITE_RETURN =
224 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_START,
225 AMDGPU_RAS_BLOCK__GFX_TCC_ATOMIC_RETURN_BUFFER,
226 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_END =
227 AMDGPU_RAS_BLOCK__GFX_TCC_ATOMIC_RETURN_BUFFER,
228 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX_END =
229 AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_END,
231 AMDGPU_RAS_BLOCK__GFX_TCI_WRITE_RAM,
233 AMDGPU_RAS_BLOCK__GFX_TCP_INDEX_START,
234 AMDGPU_RAS_BLOCK__GFX_TCP_CACHE_RAM =
235 AMDGPU_RAS_BLOCK__GFX_TCP_INDEX_START,
236 AMDGPU_RAS_BLOCK__GFX_TCP_LFIFO_RAM,
237 AMDGPU_RAS_BLOCK__GFX_TCP_CMD_FIFO,
238 AMDGPU_RAS_BLOCK__GFX_TCP_VM_FIFO,
239 AMDGPU_RAS_BLOCK__GFX_TCP_DB_RAM,
240 AMDGPU_RAS_BLOCK__GFX_TCP_UTCL1_LFIFO0,
241 AMDGPU_RAS_BLOCK__GFX_TCP_UTCL1_LFIFO1,
242 AMDGPU_RAS_BLOCK__GFX_TCP_INDEX_END =
243 AMDGPU_RAS_BLOCK__GFX_TCP_UTCL1_LFIFO1,
245 AMDGPU_RAS_BLOCK__GFX_TD_INDEX_START,
246 AMDGPU_RAS_BLOCK__GFX_TD_SS_FIFO_LO =
247 AMDGPU_RAS_BLOCK__GFX_TD_INDEX_START,
248 AMDGPU_RAS_BLOCK__GFX_TD_SS_FIFO_HI,
249 AMDGPU_RAS_BLOCK__GFX_TD_CS_FIFO,
250 AMDGPU_RAS_BLOCK__GFX_TD_INDEX_END = AMDGPU_RAS_BLOCK__GFX_TD_CS_FIFO,
251 /* EA (3 sub-ranges) */
252 AMDGPU_RAS_BLOCK__GFX_EA_INDEX_START,
254 AMDGPU_RAS_BLOCK__GFX_EA_INDEX0_START =
255 AMDGPU_RAS_BLOCK__GFX_EA_INDEX_START,
256 AMDGPU_RAS_BLOCK__GFX_EA_DRAMRD_CMDMEM =
257 AMDGPU_RAS_BLOCK__GFX_EA_INDEX0_START,
258 AMDGPU_RAS_BLOCK__GFX_EA_DRAMWR_CMDMEM,
259 AMDGPU_RAS_BLOCK__GFX_EA_DRAMWR_DATAMEM,
260 AMDGPU_RAS_BLOCK__GFX_EA_RRET_TAGMEM,
261 AMDGPU_RAS_BLOCK__GFX_EA_WRET_TAGMEM,
262 AMDGPU_RAS_BLOCK__GFX_EA_GMIRD_CMDMEM,
263 AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_CMDMEM,
264 AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_DATAMEM,
265 AMDGPU_RAS_BLOCK__GFX_EA_INDEX0_END =
266 AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_DATAMEM,
268 AMDGPU_RAS_BLOCK__GFX_EA_INDEX1_START,
269 AMDGPU_RAS_BLOCK__GFX_EA_DRAMRD_PAGEMEM =
270 AMDGPU_RAS_BLOCK__GFX_EA_INDEX1_START,
271 AMDGPU_RAS_BLOCK__GFX_EA_DRAMWR_PAGEMEM,
272 AMDGPU_RAS_BLOCK__GFX_EA_IORD_CMDMEM,
273 AMDGPU_RAS_BLOCK__GFX_EA_IOWR_CMDMEM,
274 AMDGPU_RAS_BLOCK__GFX_EA_IOWR_DATAMEM,
275 AMDGPU_RAS_BLOCK__GFX_EA_GMIRD_PAGEMEM,
276 AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_PAGEMEM,
277 AMDGPU_RAS_BLOCK__GFX_EA_INDEX1_END =
278 AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_PAGEMEM,
280 AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_START,
281 AMDGPU_RAS_BLOCK__GFX_EA_MAM_D0MEM =
282 AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_START,
283 AMDGPU_RAS_BLOCK__GFX_EA_MAM_D1MEM,
284 AMDGPU_RAS_BLOCK__GFX_EA_MAM_D2MEM,
285 AMDGPU_RAS_BLOCK__GFX_EA_MAM_D3MEM,
286 AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_END =
287 AMDGPU_RAS_BLOCK__GFX_EA_MAM_D3MEM,
288 AMDGPU_RAS_BLOCK__GFX_EA_INDEX_END =
289 AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_END,
291 AMDGPU_RAS_BLOCK__UTC_VML2_BANK_CACHE,
293 AMDGPU_RAS_BLOCK__UTC_VML2_WALKER,
294 /* UTC ATC L2 2MB cache */
295 AMDGPU_RAS_BLOCK__UTC_ATCL2_CACHE_2M_BANK,
296 /* UTC ATC L2 4KB cache */
297 AMDGPU_RAS_BLOCK__UTC_ATCL2_CACHE_4K_BANK,
298 AMDGPU_RAS_BLOCK__GFX_MAX
301 enum amdgpu_ras_error_type {
302 AMDGPU_RAS_ERROR__NONE = 0,
303 AMDGPU_RAS_ERROR__PARITY = 1,
304 AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE = 2,
305 AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE = 4,
306 AMDGPU_RAS_ERROR__POISON = 8,
309 enum amdgpu_ras_ret {
310 AMDGPU_RAS_SUCCESS = 0,
317 /* ras error status reisger fields */
318 #define ERR_STATUS_LO__ERR_STATUS_VALID_FLAG__SHIFT 0x0
319 #define ERR_STATUS_LO__ERR_STATUS_VALID_FLAG_MASK 0x00000001L
320 #define ERR_STATUS_LO__MEMORY_ID__SHIFT 0x18
321 #define ERR_STATUS_LO__MEMORY_ID_MASK 0xFF000000L
322 #define ERR_STATUS_HI__ERR_INFO_VALID_FLAG__SHIFT 0x2
323 #define ERR_STATUS_HI__ERR_INFO_VALID_FLAG_MASK 0x00000004L
324 #define ERR_STATUS__ERR_CNT__SHIFT 0x17
325 #define ERR_STATUS__ERR_CNT_MASK 0x03800000L
327 #define AMDGPU_RAS_REG_ENTRY(ip, inst, reg_lo, reg_hi) \
328 ip##_HWIP, inst, reg_lo##_BASE_IDX, reg_lo, reg_hi##_BASE_IDX, reg_hi
330 #define AMDGPU_RAS_REG_ENTRY_OFFSET(hwip, ip_inst, segment, reg) \
331 (adev->reg_offset[hwip][ip_inst][segment] + (reg))
333 #define AMDGPU_RAS_ERR_INFO_VALID (1 << 0)
334 #define AMDGPU_RAS_ERR_STATUS_VALID (1 << 1)
335 #define AMDGPU_RAS_ERR_ADDRESS_VALID (1 << 2)
337 struct amdgpu_ras_err_status_reg_entry {
346 const char *block_name;
349 struct amdgpu_ras_memory_id_entry {
354 struct ras_common_if {
355 enum amdgpu_ras_block block;
356 enum amdgpu_ras_error_type type;
357 uint32_t sub_block_index;
361 #define MAX_UMC_CHANNEL_NUM 32
363 struct ecc_info_per_ch {
364 uint16_t ce_count_lo_chip;
365 uint16_t ce_count_hi_chip;
366 uint64_t mca_umc_status;
367 uint64_t mca_umc_addr;
368 uint64_t mca_ceumc_addr;
371 struct umc_ecc_info {
372 struct ecc_info_per_ch ecc[MAX_UMC_CHANNEL_NUM];
374 /* Determine smu ecctable whether support
375 * record correctable error address
377 int record_ce_addr_supported;
381 /* ras infrastructure */
382 /* for ras itself. */
384 struct list_head head;
386 struct device_attribute features_attr;
387 struct bin_attribute badpages_attr;
388 struct dentry *de_ras_eeprom_table;
390 struct ras_manager *objs;
393 struct work_struct recovery_work;
394 atomic_t in_recovery;
395 struct amdgpu_device *adev;
396 /* error handler data */
397 struct ras_err_handler_data *eh_data;
398 struct mutex recovery_lock;
402 struct amdgpu_ras_eeprom_control eeprom_control;
404 bool error_query_ready;
406 /* bad page count threshold */
407 uint32_t bad_page_cnt_threshold;
409 /* disable ras error count harvest in recovery */
410 bool disable_ras_err_cnt_harvest;
412 /* is poison mode supported */
413 bool poison_supported;
415 /* RAS count errors delayed work */
416 struct delayed_work ras_counte_delay_work;
417 atomic_t ras_ue_count;
418 atomic_t ras_ce_count;
420 /* record umc error info queried from smu */
421 struct umc_ecc_info umc_ecc;
423 /* Indicates smu whether need update bad channel info */
424 bool update_channel_flag;
429 char debugfs_name[32];
432 struct ras_err_data {
433 unsigned long ue_count;
434 unsigned long ce_count;
435 unsigned long err_addr_cnt;
436 struct eeprom_table_record *err_addr;
439 struct ras_err_handler_data {
440 /* point to bad page records array */
441 struct eeprom_table_record *bps;
442 /* the count of entries */
444 /* the space can place new entries */
448 typedef int (*ras_ih_cb)(struct amdgpu_device *adev,
450 struct amdgpu_iv_entry *entry);
453 /* interrupt bottom half */
454 struct work_struct ih_work;
458 /* full of entries */
460 unsigned int ring_size;
461 unsigned int element_size;
462 unsigned int aligned_element_size;
468 struct ras_common_if head;
469 /* reference count */
472 struct list_head node;
474 struct amdgpu_device *adev;
476 struct device_attribute sysfs_attr;
480 struct ras_fs_data fs_data;
483 struct ras_ih_data ih_data;
485 struct ras_err_data err_data;
494 /* interfaces for IP */
496 struct ras_common_if head;
497 const char* sysfs_name;
498 char debugfs_name[32];
501 struct ras_query_if {
502 struct ras_common_if head;
503 unsigned long ue_count;
504 unsigned long ce_count;
507 struct ras_inject_if {
508 struct ras_common_if head;
514 struct ras_common_if head;
519 struct ras_common_if head;
523 struct ras_dispatch_if {
524 struct ras_common_if head;
525 struct amdgpu_iv_entry *entry;
528 struct ras_debug_if {
530 struct ras_common_if head;
531 struct ras_inject_if inject;
536 struct amdgpu_ras_block_object {
537 struct ras_common_if ras_comm;
539 int (*ras_block_match)(struct amdgpu_ras_block_object *block_obj,
540 enum amdgpu_ras_block block, uint32_t sub_block_index);
541 int (*ras_late_init)(struct amdgpu_device *adev, struct ras_common_if *ras_block);
542 void (*ras_fini)(struct amdgpu_device *adev, struct ras_common_if *ras_block);
544 const struct amdgpu_ras_block_hw_ops *hw_ops;
547 struct amdgpu_ras_block_hw_ops {
548 int (*ras_error_inject)(struct amdgpu_device *adev, void *inject_if);
549 void (*query_ras_error_count)(struct amdgpu_device *adev, void *ras_error_status);
550 void (*query_ras_error_status)(struct amdgpu_device *adev);
551 void (*query_ras_error_address)(struct amdgpu_device *adev, void *ras_error_status);
552 void (*reset_ras_error_count)(struct amdgpu_device *adev);
553 void (*reset_ras_error_status)(struct amdgpu_device *adev);
554 bool (*query_poison_status)(struct amdgpu_device *adev);
555 bool (*handle_poison_consumption)(struct amdgpu_device *adev);
560 * 1: ras feature enable (enabled by default)
562 * 2: ras framework init (in ip_init)
565 * 4: debugfs/sysfs create
567 * 6: debugfs/sysfs remove
573 int amdgpu_ras_recovery_init(struct amdgpu_device *adev);
575 void amdgpu_ras_resume(struct amdgpu_device *adev);
576 void amdgpu_ras_suspend(struct amdgpu_device *adev);
578 int amdgpu_ras_query_error_count(struct amdgpu_device *adev,
579 unsigned long *ce_count,
580 unsigned long *ue_count,
581 struct ras_query_if *query_info);
583 /* error handling functions */
584 int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev,
585 struct eeprom_table_record *bps, int pages);
587 int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev,
588 unsigned long *new_cnt);
590 static inline enum ta_ras_block
591 amdgpu_ras_block_to_ta(enum amdgpu_ras_block block) {
593 case AMDGPU_RAS_BLOCK__UMC:
594 return TA_RAS_BLOCK__UMC;
595 case AMDGPU_RAS_BLOCK__SDMA:
596 return TA_RAS_BLOCK__SDMA;
597 case AMDGPU_RAS_BLOCK__GFX:
598 return TA_RAS_BLOCK__GFX;
599 case AMDGPU_RAS_BLOCK__MMHUB:
600 return TA_RAS_BLOCK__MMHUB;
601 case AMDGPU_RAS_BLOCK__ATHUB:
602 return TA_RAS_BLOCK__ATHUB;
603 case AMDGPU_RAS_BLOCK__PCIE_BIF:
604 return TA_RAS_BLOCK__PCIE_BIF;
605 case AMDGPU_RAS_BLOCK__HDP:
606 return TA_RAS_BLOCK__HDP;
607 case AMDGPU_RAS_BLOCK__XGMI_WAFL:
608 return TA_RAS_BLOCK__XGMI_WAFL;
609 case AMDGPU_RAS_BLOCK__DF:
610 return TA_RAS_BLOCK__DF;
611 case AMDGPU_RAS_BLOCK__SMN:
612 return TA_RAS_BLOCK__SMN;
613 case AMDGPU_RAS_BLOCK__SEM:
614 return TA_RAS_BLOCK__SEM;
615 case AMDGPU_RAS_BLOCK__MP0:
616 return TA_RAS_BLOCK__MP0;
617 case AMDGPU_RAS_BLOCK__MP1:
618 return TA_RAS_BLOCK__MP1;
619 case AMDGPU_RAS_BLOCK__FUSE:
620 return TA_RAS_BLOCK__FUSE;
621 case AMDGPU_RAS_BLOCK__MCA:
622 return TA_RAS_BLOCK__MCA;
623 case AMDGPU_RAS_BLOCK__VCN:
624 return TA_RAS_BLOCK__VCN;
625 case AMDGPU_RAS_BLOCK__JPEG:
626 return TA_RAS_BLOCK__JPEG;
628 WARN_ONCE(1, "RAS ERROR: unexpected block id %d\n", block);
629 return TA_RAS_BLOCK__UMC;
633 static inline enum ta_ras_error_type
634 amdgpu_ras_error_to_ta(enum amdgpu_ras_error_type error) {
636 case AMDGPU_RAS_ERROR__NONE:
637 return TA_RAS_ERROR__NONE;
638 case AMDGPU_RAS_ERROR__PARITY:
639 return TA_RAS_ERROR__PARITY;
640 case AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE:
641 return TA_RAS_ERROR__SINGLE_CORRECTABLE;
642 case AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE:
643 return TA_RAS_ERROR__MULTI_UNCORRECTABLE;
644 case AMDGPU_RAS_ERROR__POISON:
645 return TA_RAS_ERROR__POISON;
647 WARN_ONCE(1, "RAS ERROR: unexpected error type %d\n", error);
648 return TA_RAS_ERROR__NONE;
652 /* called in ip_init and ip_fini */
653 int amdgpu_ras_init(struct amdgpu_device *adev);
654 int amdgpu_ras_late_init(struct amdgpu_device *adev);
655 int amdgpu_ras_fini(struct amdgpu_device *adev);
656 int amdgpu_ras_pre_fini(struct amdgpu_device *adev);
658 int amdgpu_ras_block_late_init(struct amdgpu_device *adev,
659 struct ras_common_if *ras_block);
661 void amdgpu_ras_block_late_fini(struct amdgpu_device *adev,
662 struct ras_common_if *ras_block);
664 int amdgpu_ras_feature_enable(struct amdgpu_device *adev,
665 struct ras_common_if *head, bool enable);
667 int amdgpu_ras_feature_enable_on_boot(struct amdgpu_device *adev,
668 struct ras_common_if *head, bool enable);
670 int amdgpu_ras_sysfs_create(struct amdgpu_device *adev,
671 struct ras_common_if *head);
673 int amdgpu_ras_sysfs_remove(struct amdgpu_device *adev,
674 struct ras_common_if *head);
676 void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev);
678 int amdgpu_ras_query_error_status(struct amdgpu_device *adev,
679 struct ras_query_if *info);
681 int amdgpu_ras_reset_error_status(struct amdgpu_device *adev,
682 enum amdgpu_ras_block block);
684 int amdgpu_ras_error_inject(struct amdgpu_device *adev,
685 struct ras_inject_if *info);
687 int amdgpu_ras_interrupt_add_handler(struct amdgpu_device *adev,
688 struct ras_common_if *head);
690 int amdgpu_ras_interrupt_remove_handler(struct amdgpu_device *adev,
691 struct ras_common_if *head);
693 int amdgpu_ras_interrupt_dispatch(struct amdgpu_device *adev,
694 struct ras_dispatch_if *info);
696 struct ras_manager *amdgpu_ras_find_obj(struct amdgpu_device *adev,
697 struct ras_common_if *head);
699 extern atomic_t amdgpu_ras_in_intr;
701 static inline bool amdgpu_ras_intr_triggered(void)
703 return !!atomic_read(&amdgpu_ras_in_intr);
706 static inline void amdgpu_ras_intr_cleared(void)
708 atomic_set(&amdgpu_ras_in_intr, 0);
711 void amdgpu_ras_global_ras_isr(struct amdgpu_device *adev);
713 void amdgpu_ras_set_error_query_ready(struct amdgpu_device *adev, bool ready);
715 bool amdgpu_ras_need_emergency_restart(struct amdgpu_device *adev);
717 void amdgpu_release_ras_context(struct amdgpu_device *adev);
719 int amdgpu_persistent_edc_harvesting_supported(struct amdgpu_device *adev);
721 const char *get_ras_block_str(struct ras_common_if *ras_block);
723 bool amdgpu_ras_is_poison_mode_supported(struct amdgpu_device *adev);
725 int amdgpu_ras_is_supported(struct amdgpu_device *adev, unsigned int block);
727 int amdgpu_ras_reset_gpu(struct amdgpu_device *adev);
729 struct amdgpu_ras* amdgpu_ras_get_context(struct amdgpu_device *adev);
731 int amdgpu_ras_set_context(struct amdgpu_device *adev, struct amdgpu_ras *ras_con);
733 int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
734 struct amdgpu_ras_block_object *ras_block_obj);
735 void amdgpu_ras_interrupt_fatal_error_handler(struct amdgpu_device *adev);
736 void amdgpu_ras_get_error_type_name(uint32_t err_type, char *err_type_name);
737 bool amdgpu_ras_inst_get_memory_id_field(struct amdgpu_device *adev,
738 const struct amdgpu_ras_err_status_reg_entry *reg_entry,
740 uint32_t *memory_id);
741 bool amdgpu_ras_inst_get_err_cnt_field(struct amdgpu_device *adev,
742 const struct amdgpu_ras_err_status_reg_entry *reg_entry,
744 unsigned long *err_cnt);
745 void amdgpu_ras_inst_query_ras_error_count(struct amdgpu_device *adev,
746 const struct amdgpu_ras_err_status_reg_entry *reg_list,
747 uint32_t reg_list_size,
748 const struct amdgpu_ras_memory_id_entry *mem_list,
749 uint32_t mem_list_size,
752 unsigned long *err_count);
753 void amdgpu_ras_inst_reset_ras_error_count(struct amdgpu_device *adev,
754 const struct amdgpu_ras_err_status_reg_entry *reg_list,
755 uint32_t reg_list_size,