1c030f2e4Sxinhui pan /*
2c030f2e4Sxinhui pan * Copyright 2018 Advanced Micro Devices, Inc.
3c030f2e4Sxinhui pan *
4c030f2e4Sxinhui pan * Permission is hereby granted, free of charge, to any person obtaining a
5c030f2e4Sxinhui pan * copy of this software and associated documentation files (the "Software"),
6c030f2e4Sxinhui pan * to deal in the Software without restriction, including without limitation
7c030f2e4Sxinhui pan * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8c030f2e4Sxinhui pan * and/or sell copies of the Software, and to permit persons to whom the
9c030f2e4Sxinhui pan * Software is furnished to do so, subject to the following conditions:
10c030f2e4Sxinhui pan *
11c030f2e4Sxinhui pan * The above copyright notice and this permission notice shall be included in
12c030f2e4Sxinhui pan * all copies or substantial portions of the Software.
13c030f2e4Sxinhui pan *
14c030f2e4Sxinhui pan * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15c030f2e4Sxinhui pan * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16c030f2e4Sxinhui pan * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
17c030f2e4Sxinhui pan * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
18c030f2e4Sxinhui pan * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
19c030f2e4Sxinhui pan * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
20c030f2e4Sxinhui pan * OTHER DEALINGS IN THE SOFTWARE.
21c030f2e4Sxinhui pan *
22c030f2e4Sxinhui pan *
23c030f2e4Sxinhui pan */
24c030f2e4Sxinhui pan #ifndef _AMDGPU_RAS_H
25c030f2e4Sxinhui pan #define _AMDGPU_RAS_H
26c030f2e4Sxinhui pan
27c030f2e4Sxinhui pan #include <linux/debugfs.h>
28c030f2e4Sxinhui pan #include <linux/list.h>
29c030f2e4Sxinhui pan #include "ta_ras_if.h"
3064f55e62SAndrey Grodzovsky #include "amdgpu_ras_eeprom.h"
31c030f2e4Sxinhui pan
327cab2124Syipechai struct amdgpu_iv_entry;
337cab2124Syipechai
3435cd2cdaSGuchun Chen #define AMDGPU_RAS_FLAG_INIT_BY_VBIOS (0x1 << 0)
3535cd2cdaSGuchun Chen /* position of instance value in sub_block_index of
36c030f2e4Sxinhui pan * ta_ras_trigger_error_input, the sub block uses lower 12 bits
37c030f2e4Sxinhui pan */
38c030f2e4Sxinhui pan #define AMDGPU_RAS_INST_MASK 0xfffff000
39c030f2e4Sxinhui pan #define AMDGPU_RAS_INST_SHIFT 0xc
40c030f2e4Sxinhui pan
41c030f2e4Sxinhui pan enum amdgpu_ras_block {
42c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__UMC = 0,
43c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__SDMA,
44c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__GFX,
45c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__MMHUB,
46c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__ATHUB,
47c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__PCIE_BIF,
48c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__HDP,
49c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__XGMI_WAFL,
50c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__DF,
51640ae42eSJohn Clements AMDGPU_RAS_BLOCK__SMN,
52a3d63c62SMohammad Zafar Ziya AMDGPU_RAS_BLOCK__SEM,
53a3d63c62SMohammad Zafar Ziya AMDGPU_RAS_BLOCK__MP0,
54c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__MP1,
55c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__FUSE,
56c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__MCA,
57c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__VCN,
58640ae42eSJohn Clements AMDGPU_RAS_BLOCK__JPEG,
59640ae42eSJohn Clements
60640ae42eSJohn Clements AMDGPU_RAS_BLOCK__LAST
61640ae42eSJohn Clements };
62640ae42eSJohn Clements
63893cf382SCandice Li enum amdgpu_ras_mca_block {
64640ae42eSJohn Clements AMDGPU_RAS_MCA_BLOCK__MP0 = 0,
65640ae42eSJohn Clements AMDGPU_RAS_MCA_BLOCK__MP1,
66640ae42eSJohn Clements AMDGPU_RAS_MCA_BLOCK__MPIO,
67c030f2e4Sxinhui pan AMDGPU_RAS_MCA_BLOCK__IOHC,
68640ae42eSJohn Clements
69c030f2e4Sxinhui pan AMDGPU_RAS_MCA_BLOCK__LAST
70c030f2e4Sxinhui pan };
71dc23a08fSDennis Li
72dc23a08fSDennis Li #define AMDGPU_RAS_BLOCK_COUNT AMDGPU_RAS_BLOCK__LAST
73dc23a08fSDennis Li #define AMDGPU_RAS_MCA_BLOCK_COUNT AMDGPU_RAS_MCA_BLOCK__LAST
74dc23a08fSDennis Li #define AMDGPU_RAS_BLOCK_MASK ((1ULL << AMDGPU_RAS_BLOCK_COUNT) - 1)
75dc23a08fSDennis Li
76dc23a08fSDennis Li enum amdgpu_ras_gfx_subblock {
77dc23a08fSDennis Li /* CPC */
78dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPC_INDEX_START = 0,
79dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPC_SCRATCH =
80dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPC_INDEX_START,
81dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPC_UCODE,
82dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_DC_STATE_ME1,
83dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_DC_CSINVOC_ME1,
84dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_DC_RESTORE_ME1,
85dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_DC_STATE_ME2,
86dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_DC_CSINVOC_ME2,
87dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_DC_RESTORE_ME2,
88dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPC_INDEX_END =
89dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_DC_RESTORE_ME2,
90dc23a08fSDennis Li /* CPF */
91dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPF_INDEX_START,
92dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPF_ROQ_ME2 =
93dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPF_INDEX_START,
94dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPF_ROQ_ME1,
95dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPF_TAG,
96dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPF_INDEX_END = AMDGPU_RAS_BLOCK__GFX_CPF_TAG,
97dc23a08fSDennis Li /* CPG */
98dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPG_INDEX_START,
99dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPG_DMA_ROQ =
100dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPG_INDEX_START,
101dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPG_DMA_TAG,
102dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPG_TAG,
103dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_CPG_INDEX_END = AMDGPU_RAS_BLOCK__GFX_CPG_TAG,
104dc23a08fSDennis Li /* GDS */
105dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_GDS_INDEX_START,
106dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_GDS_MEM = AMDGPU_RAS_BLOCK__GFX_GDS_INDEX_START,
107dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_GDS_INPUT_QUEUE,
108dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_GDS_OA_PHY_CMD_RAM_MEM,
109dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_GDS_OA_PHY_DATA_RAM_MEM,
110dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_GDS_OA_PIPE_MEM,
111dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_GDS_INDEX_END =
112dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_GDS_OA_PIPE_MEM,
113dc23a08fSDennis Li /* SPI */
114dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SPI_SR_MEM,
115dc23a08fSDennis Li /* SQ */
116dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQ_INDEX_START,
117dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQ_SGPR = AMDGPU_RAS_BLOCK__GFX_SQ_INDEX_START,
118dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQ_LDS_D,
119dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQ_LDS_I,
120dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQ_VGPR,
121dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQ_INDEX_END = AMDGPU_RAS_BLOCK__GFX_SQ_VGPR,
122dc23a08fSDennis Li /* SQC (3 ranges) */
123dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX_START,
124dc23a08fSDennis Li /* SQC range 0 */
125dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX0_START =
126dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX_START,
127dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INST_UTCL1_LFIFO =
128dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX0_START,
129dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU0_WRITE_DATA_BUF,
130dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU0_UTCL1_LFIFO,
131dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU1_WRITE_DATA_BUF,
132dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU1_UTCL1_LFIFO,
133dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU2_WRITE_DATA_BUF,
134dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU2_UTCL1_LFIFO,
135dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX0_END =
136dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_CU2_UTCL1_LFIFO,
137dc23a08fSDennis Li /* SQC range 1 */
138dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX1_START,
139dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_TAG_RAM =
140dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX1_START,
141dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_UTCL1_MISS_FIFO,
142dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_MISS_FIFO,
143dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKA_BANK_RAM,
144dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_TAG_RAM,
145dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_HIT_FIFO,
146dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_MISS_FIFO,
147dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_DIRTY_BIT_RAM,
148dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_BANK_RAM,
149dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX1_END =
150dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKA_BANK_RAM,
151dc23a08fSDennis Li /* SQC range 2 */
152dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_START,
153dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_TAG_RAM =
154dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_START,
155dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_UTCL1_MISS_FIFO,
156dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_MISS_FIFO,
157dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INST_BANKB_BANK_RAM,
158dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_TAG_RAM,
159dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_HIT_FIFO,
160dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_MISS_FIFO,
161dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_DIRTY_BIT_RAM,
162dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_BANK_RAM,
163dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_END =
164dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_DATA_BANKB_BANK_RAM,
165dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX_END =
166dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_SQC_INDEX2_END,
167dc23a08fSDennis Li /* TA */
168dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TA_INDEX_START,
169dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TA_FS_DFIFO =
170dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TA_INDEX_START,
171dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TA_FS_AFIFO,
172dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TA_FL_LFIFO,
173dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TA_FX_LFIFO,
174dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TA_FS_CFIFO,
175dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TA_INDEX_END = AMDGPU_RAS_BLOCK__GFX_TA_FS_CFIFO,
176dc23a08fSDennis Li /* TCA */
177dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCA_INDEX_START,
178dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCA_HOLE_FIFO =
179dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCA_INDEX_START,
180dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCA_REQ_FIFO,
181dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCA_INDEX_END =
182dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCA_REQ_FIFO,
183dc23a08fSDennis Li /* TCC (5 sub-ranges) */
184dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX_START,
185dc23a08fSDennis Li /* TCC range 0 */
186dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX0_START =
187dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX_START,
188dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA =
189dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX0_START,
190dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_0_1,
191dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_1_0,
192dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DATA_BANK_1_1,
193dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DIRTY_BANK_0,
194dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_DIRTY_BANK_1,
195dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_HIGH_RATE_TAG,
196dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_LOW_RATE_TAG,
197dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX0_END =
198dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_LOW_RATE_TAG,
199dc23a08fSDennis Li /* TCC range 1 */
200dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX1_START,
201dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_IN_USE_DEC =
202dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX1_START,
203dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_IN_USE_TRANSFER,
204dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX1_END =
205dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_IN_USE_TRANSFER,
206dc23a08fSDennis Li /* TCC range 2 */
207dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX2_START,
208dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_RETURN_DATA =
209dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX2_START,
210dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_RETURN_CONTROL,
211dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_UC_ATOMIC_FIFO,
212dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_WRITE_RETURN,
213dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_WRITE_CACHE_READ,
214dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_SRC_FIFO,
215dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_SRC_FIFO_NEXT_RAM,
216dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_TAG_PROBE_FIFO,
217dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX2_END =
218dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_CACHE_TAG_PROBE_FIFO,
219dc23a08fSDennis Li /* TCC range 3 */
220dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX3_START,
221dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_LATENCY_FIFO =
222dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX3_START,
223dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_LATENCY_FIFO_NEXT_RAM,
224dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX3_END =
225dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_LATENCY_FIFO_NEXT_RAM,
226dc23a08fSDennis Li /* TCC range 4 */
227dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_START,
228dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_WRRET_TAG_WRITE_RETURN =
229dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_START,
230dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_ATOMIC_RETURN_BUFFER,
231dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_END =
232dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_ATOMIC_RETURN_BUFFER,
233dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX_END =
234dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCC_INDEX4_END,
235dc23a08fSDennis Li /* TCI */
236dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCI_WRITE_RAM,
237dc23a08fSDennis Li /* TCP */
238dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_INDEX_START,
239dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_CACHE_RAM =
240dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_INDEX_START,
241dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_LFIFO_RAM,
242dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_CMD_FIFO,
243dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_VM_FIFO,
244dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_DB_RAM,
245dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_UTCL1_LFIFO0,
246dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_UTCL1_LFIFO1,
247dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_INDEX_END =
248dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TCP_UTCL1_LFIFO1,
249dc23a08fSDennis Li /* TD */
250dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TD_INDEX_START,
251dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TD_SS_FIFO_LO =
252dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TD_INDEX_START,
253dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TD_SS_FIFO_HI,
254dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TD_CS_FIFO,
255dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_TD_INDEX_END = AMDGPU_RAS_BLOCK__GFX_TD_CS_FIFO,
256dc23a08fSDennis Li /* EA (3 sub-ranges) */
257dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX_START,
258dc23a08fSDennis Li /* EA range 0 */
259dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX0_START =
260dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX_START,
261dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_DRAMRD_CMDMEM =
262dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX0_START,
263dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_DRAMWR_CMDMEM,
264dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_DRAMWR_DATAMEM,
265dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_RRET_TAGMEM,
266dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_WRET_TAGMEM,
267dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_GMIRD_CMDMEM,
268dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_CMDMEM,
269dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_DATAMEM,
270dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX0_END =
271dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_DATAMEM,
272dc23a08fSDennis Li /* EA range 1 */
273dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX1_START,
274dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_DRAMRD_PAGEMEM =
275dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX1_START,
276dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_DRAMWR_PAGEMEM,
277dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_IORD_CMDMEM,
278dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_IOWR_CMDMEM,
279dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_IOWR_DATAMEM,
280dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_GMIRD_PAGEMEM,
281dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_PAGEMEM,
282dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX1_END =
283dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_GMIWR_PAGEMEM,
284dc23a08fSDennis Li /* EA range 2 */
285dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_START,
286dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_MAM_D0MEM =
287dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_START,
288dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_MAM_D1MEM,
289dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_MAM_D2MEM,
290dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_MAM_D3MEM,
291dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_END =
292dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_MAM_D3MEM,
293dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX_END =
294dc23a08fSDennis Li AMDGPU_RAS_BLOCK__GFX_EA_INDEX2_END,
295dc23a08fSDennis Li /* UTC VM L2 bank */
296dc23a08fSDennis Li AMDGPU_RAS_BLOCK__UTC_VML2_BANK_CACHE,
297dc23a08fSDennis Li /* UTC VM walker */
298dc23a08fSDennis Li AMDGPU_RAS_BLOCK__UTC_VML2_WALKER,
299dc23a08fSDennis Li /* UTC ATC L2 2MB cache */
300dc23a08fSDennis Li AMDGPU_RAS_BLOCK__UTC_ATCL2_CACHE_2M_BANK,
301c030f2e4Sxinhui pan /* UTC ATC L2 4KB cache */
302c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__UTC_ATCL2_CACHE_4K_BANK,
303c030f2e4Sxinhui pan AMDGPU_RAS_BLOCK__GFX_MAX
304c030f2e4Sxinhui pan };
305c030f2e4Sxinhui pan
306c030f2e4Sxinhui pan enum amdgpu_ras_error_type {
307c030f2e4Sxinhui pan AMDGPU_RAS_ERROR__NONE = 0,
308c030f2e4Sxinhui pan AMDGPU_RAS_ERROR__PARITY = 1,
309c030f2e4Sxinhui pan AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE = 2,
310c030f2e4Sxinhui pan AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE = 4,
311c030f2e4Sxinhui pan AMDGPU_RAS_ERROR__POISON = 8,
312c030f2e4Sxinhui pan };
313c030f2e4Sxinhui pan
314c030f2e4Sxinhui pan enum amdgpu_ras_ret {
315c030f2e4Sxinhui pan AMDGPU_RAS_SUCCESS = 0,
316c030f2e4Sxinhui pan AMDGPU_RAS_FAIL,
317c030f2e4Sxinhui pan AMDGPU_RAS_UE,
318c030f2e4Sxinhui pan AMDGPU_RAS_CE,
319c030f2e4Sxinhui pan AMDGPU_RAS_PT,
320c030f2e4Sxinhui pan };
321355e3e4cSCandice Li
322c030f2e4Sxinhui pan /* ras error status reisger fields */
323c030f2e4Sxinhui pan #define ERR_STATUS_LO__ERR_STATUS_VALID_FLAG__SHIFT 0x0
3248882f90aSStanley.Yang #define ERR_STATUS_LO__ERR_STATUS_VALID_FLAG_MASK 0x00000001L
3258882f90aSStanley.Yang #define ERR_STATUS_LO__MEMORY_ID__SHIFT 0x18
3268882f90aSStanley.Yang #define ERR_STATUS_LO__MEMORY_ID_MASK 0xFF000000L
3278882f90aSStanley.Yang #define ERR_STATUS_HI__ERR_INFO_VALID_FLAG__SHIFT 0x2
3288882f90aSStanley.Yang #define ERR_STATUS_HI__ERR_INFO_VALID_FLAG_MASK 0x00000004L
3298882f90aSStanley.Yang #define ERR_STATUS__ERR_CNT__SHIFT 0x17
3308882f90aSStanley.Yang #define ERR_STATUS__ERR_CNT_MASK 0x03800000L
3312f6247daSStanley.Yang
3328882f90aSStanley.Yang #define AMDGPU_RAS_REG_ENTRY(ip, inst, reg_lo, reg_hi) \
3338882f90aSStanley.Yang ip##_HWIP, inst, reg_lo##_BASE_IDX, reg_lo, reg_hi##_BASE_IDX, reg_hi
3348882f90aSStanley.Yang
3358882f90aSStanley.Yang #define AMDGPU_RAS_REG_ENTRY_OFFSET(hwip, ip_inst, segment, reg) \
336cbd3e844SStanley.Yang (adev->reg_offset[hwip][ip_inst][segment] + (reg))
337cbd3e844SStanley.Yang
338cbd3e844SStanley.Yang #define AMDGPU_RAS_ERR_INFO_VALID (1 << 0)
339cbd3e844SStanley.Yang #define AMDGPU_RAS_ERR_STATUS_VALID (1 << 1)
340cbd3e844SStanley.Yang #define AMDGPU_RAS_ERR_ADDRESS_VALID (1 << 2)
3418882f90aSStanley.Yang
3428882f90aSStanley.Yang #define AMDGPU_RAS_GPU_RESET_MODE2_RESET (0x1 << 0)
343c030f2e4Sxinhui pan #define AMDGPU_RAS_GPU_RESET_MODE1_RESET (0x1 << 1)
344c030f2e4Sxinhui pan
3455caf466aSxinhui pan struct amdgpu_ras_err_status_reg_entry {
346c030f2e4Sxinhui pan uint32_t hwip;
347c030f2e4Sxinhui pan uint32_t ip_inst;
348c030f2e4Sxinhui pan uint32_t seg_lo;
349c030f2e4Sxinhui pan uint32_t reg_lo;
350466b1793Sxinhui pan uint32_t seg_hi;
351c65b0805SLuben Tuikov uint32_t reg_hi;
352c030f2e4Sxinhui pan uint32_t reg_inst;
353c030f2e4Sxinhui pan uint32_t flags;
354c030f2e4Sxinhui pan const char *block_name;
355c030f2e4Sxinhui pan };
356c030f2e4Sxinhui pan
357c030f2e4Sxinhui pan struct amdgpu_ras_memory_id_entry {
358c030f2e4Sxinhui pan uint32_t memory_id;
359c030f2e4Sxinhui pan const char *name;
360c030f2e4Sxinhui pan };
361c030f2e4Sxinhui pan
362108c6a63Sxinhui pan struct ras_common_if {
363108c6a63Sxinhui pan enum amdgpu_ras_block block;
364d5ea093eSAndrey Grodzovsky enum amdgpu_ras_error_type type;
36564f55e62SAndrey Grodzovsky uint32_t sub_block_index;
36661380faaSJohn Clements char name[32];
36761380faaSJohn Clements };
368c84d4670SGuchun Chen
369c84d4670SGuchun Chen #define MAX_UMC_CHANNEL_NUM 32
370c84d4670SGuchun Chen
371f75e94d8SGuchun Chen struct ecc_info_per_ch {
372f75e94d8SGuchun Chen uint16_t ce_count_lo_chip;
373f75e94d8SGuchun Chen uint16_t ce_count_hi_chip;
37405adfd80SLuben Tuikov uint64_t mca_umc_status;
375e4348849STao Zhou uint64_t mca_umc_addr;
376e4348849STao Zhou uint64_t mca_ceumc_addr;
377e4348849STao Zhou };
37805adfd80SLuben Tuikov
37905adfd80SLuben Tuikov struct umc_ecc_info {
38005adfd80SLuben Tuikov struct ecc_info_per_ch ecc[MAX_UMC_CHANNEL_NUM];
38105adfd80SLuben Tuikov
3828882f90aSStanley.Yang /* Determine smu ecctable whether support
3838882f90aSStanley.Yang * record correctable error address
3848882f90aSStanley.Yang */
38569691c82SStanley.Yang int record_ce_addr_supported;
38669691c82SStanley.Yang };
38769691c82SStanley.Yang
388c030f2e4Sxinhui pan struct amdgpu_ras {
389c030f2e4Sxinhui pan /* ras infrastructure */
3907af25d5bSHawking Zhang /* for ras itself. */
3917af25d5bSHawking Zhang uint32_t features;
3927af25d5bSHawking Zhang struct list_head head;
3937af25d5bSHawking Zhang /* sysfs */
3947af25d5bSHawking Zhang struct device_attribute features_attr;
3957af25d5bSHawking Zhang struct bin_attribute badpages_attr;
3967af25d5bSHawking Zhang struct dentry *de_ras_eeprom_table;
3977af25d5bSHawking Zhang /* block array */
3986f102dbaSTao Zhou struct ras_manager *objs;
39987d2b92fSTao Zhou
4007af25d5bSHawking Zhang /* gpu recovery */
4017af25d5bSHawking Zhang struct work_struct recovery_work;
4027af25d5bSHawking Zhang atomic_t in_recovery;
4039dc23a63STao Zhou struct amdgpu_device *adev;
4049dc23a63STao Zhou /* error handler data */
4057af25d5bSHawking Zhang struct ras_err_handler_data *eh_data;
4067af25d5bSHawking Zhang struct mutex recovery_lock;
4077af25d5bSHawking Zhang
4087af25d5bSHawking Zhang uint32_t flags;
4097af25d5bSHawking Zhang bool reboot;
4107af25d5bSHawking Zhang struct amdgpu_ras_eeprom_control eeprom_control;
411cf04dfd0STao Zhou
412f5f06e21STao Zhou bool error_query_ready;
413cf04dfd0STao Zhou
414cf04dfd0STao Zhou /* bad page count threshold */
415cf04dfd0STao Zhou uint32_t bad_page_cnt_threshold;
416cf04dfd0STao Zhou
417cf04dfd0STao Zhou /* disable ras error count harvest in recovery */
418cf04dfd0STao Zhou bool disable_ras_err_cnt_harvest;
419cf04dfd0STao Zhou
420cf04dfd0STao Zhou /* is poison mode supported */
421cf04dfd0STao Zhou bool poison_supported;
422cf04dfd0STao Zhou
423cf04dfd0STao Zhou /* RAS count errors delayed work */
424cf04dfd0STao Zhou struct delayed_work ras_counte_delay_work;
425cf04dfd0STao Zhou atomic_t ras_ue_count;
426cf04dfd0STao Zhou atomic_t ras_ce_count;
427cf04dfd0STao Zhou
428cf04dfd0STao Zhou /* record umc error info queried from smu */
429cf04dfd0STao Zhou struct umc_ecc_info umc_ecc;
4307af25d5bSHawking Zhang
4317af25d5bSHawking Zhang /* Indicates smu whether need update bad channel info */
4327af25d5bSHawking Zhang bool update_channel_flag;
4337af25d5bSHawking Zhang
4347af25d5bSHawking Zhang /* Record special requirements of gpu reset caller */
4357af25d5bSHawking Zhang uint32_t gpu_reset_flags;
4367af25d5bSHawking Zhang };
4377af25d5bSHawking Zhang
4387af25d5bSHawking Zhang struct ras_fs_data {
4397af25d5bSHawking Zhang char sysfs_name[32];
4407af25d5bSHawking Zhang char debugfs_name[32];
4417af25d5bSHawking Zhang };
4427af25d5bSHawking Zhang
4437af25d5bSHawking Zhang struct ras_err_data {
4447af25d5bSHawking Zhang unsigned long ue_count;
4457af25d5bSHawking Zhang unsigned long ce_count;
4467af25d5bSHawking Zhang unsigned long err_addr_cnt;
4477af25d5bSHawking Zhang struct eeprom_table_record *err_addr;
4487af25d5bSHawking Zhang };
4497af25d5bSHawking Zhang
4507af25d5bSHawking Zhang struct ras_err_handler_data {
4517af25d5bSHawking Zhang /* point to bad page records array */
4527af25d5bSHawking Zhang struct eeprom_table_record *bps;
4537af25d5bSHawking Zhang /* the count of entries */
4547af25d5bSHawking Zhang int count;
4557af25d5bSHawking Zhang /* the space can place new entries */
4567af25d5bSHawking Zhang int space_left;
4577af25d5bSHawking Zhang };
458c030f2e4Sxinhui pan
459c030f2e4Sxinhui pan typedef int (*ras_ih_cb)(struct amdgpu_device *adev,
4603907c492SJohn Clements void *err_data,
461c030f2e4Sxinhui pan struct amdgpu_iv_entry *entry);
462c030f2e4Sxinhui pan
463c030f2e4Sxinhui pan struct ras_ih_data {
464c030f2e4Sxinhui pan /* interrupt bottom half */
465c030f2e4Sxinhui pan struct work_struct ih_work;
466c030f2e4Sxinhui pan int inuse;
467c030f2e4Sxinhui pan /* IP callback */
468c030f2e4Sxinhui pan ras_ih_cb cb;
469c030f2e4Sxinhui pan /* full of entries */
470c030f2e4Sxinhui pan unsigned char *ring;
471c030f2e4Sxinhui pan unsigned int ring_size;
472c030f2e4Sxinhui pan unsigned int element_size;
473c030f2e4Sxinhui pan unsigned int aligned_element_size;
474c030f2e4Sxinhui pan unsigned int rptr;
475c030f2e4Sxinhui pan unsigned int wptr;
476c030f2e4Sxinhui pan };
477c030f2e4Sxinhui pan
478c030f2e4Sxinhui pan struct ras_manager {
479c030f2e4Sxinhui pan struct ras_common_if head;
480c030f2e4Sxinhui pan /* reference count */
481c030f2e4Sxinhui pan int use;
482c030f2e4Sxinhui pan /* ras block link */
483c030f2e4Sxinhui pan struct list_head node;
484c030f2e4Sxinhui pan /* the device */
485c030f2e4Sxinhui pan struct amdgpu_device *adev;
486c030f2e4Sxinhui pan /* sysfs */
487c030f2e4Sxinhui pan struct device_attribute sysfs_attr;
488c030f2e4Sxinhui pan int attr_inuse;
489c030f2e4Sxinhui pan
490c030f2e4Sxinhui pan /* fs node name */
49136ea1bd2Sxinhui pan struct ras_fs_data fs_data;
49236ea1bd2Sxinhui pan
49336ea1bd2Sxinhui pan /* IH data */
49436ea1bd2Sxinhui pan struct ras_ih_data ih_data;
49536ea1bd2Sxinhui pan
49636ea1bd2Sxinhui pan struct ras_err_data err_data;
49736ea1bd2Sxinhui pan };
4986492e1b0Syipechai
4996492e1b0Syipechai struct ras_badpage {
500bdb3489cSyipechai unsigned int bp;
5016492e1b0Syipechai unsigned int size;
502b6efdb02Syipechai unsigned int flags;
503b6efdb02Syipechai };
5044e9b1fa5Syipechai
50501d468d9Syipechai /* interfaces for IP */
506bdb3489cSyipechai struct ras_fs_if {
5076492e1b0Syipechai struct ras_common_if head;
5086492e1b0Syipechai const char* sysfs_name;
5096492e1b0Syipechai char debugfs_name[32];
5106492e1b0Syipechai };
5116492e1b0Syipechai
5126492e1b0Syipechai struct ras_query_if {
5136492e1b0Syipechai struct ras_common_if head;
5146492e1b0Syipechai unsigned long ue_count;
5156492e1b0Syipechai unsigned long ce_count;
5166492e1b0Syipechai };
517c543dcbeSMohammad Zafar Ziya
51866f87949STao Zhou struct ras_inject_if {
5196492e1b0Syipechai struct ras_common_if head;
5206492e1b0Syipechai uint64_t address;
521c030f2e4Sxinhui pan uint64_t value;
522c030f2e4Sxinhui pan uint32_t instance_mask;
523c030f2e4Sxinhui pan };
524c030f2e4Sxinhui pan
525c030f2e4Sxinhui pan struct ras_cure_if {
526c030f2e4Sxinhui pan struct ras_common_if head;
527c030f2e4Sxinhui pan uint64_t address;
528c030f2e4Sxinhui pan };
529c030f2e4Sxinhui pan
530c030f2e4Sxinhui pan struct ras_ih_if {
531c030f2e4Sxinhui pan struct ras_common_if head;
532c030f2e4Sxinhui pan ras_ih_cb cb;
533c030f2e4Sxinhui pan };
534c030f2e4Sxinhui pan
535c030f2e4Sxinhui pan struct ras_dispatch_if {
5361a6fc071STao Zhou struct ras_common_if head;
537a564808eSxinhui pan struct amdgpu_iv_entry *entry;
538511fdbc3Sxinhui pan };
539511fdbc3Sxinhui pan
540511fdbc3Sxinhui pan struct ras_debug_if {
5414d9f771eSLuben Tuikov union {
542a46751fbSLuben Tuikov struct ras_common_if head;
5434a1c9a44SHawking Zhang struct ras_inject_if inject;
5444a1c9a44SHawking Zhang };
545c030f2e4Sxinhui pan int op;
546c030f2e4Sxinhui pan };
547c030f2e4Sxinhui pan
5489dc23a63STao Zhou struct amdgpu_ras_block_object {
549c030f2e4Sxinhui pan struct ras_common_if ras_comm;
5504d33e0f1STao Zhou
5514d33e0f1STao Zhou int (*ras_block_match)(struct amdgpu_ras_block_object *block_obj,
552c030f2e4Sxinhui pan enum amdgpu_ras_block block, uint32_t sub_block_index);
553828cfa29Sxinhui pan int (*ras_late_init)(struct amdgpu_device *adev, struct ras_common_if *ras_block);
554828cfa29Sxinhui pan void (*ras_fini)(struct amdgpu_device *adev, struct ras_common_if *ras_block);
555828cfa29Sxinhui pan ras_ih_cb ras_cb;
556828cfa29Sxinhui pan const struct amdgpu_ras_block_hw_ops *hw_ops;
557828cfa29Sxinhui pan };
558828cfa29Sxinhui pan
559828cfa29Sxinhui pan struct amdgpu_ras_block_hw_ops {
560828cfa29Sxinhui pan int (*ras_error_inject)(struct amdgpu_device *adev,
561828cfa29Sxinhui pan void *inject_if, uint32_t instance_mask);
562828cfa29Sxinhui pan void (*query_ras_error_count)(struct amdgpu_device *adev, void *ras_error_status);
563828cfa29Sxinhui pan void (*query_ras_error_status)(struct amdgpu_device *adev);
564828cfa29Sxinhui pan void (*query_ras_error_address)(struct amdgpu_device *adev, void *ras_error_status);
565828cfa29Sxinhui pan void (*reset_ras_error_count)(struct amdgpu_device *adev);
566828cfa29Sxinhui pan void (*reset_ras_error_status)(struct amdgpu_device *adev);
567828cfa29Sxinhui pan bool (*query_poison_status)(struct amdgpu_device *adev);
568828cfa29Sxinhui pan bool (*handle_poison_consumption)(struct amdgpu_device *adev);
569828cfa29Sxinhui pan };
570828cfa29Sxinhui pan
571828cfa29Sxinhui pan /* work flow
572828cfa29Sxinhui pan * vbios
573828cfa29Sxinhui pan * 1: ras feature enable (enabled by default)
574828cfa29Sxinhui pan * psp
575828cfa29Sxinhui pan * 2: ras framework init (in ip_init)
576828cfa29Sxinhui pan * IP
577828cfa29Sxinhui pan * 3: IH add
578828cfa29Sxinhui pan * 4: debugfs/sysfs create
579828cfa29Sxinhui pan * 5: query/inject
580828cfa29Sxinhui pan * 6: debugfs/sysfs remove
581828cfa29Sxinhui pan * 7: IH remove
582828cfa29Sxinhui pan * 8: feature disable
583828cfa29Sxinhui pan */
584640ae42eSJohn Clements
585640ae42eSJohn Clements
586*caa4dffaSStanley.Yang int amdgpu_ras_recovery_init(struct amdgpu_device *adev);
587*caa4dffaSStanley.Yang
588*caa4dffaSStanley.Yang void amdgpu_ras_resume(struct amdgpu_device *adev);
589*caa4dffaSStanley.Yang void amdgpu_ras_suspend(struct amdgpu_device *adev);
590828cfa29Sxinhui pan
591828cfa29Sxinhui pan int amdgpu_ras_query_error_count(struct amdgpu_device *adev,
592828cfa29Sxinhui pan unsigned long *ce_count,
593828cfa29Sxinhui pan unsigned long *ue_count,
594828cfa29Sxinhui pan struct ras_query_if *query_info);
595828cfa29Sxinhui pan
596828cfa29Sxinhui pan /* error handling functions */
597828cfa29Sxinhui pan int amdgpu_ras_add_bad_pages(struct amdgpu_device *adev,
598828cfa29Sxinhui pan struct eeprom_table_record *bps, int pages);
599828cfa29Sxinhui pan
600828cfa29Sxinhui pan int amdgpu_ras_save_bad_pages(struct amdgpu_device *adev,
601828cfa29Sxinhui pan unsigned long *new_cnt);
602828cfa29Sxinhui pan
603828cfa29Sxinhui pan static inline enum ta_ras_block
amdgpu_ras_block_to_ta(enum amdgpu_ras_block block)604828cfa29Sxinhui pan amdgpu_ras_block_to_ta(enum amdgpu_ras_block block) {
605828cfa29Sxinhui pan switch (block) {
606828cfa29Sxinhui pan case AMDGPU_RAS_BLOCK__UMC:
607828cfa29Sxinhui pan return TA_RAS_BLOCK__UMC;
608828cfa29Sxinhui pan case AMDGPU_RAS_BLOCK__SDMA:
609828cfa29Sxinhui pan return TA_RAS_BLOCK__SDMA;
610828cfa29Sxinhui pan case AMDGPU_RAS_BLOCK__GFX:
611828cfa29Sxinhui pan return TA_RAS_BLOCK__GFX;
612828cfa29Sxinhui pan case AMDGPU_RAS_BLOCK__MMHUB:
613828cfa29Sxinhui pan return TA_RAS_BLOCK__MMHUB;
614828cfa29Sxinhui pan case AMDGPU_RAS_BLOCK__ATHUB:
615c030f2e4Sxinhui pan return TA_RAS_BLOCK__ATHUB;
616c030f2e4Sxinhui pan case AMDGPU_RAS_BLOCK__PCIE_BIF:
617867e24caSyipechai return TA_RAS_BLOCK__PCIE_BIF;
618c030f2e4Sxinhui pan case AMDGPU_RAS_BLOCK__HDP:
619c030f2e4Sxinhui pan return TA_RAS_BLOCK__HDP;
620bdb3489cSyipechai case AMDGPU_RAS_BLOCK__XGMI_WAFL:
621bdb3489cSyipechai return TA_RAS_BLOCK__XGMI_WAFL;
622bdb3489cSyipechai case AMDGPU_RAS_BLOCK__DF:
623bdb3489cSyipechai return TA_RAS_BLOCK__DF;
624bdb3489cSyipechai case AMDGPU_RAS_BLOCK__SMN:
625bdb3489cSyipechai return TA_RAS_BLOCK__SMN;
626bdb3489cSyipechai case AMDGPU_RAS_BLOCK__SEM:
627c030f2e4Sxinhui pan return TA_RAS_BLOCK__SEM;
628c030f2e4Sxinhui pan case AMDGPU_RAS_BLOCK__MP0:
629c030f2e4Sxinhui pan return TA_RAS_BLOCK__MP0;
63077de502bSxinhui pan case AMDGPU_RAS_BLOCK__MP1:
63177de502bSxinhui pan return TA_RAS_BLOCK__MP1;
63277de502bSxinhui pan case AMDGPU_RAS_BLOCK__FUSE:
633c030f2e4Sxinhui pan return TA_RAS_BLOCK__FUSE;
6349252d33dSyipechai case AMDGPU_RAS_BLOCK__MCA:
635c030f2e4Sxinhui pan return TA_RAS_BLOCK__MCA;
636c030f2e4Sxinhui pan case AMDGPU_RAS_BLOCK__VCN:
637c030f2e4Sxinhui pan return TA_RAS_BLOCK__VCN;
638c030f2e4Sxinhui pan case AMDGPU_RAS_BLOCK__JPEG:
639f9317014STao Zhou return TA_RAS_BLOCK__JPEG;
640f9317014STao Zhou default:
641761d86d3SDennis Li WARN_ONCE(1, "RAS ERROR: unexpected block id %d\n", block);
642c030f2e4Sxinhui pan return TA_RAS_BLOCK__UMC;
643c030f2e4Sxinhui pan }
644761d86d3SDennis Li }
645761d86d3SDennis Li
646761d86d3SDennis Li static inline enum ta_ras_error_type
amdgpu_ras_error_to_ta(enum amdgpu_ras_error_type error)647c030f2e4Sxinhui pan amdgpu_ras_error_to_ta(enum amdgpu_ras_error_type error) {
648c030f2e4Sxinhui pan switch (error) {
649c030f2e4Sxinhui pan case AMDGPU_RAS_ERROR__NONE:
650c030f2e4Sxinhui pan return TA_RAS_ERROR__NONE;
6519252d33dSyipechai case AMDGPU_RAS_ERROR__PARITY:
652c030f2e4Sxinhui pan return TA_RAS_ERROR__PARITY;
653c030f2e4Sxinhui pan case AMDGPU_RAS_ERROR__SINGLE_CORRECTABLE:
6549252d33dSyipechai return TA_RAS_ERROR__SINGLE_CORRECTABLE;
655c030f2e4Sxinhui pan case AMDGPU_RAS_ERROR__MULTI_UNCORRECTABLE:
656c030f2e4Sxinhui pan return TA_RAS_ERROR__MULTI_UNCORRECTABLE;
657c030f2e4Sxinhui pan case AMDGPU_RAS_ERROR__POISON:
6587c6e68c7SAndrey Grodzovsky return TA_RAS_ERROR__POISON;
659f2a79be1SLe Ma default:
660f2a79be1SLe Ma WARN_ONCE(1, "RAS ERROR: unexpected error type %d\n", error);
661f2a79be1SLe Ma return TA_RAS_ERROR__NONE;
6627c6e68c7SAndrey Grodzovsky }
6637c6e68c7SAndrey Grodzovsky }
6647c6e68c7SAndrey Grodzovsky
6657c6e68c7SAndrey Grodzovsky /* called in ip_init and ip_fini */
6667c6e68c7SAndrey Grodzovsky int amdgpu_ras_init(struct amdgpu_device *adev);
6677c6e68c7SAndrey Grodzovsky int amdgpu_ras_late_init(struct amdgpu_device *adev);
6687c6e68c7SAndrey Grodzovsky int amdgpu_ras_fini(struct amdgpu_device *adev);
66900eaa571SLe Ma int amdgpu_ras_pre_fini(struct amdgpu_device *adev);
67000eaa571SLe Ma
67100eaa571SLe Ma int amdgpu_ras_block_late_init(struct amdgpu_device *adev,
67200eaa571SLe Ma struct ras_common_if *ras_block);
67300eaa571SLe Ma
6747c6e68c7SAndrey Grodzovsky void amdgpu_ras_block_late_fini(struct amdgpu_device *adev,
6757c6e68c7SAndrey Grodzovsky struct ras_common_if *ras_block);
67661380faaSJohn Clements
67761380faaSJohn Clements int amdgpu_ras_feature_enable(struct amdgpu_device *adev,
678bb5c7235SWenhui Sheng struct ras_common_if *head, bool enable);
679970fd197SStanley.Yang
680970fd197SStanley.Yang int amdgpu_ras_feature_enable_on_boot(struct amdgpu_device *adev,
6818f6368a9SJohn Clements struct ras_common_if *head, bool enable);
6828f6368a9SJohn Clements
6838f6368a9SJohn Clements int amdgpu_ras_sysfs_create(struct amdgpu_device *adev,
684640ae42eSJohn Clements struct ras_common_if *head);
685640ae42eSJohn Clements
686e4348849STao Zhou int amdgpu_ras_sysfs_remove(struct amdgpu_device *adev,
687e4348849STao Zhou struct ras_common_if *head);
6887cab2124Syipechai
6897cab2124Syipechai void amdgpu_ras_debugfs_create_all(struct amdgpu_device *adev);
6907cab2124Syipechai
6917cab2124Syipechai int amdgpu_ras_query_error_status(struct amdgpu_device *adev,
6927cab2124Syipechai struct ras_query_if *info);
6937cab2124Syipechai
6947cab2124Syipechai int amdgpu_ras_reset_error_status(struct amdgpu_device *adev,
6957cab2124Syipechai enum amdgpu_ras_block block);
696b6efdb02Syipechai
697b6efdb02Syipechai int amdgpu_ras_error_inject(struct amdgpu_device *adev,
698b3c76814STao Zhou struct ras_inject_if *info);
699c030f2e4Sxinhui pan
700 int amdgpu_ras_interrupt_add_handler(struct amdgpu_device *adev,
701 struct ras_common_if *head);
702
703 int amdgpu_ras_interrupt_remove_handler(struct amdgpu_device *adev,
704 struct ras_common_if *head);
705
706 int amdgpu_ras_interrupt_dispatch(struct amdgpu_device *adev,
707 struct ras_dispatch_if *info);
708
709 struct ras_manager *amdgpu_ras_find_obj(struct amdgpu_device *adev,
710 struct ras_common_if *head);
711
712 extern atomic_t amdgpu_ras_in_intr;
713
amdgpu_ras_intr_triggered(void)714 static inline bool amdgpu_ras_intr_triggered(void)
715 {
716 return !!atomic_read(&amdgpu_ras_in_intr);
717 }
718
amdgpu_ras_intr_cleared(void)719 static inline void amdgpu_ras_intr_cleared(void)
720 {
721 atomic_set(&amdgpu_ras_in_intr, 0);
722 }
723
724 void amdgpu_ras_global_ras_isr(struct amdgpu_device *adev);
725
726 void amdgpu_ras_set_error_query_ready(struct amdgpu_device *adev, bool ready);
727
728 bool amdgpu_ras_need_emergency_restart(struct amdgpu_device *adev);
729
730 void amdgpu_release_ras_context(struct amdgpu_device *adev);
731
732 int amdgpu_persistent_edc_harvesting_supported(struct amdgpu_device *adev);
733
734 const char *get_ras_block_str(struct ras_common_if *ras_block);
735
736 bool amdgpu_ras_is_poison_mode_supported(struct amdgpu_device *adev);
737
738 int amdgpu_ras_is_supported(struct amdgpu_device *adev, unsigned int block);
739
740 int amdgpu_ras_reset_gpu(struct amdgpu_device *adev);
741
742 struct amdgpu_ras* amdgpu_ras_get_context(struct amdgpu_device *adev);
743
744 int amdgpu_ras_set_context(struct amdgpu_device *adev, struct amdgpu_ras *ras_con);
745
746 int amdgpu_ras_register_ras_block(struct amdgpu_device *adev,
747 struct amdgpu_ras_block_object *ras_block_obj);
748 void amdgpu_ras_interrupt_fatal_error_handler(struct amdgpu_device *adev);
749 void amdgpu_ras_get_error_type_name(uint32_t err_type, char *err_type_name);
750 bool amdgpu_ras_inst_get_memory_id_field(struct amdgpu_device *adev,
751 const struct amdgpu_ras_err_status_reg_entry *reg_entry,
752 uint32_t instance,
753 uint32_t *memory_id);
754 bool amdgpu_ras_inst_get_err_cnt_field(struct amdgpu_device *adev,
755 const struct amdgpu_ras_err_status_reg_entry *reg_entry,
756 uint32_t instance,
757 unsigned long *err_cnt);
758 void amdgpu_ras_inst_query_ras_error_count(struct amdgpu_device *adev,
759 const struct amdgpu_ras_err_status_reg_entry *reg_list,
760 uint32_t reg_list_size,
761 const struct amdgpu_ras_memory_id_entry *mem_list,
762 uint32_t mem_list_size,
763 uint32_t instance,
764 uint32_t err_type,
765 unsigned long *err_count);
766 void amdgpu_ras_inst_reset_ras_error_count(struct amdgpu_device *adev,
767 const struct amdgpu_ras_err_status_reg_entry *reg_list,
768 uint32_t reg_list_size,
769 uint32_t instance);
770 #endif
771