[PATCH v9 4/8] drm/xe: Track number of written dwords from workaround batch buffer emission
Lucas De Marchi
lucas.demarchi at intel.com
Fri Jul 11 03:32:23 UTC 2025
On Wed, Jul 09, 2025 at 11:54:51AM +0100, Tvrtko Ursulin wrote:
>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 <tvrtko.ursulin at igalia.com>
>Cc: Lucas De Marchi <lucas.demarchi at intel.com>
>---
> drivers/gpu/drm/xe/xe_lrc.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
>diff --git a/drivers/gpu/drm/xe/xe_lrc.c b/drivers/gpu/drm/xe/xe_lrc.c
>index 5d5b76f16829..229cfde91799 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;
nit: since everywhere we use "len" for the number of dwords, it would
probably make more sense here. As well as s/buffer/bounce/ in the
previous patch... but not critical.
Reviewed-by: Lucas De Marchi <lucas.demarchi at intel.com>
Lucas De Marchi
> };
>
> 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);
>
>--
>2.48.0
>
More information about the Intel-xe
mailing list