[v2 17/31] drm/xe: Get xe_vma from xe_userptr

Oak Zeng oak.zeng at intel.com
Tue Apr 9 20:17:28 UTC 2024


Introduce a helper to get xe_vma from xe_userptr.

Signed-off-by: Oak Zeng <oak.zeng at intel.com>
---
 drivers/gpu/drm/xe/xe_vm.h | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/drivers/gpu/drm/xe/xe_vm.h b/drivers/gpu/drm/xe/xe_vm.h
index 0b2790f697db..4860747592ad 100644
--- a/drivers/gpu/drm/xe/xe_vm.h
+++ b/drivers/gpu/drm/xe/xe_vm.h
@@ -178,6 +178,20 @@ static inline struct xe_userptr_vma *to_userptr_vma(struct xe_vma *vma)
 	return container_of(vma, struct xe_userptr_vma, vma);
 }
 
+/**
+ * xe_userptr_to_vma() - Return xe_vma from a xe_userptr pointer
+ *
+ * @userptr: The userptr struct pointer
+ */
+
+static inline struct xe_vma *xe_userptr_to_vma(struct xe_userptr *userptr)
+{
+	struct xe_userptr_vma *uvma;
+
+	uvma = container_of(userptr, struct xe_userptr_vma, userptr);
+	return &uvma->vma;
+}
+
 u64 xe_vm_pdp4_descriptor(struct xe_vm *vm, struct xe_tile *tile);
 
 int xe_vm_create_ioctl(struct drm_device *dev, void *data,
-- 
2.26.3



More information about the Intel-xe mailing list