Skip to content

Commit 0f1f998

Browse files
lucasdemarchiSasha Levin
authored andcommitted
drm/xe/lrc: Use a temporary buffer for WA BB
[ Upstream commit 9c7632f ] In case the BO is in iomem, we can't simply take the vaddr and write to it. Instead, prepare a separate buffer that is later copied into io memory. Right now it's just a few words that could be using xe_map_write32(), but the intention is to grow the WA BB for other uses. Fixes: 617d824 ("drm/xe: Add WA BB to capture active context utilization") Cc: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Cc: Tvrtko Ursulin <tvrtko.ursulin@igalia.com> Reviewed-by: Matthew Brost <matthew.brost@intel.com> Reviewed-by: Umesh Nerlige Ramappa <umesh.nerlige.ramappa@intel.com> Link: https://lore.kernel.org/r/20250604-wa-bb-fix-v1-1-0dfc5dafcef0@intel.com Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com> (cherry picked from commit ef48715b2d3df17c060e23b9aa636af3d95652f8) Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent b7c3adb commit 0f1f998

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

drivers/gpu/drm/xe/xe_lrc.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -941,11 +941,18 @@ static void xe_lrc_finish(struct xe_lrc *lrc)
941941
* store it in the PPHSWP.
942942
*/
943943
#define CONTEXT_ACTIVE 1ULL
944-
static void xe_lrc_setup_utilization(struct xe_lrc *lrc)
944+
static int xe_lrc_setup_utilization(struct xe_lrc *lrc)
945945
{
946-
u32 *cmd;
946+
u32 *cmd, *buf = NULL;
947947

948-
cmd = lrc->bb_per_ctx_bo->vmap.vaddr;
948+
if (lrc->bb_per_ctx_bo->vmap.is_iomem) {
949+
buf = kmalloc(lrc->bb_per_ctx_bo->size, GFP_KERNEL);
950+
if (!buf)
951+
return -ENOMEM;
952+
cmd = buf;
953+
} else {
954+
cmd = lrc->bb_per_ctx_bo->vmap.vaddr;
955+
}
949956

950957
*cmd++ = MI_STORE_REGISTER_MEM | MI_SRM_USE_GGTT | MI_SRM_ADD_CS_OFFSET;
951958
*cmd++ = ENGINE_ID(0).addr;
@@ -966,9 +973,16 @@ static void xe_lrc_setup_utilization(struct xe_lrc *lrc)
966973

967974
*cmd++ = MI_BATCH_BUFFER_END;
968975

976+
if (buf) {
977+
xe_map_memcpy_to(gt_to_xe(lrc->gt), &lrc->bb_per_ctx_bo->vmap, 0,
978+
buf, (cmd - buf) * sizeof(*cmd));
979+
kfree(buf);
980+
}
981+
969982
xe_lrc_write_ctx_reg(lrc, CTX_BB_PER_CTX_PTR,
970983
xe_bo_ggtt_addr(lrc->bb_per_ctx_bo) | 1);
971984

985+
return 0;
972986
}
973987

974988
#define PVC_CTX_ASID (0x2e + 1)
@@ -1123,7 +1137,9 @@ static int xe_lrc_init(struct xe_lrc *lrc, struct xe_hw_engine *hwe,
11231137
map = __xe_lrc_start_seqno_map(lrc);
11241138
xe_map_write32(lrc_to_xe(lrc), &map, lrc->fence_ctx.next_seqno - 1);
11251139

1126-
xe_lrc_setup_utilization(lrc);
1140+
err = xe_lrc_setup_utilization(lrc);
1141+
if (err)
1142+
goto err_lrc_finish;
11271143

11281144
return 0;
11291145

0 commit comments

Comments
 (0)