[PATCH 2/5] drm/xe/lrc: Extract post context restore function
Lucas De Marchi
lucas.demarchi at intel.com
Fri May 23 18:54:36 UTC 2025
The post context restore is a mechanism in HW that may be used for
things other than the utilization setup. Create a new function called
setup_post_context_restore_bb() that wraps any function writing useful
commands in the buffer.
Signed-off-by: Lucas De Marchi <lucas.demarchi at intel.com>
---
drivers/gpu/drm/xe/xe_lrc.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
index 61a2e87990a9d..4562049a23fb1 100644
--- a/drivers/gpu/drm/xe/xe_lrc.c
+++ b/drivers/gpu/drm/xe/xe_lrc.c
@@ -917,9 +917,10 @@ static void xe_lrc_finish(struct xe_lrc *lrc)
}
/*
- * xe_lrc_setup_utilization() - Setup wa bb to assist in calculating active
- * context run ticks.
+ * wa_bb_write_utilization_state() - Write commands to wa bb to assist
+ * in calculating active context run ticks.
* @lrc: Pointer to the lrc.
+ * @cmd0: Pointer to the batch buffer location.
*
* Context Timestamp (CTX_TIMESTAMP) in the LRC accumulates the run ticks of the
* context, but only gets updated when the context switches out. In order to
@@ -944,11 +945,9 @@ static void xe_lrc_finish(struct xe_lrc *lrc)
* store it in the PPHSWP.
*/
#define CONTEXT_ACTIVE 1ULL
-static void xe_lrc_setup_utilization(struct xe_lrc *lrc)
+static size_t wa_bb_write_utilization_state(struct xe_lrc *lrc, u32 *cmd0)
{
- u32 *cmd;
-
- cmd = lrc->bb_per_ctx_bo->vmap.vaddr;
+ u32 *cmd = cmd0;
*cmd++ = MI_STORE_REGISTER_MEM | MI_SRM_USE_GGTT | MI_SRM_ADD_CS_OFFSET;
*cmd++ = ENGINE_ID(0).addr;
@@ -967,11 +966,21 @@ static void xe_lrc_setup_utilization(struct xe_lrc *lrc)
*cmd++ = upper_32_bits(CONTEXT_ACTIVE);
}
+ return cmd - cmd0;
+}
+
+static void setup_wa_bb(struct xe_lrc *lrc)
+{
+ u32 *cmd, *cmd0;
+
+ cmd0 = lrc->bb_per_ctx_bo->vmap.vaddr;
+ cmd = cmd0;
+
+ cmd += wa_bb_write_utilization_state(lrc, cmd);
*cmd++ = MI_BATCH_BUFFER_END;
xe_lrc_write_ctx_reg(lrc, CTX_BB_PER_CTX_PTR,
xe_bo_ggtt_addr(lrc->bb_per_ctx_bo) | 1);
-
}
#define PVC_CTX_ASID (0x2e + 1)
@@ -1128,7 +1137,7 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
map = __xe_lrc_start_seqno_map(lrc);
xe_map_write32(lrc_to_xe(lrc), &map, lrc->fence_ctx.next_seqno - 1);
- xe_lrc_setup_utilization(lrc);
+ setup_wa_bb(lrc);
return 0;
--
2.49.0
More information about the Intel-xe
mailing list