From: Tvrtko Ursulin Date: Fri, 11 Jul 2025 16:01:49 +0000 (+0100) Subject: drm/xe: Track number of written dwords from workaround batch buffer emission X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5ce511ad2b1e2c449e26dba11ac5027c1a142e19;p=thirdparty%2Fkernel%2Flinux.git drm/xe: Track number of written dwords from workaround batch buffer emission Indirect context setup will need to get to the number of written dwords. Lets add it as an output parameter so it can be accessed from the finish helper regardless of whether code is writing directly or via an shadow buffer. Signed-off-by: Tvrtko Ursulin Cc: Lucas De Marchi Reviewed-by: Lucas De Marchi Link: https://lore.kernel.org/r/20250711160153.49833-5-tvrtko.ursulin@igalia.com Signed-off-by: Lucas De Marchi --- diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c index bd5dde28fa4bd..16921605fa6d9 100644 --- a/drivers/gpu/drm/xe/xe_lrc.c +++ b/drivers/gpu/drm/xe/xe_lrc.c @@ -991,6 +991,7 @@ struct bo_setup_state { /* State: */ u32 *buffer; u32 *ptr; + unsigned int written; }; static int setup_bo(struct bo_setup_state *state) @@ -1023,6 +1024,7 @@ static int setup_bo(struct bo_setup_state *state) goto fail; state->ptr += len; + state->written += len; } return 0; @@ -1039,7 +1041,7 @@ static void finish_bo(struct bo_setup_state *state) xe_map_memcpy_to(gt_to_xe(state->lrc->gt), &state->lrc->bo->vmap, state->offset, state->buffer, - (state->ptr - state->buffer) * sizeof(u32)); + state->written * sizeof(u32)); kfree(state->buffer); } @@ -1063,6 +1065,7 @@ static int setup_wa_bb(struct xe_lrc *lrc, struct xe_hw_engine *hwe) return ret; *state.ptr++ = MI_BATCH_BUFFER_END; + state.written++; finish_bo(&state);