]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/xe: Wait for migration job before unmapping pages
authorNirmoy Das <nirmoy.das@intel.com>
Fri, 13 Dec 2024 12:24:15 +0000 (13:24 +0100)
committerNirmoy Das <nirmoy.das@intel.com>
Mon, 16 Dec 2024 12:46:42 +0000 (13:46 +0100)
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: 75521e8b56e8 ("drm/xe: Perform dma_map when moving system buffer objects to TT")
Cc: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: Lucas De Marchi <lucas.demarchi@intel.com>
Cc: stable@vger.kernel.org # v6.11+
Cc: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20241213122415.3880017-2-nirmoy.das@intel.com
Signed-off-by: Nirmoy Das <nirmoy.das@intel.com>
drivers/gpu/drm/xe/xe_bo.c

index 06931df876abae1b61f457c982e48b60ca336f81..e6c896ad5602a03c4040f1e9d477db0c201d468f 100644 (file)
@@ -857,8 +857,16 @@ static int xe_bo_move(struct ttm_buffer_object *ttm_bo, bool evict,
 
 out:
        if ((!ttm_bo->resource || ttm_bo->resource->mem_type == XE_PL_SYSTEM) &&
-           ttm_bo->ttm)
+           ttm_bo->ttm) {
+               long timeout = dma_resv_wait_timeout(ttm_bo->base.resv,
+                                                    DMA_RESV_USAGE_KERNEL,
+                                                    false,
+                                                    MAX_SCHEDULE_TIMEOUT);
+               if (timeout < 0)
+                       ret = timeout;
+
                xe_tt_unmap_sg(ttm_bo->ttm);
+       }
 
        return ret;
 }