]> www.infradead.org Git - users/hch/misc.git/commitdiff
drm/xe/svm: Ensure data will be migrated to system if indicated by madvise.
authorThomas Hellström <thomas.hellstrom@linux.intel.com>
Fri, 10 Oct 2025 10:41:48 +0000 (12:41 +0200)
committerLucas De Marchi <lucas.demarchi@intel.com>
Thu, 16 Oct 2025 05:48:37 +0000 (22:48 -0700)
If the location madvise() is set to
DRM_XE_PREFERRED_LOC_DEFAULT_SYSTEM, the drm_pagemap in the
SVM gpu fault handler will be set to NULL. However there is nothing
that explicitly migrates the data to system if it is already present
in device memory.

In that case, set the device memory owner to NULL to ensure
data gets properly migrated to system on page-fault.

v2:
- Remove redundant dpagemap assignment (Himal Prasad Ghimiray)

Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com> #v1
Reviewed-by: Himal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Link: https://lore.kernel.org/r/20251010104149.72783-2-thomas.hellstrom@linux.intel.com
Fixes: 10aa5c806030 ("drm/gpusvm, drm/xe: Fix userptr to not allow device private pages")
(cherry picked from commit 2cfcea7a745794f9b8e265a309717ca6ba335fc4)
Signed-off-by: Lucas De Marchi <lucas.demarchi@intel.com>
drivers/gpu/drm/xe/xe_svm.c

index b268ee0d227106ddf71976f728083883ef00e66e..da2a412f80c0fcd9834eddf455bebd735375a1d2 100644 (file)
@@ -1034,6 +1034,9 @@ retry:
        if (err)
                return err;
 
+       dpagemap = xe_vma_resolve_pagemap(vma, tile);
+       if (!dpagemap && !ctx.devmem_only)
+               ctx.device_private_page_owner = NULL;
        range = xe_svm_range_find_or_insert(vm, fault_addr, vma, &ctx);
 
        if (IS_ERR(range))
@@ -1054,7 +1057,6 @@ retry:
 
        range_debug(range, "PAGE FAULT");
 
-       dpagemap = xe_vma_resolve_pagemap(vma, tile);
        if (--migrate_try_count >= 0 &&
            xe_svm_range_needs_migrate_to_vram(range, vma, !!dpagemap || ctx.devmem_only)) {
                ktime_t migrate_start = xe_svm_stats_ktime_get();