xref: /linux/drivers/gpu/drm/xe/xe_hw_error.c (revision 889dd44491b37c890b1b4ef40876cf19032ca897)
1 // SPDX-License-Identifier: MIT
2 /*
3  * Copyright © 2025 Intel Corporation
4  */
5 
6 #include <linux/bitmap.h>
7 
8 #include "regs/xe_gsc_regs.h"
9 #include "regs/xe_hw_error_regs.h"
10 #include "regs/xe_irq_regs.h"
11 
12 #include "xe_debugfs.h"
13 #include "xe_device.h"
14 #include "xe_drm_ras.h"
15 #include "xe_hw_error.h"
16 #include "xe_mmio.h"
17 #include "xe_pm.h"
18 #include "xe_survivability_mode.h"
19 
20 #define GT_HW_ERROR_MAX_ERR_BITS		16
21 #define HEC_UNCORR_FW_ERR_BITS			4
22 #define XE_RAS_REG_SIZE				32
23 #define XE_SOC_NUM_IEH				2
24 
25 #define PVC_ERROR_MASK_SET(hw_err, err_bit)	((hw_err == HARDWARE_ERROR_CORRECTABLE) ? \
26 						 (PVC_COR_ERR_MASK & REG_BIT(err_bit)) : \
27 						 (PVC_FAT_ERR_MASK & REG_BIT(err_bit)))
28 
29 static const char * const error_severity[] = DRM_XE_RAS_ERROR_SEVERITY_NAMES;
30 
31 static const char * const hec_uncorrected_fw_errors[] = {
32 	"Fatal",
33 	"CSE Disabled",
34 	"FD Corruption",
35 	"Data Corruption"
36 };
37 
38 enum gt_vector_regs {
39 	ERR_STAT_GT_VECTOR0 = 0,
40 	ERR_STAT_GT_VECTOR1,
41 	ERR_STAT_GT_VECTOR2,
42 	ERR_STAT_GT_VECTOR3,
43 	ERR_STAT_GT_VECTOR4,
44 	ERR_STAT_GT_VECTOR5,
45 	ERR_STAT_GT_VECTOR6,
46 	ERR_STAT_GT_VECTOR7,
47 	ERR_STAT_GT_VECTOR_MAX
48 };
49 
50 #define PVC_GT_VECTOR_LEN(hw_err)	((hw_err == HARDWARE_ERROR_CORRECTABLE) ? \
51 					 ERR_STAT_GT_VECTOR4 : ERR_STAT_GT_VECTOR_MAX)
52 
53 static enum drm_xe_ras_error_severity hw_err_to_severity(const enum hardware_error hw_err)
54 {
55 	if (hw_err == HARDWARE_ERROR_CORRECTABLE)
56 		return DRM_XE_RAS_ERR_SEV_CORRECTABLE;
57 
58 	/* Uncorrectable errors comprise of both fatal and non-fatal errors */
59 	return DRM_XE_RAS_ERR_SEV_UNCORRECTABLE;
60 }
61 
62 static inline u32 err_src_to_id(u32 err_bit)
63 {
64 	switch (err_bit) {
65 	case XE_GT_ERROR:
66 		return DRM_XE_RAS_ERR_COMP_CORE_COMPUTE;
67 	case XE_SOC_ERROR:
68 		return DRM_XE_RAS_ERR_COMP_SOC_INTERNAL;
69 	default:
70 		return 0;
71 	}
72 }
73 
74 static const char * const pvc_master_global_err_reg[] = {
75 	[0 ... 1]	= "Undefined",
76 	[2]		= "HBM SS0: Channel0",
77 	[3]		= "HBM SS0: Channel1",
78 	[4]		= "HBM SS0: Channel2",
79 	[5]		= "HBM SS0: Channel3",
80 	[6]		= "HBM SS0: Channel4",
81 	[7]		= "HBM SS0: Channel5",
82 	[8]		= "HBM SS0: Channel6",
83 	[9]		= "HBM SS0: Channel7",
84 	[10]		= "HBM SS1: Channel0",
85 	[11]		= "HBM SS1: Channel1",
86 	[12]		= "HBM SS1: Channel2",
87 	[13]		= "HBM SS1: Channel3",
88 	[14]		= "HBM SS1: Channel4",
89 	[15]		= "HBM SS1: Channel5",
90 	[16]		= "HBM SS1: Channel6",
91 	[17]		= "HBM SS1: Channel7",
92 	[18 ... 31]	= "Undefined",
93 };
94 static_assert(ARRAY_SIZE(pvc_master_global_err_reg) == XE_RAS_REG_SIZE);
95 
96 static const char * const pvc_slave_global_err_reg[] = {
97 	[0]		= "Undefined",
98 	[1]		= "HBM SS2: Channel0",
99 	[2]		= "HBM SS2: Channel1",
100 	[3]		= "HBM SS2: Channel2",
101 	[4]		= "HBM SS2: Channel3",
102 	[5]		= "HBM SS2: Channel4",
103 	[6]		= "HBM SS2: Channel5",
104 	[7]		= "HBM SS2: Channel6",
105 	[8]		= "HBM SS2: Channel7",
106 	[9]		= "HBM SS3: Channel0",
107 	[10]		= "HBM SS3: Channel1",
108 	[11]		= "HBM SS3: Channel2",
109 	[12]		= "HBM SS3: Channel3",
110 	[13]		= "HBM SS3: Channel4",
111 	[14]		= "HBM SS3: Channel5",
112 	[15]		= "HBM SS3: Channel6",
113 	[16]		= "HBM SS3: Channel7",
114 	[17]		= "Undefined",
115 	[18]		= "ANR MDFI",
116 	[19 ... 31]	= "Undefined",
117 };
118 static_assert(ARRAY_SIZE(pvc_slave_global_err_reg) == XE_RAS_REG_SIZE);
119 
120 static const char * const pvc_slave_local_fatal_err_reg[] = {
121 	[0]		= "Local IEH: Malformed PCIe AER",
122 	[1]		= "Local IEH: Malformed PCIe ERR",
123 	[2]		= "Local IEH: UR conditions in IEH",
124 	[3]		= "Local IEH: From SERR Sources",
125 	[4 ... 19]	= "Undefined",
126 	[20]		= "Malformed MCA error packet (HBM/Punit)",
127 	[21 ... 31]	= "Undefined",
128 };
129 static_assert(ARRAY_SIZE(pvc_slave_local_fatal_err_reg) == XE_RAS_REG_SIZE);
130 
131 static const char * const pvc_master_local_fatal_err_reg[] = {
132 	[0]		= "Local IEH: Malformed IOSF PCIe AER",
133 	[1]		= "Local IEH: Malformed IOSF PCIe ERR",
134 	[2]		= "Local IEH: UR RESPONSE",
135 	[3]		= "Local IEH: From SERR SPI controller",
136 	[4]		= "Base Die MDFI T2T",
137 	[5]		= "Undefined",
138 	[6]		= "Base Die MDFI T2C",
139 	[7]		= "Undefined",
140 	[8]		= "Invalid CSC PSF Command Parity",
141 	[9]		= "Invalid CSC PSF Unexpected Completion",
142 	[10]		= "Invalid CSC PSF Unsupported Request",
143 	[11]		= "Invalid PCIe PSF Command Parity",
144 	[12]		= "PCIe PSF Unexpected Completion",
145 	[13]		= "PCIe PSF Unsupported Request",
146 	[14 ... 19]	= "Undefined",
147 	[20]		= "Malformed MCA error packet (HBM/Punit)",
148 	[21 ... 31]	= "Undefined",
149 };
150 static_assert(ARRAY_SIZE(pvc_master_local_fatal_err_reg) == XE_RAS_REG_SIZE);
151 
152 static const char * const pvc_master_local_nonfatal_err_reg[] = {
153 	[0 ... 3]	= "Undefined",
154 	[4]		= "Base Die MDFI T2T",
155 	[5]		= "Undefined",
156 	[6]		= "Base Die MDFI T2C",
157 	[7]		= "Undefined",
158 	[8]		= "Invalid CSC PSF Command Parity",
159 	[9]		= "Invalid CSC PSF Unexpected Completion",
160 	[10]		= "Invalid PCIe PSF Command Parity",
161 	[11 ... 31]	= "Undefined",
162 };
163 static_assert(ARRAY_SIZE(pvc_master_local_nonfatal_err_reg) == XE_RAS_REG_SIZE);
164 
165 #define PVC_MASTER_LOCAL_REG_INFO(hw_err)	((hw_err == HARDWARE_ERROR_FATAL) ? \
166 						 pvc_master_local_fatal_err_reg : \
167 						 pvc_master_local_nonfatal_err_reg)
168 
169 static void csc_hw_error_work(struct work_struct *work)
170 {
171 	struct xe_tile *tile = container_of(work, typeof(*tile), csc_hw_error_work);
172 	struct xe_device *xe = tile_to_xe(tile);
173 
174 	guard(xe_pm_runtime)(xe);
175 	xe_survivability_mode_runtime_enable(xe);
176 }
177 
178 static void csc_hw_error_handler(struct xe_tile *tile, const enum hardware_error hw_err)
179 {
180 	const enum drm_xe_ras_error_severity severity = hw_err_to_severity(hw_err);
181 	const char *severity_str = error_severity[severity];
182 	struct xe_device *xe = tile_to_xe(tile);
183 	struct xe_mmio *mmio = &tile->mmio;
184 	u32 base, err_bit, err_src;
185 	unsigned long fw_err;
186 
187 	if (xe->info.platform != XE_BATTLEMAGE)
188 		return;
189 
190 	base = BMG_GSC_HECI1_BASE;
191 	lockdep_assert_held(&xe->irq.lock);
192 	err_src = xe_mmio_read32(mmio, HEC_UNCORR_ERR_STATUS(base));
193 	if (!err_src) {
194 		drm_err_ratelimited(&xe->drm, HW_ERR "Tile%d reported %s HEC_ERR_STATUS register blank\n",
195 				    tile->id, severity_str);
196 		return;
197 	}
198 
199 	if (err_src & UNCORR_FW_REPORTED_ERR) {
200 		fw_err = xe_mmio_read32(mmio, HEC_UNCORR_FW_ERR_DW0(base));
201 		for_each_set_bit(err_bit, &fw_err, HEC_UNCORR_FW_ERR_BITS) {
202 			drm_err_ratelimited(&xe->drm, HW_ERR
203 					    "HEC FW %s %s reported, bit[%d] is set\n",
204 					     hec_uncorrected_fw_errors[err_bit], severity_str,
205 					     err_bit);
206 
207 			schedule_work(&tile->csc_hw_error_work);
208 		}
209 	}
210 
211 	xe_mmio_write32(mmio, HEC_UNCORR_ERR_STATUS(base), err_src);
212 }
213 
214 static void log_hw_error(struct xe_tile *tile, const char *name,
215 			 const enum drm_xe_ras_error_severity severity)
216 {
217 	const char *severity_str = error_severity[severity];
218 	struct xe_device *xe = tile_to_xe(tile);
219 
220 	if (severity == DRM_XE_RAS_ERR_SEV_CORRECTABLE)
221 		drm_warn(&xe->drm, HW_ERR "%s %s detected\n", name, severity_str);
222 	else
223 		drm_err_ratelimited(&xe->drm, HW_ERR "%s %s detected\n", name, severity_str);
224 }
225 
226 static void log_gt_err(struct xe_tile *tile, const char *name, int i, u32 err,
227 		       const enum drm_xe_ras_error_severity severity)
228 {
229 	const char *severity_str = error_severity[severity];
230 	struct xe_device *xe = tile_to_xe(tile);
231 
232 	if (severity == DRM_XE_RAS_ERR_SEV_CORRECTABLE)
233 		drm_warn(&xe->drm, HW_ERR "%s %s detected, ERROR_STAT_GT_VECTOR%d:0x%08x\n",
234 			 name, severity_str, i, err);
235 	else
236 		drm_err_ratelimited(&xe->drm, HW_ERR "%s %s detected, ERROR_STAT_GT_VECTOR%d:0x%08x\n",
237 				    name, severity_str, i, err);
238 }
239 
240 static void log_soc_error(struct xe_tile *tile, const char * const *reg_info,
241 			  const enum drm_xe_ras_error_severity severity, u32 err_bit, u32 index)
242 {
243 	const char *severity_str = error_severity[severity];
244 	struct xe_device *xe = tile_to_xe(tile);
245 	struct xe_drm_ras *ras = &xe->ras;
246 	struct xe_drm_ras_counter *info = ras->info[severity];
247 	const char *name;
248 
249 	name = reg_info[err_bit];
250 
251 	if (strcmp(name, "Undefined")) {
252 		if (severity == DRM_XE_RAS_ERR_SEV_CORRECTABLE)
253 			drm_warn(&xe->drm, HW_ERR "%s SOC %s detected", name, severity_str);
254 		else
255 			drm_err_ratelimited(&xe->drm, HW_ERR "%s SOC %s detected", name, severity_str);
256 		atomic_inc(&info[index].counter);
257 	}
258 }
259 
260 static void gt_hw_error_handler(struct xe_tile *tile, const enum hardware_error hw_err,
261 				u32 error_id)
262 {
263 	const enum drm_xe_ras_error_severity severity = hw_err_to_severity(hw_err);
264 	struct xe_device *xe = tile_to_xe(tile);
265 	struct xe_drm_ras *ras = &xe->ras;
266 	struct xe_drm_ras_counter *info = ras->info[severity];
267 	struct xe_mmio *mmio = &tile->mmio;
268 	unsigned long err_stat = 0;
269 	int i;
270 
271 	if (xe->info.platform != XE_PVC)
272 		return;
273 
274 	if (hw_err == HARDWARE_ERROR_NONFATAL) {
275 		atomic_inc(&info[error_id].counter);
276 		log_hw_error(tile, info[error_id].name, severity);
277 		return;
278 	}
279 
280 	for (i = 0; i < PVC_GT_VECTOR_LEN(hw_err); i++) {
281 		u32 vector, val;
282 
283 		vector = xe_mmio_read32(mmio, ERR_STAT_GT_VECTOR_REG(hw_err, i));
284 		if (!vector)
285 			continue;
286 
287 		switch (i) {
288 		case ERR_STAT_GT_VECTOR0:
289 		case ERR_STAT_GT_VECTOR1: {
290 			u32 errbit;
291 
292 			val = hweight32(vector);
293 			atomic_add(val, &info[error_id].counter);
294 			log_gt_err(tile, "Subslice", i, vector, severity);
295 
296 			/*
297 			 * Error status register is only populated once per error.
298 			 * Read the register and clear once.
299 			 */
300 			if (err_stat)
301 				break;
302 
303 			err_stat = xe_mmio_read32(mmio, ERR_STAT_GT_REG(hw_err));
304 			for_each_set_bit(errbit, &err_stat, GT_HW_ERROR_MAX_ERR_BITS) {
305 				if (PVC_ERROR_MASK_SET(hw_err, errbit))
306 					atomic_inc(&info[error_id].counter);
307 			}
308 			if (err_stat)
309 				xe_mmio_write32(mmio, ERR_STAT_GT_REG(hw_err), err_stat);
310 			break;
311 		}
312 		case ERR_STAT_GT_VECTOR2:
313 		case ERR_STAT_GT_VECTOR3:
314 			val = hweight32(vector);
315 			atomic_add(val, &info[error_id].counter);
316 			log_gt_err(tile, "L3 BANK", i, vector, severity);
317 			break;
318 		case ERR_STAT_GT_VECTOR6:
319 			val = hweight32(vector);
320 			atomic_add(val, &info[error_id].counter);
321 			log_gt_err(tile, "TLB", i, vector, severity);
322 			break;
323 		case ERR_STAT_GT_VECTOR7:
324 			val = hweight32(vector);
325 			atomic_add(val, &info[error_id].counter);
326 			log_gt_err(tile, "L3 Fabric", i, vector, severity);
327 			break;
328 		default:
329 			log_gt_err(tile, "Undefined", i, vector, severity);
330 		}
331 
332 		xe_mmio_write32(mmio, ERR_STAT_GT_VECTOR_REG(hw_err, i), vector);
333 	}
334 }
335 
336 static void soc_slave_ieh_handler(struct xe_tile *tile, const enum hardware_error hw_err, u32 error_id)
337 {
338 	const enum drm_xe_ras_error_severity severity = hw_err_to_severity(hw_err);
339 	unsigned long slave_global_errstat, slave_local_errstat;
340 	struct xe_mmio *mmio = &tile->mmio;
341 	u32 regbit, slave;
342 
343 	slave = SOC_PVC_SLAVE_BASE;
344 	slave_global_errstat = xe_mmio_read32(mmio, SOC_GLOBAL_ERR_STAT_REG(slave, hw_err));
345 
346 	if (slave_global_errstat & SOC_IEH1_LOCAL_ERR_STATUS) {
347 		slave_local_errstat = xe_mmio_read32(mmio, SOC_LOCAL_ERR_STAT_REG(slave, hw_err));
348 
349 		if (hw_err == HARDWARE_ERROR_FATAL) {
350 			for_each_set_bit(regbit, &slave_local_errstat, XE_RAS_REG_SIZE)
351 				log_soc_error(tile, pvc_slave_local_fatal_err_reg, severity,
352 					      regbit, error_id);
353 		}
354 
355 		xe_mmio_write32(mmio, SOC_LOCAL_ERR_STAT_REG(slave, hw_err),
356 				slave_local_errstat);
357 	}
358 
359 	for_each_set_bit(regbit, &slave_global_errstat, XE_RAS_REG_SIZE)
360 		log_soc_error(tile, pvc_slave_global_err_reg, severity, regbit, error_id);
361 
362 	xe_mmio_write32(mmio, SOC_GLOBAL_ERR_STAT_REG(slave, hw_err), slave_global_errstat);
363 }
364 
365 static void soc_hw_error_handler(struct xe_tile *tile, const enum hardware_error hw_err,
366 				 u32 error_id)
367 {
368 	const enum drm_xe_ras_error_severity severity = hw_err_to_severity(hw_err);
369 	struct xe_device *xe = tile_to_xe(tile);
370 	struct xe_mmio *mmio = &tile->mmio;
371 	unsigned long master_global_errstat, master_local_errstat;
372 	u32 master, slave, regbit;
373 	int i;
374 
375 	if (xe->info.platform != XE_PVC)
376 		return;
377 
378 	master = SOC_PVC_MASTER_BASE;
379 	slave = SOC_PVC_SLAVE_BASE;
380 
381 	/* Mask error type in GSYSEVTCTL so that no new errors of the type will be reported */
382 	for (i = 0; i < XE_SOC_NUM_IEH; i++)
383 		xe_mmio_write32(mmio, SOC_GSYSEVTCTL_REG(master, slave, i), ~REG_BIT(hw_err));
384 
385 	if (hw_err == HARDWARE_ERROR_CORRECTABLE) {
386 		xe_mmio_write32(mmio, SOC_GLOBAL_ERR_STAT_REG(master, hw_err), REG_GENMASK(31, 0));
387 		xe_mmio_write32(mmio, SOC_LOCAL_ERR_STAT_REG(master, hw_err), REG_GENMASK(31, 0));
388 		xe_mmio_write32(mmio, SOC_GLOBAL_ERR_STAT_REG(slave, hw_err), REG_GENMASK(31, 0));
389 		xe_mmio_write32(mmio, SOC_LOCAL_ERR_STAT_REG(slave, hw_err), REG_GENMASK(31, 0));
390 		goto unmask_gsysevtctl;
391 	}
392 
393 	/*
394 	 * Read the master global IEH error register, if BIT(1) is set then process
395 	 * the slave IEH first. If BIT(0) in global error register is set then process
396 	 * the corresponding local error registers.
397 	 */
398 	master_global_errstat = xe_mmio_read32(mmio, SOC_GLOBAL_ERR_STAT_REG(master, hw_err));
399 	if (master_global_errstat & SOC_SLAVE_IEH)
400 		soc_slave_ieh_handler(tile, hw_err, error_id);
401 
402 	if (master_global_errstat & SOC_IEH0_LOCAL_ERR_STATUS) {
403 		master_local_errstat = xe_mmio_read32(mmio, SOC_LOCAL_ERR_STAT_REG(master, hw_err));
404 
405 		for_each_set_bit(regbit, &master_local_errstat, XE_RAS_REG_SIZE)
406 			log_soc_error(tile, PVC_MASTER_LOCAL_REG_INFO(hw_err), severity, regbit, error_id);
407 
408 		xe_mmio_write32(mmio, SOC_LOCAL_ERR_STAT_REG(master, hw_err), master_local_errstat);
409 	}
410 
411 	for_each_set_bit(regbit, &master_global_errstat, XE_RAS_REG_SIZE)
412 		log_soc_error(tile, pvc_master_global_err_reg, severity, regbit, error_id);
413 
414 	xe_mmio_write32(mmio, SOC_GLOBAL_ERR_STAT_REG(master, hw_err), master_global_errstat);
415 
416 unmask_gsysevtctl:
417 	for (i = 0; i < XE_SOC_NUM_IEH; i++)
418 		xe_mmio_write32(mmio, SOC_GSYSEVTCTL_REG(master, slave, i),
419 				(HARDWARE_ERROR_MAX << 1) + 1);
420 }
421 
422 static void hw_error_source_handler(struct xe_tile *tile, const enum hardware_error hw_err)
423 {
424 	const enum drm_xe_ras_error_severity severity = hw_err_to_severity(hw_err);
425 	const char *severity_str = error_severity[severity];
426 	struct xe_device *xe = tile_to_xe(tile);
427 	struct xe_drm_ras *ras = &xe->ras;
428 	struct xe_drm_ras_counter *info = ras->info[severity];
429 	unsigned long flags, err_src;
430 	u32 err_bit;
431 
432 	if (!IS_DGFX(xe))
433 		return;
434 
435 	/*
436 	 * Hardware errors are reported through System Controller on the platforms that
437 	 * support it, and never routed as direct IRQ to SGUnit. So we should never be
438 	 * here for those platforms.
439 	 */
440 	if (xe->info.has_sysctrl) {
441 		drm_err_ratelimited(&xe->drm, HW_ERR "Invalid error routing\n");
442 		return;
443 	}
444 
445 	spin_lock_irqsave(&xe->irq.lock, flags);
446 	err_src = xe_mmio_read32(&tile->mmio, DEV_ERR_STAT_REG(hw_err));
447 	if (!err_src) {
448 		drm_err_ratelimited(&xe->drm, HW_ERR "Tile%d reported %s DEV_ERR_STAT register blank!\n",
449 				    tile->id, severity_str);
450 		goto unlock;
451 	}
452 
453 	/*
454 	 * On encountering CSC firmware errors, the graphics device becomes unrecoverable
455 	 * so return immediately on error. The only way to recover from these errors is
456 	 * firmware flash. The device will enter Runtime Survivability mode when such
457 	 * errors are detected.
458 	 */
459 	if (err_src & REG_BIT(XE_CSC_ERROR)) {
460 		csc_hw_error_handler(tile, hw_err);
461 		goto clear_reg;
462 	}
463 
464 	if (!info)
465 		goto clear_reg;
466 
467 	for_each_set_bit(err_bit, &err_src, XE_RAS_REG_SIZE) {
468 		const char *name;
469 		u32 error_id;
470 
471 		error_id = err_src_to_id(err_bit);
472 		if (!error_id)
473 			continue;
474 
475 		name = info[error_id].name;
476 		if (!name)
477 			continue;
478 
479 		if (severity == DRM_XE_RAS_ERR_SEV_CORRECTABLE) {
480 			drm_warn(&xe->drm, HW_ERR
481 				 "TILE%d reported %s %s, bit[%d] is set\n",
482 				 tile->id, name, severity_str, err_bit);
483 		} else {
484 			drm_err_ratelimited(&xe->drm, HW_ERR
485 					    "TILE%d reported %s %s, bit[%d] is set\n",
486 					    tile->id, name, severity_str, err_bit);
487 		}
488 
489 		if (err_bit == XE_GT_ERROR)
490 			gt_hw_error_handler(tile, hw_err, error_id);
491 		if (err_bit == XE_SOC_ERROR)
492 			soc_hw_error_handler(tile, hw_err, error_id);
493 	}
494 
495 clear_reg:
496 	xe_mmio_write32(&tile->mmio, DEV_ERR_STAT_REG(hw_err), err_src);
497 unlock:
498 	spin_unlock_irqrestore(&xe->irq.lock, flags);
499 }
500 
501 /**
502  * xe_hw_error_irq_handler - irq handling for hw errors
503  * @tile: tile instance
504  * @master_ctl: value read from master interrupt register
505  *
506  * Xe platforms add three error bits to the master interrupt register to support error handling.
507  * These three bits are used to convey the class of error FATAL, NONFATAL, or CORRECTABLE.
508  * To process the interrupt, determine the source of error by reading the Device Error Source
509  * Register that corresponds to the class of error being serviced.
510  */
511 void xe_hw_error_irq_handler(struct xe_tile *tile, const u32 master_ctl)
512 {
513 	enum hardware_error hw_err;
514 
515 	if (xe_fault_csc_hw_error())
516 		schedule_work(&tile->csc_hw_error_work);
517 
518 	for (hw_err = 0; hw_err < HARDWARE_ERROR_MAX; hw_err++) {
519 		if (master_ctl & ERROR_IRQ(hw_err))
520 			hw_error_source_handler(tile, hw_err);
521 	}
522 }
523 
524 /*
525  * Process hardware errors during boot
526  */
527 static void process_hw_errors(struct xe_device *xe)
528 {
529 	struct xe_tile *tile;
530 	u32 master_ctl;
531 	u8 id;
532 
533 	for_each_tile(tile, xe, id) {
534 		master_ctl = xe_mmio_read32(&tile->mmio, GFX_MSTR_IRQ);
535 		xe_hw_error_irq_handler(tile, master_ctl);
536 		xe_mmio_write32(&tile->mmio, GFX_MSTR_IRQ, master_ctl);
537 	}
538 }
539 
540 /**
541  * xe_hw_error_init - Initialize hw errors
542  * @xe: xe device instance
543  *
544  * Initialize and check for errors that occurred during boot
545  * prior to driver load
546  */
547 void xe_hw_error_init(struct xe_device *xe)
548 {
549 	struct xe_tile *tile = xe_device_get_root_tile(xe);
550 
551 	if (!IS_DGFX(xe) || IS_SRIOV_VF(xe))
552 		return;
553 
554 	INIT_WORK(&tile->csc_hw_error_work, csc_hw_error_work);
555 
556 	process_hw_errors(xe);
557 }
558