diff mbox series

[RFC,8/8] drm/i915/svm: VM_BIND for endless batch buffer

Message ID 20200124085402.11644-9-niranjana.vishwanathapura@intel.com (mailing list archive)
State New, archived
Headers show
Series drm/i915/svm: [WIP] SVM runtime allocator support | expand

Commit Message

Niranjana Vishwanathapura Jan. 24, 2020, 8:54 a.m. UTC
Initial attempt at supporting VM_BIND for  endless batch buffer.
Not tested.

Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Jon Bloomfield <jon.bloomfield@intel.com>
Cc: Daniel Vetter <daniel.vetter@intel.com>
Cc: Chris P Wilson <chris.p.wilson@intel.com>
Cc: Sudeep Dutt <sudeep.dutt@intel.com>
Cc: Stuart Summers <stuart.summers@intel.com>
Signed-off-by: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_svm.c | 11 +++++++++++
 1 file changed, 11 insertions(+)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_svm.c b/drivers/gpu/drm/i915/gem/i915_gem_svm.c
index e5e45ccc4262..dd12c2c46aa8 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_svm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_svm.c
@@ -68,9 +68,20 @@  int i915_gem_vm_bind_svm_obj(struct i915_address_space *vm,
 		 * and we don't need to store va_start.
 		 */
 		mutex_lock(&vm->svm_mutex);
+		if (i915_vm_is_active(vm)) {
+			u64 pin_flags = vma->va_start |
+					PIN_OFFSET_FIXED | PIN_USER;
+
+			ret = i915_vma_pin(vma, 0, 0, pin_flags);
+			if (ret) {
+				mutex_unlock(&vm->mutex);
+				goto put_obj;
+			}
+		}
 		list_add(&vma->svm_link, &vm->svm_list);
 		mutex_unlock(&vm->svm_mutex);
 	} else {
+		/* FIXME: Do async unbind if vm is active */
 		vma = i915_gem_vm_lookup_svm_vma(vm, obj, va);
 		if (vma) {
 			__i915_vma_unpin(vma);