drm/xe: Add build on bug to assert page fault queue works
authorMatthew Brost <matthew.brost@intel.com>
Wed, 10 Jan 2024 01:24:36 +0000 (17:24 -0800)
committerMatthew Brost <matthew.brost@intel.com>
Wed, 10 Jan 2024 23:11:22 +0000 (15:11 -0800)
If PF_QUEUE_NUM_DW % PF_MSG_LEN_DW != 0 then the page fault queue logic
does not work when wrapping occurs. Add a build bug on to assert
PF_QUEUE_NUM_DW % PF_MSG_LEN_DW == 0 to enforce this restriction and
document the code.

v2:
- s/NUM_PF_QUEUE/PF_QUEUE_NUM_DW (Brian)

Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
Reviewed-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_gt_pagefault.c

index 4489aadc7a525f4222c0d8841e3e2bdf2cfc1b5a..0a61e4413679ecc07bcef1ac57123318c5562a6a 100644 (file)
@@ -328,6 +328,11 @@ int xe_guc_pagefault_handler(struct xe_guc *guc, u32 *msg, u32 len)
        u32 asid;
        bool full;
 
+       /*
+        * The below logic doesn't work unless PF_QUEUE_NUM_DW % PF_MSG_LEN_DW == 0
+        */
+       BUILD_BUG_ON(PF_QUEUE_NUM_DW % PF_MSG_LEN_DW);
+
        if (unlikely(len != PF_MSG_LEN_DW))
                return -EPROTO;