All of lore.kernel.org
 help / color / mirror / Atom feed
From: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
To: intel-gfx@lists.freedesktop.org
Cc: chris.p.wilson@intel.com, jason.ekstrand@intel.com,
	daniel.vetter@intel.com
Subject: [Intel-gfx] [RFC 5/8] drm/i915/svm: Handle persistent vmas
Date: Fri, 24 Jan 2020 00:53:59 -0800	[thread overview]
Message-ID: <20200124085402.11644-6-niranjana.vishwanathapura@intel.com> (raw)
In-Reply-To: <20200124085402.11644-1-niranjana.vishwanathapura@intel.com>

Treat VM_BIND vmas as persistent and handle them during the
request submission in the execbuff path.

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>
---
 .../gpu/drm/i915/gem/i915_gem_execbuffer.c    | 26 +++++++++++++++++++
 drivers/gpu/drm/i915/gem/i915_gem_svm.c       |  1 +
 drivers/gpu/drm/i915/gt/intel_gtt.c           | 10 +++++++
 drivers/gpu/drm/i915/i915_vma.h               | 15 ++++++++++-
 drivers/gpu/drm/i915/i915_vma_types.h         |  4 +++
 5 files changed, 55 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index b3d9a4a02568..6aaffb9a817f 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -723,6 +723,26 @@ static int eb_select_context(struct i915_execbuffer *eb)
 	return 0;
 }
 
+static int eb_lookup_persistent_vmas(struct i915_address_space *vm)
+{
+	struct i915_vma *vma;
+	int ret = 0;
+
+	mutex_lock(&vm->svm_mutex);
+	list_for_each_entry(vma, &vm->svm_list, svm_link) {
+		u64 pin_flags = vma->va_start | PIN_OFFSET_FIXED | PIN_USER;
+
+		if (drm_mm_node_allocated(&vma->node))
+			continue;
+
+		ret = i915_vma_pin(vma, 0, 0, pin_flags);
+		if (ret)
+			break;
+	}
+	mutex_unlock(&vm->svm_mutex);
+	return ret;
+}
+
 static int eb_lookup_vmas(struct i915_execbuffer *eb)
 {
 	struct radix_tree_root *handles_vma = &eb->gem_context->handles_vma;
@@ -1765,6 +1785,12 @@ static noinline int eb_relocate_slow(struct i915_execbuffer *eb)
 
 static int eb_relocate(struct i915_execbuffer *eb)
 {
+	int ret;
+
+	ret = eb_lookup_persistent_vmas(eb->context->vm);
+	if (ret)
+		return ret;
+
 	if (eb_lookup_vmas(eb))
 		goto slow;
 
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_svm.c b/drivers/gpu/drm/i915/gem/i915_gem_svm.c
index f26567ea0e3a..e5e45ccc4262 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_svm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_svm.c
@@ -58,6 +58,7 @@ int i915_gem_vm_bind_svm_obj(struct i915_address_space *vm,
 			goto put_obj;
 		}
 		vma->va_start = va->start;
+		i915_vma_set_persistent(vma);
 		/* Disable eviction for now */
 		__i915_vma_pin(vma);
 
diff --git a/drivers/gpu/drm/i915/gt/intel_gtt.c b/drivers/gpu/drm/i915/gt/intel_gtt.c
index 897aad1f7c08..e0195906de20 100644
--- a/drivers/gpu/drm/i915/gt/intel_gtt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gtt.c
@@ -234,9 +234,19 @@ static inline struct i915_address_space *active_to_vm(struct i915_active *ref)
 int i915_vm_move_to_active(struct i915_address_space *vm,
 			   struct i915_request *rq)
 {
+	struct i915_vma *vma;
 	int ret = 0;
 
 	mutex_lock(&vm->svm_mutex);
+	list_for_each_entry(vma, &vm->svm_list, svm_link) {
+		/* Wait for the vma to be bound before we start! */
+		ret = i915_request_await_active(rq, &vma->active);
+		if (ret)
+			break;
+
+		if (!ret)
+			ret = i915_active_add_request(&vm->active, rq);
+	}
 	ret = i915_active_add_request(&vm->active, rq);
 	mutex_unlock(&vm->svm_mutex);
 	return ret;
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index 044f3400575c..56cff222e7ca 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -124,6 +124,16 @@ static inline u32 i915_ggtt_pin_bias(struct i915_vma *vma)
 	return i915_vm_to_ggtt(vma->vm)->pin_bias;
 }
 
+static inline bool i915_vma_is_persistent(const struct i915_vma *vma)
+{
+	return test_bit(I915_VMA_PERSISTENT_BIT, __i915_vma_flags(vma));
+}
+
+static inline void i915_vma_set_persistent(struct i915_vma *vma)
+{
+	set_bit(I915_VMA_PERSISTENT_BIT, __i915_vma_flags(vma));
+}
+
 static inline struct i915_vma *i915_vma_get(struct i915_vma *vma)
 {
 	i915_gem_object_get(vma->obj);
@@ -376,7 +386,10 @@ void i915_vma_make_purgeable(struct i915_vma *vma);
 static inline int i915_vma_sync(struct i915_vma *vma)
 {
 	/* Wait for the asynchronous bindings and pending GPU reads */
-	return i915_active_wait(&vma->active);
+	if (i915_vma_is_persistent(vma))
+		return i915_vm_sync(vma->vm);
+	else
+		return i915_active_wait(&vma->active);
 }
 
 #endif
diff --git a/drivers/gpu/drm/i915/i915_vma_types.h b/drivers/gpu/drm/i915/i915_vma_types.h
index d5a4fb4e43a4..8a270280a5ca 100644
--- a/drivers/gpu/drm/i915/i915_vma_types.h
+++ b/drivers/gpu/drm/i915/i915_vma_types.h
@@ -250,6 +250,10 @@ struct i915_vma {
 #define I915_VMA_USERFAULT	((int)BIT(I915_VMA_USERFAULT_BIT))
 #define I915_VMA_GGTT_WRITE	((int)BIT(I915_VMA_GGTT_WRITE_BIT))
 
+#define I915_VMA_PERSISTENT_BIT	18
+
+#define I915_VMA_PERSISTENT	((int)BIT(I915_VMA_PERSISTENT_BIT))
+
 	struct i915_active active;
 
 #define I915_VMA_PAGES_BIAS 24
-- 
2.21.0.rc0.32.g243a4c7e27

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2020-01-24  9:06 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-01-24  8:53 [Intel-gfx] [RFC 0/8] drm/i915/svm: [WIP] SVM runtime allocator support Niranjana Vishwanathapura
2020-01-24  8:53 ` [Intel-gfx] [RFC 1/8] drm/i915/svm: Support partial binding in ppgtt Niranjana Vishwanathapura
2020-01-24  8:53 ` [Intel-gfx] [RFC 2/8] drm/i915/svm: Add support to mark VMs as active Niranjana Vishwanathapura
2020-01-24  8:53 ` [Intel-gfx] [RFC 3/8] drm/i915/svm: Introduce VM_BIND ioctl Niranjana Vishwanathapura
2020-01-25 14:49   ` kbuild test robot
2020-01-26  7:35   ` kbuild test robot
2020-01-24  8:53 ` [Intel-gfx] [RFC 4/8] drm/i915/svm: Manage SVM bindings added using VM_BIND Niranjana Vishwanathapura
2020-01-24  8:53 ` Niranjana Vishwanathapura [this message]
2020-01-24  8:54 ` [Intel-gfx] [RFC 6/8] drm/i915/svm: Skip vma_lookup for persistent vmas Niranjana Vishwanathapura
2020-01-24  8:54 ` [Intel-gfx] [RFC 7/8] drm/i915/svm: Add support to en/disable SVM Niranjana Vishwanathapura
2020-01-25 16:40   ` kbuild test robot
2020-01-24  8:54 ` [Intel-gfx] [RFC 8/8] drm/i915/svm: VM_BIND for endless batch buffer Niranjana Vishwanathapura
2020-01-24  9:54 ` [Intel-gfx] ✗ Fi.CI.BUILD: failure for drm/i915/svm: [WIP] SVM runtime allocator support Patchwork
2020-01-24 18:54 ` [Intel-gfx] [RFC 0/8] " Niranjana Vishwanathapura

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200124085402.11644-6-niranjana.vishwanathapura@intel.com \
    --to=niranjana.vishwanathapura@intel.com \
    --cc=chris.p.wilson@intel.com \
    --cc=daniel.vetter@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=jason.ekstrand@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.