Commit 03c346d4 authored by Thomas Hellström's avatar Thomas Hellström
Browse files

drm/xe/vm: Validate userptr during gpu vma prefetching



If a userptr vma subject to prefetching was already invalidated
or invalidated during the prefetch operation, the operation would
repeatedly return -EAGAIN which would typically cause an infinite
loop.

Validate the userptr to ensure this doesn't happen.

v2:
- Don't fallthrough from UNMAP to PREFETCH (Matthew Brost)

Fixes: 5bd24e78 ("drm/xe/vm: Subclass userptr vmas")
Fixes: 617eebb9 ("drm/xe: Fix array of binds")
Cc: Matthew Brost <matthew.brost@intel.com>
Cc: <stable@vger.kernel.org> # v6.9+
Suggested-by: default avatarMatthew Brost <matthew.brost@intel.com>
Signed-off-by: default avatarThomas Hellström <thomas.hellstrom@linux.intel.com>
Reviewed-by: default avatarMatthew Brost <matthew.brost@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20250228073058.59510-2-thomas.hellstrom@linux.intel.com
parent 5488bec9
Loading
Loading
Loading
Loading
+10 −1
Original line number Diff line number Diff line
@@ -2306,8 +2306,17 @@ static int vm_bind_ioctl_ops_parse(struct xe_vm *vm, struct drm_gpuva_ops *ops,
			break;
		}
		case DRM_GPUVA_OP_UNMAP:
			xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
			break;
		case DRM_GPUVA_OP_PREFETCH:
			/* FIXME: Need to skip some prefetch ops */
			vma = gpuva_to_vma(op->base.prefetch.va);

			if (xe_vma_is_userptr(vma)) {
				err = xe_vma_userptr_pin_pages(to_userptr_vma(vma));
				if (err)
					return err;
			}

			xe_vma_ops_incr_pt_update_ops(vops, op->tile_mask);
			break;
		default: