193b2f7deSShashank Gupta // SPDX-License-Identifier: GPL-2.0-only
293b2f7deSShashank Gupta /* Copyright(c) 2023 Intel Corporation */
393b2f7deSShashank Gupta #include "adf_common_drv.h"
4df8c184bSShashank Gupta #include "adf_gen4_hw_data.h"
593b2f7deSShashank Gupta #include "adf_gen4_ras.h"
699b1c982SShashank Gupta #include "adf_sysfs_ras_counters.h"
799b1c982SShashank Gupta
899b1c982SShashank Gupta #define BITS_PER_REG(_n_) (sizeof(_n_) * BITS_PER_BYTE)
993b2f7deSShashank Gupta
enable_errsou_reporting(void __iomem * csr)10df8c184bSShashank Gupta static void enable_errsou_reporting(void __iomem *csr)
11df8c184bSShashank Gupta {
12df8c184bSShashank Gupta /* Enable correctable error reporting in ERRSOU0 */
13df8c184bSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_ERRMSK0, 0);
144926e89dSShashank Gupta
154926e89dSShashank Gupta /* Enable uncorrectable error reporting in ERRSOU1 */
164926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_ERRMSK1, 0);
17895f7d53SShashank Gupta
18895f7d53SShashank Gupta /*
19895f7d53SShashank Gupta * Enable uncorrectable error reporting in ERRSOU2
20895f7d53SShashank Gupta * but disable PM interrupt and CFC attention interrupt by default
21895f7d53SShashank Gupta */
22895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_ERRMSK2,
23895f7d53SShashank Gupta ADF_GEN4_ERRSOU2_PM_INT_BIT |
24895f7d53SShashank Gupta ADF_GEN4_ERRSOU2_CPP_CFC_ATT_INT_BITMASK);
2522289dc9SShashank Gupta
2622289dc9SShashank Gupta /*
2722289dc9SShashank Gupta * Enable uncorrectable error reporting in ERRSOU3
2822289dc9SShashank Gupta * but disable RLT error interrupt and VFLR notify interrupt by default
2922289dc9SShashank Gupta */
3022289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_ERRMSK3,
3122289dc9SShashank Gupta ADF_GEN4_ERRSOU3_RLTERROR_BIT |
3222289dc9SShashank Gupta ADF_GEN4_ERRSOU3_VFLRNOTIFY_BIT);
33df8c184bSShashank Gupta }
34df8c184bSShashank Gupta
disable_errsou_reporting(void __iomem * csr)35df8c184bSShashank Gupta static void disable_errsou_reporting(void __iomem *csr)
36df8c184bSShashank Gupta {
37895f7d53SShashank Gupta u32 val = 0;
38895f7d53SShashank Gupta
39df8c184bSShashank Gupta /* Disable correctable error reporting in ERRSOU0 */
40df8c184bSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_ERRMSK0, ADF_GEN4_ERRSOU0_BIT);
414926e89dSShashank Gupta
424926e89dSShashank Gupta /* Disable uncorrectable error reporting in ERRSOU1 */
434926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_ERRMSK1, ADF_GEN4_ERRSOU1_BITMASK);
44895f7d53SShashank Gupta
45895f7d53SShashank Gupta /* Disable uncorrectable error reporting in ERRSOU2 */
46895f7d53SShashank Gupta val = ADF_CSR_RD(csr, ADF_GEN4_ERRMSK2);
47895f7d53SShashank Gupta val |= ADF_GEN4_ERRSOU2_DIS_BITMASK;
48895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_ERRMSK2, val);
4922289dc9SShashank Gupta
5022289dc9SShashank Gupta /* Disable uncorrectable error reporting in ERRSOU3 */
5122289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_ERRMSK3, ADF_GEN4_ERRSOU3_BITMASK);
52df8c184bSShashank Gupta }
53df8c184bSShashank Gupta
enable_ae_error_reporting(struct adf_accel_dev * accel_dev,void __iomem * csr)54df8c184bSShashank Gupta static void enable_ae_error_reporting(struct adf_accel_dev *accel_dev,
55df8c184bSShashank Gupta void __iomem *csr)
56df8c184bSShashank Gupta {
57df8c184bSShashank Gupta u32 ae_mask = GET_HW_DATA(accel_dev)->ae_mask;
58df8c184bSShashank Gupta
59df8c184bSShashank Gupta /* Enable Acceleration Engine correctable error reporting */
60df8c184bSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_HIAECORERRLOGENABLE_CPP0, ae_mask);
614926e89dSShashank Gupta
624926e89dSShashank Gupta /* Enable Acceleration Engine uncorrectable error reporting */
634926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_HIAEUNCERRLOGENABLE_CPP0, ae_mask);
64df8c184bSShashank Gupta }
65df8c184bSShashank Gupta
disable_ae_error_reporting(void __iomem * csr)66df8c184bSShashank Gupta static void disable_ae_error_reporting(void __iomem *csr)
67df8c184bSShashank Gupta {
68df8c184bSShashank Gupta /* Disable Acceleration Engine correctable error reporting */
69df8c184bSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_HIAECORERRLOGENABLE_CPP0, 0);
704926e89dSShashank Gupta
714926e89dSShashank Gupta /* Disable Acceleration Engine uncorrectable error reporting */
724926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_HIAEUNCERRLOGENABLE_CPP0, 0);
734926e89dSShashank Gupta }
744926e89dSShashank Gupta
enable_cpp_error_reporting(struct adf_accel_dev * accel_dev,void __iomem * csr)754926e89dSShashank Gupta static void enable_cpp_error_reporting(struct adf_accel_dev *accel_dev,
764926e89dSShashank Gupta void __iomem *csr)
774926e89dSShashank Gupta {
784926e89dSShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
794926e89dSShashank Gupta
804926e89dSShashank Gupta /* Enable HI CPP Agents Command Parity Error Reporting */
814926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_HICPPAGENTCMDPARERRLOGENABLE,
824926e89dSShashank Gupta err_mask->cppagentcmdpar_mask);
83895f7d53SShashank Gupta
84895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_CPP_CFC_ERR_CTRL,
85895f7d53SShashank Gupta ADF_GEN4_CPP_CFC_ERR_CTRL_BITMASK);
864926e89dSShashank Gupta }
874926e89dSShashank Gupta
disable_cpp_error_reporting(void __iomem * csr)884926e89dSShashank Gupta static void disable_cpp_error_reporting(void __iomem *csr)
894926e89dSShashank Gupta {
904926e89dSShashank Gupta /* Disable HI CPP Agents Command Parity Error Reporting */
914926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_HICPPAGENTCMDPARERRLOGENABLE, 0);
92895f7d53SShashank Gupta
93895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_CPP_CFC_ERR_CTRL,
94895f7d53SShashank Gupta ADF_GEN4_CPP_CFC_ERR_CTRL_DIS_BITMASK);
954926e89dSShashank Gupta }
964926e89dSShashank Gupta
enable_ti_ri_error_reporting(void __iomem * csr)974926e89dSShashank Gupta static void enable_ti_ri_error_reporting(void __iomem *csr)
984926e89dSShashank Gupta {
9922289dc9SShashank Gupta u32 reg;
10022289dc9SShashank Gupta
1014926e89dSShashank Gupta /* Enable RI Memory error reporting */
1024926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_RI_MEM_PAR_ERR_EN0,
1034926e89dSShashank Gupta ADF_GEN4_RIMEM_PARERR_STS_FATAL_BITMASK |
1044926e89dSShashank Gupta ADF_GEN4_RIMEM_PARERR_STS_UNCERR_BITMASK);
1054926e89dSShashank Gupta
1064926e89dSShashank Gupta /* Enable IOSF Primary Command Parity error Reporting */
1074926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_RIMISCCTL, ADF_GEN4_RIMISCSTS_BIT);
1084926e89dSShashank Gupta
1094926e89dSShashank Gupta /* Enable TI Internal Memory Parity Error reporting */
1104926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_CI_PAR_ERR_MASK, 0);
1114926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_PULL0FUB_PAR_ERR_MASK, 0);
1124926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_PUSHFUB_PAR_ERR_MASK, 0);
1134926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_CD_PAR_ERR_MASK, 0);
1144926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_TRNSB_PAR_ERR_MASK, 0);
11522289dc9SShashank Gupta
11622289dc9SShashank Gupta /* Enable error handling in RI, TI CPP interface control registers */
11722289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_RICPPINTCTL, ADF_GEN4_RICPPINTCTL_BITMASK);
11822289dc9SShashank Gupta
11922289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TICPPINTCTL, ADF_GEN4_TICPPINTCTL_BITMASK);
12022289dc9SShashank Gupta
12122289dc9SShashank Gupta /*
12222289dc9SShashank Gupta * Enable error detection and reporting in TIMISCSTS
12322289dc9SShashank Gupta * with bits 1, 2 and 30 value preserved
12422289dc9SShashank Gupta */
12522289dc9SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_TIMISCCTL);
12622289dc9SShashank Gupta reg &= ADF_GEN4_TIMSCCTL_RELAY_BITMASK;
12722289dc9SShashank Gupta reg |= ADF_GEN4_TIMISCCTL_BIT;
12822289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TIMISCCTL, reg);
1294926e89dSShashank Gupta }
1304926e89dSShashank Gupta
disable_ti_ri_error_reporting(void __iomem * csr)1314926e89dSShashank Gupta static void disable_ti_ri_error_reporting(void __iomem *csr)
1324926e89dSShashank Gupta {
13322289dc9SShashank Gupta u32 reg;
13422289dc9SShashank Gupta
1354926e89dSShashank Gupta /* Disable RI Memory error reporting */
1364926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_RI_MEM_PAR_ERR_EN0, 0);
1374926e89dSShashank Gupta
1384926e89dSShashank Gupta /* Disable IOSF Primary Command Parity error Reporting */
1394926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_RIMISCCTL, 0);
1404926e89dSShashank Gupta
1414926e89dSShashank Gupta /* Disable TI Internal Memory Parity Error reporting */
1424926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_CI_PAR_ERR_MASK,
1434926e89dSShashank Gupta ADF_GEN4_TI_CI_PAR_STS_BITMASK);
1444926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_PULL0FUB_PAR_ERR_MASK,
1454926e89dSShashank Gupta ADF_GEN4_TI_PULL0FUB_PAR_STS_BITMASK);
1464926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_PUSHFUB_PAR_ERR_MASK,
1474926e89dSShashank Gupta ADF_GEN4_TI_PUSHFUB_PAR_STS_BITMASK);
1484926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_CD_PAR_ERR_MASK,
1494926e89dSShashank Gupta ADF_GEN4_TI_CD_PAR_STS_BITMASK);
1504926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_TRNSB_PAR_ERR_MASK,
1514926e89dSShashank Gupta ADF_GEN4_TI_TRNSB_PAR_STS_BITMASK);
15222289dc9SShashank Gupta
15322289dc9SShashank Gupta /* Disable error handling in RI, TI CPP interface control registers */
15422289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_RICPPINTCTL, 0);
15522289dc9SShashank Gupta
15622289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TICPPINTCTL, 0);
15722289dc9SShashank Gupta
15822289dc9SShashank Gupta /*
15922289dc9SShashank Gupta * Disable error detection and reporting in TIMISCSTS
16022289dc9SShashank Gupta * with bits 1, 2 and 30 value preserved
16122289dc9SShashank Gupta */
16222289dc9SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_TIMISCCTL);
16322289dc9SShashank Gupta reg &= ADF_GEN4_TIMSCCTL_RELAY_BITMASK;
16422289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TIMISCCTL, reg);
165df8c184bSShashank Gupta }
166df8c184bSShashank Gupta
enable_rf_error_reporting(struct adf_accel_dev * accel_dev,void __iomem * csr)167895f7d53SShashank Gupta static void enable_rf_error_reporting(struct adf_accel_dev *accel_dev,
168895f7d53SShashank Gupta void __iomem *csr)
169895f7d53SShashank Gupta {
170895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
171895f7d53SShashank Gupta
172895f7d53SShashank Gupta /* Enable RF parity error in Shared RAM */
173895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_SRC, 0);
174895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_ATH_CPH, 0);
175895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_CPR_XLT, 0);
176895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_DCPR_UCS, 0);
177895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_PKE, 0);
178895f7d53SShashank Gupta
179895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask)
180895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_WAT_WCP, 0);
181895f7d53SShashank Gupta }
182895f7d53SShashank Gupta
disable_rf_error_reporting(struct adf_accel_dev * accel_dev,void __iomem * csr)183895f7d53SShashank Gupta static void disable_rf_error_reporting(struct adf_accel_dev *accel_dev,
184895f7d53SShashank Gupta void __iomem *csr)
185895f7d53SShashank Gupta {
186895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
187895f7d53SShashank Gupta
188895f7d53SShashank Gupta /* Disable RF Parity Error reporting in Shared RAM */
189895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_SRC,
190895f7d53SShashank Gupta ADF_GEN4_SSMSOFTERRORPARITY_SRC_BIT);
191895f7d53SShashank Gupta
192895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_ATH_CPH,
193895f7d53SShashank Gupta err_mask->parerr_ath_cph_mask);
194895f7d53SShashank Gupta
195895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_CPR_XLT,
196895f7d53SShashank Gupta err_mask->parerr_cpr_xlt_mask);
197895f7d53SShashank Gupta
198895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_DCPR_UCS,
199895f7d53SShashank Gupta err_mask->parerr_dcpr_ucs_mask);
200895f7d53SShashank Gupta
201895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_PKE,
202895f7d53SShashank Gupta err_mask->parerr_pke_mask);
203895f7d53SShashank Gupta
204895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask)
205895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITYMASK_WAT_WCP,
206895f7d53SShashank Gupta err_mask->parerr_wat_wcp_mask);
207895f7d53SShashank Gupta }
208895f7d53SShashank Gupta
enable_ssm_error_reporting(struct adf_accel_dev * accel_dev,void __iomem * csr)209895f7d53SShashank Gupta static void enable_ssm_error_reporting(struct adf_accel_dev *accel_dev,
210895f7d53SShashank Gupta void __iomem *csr)
211895f7d53SShashank Gupta {
212895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
213895f7d53SShashank Gupta u32 val = 0;
214895f7d53SShashank Gupta
215895f7d53SShashank Gupta /* Enable SSM interrupts */
216895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_INTMASKSSM, 0);
217895f7d53SShashank Gupta
218895f7d53SShashank Gupta /* Enable shared memory error detection & correction */
219895f7d53SShashank Gupta val = ADF_CSR_RD(csr, ADF_GEN4_SSMFEATREN);
220895f7d53SShashank Gupta val |= err_mask->ssmfeatren_mask;
221895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMFEATREN, val);
222895f7d53SShashank Gupta
223895f7d53SShashank Gupta /* Enable SER detection in SER_err_ssmsh register */
224895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SER_EN_SSMSH,
225895f7d53SShashank Gupta ADF_GEN4_SER_EN_SSMSH_BITMASK);
226895f7d53SShashank Gupta
227895f7d53SShashank Gupta /* Enable SSM soft parity error */
228895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_ATH_CPH, 0);
229895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_CPR_XLT, 0);
230895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_DCPR_UCS, 0);
231895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_PKE, 0);
232895f7d53SShashank Gupta
233895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask)
234895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_WAT_WCP, 0);
235895f7d53SShashank Gupta
236895f7d53SShashank Gupta /* Enable slice hang interrupt reporting */
237895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_ATH_CPH, 0);
238895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_CPR_XLT, 0);
239895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_DCPR_UCS, 0);
240895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_PKE, 0);
241895f7d53SShashank Gupta
242895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask)
243895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_WAT_WCP, 0);
244895f7d53SShashank Gupta }
245895f7d53SShashank Gupta
disable_ssm_error_reporting(struct adf_accel_dev * accel_dev,void __iomem * csr)246895f7d53SShashank Gupta static void disable_ssm_error_reporting(struct adf_accel_dev *accel_dev,
247895f7d53SShashank Gupta void __iomem *csr)
248895f7d53SShashank Gupta {
249895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
250895f7d53SShashank Gupta u32 val = 0;
251895f7d53SShashank Gupta
252895f7d53SShashank Gupta /* Disable SSM interrupts */
253895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_INTMASKSSM,
254895f7d53SShashank Gupta ADF_GEN4_INTMASKSSM_BITMASK);
255895f7d53SShashank Gupta
256895f7d53SShashank Gupta /* Disable shared memory error detection & correction */
257895f7d53SShashank Gupta val = ADF_CSR_RD(csr, ADF_GEN4_SSMFEATREN);
258895f7d53SShashank Gupta val &= ADF_GEN4_SSMFEATREN_DIS_BITMASK;
259895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMFEATREN, val);
260895f7d53SShashank Gupta
261895f7d53SShashank Gupta /* Disable SER detection in SER_err_ssmsh register */
262895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SER_EN_SSMSH, 0);
263895f7d53SShashank Gupta
264895f7d53SShashank Gupta /* Disable SSM soft parity error */
265895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_ATH_CPH,
266895f7d53SShashank Gupta err_mask->parerr_ath_cph_mask);
267895f7d53SShashank Gupta
268895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_CPR_XLT,
269895f7d53SShashank Gupta err_mask->parerr_cpr_xlt_mask);
270895f7d53SShashank Gupta
271895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_DCPR_UCS,
272895f7d53SShashank Gupta err_mask->parerr_dcpr_ucs_mask);
273895f7d53SShashank Gupta
274895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_PKE,
275895f7d53SShashank Gupta err_mask->parerr_pke_mask);
276895f7d53SShashank Gupta
277895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask)
278895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPARERRMSK_WAT_WCP,
279895f7d53SShashank Gupta err_mask->parerr_wat_wcp_mask);
280895f7d53SShashank Gupta
281895f7d53SShashank Gupta /* Disable slice hang interrupt reporting */
282895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_ATH_CPH,
283895f7d53SShashank Gupta err_mask->parerr_ath_cph_mask);
284895f7d53SShashank Gupta
285895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_CPR_XLT,
286895f7d53SShashank Gupta err_mask->parerr_cpr_xlt_mask);
287895f7d53SShashank Gupta
288895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_DCPR_UCS,
289895f7d53SShashank Gupta err_mask->parerr_dcpr_ucs_mask);
290895f7d53SShashank Gupta
291895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_PKE,
292895f7d53SShashank Gupta err_mask->parerr_pke_mask);
293895f7d53SShashank Gupta
294895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask)
295895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SHINTMASKSSM_WAT_WCP,
296895f7d53SShashank Gupta err_mask->parerr_wat_wcp_mask);
297895f7d53SShashank Gupta }
298895f7d53SShashank Gupta
enable_aram_error_reporting(void __iomem * csr)29922289dc9SShashank Gupta static void enable_aram_error_reporting(void __iomem *csr)
30022289dc9SShashank Gupta {
30122289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_ARAMCERRUERR_EN,
30222289dc9SShashank Gupta ADF_GEN4_REG_ARAMCERRUERR_EN_BITMASK);
30322289dc9SShashank Gupta
30422289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_ARAMCERR,
30522289dc9SShashank Gupta ADF_GEN4_REG_ARAMCERR_EN_BITMASK);
30622289dc9SShashank Gupta
30722289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_ARAMUERR,
30822289dc9SShashank Gupta ADF_GEN4_REG_ARAMUERR_EN_BITMASK);
30922289dc9SShashank Gupta
31022289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_CPPMEMTGTERR,
31122289dc9SShashank Gupta ADF_GEN4_REG_CPPMEMTGTERR_EN_BITMASK);
31222289dc9SShashank Gupta }
31322289dc9SShashank Gupta
disable_aram_error_reporting(void __iomem * csr)31422289dc9SShashank Gupta static void disable_aram_error_reporting(void __iomem *csr)
31522289dc9SShashank Gupta {
31622289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_ARAMCERRUERR_EN, 0);
31722289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_ARAMCERR, 0);
31822289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_ARAMUERR, 0);
31922289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_CPPMEMTGTERR, 0);
32022289dc9SShashank Gupta }
32122289dc9SShashank Gupta
adf_gen4_enable_ras(struct adf_accel_dev * accel_dev)32293b2f7deSShashank Gupta static void adf_gen4_enable_ras(struct adf_accel_dev *accel_dev)
32393b2f7deSShashank Gupta {
32422289dc9SShashank Gupta void __iomem *aram_csr = adf_get_aram_base(accel_dev);
325df8c184bSShashank Gupta void __iomem *csr = adf_get_pmisc_base(accel_dev);
326df8c184bSShashank Gupta
327df8c184bSShashank Gupta enable_errsou_reporting(csr);
328df8c184bSShashank Gupta enable_ae_error_reporting(accel_dev, csr);
3294926e89dSShashank Gupta enable_cpp_error_reporting(accel_dev, csr);
3304926e89dSShashank Gupta enable_ti_ri_error_reporting(csr);
331895f7d53SShashank Gupta enable_rf_error_reporting(accel_dev, csr);
332895f7d53SShashank Gupta enable_ssm_error_reporting(accel_dev, csr);
33322289dc9SShashank Gupta enable_aram_error_reporting(aram_csr);
33493b2f7deSShashank Gupta }
33593b2f7deSShashank Gupta
adf_gen4_disable_ras(struct adf_accel_dev * accel_dev)33693b2f7deSShashank Gupta static void adf_gen4_disable_ras(struct adf_accel_dev *accel_dev)
33793b2f7deSShashank Gupta {
33822289dc9SShashank Gupta void __iomem *aram_csr = adf_get_aram_base(accel_dev);
339df8c184bSShashank Gupta void __iomem *csr = adf_get_pmisc_base(accel_dev);
340df8c184bSShashank Gupta
341df8c184bSShashank Gupta disable_errsou_reporting(csr);
342df8c184bSShashank Gupta disable_ae_error_reporting(csr);
3434926e89dSShashank Gupta disable_cpp_error_reporting(csr);
3444926e89dSShashank Gupta disable_ti_ri_error_reporting(csr);
345895f7d53SShashank Gupta disable_rf_error_reporting(accel_dev, csr);
346895f7d53SShashank Gupta disable_ssm_error_reporting(accel_dev, csr);
34722289dc9SShashank Gupta disable_aram_error_reporting(aram_csr);
348df8c184bSShashank Gupta }
349df8c184bSShashank Gupta
adf_gen4_process_errsou0(struct adf_accel_dev * accel_dev,void __iomem * csr)350df8c184bSShashank Gupta static void adf_gen4_process_errsou0(struct adf_accel_dev *accel_dev,
351df8c184bSShashank Gupta void __iomem *csr)
352df8c184bSShashank Gupta {
353df8c184bSShashank Gupta u32 aecorrerr = ADF_CSR_RD(csr, ADF_GEN4_HIAECORERRLOG_CPP0);
354df8c184bSShashank Gupta
355df8c184bSShashank Gupta aecorrerr &= GET_HW_DATA(accel_dev)->ae_mask;
356df8c184bSShashank Gupta
357df8c184bSShashank Gupta dev_warn(&GET_DEV(accel_dev),
358df8c184bSShashank Gupta "Correctable error detected in AE: 0x%x\n",
359df8c184bSShashank Gupta aecorrerr);
360df8c184bSShashank Gupta
36199b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_CORR);
36299b1c982SShashank Gupta
363df8c184bSShashank Gupta /* Clear interrupt from ERRSOU0 */
364df8c184bSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_HIAECORERRLOG_CPP0, aecorrerr);
36593b2f7deSShashank Gupta }
36693b2f7deSShashank Gupta
adf_handle_cpp_aeunc(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)3674926e89dSShashank Gupta static bool adf_handle_cpp_aeunc(struct adf_accel_dev *accel_dev,
3684926e89dSShashank Gupta void __iomem *csr, u32 errsou)
3694926e89dSShashank Gupta {
3704926e89dSShashank Gupta u32 aeuncorerr;
3714926e89dSShashank Gupta
3724926e89dSShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU1_HIAEUNCERRLOG_CPP0_BIT))
3734926e89dSShashank Gupta return false;
3744926e89dSShashank Gupta
3754926e89dSShashank Gupta aeuncorerr = ADF_CSR_RD(csr, ADF_GEN4_HIAEUNCERRLOG_CPP0);
3764926e89dSShashank Gupta aeuncorerr &= GET_HW_DATA(accel_dev)->ae_mask;
3774926e89dSShashank Gupta
3784926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
3794926e89dSShashank Gupta "Uncorrectable error detected in AE: 0x%x\n",
3804926e89dSShashank Gupta aeuncorerr);
3814926e89dSShashank Gupta
38299b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
38399b1c982SShashank Gupta
3844926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_HIAEUNCERRLOG_CPP0, aeuncorerr);
3854926e89dSShashank Gupta
3864926e89dSShashank Gupta return false;
3874926e89dSShashank Gupta }
3884926e89dSShashank Gupta
adf_handle_cppcmdparerr(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)3894926e89dSShashank Gupta static bool adf_handle_cppcmdparerr(struct adf_accel_dev *accel_dev,
3904926e89dSShashank Gupta void __iomem *csr, u32 errsou)
3914926e89dSShashank Gupta {
3924926e89dSShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
3934926e89dSShashank Gupta u32 cmdparerr;
3944926e89dSShashank Gupta
3954926e89dSShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU1_HICPPAGENTCMDPARERRLOG_BIT))
3964926e89dSShashank Gupta return false;
3974926e89dSShashank Gupta
3984926e89dSShashank Gupta cmdparerr = ADF_CSR_RD(csr, ADF_GEN4_HICPPAGENTCMDPARERRLOG);
3994926e89dSShashank Gupta cmdparerr &= err_mask->cppagentcmdpar_mask;
4004926e89dSShashank Gupta
4014926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
4024926e89dSShashank Gupta "HI CPP agent command parity error: 0x%x\n",
4034926e89dSShashank Gupta cmdparerr);
4044926e89dSShashank Gupta
40599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
40699b1c982SShashank Gupta
4074926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_HICPPAGENTCMDPARERRLOG, cmdparerr);
4084926e89dSShashank Gupta
4094926e89dSShashank Gupta return true;
4104926e89dSShashank Gupta }
4114926e89dSShashank Gupta
adf_handle_ri_mem_par_err(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)4124926e89dSShashank Gupta static bool adf_handle_ri_mem_par_err(struct adf_accel_dev *accel_dev,
4134926e89dSShashank Gupta void __iomem *csr, u32 errsou)
4144926e89dSShashank Gupta {
4154926e89dSShashank Gupta bool reset_required = false;
4164926e89dSShashank Gupta u32 rimem_parerr_sts;
4174926e89dSShashank Gupta
4184926e89dSShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU1_RIMEM_PARERR_STS_BIT))
4194926e89dSShashank Gupta return false;
4204926e89dSShashank Gupta
4214926e89dSShashank Gupta rimem_parerr_sts = ADF_CSR_RD(csr, ADF_GEN4_RIMEM_PARERR_STS);
4224926e89dSShashank Gupta rimem_parerr_sts &= ADF_GEN4_RIMEM_PARERR_STS_UNCERR_BITMASK |
4234926e89dSShashank Gupta ADF_GEN4_RIMEM_PARERR_STS_FATAL_BITMASK;
4244926e89dSShashank Gupta
42599b1c982SShashank Gupta if (rimem_parerr_sts & ADF_GEN4_RIMEM_PARERR_STS_UNCERR_BITMASK) {
4264926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
4274926e89dSShashank Gupta "RI Memory Parity uncorrectable error: 0x%x\n",
4284926e89dSShashank Gupta rimem_parerr_sts);
42999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
43099b1c982SShashank Gupta }
4314926e89dSShashank Gupta
4324926e89dSShashank Gupta if (rimem_parerr_sts & ADF_GEN4_RIMEM_PARERR_STS_FATAL_BITMASK) {
4334926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
4344926e89dSShashank Gupta "RI Memory Parity fatal error: 0x%x\n",
4354926e89dSShashank Gupta rimem_parerr_sts);
43699b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
4374926e89dSShashank Gupta reset_required = true;
4384926e89dSShashank Gupta }
4394926e89dSShashank Gupta
4404926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_RIMEM_PARERR_STS, rimem_parerr_sts);
4414926e89dSShashank Gupta
4424926e89dSShashank Gupta return reset_required;
4434926e89dSShashank Gupta }
4444926e89dSShashank Gupta
adf_handle_ti_ci_par_sts(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)4454926e89dSShashank Gupta static bool adf_handle_ti_ci_par_sts(struct adf_accel_dev *accel_dev,
4464926e89dSShashank Gupta void __iomem *csr, u32 errsou)
4474926e89dSShashank Gupta {
4484926e89dSShashank Gupta u32 ti_ci_par_sts;
4494926e89dSShashank Gupta
4504926e89dSShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU1_TIMEM_PARERR_STS_BIT))
4514926e89dSShashank Gupta return false;
4524926e89dSShashank Gupta
4534926e89dSShashank Gupta ti_ci_par_sts = ADF_CSR_RD(csr, ADF_GEN4_TI_CI_PAR_STS);
4544926e89dSShashank Gupta ti_ci_par_sts &= ADF_GEN4_TI_CI_PAR_STS_BITMASK;
4554926e89dSShashank Gupta
4564926e89dSShashank Gupta if (ti_ci_par_sts) {
4574926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
4584926e89dSShashank Gupta "TI Memory Parity Error: 0x%x\n", ti_ci_par_sts);
4594926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_CI_PAR_STS, ti_ci_par_sts);
46099b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
4614926e89dSShashank Gupta }
4624926e89dSShashank Gupta
4634926e89dSShashank Gupta return false;
4644926e89dSShashank Gupta }
4654926e89dSShashank Gupta
adf_handle_ti_pullfub_par_sts(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)4664926e89dSShashank Gupta static bool adf_handle_ti_pullfub_par_sts(struct adf_accel_dev *accel_dev,
4674926e89dSShashank Gupta void __iomem *csr, u32 errsou)
4684926e89dSShashank Gupta {
4694926e89dSShashank Gupta u32 ti_pullfub_par_sts;
4704926e89dSShashank Gupta
4714926e89dSShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU1_TIMEM_PARERR_STS_BIT))
4724926e89dSShashank Gupta return false;
4734926e89dSShashank Gupta
4744926e89dSShashank Gupta ti_pullfub_par_sts = ADF_CSR_RD(csr, ADF_GEN4_TI_PULL0FUB_PAR_STS);
4754926e89dSShashank Gupta ti_pullfub_par_sts &= ADF_GEN4_TI_PULL0FUB_PAR_STS_BITMASK;
4764926e89dSShashank Gupta
4774926e89dSShashank Gupta if (ti_pullfub_par_sts) {
4784926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
4794926e89dSShashank Gupta "TI Pull Parity Error: 0x%x\n", ti_pullfub_par_sts);
4804926e89dSShashank Gupta
4814926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_PULL0FUB_PAR_STS,
4824926e89dSShashank Gupta ti_pullfub_par_sts);
48399b1c982SShashank Gupta
48499b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
4854926e89dSShashank Gupta }
4864926e89dSShashank Gupta
4874926e89dSShashank Gupta return false;
4884926e89dSShashank Gupta }
4894926e89dSShashank Gupta
adf_handle_ti_pushfub_par_sts(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)4904926e89dSShashank Gupta static bool adf_handle_ti_pushfub_par_sts(struct adf_accel_dev *accel_dev,
4914926e89dSShashank Gupta void __iomem *csr, u32 errsou)
4924926e89dSShashank Gupta {
4934926e89dSShashank Gupta u32 ti_pushfub_par_sts;
4944926e89dSShashank Gupta
4954926e89dSShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU1_TIMEM_PARERR_STS_BIT))
4964926e89dSShashank Gupta return false;
4974926e89dSShashank Gupta
4984926e89dSShashank Gupta ti_pushfub_par_sts = ADF_CSR_RD(csr, ADF_GEN4_TI_PUSHFUB_PAR_STS);
4994926e89dSShashank Gupta ti_pushfub_par_sts &= ADF_GEN4_TI_PUSHFUB_PAR_STS_BITMASK;
5004926e89dSShashank Gupta
5014926e89dSShashank Gupta if (ti_pushfub_par_sts) {
5024926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
5034926e89dSShashank Gupta "TI Push Parity Error: 0x%x\n", ti_pushfub_par_sts);
5044926e89dSShashank Gupta
50599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
50699b1c982SShashank Gupta
5074926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_PUSHFUB_PAR_STS,
5084926e89dSShashank Gupta ti_pushfub_par_sts);
5094926e89dSShashank Gupta }
5104926e89dSShashank Gupta
5114926e89dSShashank Gupta return false;
5124926e89dSShashank Gupta }
5134926e89dSShashank Gupta
adf_handle_ti_cd_par_sts(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)5144926e89dSShashank Gupta static bool adf_handle_ti_cd_par_sts(struct adf_accel_dev *accel_dev,
5154926e89dSShashank Gupta void __iomem *csr, u32 errsou)
5164926e89dSShashank Gupta {
5174926e89dSShashank Gupta u32 ti_cd_par_sts;
5184926e89dSShashank Gupta
5194926e89dSShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU1_TIMEM_PARERR_STS_BIT))
5204926e89dSShashank Gupta return false;
5214926e89dSShashank Gupta
5224926e89dSShashank Gupta ti_cd_par_sts = ADF_CSR_RD(csr, ADF_GEN4_TI_CD_PAR_STS);
5234926e89dSShashank Gupta ti_cd_par_sts &= ADF_GEN4_TI_CD_PAR_STS_BITMASK;
5244926e89dSShashank Gupta
5254926e89dSShashank Gupta if (ti_cd_par_sts) {
5264926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
5274926e89dSShashank Gupta "TI CD Parity Error: 0x%x\n", ti_cd_par_sts);
5284926e89dSShashank Gupta
52999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
53099b1c982SShashank Gupta
5314926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_CD_PAR_STS, ti_cd_par_sts);
5324926e89dSShashank Gupta }
5334926e89dSShashank Gupta
5344926e89dSShashank Gupta return false;
5354926e89dSShashank Gupta }
5364926e89dSShashank Gupta
adf_handle_ti_trnsb_par_sts(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)5374926e89dSShashank Gupta static bool adf_handle_ti_trnsb_par_sts(struct adf_accel_dev *accel_dev,
5384926e89dSShashank Gupta void __iomem *csr, u32 errsou)
5394926e89dSShashank Gupta {
5404926e89dSShashank Gupta u32 ti_trnsb_par_sts;
5414926e89dSShashank Gupta
5424926e89dSShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU1_TIMEM_PARERR_STS_BIT))
5434926e89dSShashank Gupta return false;
5444926e89dSShashank Gupta
5454926e89dSShashank Gupta ti_trnsb_par_sts = ADF_CSR_RD(csr, ADF_GEN4_TI_TRNSB_PAR_STS);
5464926e89dSShashank Gupta ti_trnsb_par_sts &= ADF_GEN4_TI_TRNSB_PAR_STS_BITMASK;
5474926e89dSShashank Gupta
5484926e89dSShashank Gupta if (ti_trnsb_par_sts) {
5494926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
5504926e89dSShashank Gupta "TI TRNSB Parity Error: 0x%x\n", ti_trnsb_par_sts);
5514926e89dSShashank Gupta
55299b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
55399b1c982SShashank Gupta
5544926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TI_TRNSB_PAR_STS, ti_trnsb_par_sts);
5554926e89dSShashank Gupta }
5564926e89dSShashank Gupta
5574926e89dSShashank Gupta return false;
5584926e89dSShashank Gupta }
5594926e89dSShashank Gupta
adf_handle_iosfp_cmd_parerr(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)5604926e89dSShashank Gupta static bool adf_handle_iosfp_cmd_parerr(struct adf_accel_dev *accel_dev,
5614926e89dSShashank Gupta void __iomem *csr, u32 errsou)
5624926e89dSShashank Gupta {
5634926e89dSShashank Gupta u32 rimiscsts;
5644926e89dSShashank Gupta
5654926e89dSShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU1_TIMEM_PARERR_STS_BIT))
5664926e89dSShashank Gupta return false;
5674926e89dSShashank Gupta
5684926e89dSShashank Gupta rimiscsts = ADF_CSR_RD(csr, ADF_GEN4_RIMISCSTS);
5694926e89dSShashank Gupta rimiscsts &= ADF_GEN4_RIMISCSTS_BIT;
5704926e89dSShashank Gupta
5714926e89dSShashank Gupta dev_err(&GET_DEV(accel_dev),
5724926e89dSShashank Gupta "Command Parity error detected on IOSFP: 0x%x\n",
5734926e89dSShashank Gupta rimiscsts);
5744926e89dSShashank Gupta
57599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
57699b1c982SShashank Gupta
5774926e89dSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_RIMISCSTS, rimiscsts);
5784926e89dSShashank Gupta
5794926e89dSShashank Gupta return true;
5804926e89dSShashank Gupta }
5814926e89dSShashank Gupta
adf_gen4_process_errsou1(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou,bool * reset_required)5824926e89dSShashank Gupta static void adf_gen4_process_errsou1(struct adf_accel_dev *accel_dev,
5834926e89dSShashank Gupta void __iomem *csr, u32 errsou,
5844926e89dSShashank Gupta bool *reset_required)
5854926e89dSShashank Gupta {
5864926e89dSShashank Gupta *reset_required |= adf_handle_cpp_aeunc(accel_dev, csr, errsou);
5874926e89dSShashank Gupta *reset_required |= adf_handle_cppcmdparerr(accel_dev, csr, errsou);
5884926e89dSShashank Gupta *reset_required |= adf_handle_ri_mem_par_err(accel_dev, csr, errsou);
5894926e89dSShashank Gupta *reset_required |= adf_handle_ti_ci_par_sts(accel_dev, csr, errsou);
5904926e89dSShashank Gupta *reset_required |= adf_handle_ti_pullfub_par_sts(accel_dev, csr, errsou);
5914926e89dSShashank Gupta *reset_required |= adf_handle_ti_pushfub_par_sts(accel_dev, csr, errsou);
5924926e89dSShashank Gupta *reset_required |= adf_handle_ti_cd_par_sts(accel_dev, csr, errsou);
5934926e89dSShashank Gupta *reset_required |= adf_handle_ti_trnsb_par_sts(accel_dev, csr, errsou);
5944926e89dSShashank Gupta *reset_required |= adf_handle_iosfp_cmd_parerr(accel_dev, csr, errsou);
5954926e89dSShashank Gupta }
5964926e89dSShashank Gupta
adf_handle_uerrssmsh(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 iastatssm)597895f7d53SShashank Gupta static bool adf_handle_uerrssmsh(struct adf_accel_dev *accel_dev,
598895f7d53SShashank Gupta void __iomem *csr, u32 iastatssm)
599895f7d53SShashank Gupta {
600895f7d53SShashank Gupta u32 reg;
601895f7d53SShashank Gupta
602895f7d53SShashank Gupta if (!(iastatssm & ADF_GEN4_IAINTSTATSSM_UERRSSMSH_BIT))
603895f7d53SShashank Gupta return false;
604895f7d53SShashank Gupta
605895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_UERRSSMSH);
606895f7d53SShashank Gupta reg &= ADF_GEN4_UERRSSMSH_BITMASK;
607895f7d53SShashank Gupta
608895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
609895f7d53SShashank Gupta "Uncorrectable error on ssm shared memory: 0x%x\n",
610895f7d53SShashank Gupta reg);
611895f7d53SShashank Gupta
61299b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
61399b1c982SShashank Gupta
614895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_UERRSSMSH, reg);
615895f7d53SShashank Gupta
616895f7d53SShashank Gupta return false;
617895f7d53SShashank Gupta }
618895f7d53SShashank Gupta
adf_handle_cerrssmsh(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 iastatssm)619895f7d53SShashank Gupta static bool adf_handle_cerrssmsh(struct adf_accel_dev *accel_dev,
620895f7d53SShashank Gupta void __iomem *csr, u32 iastatssm)
621895f7d53SShashank Gupta {
622895f7d53SShashank Gupta u32 reg;
623895f7d53SShashank Gupta
624895f7d53SShashank Gupta if (!(iastatssm & ADF_GEN4_IAINTSTATSSM_CERRSSMSH_BIT))
625895f7d53SShashank Gupta return false;
626895f7d53SShashank Gupta
627895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_CERRSSMSH);
628895f7d53SShashank Gupta reg &= ADF_GEN4_CERRSSMSH_ERROR_BIT;
629895f7d53SShashank Gupta
630895f7d53SShashank Gupta dev_warn(&GET_DEV(accel_dev),
631895f7d53SShashank Gupta "Correctable error on ssm shared memory: 0x%x\n",
632895f7d53SShashank Gupta reg);
633895f7d53SShashank Gupta
63499b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_CORR);
63599b1c982SShashank Gupta
636895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_CERRSSMSH, reg);
637895f7d53SShashank Gupta
638895f7d53SShashank Gupta return false;
639895f7d53SShashank Gupta }
640895f7d53SShashank Gupta
adf_handle_pperr_err(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 iastatssm)641895f7d53SShashank Gupta static bool adf_handle_pperr_err(struct adf_accel_dev *accel_dev,
642895f7d53SShashank Gupta void __iomem *csr, u32 iastatssm)
643895f7d53SShashank Gupta {
644895f7d53SShashank Gupta u32 reg;
645895f7d53SShashank Gupta
646895f7d53SShashank Gupta if (!(iastatssm & ADF_GEN4_IAINTSTATSSM_PPERR_BIT))
647895f7d53SShashank Gupta return false;
648895f7d53SShashank Gupta
649895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_PPERR);
650895f7d53SShashank Gupta reg &= ADF_GEN4_PPERR_BITMASK;
651895f7d53SShashank Gupta
652895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
653895f7d53SShashank Gupta "Uncorrectable error CPP transaction on memory target: 0x%x\n",
654895f7d53SShashank Gupta reg);
655895f7d53SShashank Gupta
65699b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
65799b1c982SShashank Gupta
658895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_PPERR, reg);
659895f7d53SShashank Gupta
660895f7d53SShashank Gupta return false;
661895f7d53SShashank Gupta }
662895f7d53SShashank Gupta
adf_poll_slicehang_csr(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 slice_hang_offset,char * slice_name)663895f7d53SShashank Gupta static void adf_poll_slicehang_csr(struct adf_accel_dev *accel_dev,
664895f7d53SShashank Gupta void __iomem *csr, u32 slice_hang_offset,
665895f7d53SShashank Gupta char *slice_name)
666895f7d53SShashank Gupta {
667895f7d53SShashank Gupta u32 slice_hang_reg = ADF_CSR_RD(csr, slice_hang_offset);
668895f7d53SShashank Gupta
669895f7d53SShashank Gupta if (!slice_hang_reg)
670895f7d53SShashank Gupta return;
671895f7d53SShashank Gupta
672895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
673895f7d53SShashank Gupta "Slice %s hang error encountered\n", slice_name);
67499b1c982SShashank Gupta
67599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
676895f7d53SShashank Gupta }
677895f7d53SShashank Gupta
adf_handle_slice_hang_error(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 iastatssm)678895f7d53SShashank Gupta static bool adf_handle_slice_hang_error(struct adf_accel_dev *accel_dev,
679895f7d53SShashank Gupta void __iomem *csr, u32 iastatssm)
680895f7d53SShashank Gupta {
681895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
682895f7d53SShashank Gupta
683895f7d53SShashank Gupta if (!(iastatssm & ADF_GEN4_IAINTSTATSSM_SLICEHANG_ERR_BIT))
684895f7d53SShashank Gupta return false;
685895f7d53SShashank Gupta
686895f7d53SShashank Gupta adf_poll_slicehang_csr(accel_dev, csr,
687895f7d53SShashank Gupta ADF_GEN4_SLICEHANGSTATUS_ATH_CPH, "ath_cph");
688895f7d53SShashank Gupta adf_poll_slicehang_csr(accel_dev, csr,
689895f7d53SShashank Gupta ADF_GEN4_SLICEHANGSTATUS_CPR_XLT, "cpr_xlt");
690895f7d53SShashank Gupta adf_poll_slicehang_csr(accel_dev, csr,
691895f7d53SShashank Gupta ADF_GEN4_SLICEHANGSTATUS_DCPR_UCS, "dcpr_ucs");
692895f7d53SShashank Gupta adf_poll_slicehang_csr(accel_dev, csr,
693895f7d53SShashank Gupta ADF_GEN4_SLICEHANGSTATUS_PKE, "pke");
694895f7d53SShashank Gupta
695895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask)
696895f7d53SShashank Gupta adf_poll_slicehang_csr(accel_dev, csr,
697895f7d53SShashank Gupta ADF_GEN4_SLICEHANGSTATUS_WAT_WCP,
698895f7d53SShashank Gupta "ath_cph");
699895f7d53SShashank Gupta
700895f7d53SShashank Gupta return false;
701895f7d53SShashank Gupta }
702895f7d53SShashank Gupta
adf_handle_spp_pullcmd_err(struct adf_accel_dev * accel_dev,void __iomem * csr)703895f7d53SShashank Gupta static bool adf_handle_spp_pullcmd_err(struct adf_accel_dev *accel_dev,
704895f7d53SShashank Gupta void __iomem *csr)
705895f7d53SShashank Gupta {
706895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
707895f7d53SShashank Gupta bool reset_required = false;
708895f7d53SShashank Gupta u32 reg;
709895f7d53SShashank Gupta
710895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLCMDPARERR_ATH_CPH);
711895f7d53SShashank Gupta reg &= err_mask->parerr_ath_cph_mask;
712895f7d53SShashank Gupta if (reg) {
713895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
714895f7d53SShashank Gupta "SPP pull command fatal error ATH_CPH: 0x%x\n", reg);
715895f7d53SShashank Gupta
71699b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
71799b1c982SShashank Gupta
718895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLCMDPARERR_ATH_CPH, reg);
719895f7d53SShashank Gupta
720895f7d53SShashank Gupta reset_required = true;
721895f7d53SShashank Gupta }
722895f7d53SShashank Gupta
723895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLCMDPARERR_CPR_XLT);
724895f7d53SShashank Gupta reg &= err_mask->parerr_cpr_xlt_mask;
725895f7d53SShashank Gupta if (reg) {
726895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
727895f7d53SShashank Gupta "SPP pull command fatal error CPR_XLT: 0x%x\n", reg);
728895f7d53SShashank Gupta
72999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
73099b1c982SShashank Gupta
731895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLCMDPARERR_CPR_XLT, reg);
732895f7d53SShashank Gupta
733895f7d53SShashank Gupta reset_required = true;
734895f7d53SShashank Gupta }
735895f7d53SShashank Gupta
736895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLCMDPARERR_DCPR_UCS);
737895f7d53SShashank Gupta reg &= err_mask->parerr_dcpr_ucs_mask;
738895f7d53SShashank Gupta if (reg) {
739895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
740895f7d53SShashank Gupta "SPP pull command fatal error DCPR_UCS: 0x%x\n", reg);
741895f7d53SShashank Gupta
74299b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
74399b1c982SShashank Gupta
744895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLCMDPARERR_DCPR_UCS, reg);
745895f7d53SShashank Gupta
746895f7d53SShashank Gupta reset_required = true;
747895f7d53SShashank Gupta }
748895f7d53SShashank Gupta
749895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLCMDPARERR_PKE);
750895f7d53SShashank Gupta reg &= err_mask->parerr_pke_mask;
751895f7d53SShashank Gupta if (reg) {
752895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
753895f7d53SShashank Gupta "SPP pull command fatal error PKE: 0x%x\n", reg);
754895f7d53SShashank Gupta
75599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
75699b1c982SShashank Gupta
757895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLCMDPARERR_PKE, reg);
758895f7d53SShashank Gupta
759895f7d53SShashank Gupta reset_required = true;
760895f7d53SShashank Gupta }
761895f7d53SShashank Gupta
762895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask) {
763895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLCMDPARERR_WAT_WCP);
764895f7d53SShashank Gupta reg &= err_mask->parerr_wat_wcp_mask;
765895f7d53SShashank Gupta if (reg) {
766895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
767895f7d53SShashank Gupta "SPP pull command fatal error WAT_WCP: 0x%x\n", reg);
768895f7d53SShashank Gupta
76999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
77099b1c982SShashank Gupta
771895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLCMDPARERR_WAT_WCP, reg);
772895f7d53SShashank Gupta
773895f7d53SShashank Gupta reset_required = true;
774895f7d53SShashank Gupta }
775895f7d53SShashank Gupta }
776895f7d53SShashank Gupta
777895f7d53SShashank Gupta return reset_required;
778895f7d53SShashank Gupta }
779895f7d53SShashank Gupta
adf_handle_spp_pulldata_err(struct adf_accel_dev * accel_dev,void __iomem * csr)780895f7d53SShashank Gupta static bool adf_handle_spp_pulldata_err(struct adf_accel_dev *accel_dev,
781895f7d53SShashank Gupta void __iomem *csr)
782895f7d53SShashank Gupta {
783895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
784895f7d53SShashank Gupta u32 reg;
785895f7d53SShashank Gupta
786895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLDATAPARERR_ATH_CPH);
787895f7d53SShashank Gupta reg &= err_mask->parerr_ath_cph_mask;
788895f7d53SShashank Gupta if (reg) {
789895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
790895f7d53SShashank Gupta "SPP pull data err ATH_CPH: 0x%x\n", reg);
791895f7d53SShashank Gupta
79299b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
79399b1c982SShashank Gupta
794895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLDATAPARERR_ATH_CPH, reg);
795895f7d53SShashank Gupta }
796895f7d53SShashank Gupta
797895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLDATAPARERR_CPR_XLT);
798895f7d53SShashank Gupta reg &= err_mask->parerr_cpr_xlt_mask;
799895f7d53SShashank Gupta if (reg) {
800895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
801895f7d53SShashank Gupta "SPP pull data err CPR_XLT: 0x%x\n", reg);
802895f7d53SShashank Gupta
80399b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
80499b1c982SShashank Gupta
805895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLDATAPARERR_CPR_XLT, reg);
806895f7d53SShashank Gupta }
807895f7d53SShashank Gupta
808895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLDATAPARERR_DCPR_UCS);
809895f7d53SShashank Gupta reg &= err_mask->parerr_dcpr_ucs_mask;
810895f7d53SShashank Gupta if (reg) {
811895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
812895f7d53SShashank Gupta "SPP pull data err DCPR_UCS: 0x%x\n", reg);
813895f7d53SShashank Gupta
81499b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
81599b1c982SShashank Gupta
816895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLDATAPARERR_DCPR_UCS, reg);
817895f7d53SShashank Gupta }
818895f7d53SShashank Gupta
819895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLDATAPARERR_PKE);
820895f7d53SShashank Gupta reg &= err_mask->parerr_pke_mask;
821895f7d53SShashank Gupta if (reg) {
822895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
823895f7d53SShashank Gupta "SPP pull data err PKE: 0x%x\n", reg);
824895f7d53SShashank Gupta
82599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
82699b1c982SShashank Gupta
827895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLDATAPARERR_PKE, reg);
828895f7d53SShashank Gupta }
829895f7d53SShashank Gupta
830895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask) {
831895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPULLDATAPARERR_WAT_WCP);
832895f7d53SShashank Gupta reg &= err_mask->parerr_wat_wcp_mask;
833895f7d53SShashank Gupta if (reg) {
834895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
835895f7d53SShashank Gupta "SPP pull data err WAT_WCP: 0x%x\n", reg);
836895f7d53SShashank Gupta
83799b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
83899b1c982SShashank Gupta
839895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPULLDATAPARERR_WAT_WCP, reg);
840895f7d53SShashank Gupta }
841895f7d53SShashank Gupta }
842895f7d53SShashank Gupta
843895f7d53SShashank Gupta return false;
844895f7d53SShashank Gupta }
845895f7d53SShashank Gupta
adf_handle_spp_pushcmd_err(struct adf_accel_dev * accel_dev,void __iomem * csr)846895f7d53SShashank Gupta static bool adf_handle_spp_pushcmd_err(struct adf_accel_dev *accel_dev,
847895f7d53SShashank Gupta void __iomem *csr)
848895f7d53SShashank Gupta {
849895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
850895f7d53SShashank Gupta bool reset_required = false;
851895f7d53SShashank Gupta u32 reg;
852895f7d53SShashank Gupta
853895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHCMDPARERR_ATH_CPH);
854895f7d53SShashank Gupta reg &= err_mask->parerr_ath_cph_mask;
855895f7d53SShashank Gupta if (reg) {
856895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
857895f7d53SShashank Gupta "SPP push command fatal error ATH_CPH: 0x%x\n", reg);
858895f7d53SShashank Gupta
85999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
86099b1c982SShashank Gupta
861895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHCMDPARERR_ATH_CPH, reg);
862895f7d53SShashank Gupta
863895f7d53SShashank Gupta reset_required = true;
864895f7d53SShashank Gupta }
865895f7d53SShashank Gupta
866895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHCMDPARERR_CPR_XLT);
867895f7d53SShashank Gupta reg &= err_mask->parerr_cpr_xlt_mask;
868895f7d53SShashank Gupta if (reg) {
869895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
870895f7d53SShashank Gupta "SPP push command fatal error CPR_XLT: 0x%x\n", reg);
871895f7d53SShashank Gupta
87299b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
87399b1c982SShashank Gupta
874895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHCMDPARERR_CPR_XLT, reg);
875895f7d53SShashank Gupta
876895f7d53SShashank Gupta reset_required = true;
877895f7d53SShashank Gupta }
878895f7d53SShashank Gupta
879895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHCMDPARERR_DCPR_UCS);
880895f7d53SShashank Gupta reg &= err_mask->parerr_dcpr_ucs_mask;
881895f7d53SShashank Gupta if (reg) {
882895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
883895f7d53SShashank Gupta "SPP push command fatal error DCPR_UCS: 0x%x\n", reg);
884895f7d53SShashank Gupta
88599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
88699b1c982SShashank Gupta
887895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHCMDPARERR_DCPR_UCS, reg);
888895f7d53SShashank Gupta
889895f7d53SShashank Gupta reset_required = true;
890895f7d53SShashank Gupta }
891895f7d53SShashank Gupta
892895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHCMDPARERR_PKE);
893895f7d53SShashank Gupta reg &= err_mask->parerr_pke_mask;
894895f7d53SShashank Gupta if (reg) {
895895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
896895f7d53SShashank Gupta "SPP push command fatal error PKE: 0x%x\n",
897895f7d53SShashank Gupta reg);
898895f7d53SShashank Gupta
89999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
90099b1c982SShashank Gupta
901895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHCMDPARERR_PKE, reg);
902895f7d53SShashank Gupta
903895f7d53SShashank Gupta reset_required = true;
904895f7d53SShashank Gupta }
905895f7d53SShashank Gupta
906895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask) {
907895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHCMDPARERR_WAT_WCP);
908895f7d53SShashank Gupta reg &= err_mask->parerr_wat_wcp_mask;
909895f7d53SShashank Gupta if (reg) {
910895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
911895f7d53SShashank Gupta "SPP push command fatal error WAT_WCP: 0x%x\n", reg);
912895f7d53SShashank Gupta
91399b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
91499b1c982SShashank Gupta
915895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHCMDPARERR_WAT_WCP, reg);
916895f7d53SShashank Gupta
917895f7d53SShashank Gupta reset_required = true;
918895f7d53SShashank Gupta }
919895f7d53SShashank Gupta }
920895f7d53SShashank Gupta
921895f7d53SShashank Gupta return reset_required;
922895f7d53SShashank Gupta }
923895f7d53SShashank Gupta
adf_handle_spp_pushdata_err(struct adf_accel_dev * accel_dev,void __iomem * csr)924895f7d53SShashank Gupta static bool adf_handle_spp_pushdata_err(struct adf_accel_dev *accel_dev,
925895f7d53SShashank Gupta void __iomem *csr)
926895f7d53SShashank Gupta {
927895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
928895f7d53SShashank Gupta u32 reg;
929895f7d53SShashank Gupta
930895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHDATAPARERR_ATH_CPH);
931895f7d53SShashank Gupta reg &= err_mask->parerr_ath_cph_mask;
932895f7d53SShashank Gupta if (reg) {
933895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
934895f7d53SShashank Gupta "SPP push data err ATH_CPH: 0x%x\n", reg);
935895f7d53SShashank Gupta
93699b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
93799b1c982SShashank Gupta
938895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHDATAPARERR_ATH_CPH, reg);
939895f7d53SShashank Gupta }
940895f7d53SShashank Gupta
941895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHDATAPARERR_CPR_XLT);
942895f7d53SShashank Gupta reg &= err_mask->parerr_cpr_xlt_mask;
943895f7d53SShashank Gupta if (reg) {
944895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
945895f7d53SShashank Gupta "SPP push data err CPR_XLT: 0x%x\n", reg);
946895f7d53SShashank Gupta
94799b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
94899b1c982SShashank Gupta
949895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHDATAPARERR_CPR_XLT, reg);
950895f7d53SShashank Gupta }
951895f7d53SShashank Gupta
952895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHDATAPARERR_DCPR_UCS);
953895f7d53SShashank Gupta reg &= err_mask->parerr_dcpr_ucs_mask;
954895f7d53SShashank Gupta if (reg) {
955895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
956895f7d53SShashank Gupta "SPP push data err DCPR_UCS: 0x%x\n", reg);
957895f7d53SShashank Gupta
95899b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
95999b1c982SShashank Gupta
960895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHDATAPARERR_DCPR_UCS, reg);
961895f7d53SShashank Gupta }
962895f7d53SShashank Gupta
963895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHDATAPARERR_PKE);
964895f7d53SShashank Gupta reg &= err_mask->parerr_pke_mask;
965895f7d53SShashank Gupta if (reg) {
966895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
967895f7d53SShashank Gupta "SPP push data err PKE: 0x%x\n", reg);
968895f7d53SShashank Gupta
96999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
97099b1c982SShashank Gupta
971895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHDATAPARERR_PKE, reg);
972895f7d53SShashank Gupta }
973895f7d53SShashank Gupta
974895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask) {
975895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SPPPUSHDATAPARERR_WAT_WCP);
976895f7d53SShashank Gupta reg &= err_mask->parerr_wat_wcp_mask;
977895f7d53SShashank Gupta if (reg) {
978895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
979895f7d53SShashank Gupta "SPP push data err WAT_WCP: 0x%x\n", reg);
980895f7d53SShashank Gupta
98199b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
98299b1c982SShashank Gupta
983895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SPPPUSHDATAPARERR_WAT_WCP,
984895f7d53SShashank Gupta reg);
985895f7d53SShashank Gupta }
986895f7d53SShashank Gupta }
987895f7d53SShashank Gupta
988895f7d53SShashank Gupta return false;
989895f7d53SShashank Gupta }
990895f7d53SShashank Gupta
adf_handle_spppar_err(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 iastatssm)991895f7d53SShashank Gupta static bool adf_handle_spppar_err(struct adf_accel_dev *accel_dev,
992895f7d53SShashank Gupta void __iomem *csr, u32 iastatssm)
993895f7d53SShashank Gupta {
994895f7d53SShashank Gupta bool reset_required;
995895f7d53SShashank Gupta
996895f7d53SShashank Gupta if (!(iastatssm & ADF_GEN4_IAINTSTATSSM_SPPPARERR_BIT))
997895f7d53SShashank Gupta return false;
998895f7d53SShashank Gupta
999895f7d53SShashank Gupta reset_required = adf_handle_spp_pullcmd_err(accel_dev, csr);
1000895f7d53SShashank Gupta reset_required |= adf_handle_spp_pulldata_err(accel_dev, csr);
1001895f7d53SShashank Gupta reset_required |= adf_handle_spp_pushcmd_err(accel_dev, csr);
1002895f7d53SShashank Gupta reset_required |= adf_handle_spp_pushdata_err(accel_dev, csr);
1003895f7d53SShashank Gupta
1004895f7d53SShashank Gupta return reset_required;
1005895f7d53SShashank Gupta }
1006895f7d53SShashank Gupta
adf_handle_ssmcpppar_err(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 iastatssm)1007895f7d53SShashank Gupta static bool adf_handle_ssmcpppar_err(struct adf_accel_dev *accel_dev,
1008895f7d53SShashank Gupta void __iomem *csr, u32 iastatssm)
1009895f7d53SShashank Gupta {
1010*a66cf93aSAdam Guerin u32 reg, bits_num = BITS_PER_REG(reg);
1011895f7d53SShashank Gupta bool reset_required = false;
101299b1c982SShashank Gupta unsigned long errs_bits;
101399b1c982SShashank Gupta u32 bit_iterator;
1014895f7d53SShashank Gupta
1015895f7d53SShashank Gupta if (!(iastatssm & ADF_GEN4_IAINTSTATSSM_SSMCPPERR_BIT))
1016895f7d53SShashank Gupta return false;
1017895f7d53SShashank Gupta
1018895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SSMCPPERR);
1019895f7d53SShashank Gupta reg &= ADF_GEN4_SSMCPPERR_FATAL_BITMASK | ADF_GEN4_SSMCPPERR_UNCERR_BITMASK;
1020895f7d53SShashank Gupta if (reg & ADF_GEN4_SSMCPPERR_FATAL_BITMASK) {
1021895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
1022895f7d53SShashank Gupta "Fatal SSM CPP parity error: 0x%x\n", reg);
1023895f7d53SShashank Gupta
102499b1c982SShashank Gupta errs_bits = reg & ADF_GEN4_SSMCPPERR_FATAL_BITMASK;
102599b1c982SShashank Gupta for_each_set_bit(bit_iterator, &errs_bits, bits_num) {
102699b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
102799b1c982SShashank Gupta }
1028895f7d53SShashank Gupta reset_required = true;
1029895f7d53SShashank Gupta }
1030895f7d53SShashank Gupta
103199b1c982SShashank Gupta if (reg & ADF_GEN4_SSMCPPERR_UNCERR_BITMASK) {
1032895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
1033895f7d53SShashank Gupta "non-Fatal SSM CPP parity error: 0x%x\n", reg);
103499b1c982SShashank Gupta errs_bits = reg & ADF_GEN4_SSMCPPERR_UNCERR_BITMASK;
103599b1c982SShashank Gupta
103699b1c982SShashank Gupta for_each_set_bit(bit_iterator, &errs_bits, bits_num) {
103799b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
103899b1c982SShashank Gupta }
103999b1c982SShashank Gupta }
1040895f7d53SShashank Gupta
1041895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMCPPERR, reg);
1042895f7d53SShashank Gupta
1043895f7d53SShashank Gupta return reset_required;
1044895f7d53SShashank Gupta }
1045895f7d53SShashank Gupta
adf_handle_rf_parr_err(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 iastatssm)1046895f7d53SShashank Gupta static bool adf_handle_rf_parr_err(struct adf_accel_dev *accel_dev,
1047895f7d53SShashank Gupta void __iomem *csr, u32 iastatssm)
1048895f7d53SShashank Gupta {
1049895f7d53SShashank Gupta struct adf_dev_err_mask *err_mask = GET_ERR_MASK(accel_dev);
1050895f7d53SShashank Gupta u32 reg;
1051895f7d53SShashank Gupta
1052895f7d53SShashank Gupta if (!(iastatssm & ADF_GEN4_IAINTSTATSSM_SSMSOFTERRORPARITY_BIT))
1053895f7d53SShashank Gupta return false;
1054895f7d53SShashank Gupta
1055895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SSMSOFTERRORPARITY_SRC);
1056895f7d53SShashank Gupta reg &= ADF_GEN4_SSMSOFTERRORPARITY_SRC_BIT;
105799b1c982SShashank Gupta if (reg) {
105899b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
1059895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITY_SRC, reg);
106099b1c982SShashank Gupta }
1061895f7d53SShashank Gupta
1062895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SSMSOFTERRORPARITY_ATH_CPH);
1063895f7d53SShashank Gupta reg &= err_mask->parerr_ath_cph_mask;
106499b1c982SShashank Gupta if (reg) {
106599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
1066895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITY_ATH_CPH, reg);
106799b1c982SShashank Gupta }
1068895f7d53SShashank Gupta
1069895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SSMSOFTERRORPARITY_CPR_XLT);
1070895f7d53SShashank Gupta reg &= err_mask->parerr_cpr_xlt_mask;
107199b1c982SShashank Gupta if (reg) {
107299b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
1073895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITY_CPR_XLT, reg);
107499b1c982SShashank Gupta }
1075895f7d53SShashank Gupta
1076895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SSMSOFTERRORPARITY_DCPR_UCS);
1077895f7d53SShashank Gupta reg &= err_mask->parerr_dcpr_ucs_mask;
107899b1c982SShashank Gupta if (reg) {
107999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
1080895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITY_DCPR_UCS, reg);
108199b1c982SShashank Gupta }
1082895f7d53SShashank Gupta
1083895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SSMSOFTERRORPARITY_PKE);
1084895f7d53SShashank Gupta reg &= err_mask->parerr_pke_mask;
108599b1c982SShashank Gupta if (reg) {
108699b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
1087895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITY_PKE, reg);
108899b1c982SShashank Gupta }
1089895f7d53SShashank Gupta
1090895f7d53SShashank Gupta if (err_mask->parerr_wat_wcp_mask) {
1091895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SSMSOFTERRORPARITY_WAT_WCP);
1092895f7d53SShashank Gupta reg &= err_mask->parerr_wat_wcp_mask;
109399b1c982SShashank Gupta if (reg) {
109499b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
1095895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SSMSOFTERRORPARITY_WAT_WCP,
1096895f7d53SShashank Gupta reg);
1097895f7d53SShashank Gupta }
109899b1c982SShashank Gupta }
1099895f7d53SShashank Gupta
1100895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev), "Slice ssm soft parity error reported");
1101895f7d53SShashank Gupta
1102895f7d53SShashank Gupta return false;
1103895f7d53SShashank Gupta }
1104895f7d53SShashank Gupta
adf_handle_ser_err_ssmsh(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 iastatssm)1105895f7d53SShashank Gupta static bool adf_handle_ser_err_ssmsh(struct adf_accel_dev *accel_dev,
1106895f7d53SShashank Gupta void __iomem *csr, u32 iastatssm)
1107895f7d53SShashank Gupta {
1108*a66cf93aSAdam Guerin u32 reg, bits_num = BITS_PER_REG(reg);
1109895f7d53SShashank Gupta bool reset_required = false;
111099b1c982SShashank Gupta unsigned long errs_bits;
111199b1c982SShashank Gupta u32 bit_iterator;
1112895f7d53SShashank Gupta
1113895f7d53SShashank Gupta if (!(iastatssm & (ADF_GEN4_IAINTSTATSSM_SER_ERR_SSMSH_CERR_BIT |
1114895f7d53SShashank Gupta ADF_GEN4_IAINTSTATSSM_SER_ERR_SSMSH_UNCERR_BIT)))
1115895f7d53SShashank Gupta return false;
1116895f7d53SShashank Gupta
1117895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_SER_ERR_SSMSH);
1118895f7d53SShashank Gupta reg &= ADF_GEN4_SER_ERR_SSMSH_FATAL_BITMASK |
1119895f7d53SShashank Gupta ADF_GEN4_SER_ERR_SSMSH_UNCERR_BITMASK |
1120895f7d53SShashank Gupta ADF_GEN4_SER_ERR_SSMSH_CERR_BITMASK;
1121895f7d53SShashank Gupta if (reg & ADF_GEN4_SER_ERR_SSMSH_FATAL_BITMASK) {
1122895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
1123895f7d53SShashank Gupta "Fatal SER_SSMSH_ERR: 0x%x\n", reg);
1124895f7d53SShashank Gupta
112599b1c982SShashank Gupta errs_bits = reg & ADF_GEN4_SER_ERR_SSMSH_FATAL_BITMASK;
112699b1c982SShashank Gupta for_each_set_bit(bit_iterator, &errs_bits, bits_num) {
112799b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
112899b1c982SShashank Gupta }
112999b1c982SShashank Gupta
1130895f7d53SShashank Gupta reset_required = true;
1131895f7d53SShashank Gupta }
1132895f7d53SShashank Gupta
113399b1c982SShashank Gupta if (reg & ADF_GEN4_SER_ERR_SSMSH_UNCERR_BITMASK) {
1134895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
1135895f7d53SShashank Gupta "non-fatal SER_SSMSH_ERR: 0x%x\n", reg);
1136895f7d53SShashank Gupta
113799b1c982SShashank Gupta errs_bits = reg & ADF_GEN4_SER_ERR_SSMSH_UNCERR_BITMASK;
113899b1c982SShashank Gupta for_each_set_bit(bit_iterator, &errs_bits, bits_num) {
113999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
114099b1c982SShashank Gupta }
114199b1c982SShashank Gupta }
114299b1c982SShashank Gupta
114399b1c982SShashank Gupta if (reg & ADF_GEN4_SER_ERR_SSMSH_CERR_BITMASK) {
1144895f7d53SShashank Gupta dev_warn(&GET_DEV(accel_dev),
1145895f7d53SShashank Gupta "Correctable SER_SSMSH_ERR: 0x%x\n", reg);
1146895f7d53SShashank Gupta
114799b1c982SShashank Gupta errs_bits = reg & ADF_GEN4_SER_ERR_SSMSH_CERR_BITMASK;
114899b1c982SShashank Gupta for_each_set_bit(bit_iterator, &errs_bits, bits_num) {
114999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_CORR);
115099b1c982SShashank Gupta }
115199b1c982SShashank Gupta }
115299b1c982SShashank Gupta
1153895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_SER_ERR_SSMSH, reg);
1154895f7d53SShashank Gupta
1155895f7d53SShashank Gupta return reset_required;
1156895f7d53SShashank Gupta }
1157895f7d53SShashank Gupta
adf_handle_iaintstatssm(struct adf_accel_dev * accel_dev,void __iomem * csr)1158895f7d53SShashank Gupta static bool adf_handle_iaintstatssm(struct adf_accel_dev *accel_dev,
1159895f7d53SShashank Gupta void __iomem *csr)
1160895f7d53SShashank Gupta {
1161895f7d53SShashank Gupta u32 iastatssm = ADF_CSR_RD(csr, ADF_GEN4_IAINTSTATSSM);
1162895f7d53SShashank Gupta bool reset_required;
1163895f7d53SShashank Gupta
1164895f7d53SShashank Gupta iastatssm &= ADF_GEN4_IAINTSTATSSM_BITMASK;
1165895f7d53SShashank Gupta if (!iastatssm)
1166895f7d53SShashank Gupta return false;
1167895f7d53SShashank Gupta
1168895f7d53SShashank Gupta reset_required = adf_handle_uerrssmsh(accel_dev, csr, iastatssm);
1169895f7d53SShashank Gupta reset_required |= adf_handle_cerrssmsh(accel_dev, csr, iastatssm);
1170895f7d53SShashank Gupta reset_required |= adf_handle_pperr_err(accel_dev, csr, iastatssm);
1171895f7d53SShashank Gupta reset_required |= adf_handle_slice_hang_error(accel_dev, csr, iastatssm);
1172895f7d53SShashank Gupta reset_required |= adf_handle_spppar_err(accel_dev, csr, iastatssm);
1173895f7d53SShashank Gupta reset_required |= adf_handle_ssmcpppar_err(accel_dev, csr, iastatssm);
1174895f7d53SShashank Gupta reset_required |= adf_handle_rf_parr_err(accel_dev, csr, iastatssm);
1175895f7d53SShashank Gupta reset_required |= adf_handle_ser_err_ssmsh(accel_dev, csr, iastatssm);
1176895f7d53SShashank Gupta
1177895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_IAINTSTATSSM, iastatssm);
1178895f7d53SShashank Gupta
1179895f7d53SShashank Gupta return reset_required;
1180895f7d53SShashank Gupta }
1181895f7d53SShashank Gupta
adf_handle_exprpssmcmpr(struct adf_accel_dev * accel_dev,void __iomem * csr)1182b67bf7baSShashank Gupta static bool adf_handle_exprpssmcmpr(struct adf_accel_dev *accel_dev,
1183b67bf7baSShashank Gupta void __iomem *csr)
1184b67bf7baSShashank Gupta {
1185b67bf7baSShashank Gupta u32 reg = ADF_CSR_RD(csr, ADF_GEN4_EXPRPSSMCPR);
1186b67bf7baSShashank Gupta
1187b67bf7baSShashank Gupta reg &= ADF_GEN4_EXPRPSSMCPR_UNCERR_BITMASK;
1188b67bf7baSShashank Gupta if (!reg)
1189b67bf7baSShashank Gupta return false;
1190b67bf7baSShashank Gupta
1191b67bf7baSShashank Gupta dev_err(&GET_DEV(accel_dev),
1192b67bf7baSShashank Gupta "Uncorrectable error exception in SSM CMP: 0x%x", reg);
1193b67bf7baSShashank Gupta
119499b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
119599b1c982SShashank Gupta
1196b67bf7baSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_EXPRPSSMCPR, reg);
1197b67bf7baSShashank Gupta
1198b67bf7baSShashank Gupta return false;
1199b67bf7baSShashank Gupta }
1200b67bf7baSShashank Gupta
adf_handle_exprpssmxlt(struct adf_accel_dev * accel_dev,void __iomem * csr)1201b67bf7baSShashank Gupta static bool adf_handle_exprpssmxlt(struct adf_accel_dev *accel_dev,
1202b67bf7baSShashank Gupta void __iomem *csr)
1203b67bf7baSShashank Gupta {
1204b67bf7baSShashank Gupta u32 reg = ADF_CSR_RD(csr, ADF_GEN4_EXPRPSSMXLT);
1205b67bf7baSShashank Gupta
1206b67bf7baSShashank Gupta reg &= ADF_GEN4_EXPRPSSMXLT_UNCERR_BITMASK |
1207b67bf7baSShashank Gupta ADF_GEN4_EXPRPSSMXLT_CERR_BIT;
1208b67bf7baSShashank Gupta if (!reg)
1209b67bf7baSShashank Gupta return false;
1210b67bf7baSShashank Gupta
121199b1c982SShashank Gupta if (reg & ADF_GEN4_EXPRPSSMXLT_UNCERR_BITMASK) {
1212b67bf7baSShashank Gupta dev_err(&GET_DEV(accel_dev),
1213b67bf7baSShashank Gupta "Uncorrectable error exception in SSM XLT: 0x%x", reg);
1214b67bf7baSShashank Gupta
121599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
121699b1c982SShashank Gupta }
121799b1c982SShashank Gupta
121899b1c982SShashank Gupta if (reg & ADF_GEN4_EXPRPSSMXLT_CERR_BIT) {
1219b67bf7baSShashank Gupta dev_warn(&GET_DEV(accel_dev),
1220b67bf7baSShashank Gupta "Correctable error exception in SSM XLT: 0x%x", reg);
1221b67bf7baSShashank Gupta
122299b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_CORR);
122399b1c982SShashank Gupta }
122499b1c982SShashank Gupta
1225b67bf7baSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_EXPRPSSMXLT, reg);
1226b67bf7baSShashank Gupta
1227b67bf7baSShashank Gupta return false;
1228b67bf7baSShashank Gupta }
1229b67bf7baSShashank Gupta
adf_handle_exprpssmdcpr(struct adf_accel_dev * accel_dev,void __iomem * csr)1230b67bf7baSShashank Gupta static bool adf_handle_exprpssmdcpr(struct adf_accel_dev *accel_dev,
1231b67bf7baSShashank Gupta void __iomem *csr)
1232b67bf7baSShashank Gupta {
1233b67bf7baSShashank Gupta u32 reg;
1234b67bf7baSShashank Gupta int i;
1235b67bf7baSShashank Gupta
1236b67bf7baSShashank Gupta for (i = 0; i < ADF_GEN4_DCPR_SLICES_NUM; i++) {
1237b67bf7baSShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_EXPRPSSMDCPR(i));
1238b67bf7baSShashank Gupta reg &= ADF_GEN4_EXPRPSSMDCPR_UNCERR_BITMASK |
1239b67bf7baSShashank Gupta ADF_GEN4_EXPRPSSMDCPR_CERR_BITMASK;
1240b67bf7baSShashank Gupta if (!reg)
1241b67bf7baSShashank Gupta continue;
1242b67bf7baSShashank Gupta
124399b1c982SShashank Gupta if (reg & ADF_GEN4_EXPRPSSMDCPR_UNCERR_BITMASK) {
1244b67bf7baSShashank Gupta dev_err(&GET_DEV(accel_dev),
1245b67bf7baSShashank Gupta "Uncorrectable error exception in SSM DCMP: 0x%x", reg);
1246b67bf7baSShashank Gupta
124799b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
124899b1c982SShashank Gupta }
124999b1c982SShashank Gupta
125099b1c982SShashank Gupta if (reg & ADF_GEN4_EXPRPSSMDCPR_CERR_BITMASK) {
1251b67bf7baSShashank Gupta dev_warn(&GET_DEV(accel_dev),
1252b67bf7baSShashank Gupta "Correctable error exception in SSM DCMP: 0x%x", reg);
1253b67bf7baSShashank Gupta
125499b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_CORR);
125599b1c982SShashank Gupta }
125699b1c982SShashank Gupta
1257b67bf7baSShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_EXPRPSSMDCPR(i), reg);
1258b67bf7baSShashank Gupta }
1259b67bf7baSShashank Gupta
1260b67bf7baSShashank Gupta return false;
1261b67bf7baSShashank Gupta }
1262b67bf7baSShashank Gupta
adf_handle_ssm(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)1263895f7d53SShashank Gupta static bool adf_handle_ssm(struct adf_accel_dev *accel_dev, void __iomem *csr,
1264895f7d53SShashank Gupta u32 errsou)
1265895f7d53SShashank Gupta {
1266b67bf7baSShashank Gupta bool reset_required;
1267b67bf7baSShashank Gupta
1268895f7d53SShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU2_SSM_ERR_BIT))
1269895f7d53SShashank Gupta return false;
1270895f7d53SShashank Gupta
1271b67bf7baSShashank Gupta reset_required = adf_handle_iaintstatssm(accel_dev, csr);
1272b67bf7baSShashank Gupta reset_required |= adf_handle_exprpssmcmpr(accel_dev, csr);
1273b67bf7baSShashank Gupta reset_required |= adf_handle_exprpssmxlt(accel_dev, csr);
1274b67bf7baSShashank Gupta reset_required |= adf_handle_exprpssmdcpr(accel_dev, csr);
1275b67bf7baSShashank Gupta
1276b67bf7baSShashank Gupta return reset_required;
1277895f7d53SShashank Gupta }
1278895f7d53SShashank Gupta
adf_handle_cpp_cfc_err(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)1279895f7d53SShashank Gupta static bool adf_handle_cpp_cfc_err(struct adf_accel_dev *accel_dev,
1280895f7d53SShashank Gupta void __iomem *csr, u32 errsou)
1281895f7d53SShashank Gupta {
1282895f7d53SShashank Gupta bool reset_required = false;
1283895f7d53SShashank Gupta u32 reg;
1284895f7d53SShashank Gupta
1285895f7d53SShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU2_CPP_CFC_ERR_STATUS_BIT))
1286895f7d53SShashank Gupta return false;
1287895f7d53SShashank Gupta
1288895f7d53SShashank Gupta reg = ADF_CSR_RD(csr, ADF_GEN4_CPP_CFC_ERR_STATUS);
1289895f7d53SShashank Gupta if (reg & ADF_GEN4_CPP_CFC_ERR_STATUS_DATAPAR_BIT) {
1290895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
1291895f7d53SShashank Gupta "CPP_CFC_ERR: data parity: 0x%x", reg);
129299b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
1293895f7d53SShashank Gupta }
1294895f7d53SShashank Gupta
1295895f7d53SShashank Gupta if (reg & ADF_GEN4_CPP_CFC_ERR_STATUS_CMDPAR_BIT) {
1296895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
1297895f7d53SShashank Gupta "CPP_CFC_ERR: command parity: 0x%x", reg);
129899b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
1299895f7d53SShashank Gupta
1300895f7d53SShashank Gupta reset_required = true;
1301895f7d53SShashank Gupta }
1302895f7d53SShashank Gupta
1303895f7d53SShashank Gupta if (reg & ADF_GEN4_CPP_CFC_ERR_STATUS_MERR_BIT) {
1304895f7d53SShashank Gupta dev_err(&GET_DEV(accel_dev),
1305895f7d53SShashank Gupta "CPP_CFC_ERR: multiple errors: 0x%x", reg);
130699b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
1307895f7d53SShashank Gupta
1308895f7d53SShashank Gupta reset_required = true;
1309895f7d53SShashank Gupta }
1310895f7d53SShashank Gupta
1311895f7d53SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_CPP_CFC_ERR_STATUS_CLR,
1312895f7d53SShashank Gupta ADF_GEN4_CPP_CFC_ERR_STATUS_CLR_BITMASK);
1313895f7d53SShashank Gupta
1314895f7d53SShashank Gupta return reset_required;
1315895f7d53SShashank Gupta }
1316895f7d53SShashank Gupta
adf_gen4_process_errsou2(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou,bool * reset_required)1317895f7d53SShashank Gupta static void adf_gen4_process_errsou2(struct adf_accel_dev *accel_dev,
1318895f7d53SShashank Gupta void __iomem *csr, u32 errsou,
1319895f7d53SShashank Gupta bool *reset_required)
1320895f7d53SShashank Gupta {
1321895f7d53SShashank Gupta *reset_required |= adf_handle_ssm(accel_dev, csr, errsou);
1322895f7d53SShashank Gupta *reset_required |= adf_handle_cpp_cfc_err(accel_dev, csr, errsou);
1323895f7d53SShashank Gupta }
1324895f7d53SShashank Gupta
adf_handle_timiscsts(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)132522289dc9SShashank Gupta static bool adf_handle_timiscsts(struct adf_accel_dev *accel_dev,
132622289dc9SShashank Gupta void __iomem *csr, u32 errsou)
132722289dc9SShashank Gupta {
132822289dc9SShashank Gupta u32 timiscsts;
132922289dc9SShashank Gupta
133022289dc9SShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU3_TIMISCSTS_BIT))
133122289dc9SShashank Gupta return false;
133222289dc9SShashank Gupta
133322289dc9SShashank Gupta timiscsts = ADF_CSR_RD(csr, ADF_GEN4_TIMISCSTS);
133422289dc9SShashank Gupta
133522289dc9SShashank Gupta dev_err(&GET_DEV(accel_dev),
133622289dc9SShashank Gupta "Fatal error in Transmit Interface: 0x%x\n", timiscsts);
133722289dc9SShashank Gupta
133899b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
133999b1c982SShashank Gupta
134022289dc9SShashank Gupta return true;
134122289dc9SShashank Gupta }
134222289dc9SShashank Gupta
adf_handle_ricppintsts(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)134322289dc9SShashank Gupta static bool adf_handle_ricppintsts(struct adf_accel_dev *accel_dev,
134422289dc9SShashank Gupta void __iomem *csr, u32 errsou)
134522289dc9SShashank Gupta {
134622289dc9SShashank Gupta u32 ricppintsts;
134722289dc9SShashank Gupta
134822289dc9SShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU3_RICPPINTSTS_BITMASK))
134922289dc9SShashank Gupta return false;
135022289dc9SShashank Gupta
135122289dc9SShashank Gupta ricppintsts = ADF_CSR_RD(csr, ADF_GEN4_RICPPINTSTS);
135222289dc9SShashank Gupta ricppintsts &= ADF_GEN4_RICPPINTSTS_BITMASK;
135322289dc9SShashank Gupta
135422289dc9SShashank Gupta dev_err(&GET_DEV(accel_dev),
135522289dc9SShashank Gupta "RI CPP Uncorrectable Error: 0x%x\n", ricppintsts);
135622289dc9SShashank Gupta
135799b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
135899b1c982SShashank Gupta
135922289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_RICPPINTSTS, ricppintsts);
136022289dc9SShashank Gupta
136122289dc9SShashank Gupta return false;
136222289dc9SShashank Gupta }
136322289dc9SShashank Gupta
adf_handle_ticppintsts(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)136422289dc9SShashank Gupta static bool adf_handle_ticppintsts(struct adf_accel_dev *accel_dev,
136522289dc9SShashank Gupta void __iomem *csr, u32 errsou)
136622289dc9SShashank Gupta {
136722289dc9SShashank Gupta u32 ticppintsts;
136822289dc9SShashank Gupta
136922289dc9SShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU3_TICPPINTSTS_BITMASK))
137022289dc9SShashank Gupta return false;
137122289dc9SShashank Gupta
137222289dc9SShashank Gupta ticppintsts = ADF_CSR_RD(csr, ADF_GEN4_TICPPINTSTS);
137322289dc9SShashank Gupta ticppintsts &= ADF_GEN4_TICPPINTSTS_BITMASK;
137422289dc9SShashank Gupta
137522289dc9SShashank Gupta dev_err(&GET_DEV(accel_dev),
137622289dc9SShashank Gupta "TI CPP Uncorrectable Error: 0x%x\n", ticppintsts);
137722289dc9SShashank Gupta
137899b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
137999b1c982SShashank Gupta
138022289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_TICPPINTSTS, ticppintsts);
138122289dc9SShashank Gupta
138222289dc9SShashank Gupta return false;
138322289dc9SShashank Gupta }
138422289dc9SShashank Gupta
adf_handle_aramcerr(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)138522289dc9SShashank Gupta static bool adf_handle_aramcerr(struct adf_accel_dev *accel_dev,
138622289dc9SShashank Gupta void __iomem *csr, u32 errsou)
138722289dc9SShashank Gupta {
138822289dc9SShashank Gupta u32 aram_cerr;
138922289dc9SShashank Gupta
139022289dc9SShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU3_REG_ARAMCERR_BIT))
139122289dc9SShashank Gupta return false;
139222289dc9SShashank Gupta
139322289dc9SShashank Gupta aram_cerr = ADF_CSR_RD(csr, ADF_GEN4_REG_ARAMCERR);
139422289dc9SShashank Gupta aram_cerr &= ADF_GEN4_REG_ARAMCERR_BIT;
139522289dc9SShashank Gupta
139622289dc9SShashank Gupta dev_warn(&GET_DEV(accel_dev),
139722289dc9SShashank Gupta "ARAM correctable error : 0x%x\n", aram_cerr);
139822289dc9SShashank Gupta
139999b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_CORR);
140099b1c982SShashank Gupta
140122289dc9SShashank Gupta aram_cerr |= ADF_GEN4_REG_ARAMCERR_EN_BITMASK;
140222289dc9SShashank Gupta
140322289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_ARAMCERR, aram_cerr);
140422289dc9SShashank Gupta
140522289dc9SShashank Gupta return false;
140622289dc9SShashank Gupta }
140722289dc9SShashank Gupta
adf_handle_aramuerr(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)140822289dc9SShashank Gupta static bool adf_handle_aramuerr(struct adf_accel_dev *accel_dev,
140922289dc9SShashank Gupta void __iomem *csr, u32 errsou)
141022289dc9SShashank Gupta {
141122289dc9SShashank Gupta bool reset_required = false;
141222289dc9SShashank Gupta u32 aramuerr;
141322289dc9SShashank Gupta
141422289dc9SShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU3_REG_ARAMUERR_BIT))
141522289dc9SShashank Gupta return false;
141622289dc9SShashank Gupta
141722289dc9SShashank Gupta aramuerr = ADF_CSR_RD(csr, ADF_GEN4_REG_ARAMUERR);
141822289dc9SShashank Gupta aramuerr &= ADF_GEN4_REG_ARAMUERR_ERROR_BIT |
141922289dc9SShashank Gupta ADF_GEN4_REG_ARAMUERR_MULTI_ERRORS_BIT;
142022289dc9SShashank Gupta
142122289dc9SShashank Gupta if (!aramuerr)
142222289dc9SShashank Gupta return false;
142322289dc9SShashank Gupta
142422289dc9SShashank Gupta if (aramuerr & ADF_GEN4_REG_ARAMUERR_MULTI_ERRORS_BIT) {
142522289dc9SShashank Gupta dev_err(&GET_DEV(accel_dev),
142622289dc9SShashank Gupta "ARAM multiple uncorrectable errors: 0x%x\n", aramuerr);
142722289dc9SShashank Gupta
142899b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
142999b1c982SShashank Gupta
143022289dc9SShashank Gupta reset_required = true;
143122289dc9SShashank Gupta } else {
143222289dc9SShashank Gupta dev_err(&GET_DEV(accel_dev),
143322289dc9SShashank Gupta "ARAM uncorrectable error: 0x%x\n", aramuerr);
143499b1c982SShashank Gupta
143599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
143622289dc9SShashank Gupta }
143722289dc9SShashank Gupta
143822289dc9SShashank Gupta aramuerr |= ADF_GEN4_REG_ARAMUERR_EN_BITMASK;
143922289dc9SShashank Gupta
144022289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_ARAMUERR, aramuerr);
144122289dc9SShashank Gupta
144222289dc9SShashank Gupta return reset_required;
144322289dc9SShashank Gupta }
144422289dc9SShashank Gupta
adf_handle_reg_cppmemtgterr(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)144522289dc9SShashank Gupta static bool adf_handle_reg_cppmemtgterr(struct adf_accel_dev *accel_dev,
144622289dc9SShashank Gupta void __iomem *csr, u32 errsou)
144722289dc9SShashank Gupta {
144822289dc9SShashank Gupta bool reset_required = false;
144922289dc9SShashank Gupta u32 cppmemtgterr;
145022289dc9SShashank Gupta
145122289dc9SShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU3_REG_ARAMUERR_BIT))
145222289dc9SShashank Gupta return false;
145322289dc9SShashank Gupta
145422289dc9SShashank Gupta cppmemtgterr = ADF_CSR_RD(csr, ADF_GEN4_REG_CPPMEMTGTERR);
145522289dc9SShashank Gupta cppmemtgterr &= ADF_GEN4_REG_CPPMEMTGTERR_BITMASK |
145622289dc9SShashank Gupta ADF_GEN4_REG_CPPMEMTGTERR_MULTI_ERRORS_BIT;
145722289dc9SShashank Gupta if (!cppmemtgterr)
145822289dc9SShashank Gupta return false;
145922289dc9SShashank Gupta
146022289dc9SShashank Gupta if (cppmemtgterr & ADF_GEN4_REG_CPPMEMTGTERR_MULTI_ERRORS_BIT) {
146122289dc9SShashank Gupta dev_err(&GET_DEV(accel_dev),
146222289dc9SShashank Gupta "Misc memory target multiple uncorrectable errors: 0x%x\n",
146322289dc9SShashank Gupta cppmemtgterr);
146422289dc9SShashank Gupta
146599b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_FATAL);
146699b1c982SShashank Gupta
146722289dc9SShashank Gupta reset_required = true;
146822289dc9SShashank Gupta } else {
146922289dc9SShashank Gupta dev_err(&GET_DEV(accel_dev),
147022289dc9SShashank Gupta "Misc memory target uncorrectable error: 0x%x\n", cppmemtgterr);
147199b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
147222289dc9SShashank Gupta }
147322289dc9SShashank Gupta
147422289dc9SShashank Gupta cppmemtgterr |= ADF_GEN4_REG_CPPMEMTGTERR_EN_BITMASK;
147522289dc9SShashank Gupta
147622289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_REG_CPPMEMTGTERR, cppmemtgterr);
147722289dc9SShashank Gupta
147822289dc9SShashank Gupta return reset_required;
147922289dc9SShashank Gupta }
148022289dc9SShashank Gupta
adf_handle_atufaultstatus(struct adf_accel_dev * accel_dev,void __iomem * csr,u32 errsou)148122289dc9SShashank Gupta static bool adf_handle_atufaultstatus(struct adf_accel_dev *accel_dev,
148222289dc9SShashank Gupta void __iomem *csr, u32 errsou)
148322289dc9SShashank Gupta {
148422289dc9SShashank Gupta u32 i;
148522289dc9SShashank Gupta u32 max_rp_num = GET_HW_DATA(accel_dev)->num_banks;
148622289dc9SShashank Gupta
148722289dc9SShashank Gupta if (!(errsou & ADF_GEN4_ERRSOU3_ATUFAULTSTATUS_BIT))
148822289dc9SShashank Gupta return false;
148922289dc9SShashank Gupta
149022289dc9SShashank Gupta for (i = 0; i < max_rp_num; i++) {
149122289dc9SShashank Gupta u32 atufaultstatus = ADF_CSR_RD(csr, ADF_GEN4_ATUFAULTSTATUS(i));
149222289dc9SShashank Gupta
149322289dc9SShashank Gupta atufaultstatus &= ADF_GEN4_ATUFAULTSTATUS_BIT;
149422289dc9SShashank Gupta
149522289dc9SShashank Gupta if (atufaultstatus) {
149622289dc9SShashank Gupta dev_err(&GET_DEV(accel_dev),
149722289dc9SShashank Gupta "Ring Pair (%u) ATU detected fault: 0x%x\n", i,
149822289dc9SShashank Gupta atufaultstatus);
149922289dc9SShashank Gupta
150099b1c982SShashank Gupta ADF_RAS_ERR_CTR_INC(accel_dev->ras_errors, ADF_RAS_UNCORR);
150199b1c982SShashank Gupta
150222289dc9SShashank Gupta ADF_CSR_WR(csr, ADF_GEN4_ATUFAULTSTATUS(i), atufaultstatus);
150322289dc9SShashank Gupta }
150422289dc9SShashank Gupta }
150522289dc9SShashank Gupta
150622289dc9SShashank Gupta return false;
150722289dc9SShashank Gupta }
150822289dc9SShashank Gupta
adf_gen4_process_errsou3(struct adf_accel_dev * accel_dev,void __iomem * csr,void __iomem * aram_csr,u32 errsou,bool * reset_required)150922289dc9SShashank Gupta static void adf_gen4_process_errsou3(struct adf_accel_dev *accel_dev,
151022289dc9SShashank Gupta void __iomem *csr, void __iomem *aram_csr,
151122289dc9SShashank Gupta u32 errsou, bool *reset_required)
151222289dc9SShashank Gupta {
151322289dc9SShashank Gupta *reset_required |= adf_handle_timiscsts(accel_dev, csr, errsou);
151422289dc9SShashank Gupta *reset_required |= adf_handle_ricppintsts(accel_dev, csr, errsou);
151522289dc9SShashank Gupta *reset_required |= adf_handle_ticppintsts(accel_dev, csr, errsou);
151622289dc9SShashank Gupta *reset_required |= adf_handle_aramcerr(accel_dev, aram_csr, errsou);
151722289dc9SShashank Gupta *reset_required |= adf_handle_aramuerr(accel_dev, aram_csr, errsou);
151822289dc9SShashank Gupta *reset_required |= adf_handle_reg_cppmemtgterr(accel_dev, aram_csr, errsou);
151922289dc9SShashank Gupta *reset_required |= adf_handle_atufaultstatus(accel_dev, csr, errsou);
152022289dc9SShashank Gupta }
152122289dc9SShashank Gupta
adf_gen4_handle_interrupt(struct adf_accel_dev * accel_dev,bool * reset_required)152293b2f7deSShashank Gupta static bool adf_gen4_handle_interrupt(struct adf_accel_dev *accel_dev,
152393b2f7deSShashank Gupta bool *reset_required)
152493b2f7deSShashank Gupta {
152522289dc9SShashank Gupta void __iomem *aram_csr = adf_get_aram_base(accel_dev);
1526df8c184bSShashank Gupta void __iomem *csr = adf_get_pmisc_base(accel_dev);
1527df8c184bSShashank Gupta u32 errsou = ADF_CSR_RD(csr, ADF_GEN4_ERRSOU0);
1528df8c184bSShashank Gupta bool handled = false;
1529df8c184bSShashank Gupta
1530df8c184bSShashank Gupta *reset_required = false;
1531df8c184bSShashank Gupta
1532df8c184bSShashank Gupta if (errsou & ADF_GEN4_ERRSOU0_BIT) {
1533df8c184bSShashank Gupta adf_gen4_process_errsou0(accel_dev, csr);
1534df8c184bSShashank Gupta handled = true;
1535df8c184bSShashank Gupta }
1536df8c184bSShashank Gupta
15374926e89dSShashank Gupta errsou = ADF_CSR_RD(csr, ADF_GEN4_ERRSOU1);
15384926e89dSShashank Gupta if (errsou & ADF_GEN4_ERRSOU1_BITMASK) {
15394926e89dSShashank Gupta adf_gen4_process_errsou1(accel_dev, csr, errsou, reset_required);
15404926e89dSShashank Gupta handled = true;
15414926e89dSShashank Gupta }
15424926e89dSShashank Gupta
1543895f7d53SShashank Gupta errsou = ADF_CSR_RD(csr, ADF_GEN4_ERRSOU2);
1544895f7d53SShashank Gupta if (errsou & ADF_GEN4_ERRSOU2_BITMASK) {
1545895f7d53SShashank Gupta adf_gen4_process_errsou2(accel_dev, csr, errsou, reset_required);
1546895f7d53SShashank Gupta handled = true;
1547895f7d53SShashank Gupta }
1548895f7d53SShashank Gupta
154922289dc9SShashank Gupta errsou = ADF_CSR_RD(csr, ADF_GEN4_ERRSOU3);
155022289dc9SShashank Gupta if (errsou & ADF_GEN4_ERRSOU3_BITMASK) {
155122289dc9SShashank Gupta adf_gen4_process_errsou3(accel_dev, csr, aram_csr, errsou, reset_required);
155222289dc9SShashank Gupta handled = true;
155322289dc9SShashank Gupta }
155422289dc9SShashank Gupta
1555df8c184bSShashank Gupta return handled;
155693b2f7deSShashank Gupta }
155793b2f7deSShashank Gupta
adf_gen4_init_ras_ops(struct adf_ras_ops * ras_ops)155893b2f7deSShashank Gupta void adf_gen4_init_ras_ops(struct adf_ras_ops *ras_ops)
155993b2f7deSShashank Gupta {
156093b2f7deSShashank Gupta ras_ops->enable_ras_errors = adf_gen4_enable_ras;
156193b2f7deSShashank Gupta ras_ops->disable_ras_errors = adf_gen4_disable_ras;
156293b2f7deSShashank Gupta ras_ops->handle_interrupt = adf_gen4_handle_interrupt;
156393b2f7deSShashank Gupta }
156493b2f7deSShashank Gupta EXPORT_SYMBOL_GPL(adf_gen4_init_ras_ops);
1565