[PATCH 3/3] drm/xe/oa: Fix overflow in oa batch buffer

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


By default xe_bb_create_job() appends a MI_BATCH_BUFFER_END to batch
buffer, this is not a problem if batch buffer is only used once but
oa reuses the batch buffer for the same metric and at each call
it appends a MI_BATCH_BUFFER_END, printing the warning below and then
overflowing.

[  381.072016] ------------[ cut here ]------------
[  381.072019] xe 0000:00:02.0: [drm] Assertion `bb->len * 4 + bb_prefetch(q->gt) <= size` failed!
               platform: LUNARLAKE subplatform: 1
               graphics: Xe2_LPG / Xe2_HPG 20.04 step B0
               media: Xe2_LPM / Xe2_HPM 20.00 step B0
               tile: 0 VRAM 0 B
               GT: 0 type 1

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_oa.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/xe/xe_oa.c b/drivers/gpu/drm/xe/xe_oa.c
index d3043078d89f1..37c084b3f74d8 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, true);
+	job = xe_bb_create_job(stream->k_exec_q, bb, false);
 	if (IS_ERR(job)) {
 		err = PTR_ERR(job);
 		goto exit;
@@ -666,6 +666,7 @@ static int xe_oa_modify_ctx_image(struct xe_oa_stream *stream, struct xe_lrc *lr
 	}
 
 	xe_oa_store_flex(stream, lrc, bb, flex, count);
+	bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
 
 	err = xe_oa_submit_bb(stream, bb);
 	xe_bb_free(bb, NULL);
@@ -685,6 +686,7 @@ static int xe_oa_load_with_lri(struct xe_oa_stream *stream, struct xe_oa_reg *re
 	}
 
 	write_cs_mi_lri(bb, reg_lri, 1);
+	bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
 
 	err = xe_oa_submit_bb(stream, bb);
 	xe_bb_free(bb, NULL);
@@ -884,6 +886,7 @@ __xe_oa_alloc_config_buffer(struct xe_oa_stream *stream, struct xe_oa_config *oa
 		goto err_free;
 
 	write_cs_mi_lri(bb, oa_config->regs, oa_config->regs_len);
+	bb->cs[bb->len++] = MI_BATCH_BUFFER_END;
 
 	oa_bo->bb = bb;
 	oa_bo->oa_config = xe_oa_config_get(oa_config);
-- 
2.46.0



More information about the Intel-xe mailing list