Commit 7987b93e authored by Thomas Hellström's avatar Thomas Hellström Committed by Lucas De Marchi
Browse files

drm/xe/svm: Ensure data will be migrated to system if indicated by madvise.



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: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com> #v1
Reviewed-by: default avatarHimal Prasad Ghimiray <himal.prasad.ghimiray@intel.com>
Link: https://lore.kernel.org/r/20251010104149.72783-2-thomas.hellstrom@linux.intel.com


Fixes: 10aa5c80 ("drm/gpusvm, drm/xe: Fix userptr to not allow device private pages")
(cherry picked from commit 2cfcea7a)
Signed-off-by: default avatarLucas De Marchi <lucas.demarchi@intel.com>
parent 9f64b3cd
Loading
Loading
Loading
Loading
+3 −1
Original line number Diff line number Diff line
@@ -1034,6 +1034,9 @@ static int __xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,
	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 @@ static int __xe_svm_handle_pagefault(struct xe_vm *vm, struct xe_vma *vma,

	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();