[PATCH 2/3] drm/xe: Add a parameter to xe_bb_create_job() to append or not batch buffer end instruction

Dixit, Ashutosh ashutosh.dixit at intel.com
Thu Sep 12 02:13:57 UTC 2024


On Wed, 11 Sep 2024 13:02:17 -0700, José Roberto de Souza wrote:
>

Hi Jose,

> There is overflow happening in OA because it reuses batch buffers,
> so at each submission one batch buffer end instruction is appended
> eventually causing a overflow.
> That will be fixed in the next patch, here just adding adding
> parameter and updating all the callers.

Thanks for finding this, this is indeed a bug.

However I have a much simpler fix, which is just the patch below (instead
of your two patches):

diff --git a/drivers/gpu/drm/xe/xe_bb.c b/drivers/gpu/drm/xe/xe_bb.c
index a13e0b3a169ed..148ccae265b47 100644
--- a/drivers/gpu/drm/xe/xe_bb.c
+++ b/drivers/gpu/drm/xe/xe_bb.c
@@ -65,7 +65,8 @@ __xe_bb_create_job(struct xe_exec_queue *q, struct xe_bb *bb, u64 *addr)
 {
 	u32 size = drm_suballoc_size(bb->bo);
 
-	bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
+	if (bb->cs[bb->len] != MI_BATCH_BUFFER_END)
+		bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
 
 	xe_gt_assert(q->gt, bb->len * 4 + bb_prefetch(q->gt) <= size);

So just append MI_BATCH_BUFFER_END if it is not already there. Also,
MI_BATCH_BUFFER_END can be added by the caller, otherwise the callee will
add that. Thoughts?

Please send this patch if you agree, I'll R-b it.

Thanks.
--
Ashutosh


More information about the Intel-xe mailing list