[RFC PATCH 136/162] drm/i915: create and destroy dummy vma

Matthew Auld matthew.auld at intel.com
Fri Nov 27 12:06:52 UTC 2020


From: Ramalingam C <ramalingam.c at intel.com>

Functions for window_blt_copy defined to create and destroy
the dummy vmas for virtual memory, which dont have any associated
objects.

These dummy vmas are used at window_blt_copy festure to associated to
set of pages and create ptes at runtime and submit it for blt copy.

Signed-off-by: Ramalingam C <ramalingam.c at intel.com>
Cc: Matthew Auld <matthew.auld at intel.com>
Cc: CQ Tang <cq.tang at intel.com>
---
 drivers/gpu/drm/i915/i915_vma.c | 38 +++++++++++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_vma.h |  6 ++++++
 2 files changed, 44 insertions(+)

diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 59fe82af48b2..5537950e310f 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -100,6 +100,44 @@ static void __i915_vma_retire(struct i915_active *ref)
 	i915_vma_put(active_to_vma(ref));
 }
 
+struct i915_vma *
+i915_alloc_window_vma(struct drm_i915_private *i915,
+		      struct i915_address_space *vm, u64 size,
+		      u64 min_page_size)
+{
+	struct i915_vma *vma;
+
+	vma = i915_vma_alloc();
+	if (!vma)
+		return ERR_PTR(-ENOMEM);
+
+	kref_init(&vma->ref);
+	mutex_init(&vma->pages_mutex);
+	vma->vm = i915_vm_get(vm);
+	vma->ops = &vm->vma_ops;
+	vma->obj = NULL;
+	vma->resv = NULL;
+	vma->size = size;
+	vma->display_alignment = I915_GTT_MIN_ALIGNMENT;
+	vma->page_sizes.sg = min_page_size;
+
+	i915_active_init(&vma->active, __i915_vma_active, __i915_vma_retire);
+	INIT_LIST_HEAD(&vma->closed_link);
+
+	GEM_BUG_ON(!IS_ALIGNED(vma->size, I915_GTT_PAGE_SIZE));
+	GEM_BUG_ON(i915_is_ggtt(vm));
+
+	return vma;
+}
+
+void i915_destroy_window_vma(struct i915_vma *vma)
+{
+	i915_active_fini(&vma->active);
+	i915_vm_put(vma->vm);
+	mutex_destroy(&vma->pages_mutex);
+	i915_vma_free(vma);
+}
+
 static struct i915_vma *
 vma_create(struct drm_i915_gem_object *obj,
 	   struct i915_address_space *vm,
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index 2db4f25b8d5f..f595fe706010 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -44,6 +44,12 @@ i915_vma_instance(struct drm_i915_gem_object *obj,
 		  struct i915_address_space *vm,
 		  const struct i915_ggtt_view *view);
 
+struct i915_vma *
+i915_alloc_window_vma(struct drm_i915_private *i915,
+		      struct i915_address_space *vm, u64 size,
+		      u64 min_page_size);
+void i915_destroy_window_vma(struct i915_vma *vma);
+
 void i915_vma_unpin_and_release(struct i915_vma **p_vma, unsigned int flags);
 #define I915_VMA_RELEASE_MAP BIT(0)
 
-- 
2.26.2



More information about the dri-devel mailing list