]> www.infradead.org Git - users/hch/configfs.git/commitdiff
drm/xe: Add assert for XE_WA() usage
authorLucas De Marchi <lucas.demarchi@intel.com>
Mon, 22 Jul 2024 16:06:39 +0000 (09:06 -0700)
committerLucas De Marchi <lucas.demarchi@intel.com>
Wed, 24 Jul 2024 16:05:37 +0000 (09:05 -0700)
It's not always safe to call XE_WA() in the driver initialization. Add a
xe_gt_assert() so this doesn't go unnoticed.

While at it, fix typo in kernel-doc about OOB workarounds.

Reviewed-by: Tejas Upadhyay <tejas.upadhyay@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240722160815.4085605-1-lucas.demarchi@intel.com
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_gt_types.h
drivers/gpu/drm/xe/xe_wa.c
drivers/gpu/drm/xe/xe_wa.h

index ef68c4a929726b0dfe3035f47c3f02685598c301..631928258d71c1c0e1344bc8f879adf8a4d27b9b 100644 (file)
@@ -387,8 +387,14 @@ struct xe_gt {
                unsigned long *engine;
                /** @wa_active.lrc: bitmap with active LRC workarounds */
                unsigned long *lrc;
-               /** @wa_active.oob: bitmap with active OOB workaroudns */
+               /** @wa_active.oob: bitmap with active OOB workarounds */
                unsigned long *oob;
+               /**
+                * @wa_active.oob_initialized: mark oob as initialized to help
+                * detecting misuse of XE_WA() - it can only be called on
+                * initialization after OOB WAs have being processed
+                */
+               bool oob_initialized;
        } wa_active;
 
        /** @user_engines: engines present in GT and available to userspace */
index fd009b2c68fa6072d38472cb7fd5116f805d9814..564e32e44e3b0b2cde3965538fccf8391d9a9847 100644 (file)
@@ -755,6 +755,7 @@ void xe_wa_process_oob(struct xe_gt *gt)
 
        xe_rtp_process_ctx_enable_active_tracking(&ctx, gt->wa_active.oob,
                                                  ARRAY_SIZE(oob_was));
+       gt->wa_active.oob_initialized = true;
        xe_rtp_process(&ctx, oob_was);
 }
 
index db9ddeaf69bf3473160c4d6c1b367c35f656c425..52337405b5bc8c6afaa6d941588465dcf91af528 100644 (file)
@@ -6,6 +6,8 @@
 #ifndef _XE_WA_
 #define _XE_WA_
 
+#include "xe_assert.h"
+
 struct drm_printer;
 struct xe_gt;
 struct xe_hw_engine;
@@ -25,6 +27,9 @@ void xe_wa_dump(struct xe_gt *gt, struct drm_printer *p);
  * @gt__: gt instance
  * @id__: XE_OOB_<id__>, as generated by build system in generated/xe_wa_oob.h
  */
-#define XE_WA(gt__, id__) test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob)
+#define XE_WA(gt__, id__) ({                                           \
+       xe_gt_assert(gt__, (gt__)->wa_active.oob_initialized);          \
+       test_bit(XE_WA_OOB_ ## id__, (gt__)->wa_active.oob);            \
+})
 
 #endif