Skip to content

Commit 5e0a67f

Browse files
nirmoyThomas Hellström
authored andcommitted
drm/xe: Wait for migration job before unmapping pages
Fix a potential GPU page fault during tt -> system moves by waiting for migration jobs to complete before unmapping SG. This ensures that IOMMU mappings are not prematurely torn down while a migration job is still in progress. v2: Use intr=false(Matt A) v3: Update commit message(Matt A) v4: s/DMA_RESV_USAGE_BOOKKEEP/DMA_RESV_USAGE_KERNEL(Thomas) Closes: https://gitlab.freedesktop.org/drm/xe/kernel/-/issues/3466 Fixes: 75521e8 ("drm/xe: Perform dma_map when moving system buffer objects to TT") Cc: Thomas Hellström <[email protected]> Cc: Matthew Brost <[email protected]> Cc: Lucas De Marchi <[email protected]> Cc: [email protected] # v6.11+ Cc: Matthew Auld <[email protected]> Reviewed-by: Matthew Auld <[email protected]> Reviewed-by: Thomas Hellström <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected] Signed-off-by: Nirmoy Das <[email protected]> (cherry picked from commit cda0641) Signed-off-by: Thomas Hellström <[email protected]>
1 parent 528cef1 commit 5e0a67f

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

drivers/gpu/drm/xe/xe_bo.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -848,8 +848,16 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
848848

849849
out:
850850
if ((!ttm_bo->resource || ttm_bo->resource->mem_type == XE_PL_SYSTEM) &&
851-
ttm_bo->ttm)
851+
ttm_bo->ttm) {
852+
long timeout = dma_resv_wait_timeout(ttm_bo->base.resv,
853+
DMA_RESV_USAGE_KERNEL,
854+
false,
855+
MAX_SCHEDULE_TIMEOUT);
856+
if (timeout < 0)
857+
ret = timeout;
858+
852859
xe_tt_unmap_sg(ttm_bo->ttm);
860+
}
853861

854862
return ret;
855863
}

0 commit comments

Comments
 (0)