xref: /linux/drivers/gpu/drm/xe/xe_wa.h (revision 18fbf5151d2c0bfe433c7428eef03cabf5fdb2fa)
1 /* SPDX-License-Identifier: MIT */
2 /*
3  * Copyright © 2022 Intel Corporation
4  */
5 
6 #ifndef _XE_WA_H_
7 #define _XE_WA_H_
8 
9 #include <kunit/visibility.h>
10 #include "xe_assert.h"
11 
12 struct drm_printer;
13 struct xe_gt;
14 struct xe_hw_engine;
15 struct xe_tile;
16 
17 int xe_wa_device_init(struct xe_device *xe);
18 int xe_wa_gt_init(struct xe_gt *gt);
19 void xe_wa_process_device_oob(struct xe_device *xe);
20 void xe_wa_process_gt_oob(struct xe_gt *gt);
21 void xe_wa_process_gt(struct xe_gt *gt);
22 void xe_wa_process_engine(struct xe_hw_engine *hwe);
23 void xe_wa_process_lrc(struct xe_hw_engine *hwe);
24 void xe_wa_apply_tile_workarounds(struct xe_tile *tile);
25 void xe_wa_device_dump(struct xe_device *xe, struct drm_printer *p);
26 int xe_wa_gt_dump(struct xe_gt *gt, struct drm_printer *p);
27 
28 #if IS_ENABLED(CONFIG_DRM_XE_KUNIT_TEST)
29 extern const struct xe_rtp_table_sr gt_was;
30 extern __maybe_unused const struct xe_rtp_table oob_was;
31 extern __maybe_unused const struct xe_rtp_table device_oob_was;
32 #endif
33 
34 /**
35  * XE_GT_WA - Out-of-band GT workarounds, to be queried and called as needed.
36  * @gt__: gt instance
37  * @id__: XE_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
38  */
39 #define XE_GT_WA(gt__, id__) ({						\
40 	xe_gt_assert(gt__, (gt__)->wa_active.oob_initialized);		\
41 	test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob);		\
42 })
43 
44 /**
45  * XE_DEVICE_WA - Out-of-band Device workarounds, to be queried and called
46  * as needed.
47  * @xe__: xe_device
48  * @id__: XE_DEVICE_WA_OOB_<id__>, as generated by build system in generated/xe_device_wa_oob.h
49  */
50 #define XE_DEVICE_WA(xe__, id__) ({					\
51 	xe_assert(xe__, (xe__)->wa_active.oob_initialized);		\
52 	test_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->wa_active.oob);	\
53 })
54 
55 #define XE_DEVICE_WA_DISABLE(xe__, id__) ({				\
56 	xe_assert(xe__, (xe__)->wa_active.oob_initialized);		\
57 	clear_bit(XE_DEVICE_WA_OOB_ ## id__, (xe__)->wa_active.oob);	\
58 })
59 
60 #endif
61