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

José Roberto de Souza jose.souza at intel.com
Wed Sep 11 20:02:17 UTC 2024


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.

Cc: Ashutosh Dixit <ashutosh.dixit at intel.com>
Signed-off-by: José Roberto de Souza <jose.souza at intel.com>
---
 drivers/gpu/drm/xe/xe_bb.c         | 13 ++++++++-----
 drivers/gpu/drm/xe/xe_bb.h         |  2 +-
 drivers/gpu/drm/xe/xe_gsc.c        |  2 +-
 drivers/gpu/drm/xe/xe_gsc_submit.c |  2 +-
 drivers/gpu/drm/xe/xe_gt.c         |  4 ++--
 drivers/gpu/drm/xe/xe_oa.c         |  2 +-
 6 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/xe/xe_bb.c b/drivers/gpu/drm/xe/xe_bb.c
index a13e0b3a169ed..a3dd8c3f9717e 100644
--- a/drivers/gpu/drm/xe/xe_bb.c
+++ b/drivers/gpu/drm/xe/xe_bb.c
@@ -61,11 +61,13 @@ struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 dwords, bool usm)
 }
 
 static struct xe_sched_job *
-__xe_bb_create_job(struct xe_exec_queue *q, struct xe_bb *bb, u64 *addr)
+__xe_bb_create_job(struct xe_exec_queue *q, struct xe_bb *bb, u64 *addr,
+		   bool emit_bb_end)
 {
 	u32 size = drm_suballoc_size(bb->bo);
 
-	bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
+	if (emit_bb_end)
+		bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
 
 	xe_gt_assert(q->gt, bb->len * 4 + bb_prefetch(q->gt) <= size);
 
@@ -89,17 +91,18 @@ struct xe_sched_job *xe_bb_create_migration_job(struct xe_exec_queue *q,
 	xe_gt_assert(q->gt, xe_sched_job_is_migration(q));
 	xe_gt_assert(q->gt, q->width == 1);
 
-	return __xe_bb_create_job(q, bb, addr);
+	return __xe_bb_create_job(q, bb, addr, true);
 }
 
 struct xe_sched_job *xe_bb_create_job(struct xe_exec_queue *q,
-				      struct xe_bb *bb)
+				      struct xe_bb *bb,
+				      bool emit_bb_end)
 {
 	u64 addr = xe_sa_bo_gpu_addr(bb->bo);
 
 	xe_gt_assert(q->gt, !xe_sched_job_is_migration(q));
 	xe_gt_assert(q->gt, q->width == 1);
-	return __xe_bb_create_job(q, bb, &addr);
+	return __xe_bb_create_job(q, bb, &addr, emit_bb_end);
 }
 
 void xe_bb_free(struct xe_bb *bb, struct dma_fence *fence)
diff --git a/drivers/gpu/drm/xe/xe_bb.h b/drivers/gpu/drm/xe/xe_bb.h
index fafacd73dcc38..c696726eb697e 100644
--- a/drivers/gpu/drm/xe/xe_bb.h
+++ b/drivers/gpu/drm/xe/xe_bb.h
@@ -16,7 +16,7 @@ struct xe_sched_job;
 
 struct xe_bb *xe_bb_new(struct xe_gt *gt, u32 size, bool usm);
 struct xe_sched_job *xe_bb_create_job(struct xe_exec_queue *q,
-				      struct xe_bb *bb);
+				      struct xe_bb *bb, bool emit_bb_end);
 struct xe_sched_job *xe_bb_create_migration_job(struct xe_exec_queue *q,
 						struct xe_bb *bb, u64 batch_ofs,
 						u32 second_idx);
diff --git a/drivers/gpu/drm/xe/xe_gsc.c b/drivers/gpu/drm/xe/xe_gsc.c
index 6fbea70d3d36d..8af50672097c7 100644
--- a/drivers/gpu/drm/xe/xe_gsc.c
+++ b/drivers/gpu/drm/xe/xe_gsc.c
@@ -83,7 +83,7 @@ static int emit_gsc_upload(struct xe_gsc *gsc)
 	bb->cs[bb->len++] = upper_32_bits(offset);
 	bb->cs[bb->len++] = (gsc->private->size / SZ_4K) | GSC_FW_LOAD_LIMIT_VALID;
 
-	job = xe_bb_create_job(gsc->q, bb);
+	job = xe_bb_create_job(gsc->q, bb, true);
 	if (IS_ERR(job)) {
 		xe_bb_free(bb, NULL);
 		return PTR_ERR(job);
diff --git a/drivers/gpu/drm/xe/xe_gsc_submit.c b/drivers/gpu/drm/xe/xe_gsc_submit.c
index 9ede483d37efd..ce316e8b7a46b 100644
--- a/drivers/gpu/drm/xe/xe_gsc_submit.c
+++ b/drivers/gpu/drm/xe/xe_gsc_submit.c
@@ -198,7 +198,7 @@ int xe_gsc_pkt_submit_kernel(struct xe_gsc *gsc, u64 addr_in, u32 size_in,
 	bb->cs[bb->len++] = size_out;
 	bb->cs[bb->len++] = 0;
 
-	job = xe_bb_create_job(gsc->q, bb);
+	job = xe_bb_create_job(gsc->q, bb, true);
 	if (IS_ERR(job)) {
 		xe_bb_free(bb, NULL);
 		return PTR_ERR(job);
diff --git a/drivers/gpu/drm/xe/xe_gt.c b/drivers/gpu/drm/xe/xe_gt.c
index 522f10f163c8b..39bfe2e9221a8 100644
--- a/drivers/gpu/drm/xe/xe_gt.c
+++ b/drivers/gpu/drm/xe/xe_gt.c
@@ -175,7 +175,7 @@ static int emit_nop_job(struct xe_gt *gt, struct xe_exec_queue *q)
 	if (IS_ERR(bb))
 		return PTR_ERR(bb);
 
-	job = xe_bb_create_job(q, bb);
+	job = xe_bb_create_job(q, bb, true);
 	if (IS_ERR(job)) {
 		xe_bb_free(bb, NULL);
 		return PTR_ERR(job);
@@ -261,7 +261,7 @@ static int emit_wa_job(struct xe_gt *gt, struct xe_exec_queue *q)
 
 	xe_lrc_emit_hwe_state_instructions(q, bb);
 
-	job = xe_bb_create_job(q, bb);
+	job = xe_bb_create_job(q, bb, true);
 	if (IS_ERR(job)) {
 		xe_bb_free(bb, NULL);
 		return PTR_ERR(job);
diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index 0369cc016f6ab..d3043078d89f1 100644
--- a/drivers/gpu/drm/xe/xe_oa.c
+++ b/drivers/gpu/drm/xe/xe_oa.c
@@ -575,7 +575,7 @@ static int xe_oa_submit_bb(struct xe_oa_stream *stream, struct xe_bb *bb)
 	int err = 0;
 
 	/* Kernel configuration is issued on stream->k_exec_q, not stream->exec_q */
-	job = xe_bb_create_job(stream->k_exec_q, bb);
+	job = xe_bb_create_job(stream->k_exec_q, bb, true);
 	if (IS_ERR(job)) {
 		err = PTR_ERR(job);
 		goto exit;
-- 
2.46.0



More information about the Intel-xe mailing list