[PATCH] drm/i915: Only defer destruction of user vma
Chris Wilson
chris at chris-wilson.co.uk
Mon Mar 25 14:36:25 UTC 2019
We defer destroying user vma until idle in order to facilitate recycling
of obj->vma. Userspace has the habit of destroying a vma only to reuse
it on the next frame (e.g. passing a dma-buf from the client to
compositors, with the back buffer alternating every frame, but being
freed after importing and use every time). However, that deferral has no
advantage for internal vma (allocated for ringbuffers, context images
etc) as we know they will not be reused by the user.
Fixes: 3365e2268b6b ("drm/i915: Lazily unbind vma on close")
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Tvrtko Ursulin <tvrtko.ursulin at intel.com>
---
drivers/gpu/drm/i915/i915_gem_execbuffer.c | 1 +
drivers/gpu/drm/i915/i915_vma.c | 7 ++++++-
drivers/gpu/drm/i915/i915_vma.h | 5 +++--
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/i915/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
index 3d672c9edb94..08a809cdb65e 100644
--- a/drivers/gpu/drm/i915/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/i915_gem_execbuffer.c
@@ -867,6 +867,7 @@ static int eb_lookup_vmas(struct i915_execbuffer *eb)
}
/* transfer ref to ctx */
+ vma->flags |= I915_VMA_USER;
if (!vma->open_count++)
i915_vma_reopen(vma);
list_add(&lut->obj_link, &obj->lut_list);
diff --git a/drivers/gpu/drm/i915/i915_vma.c b/drivers/gpu/drm/i915/i915_vma.c
index 36726392e737..48e901f5e772 100644
--- a/drivers/gpu/drm/i915/i915_vma.c
+++ b/drivers/gpu/drm/i915/i915_vma.c
@@ -804,7 +804,12 @@ void i915_vma_close(struct i915_vma *vma)
* causing us to rebind the VMA once more. This ends up being a lot
* of wasted work for the steady state.
*/
- list_add_tail(&vma->closed_link, &vma->vm->i915->gt.closed_vma);
+ if (vma->flags & I915_VMA_USER) {
+ list_add_tail(&vma->closed_link, &vma->vm->i915->gt.closed_vma);
+ return;
+ }
+
+ i915_vma_destroy(vma);
}
void i915_vma_reopen(struct i915_vma *vma)
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index 6eab70953a57..88b0a3e956a7 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -105,9 +105,10 @@ struct i915_vma {
#define I915_VMA_GGTT BIT(11)
#define I915_VMA_CAN_FENCE BIT(12)
#define I915_VMA_CLOSED BIT(13)
-#define I915_VMA_USERFAULT_BIT 14
+#define I915_VMA_USER BIT(14)
+#define I915_VMA_USERFAULT_BIT 15
#define I915_VMA_USERFAULT BIT(I915_VMA_USERFAULT_BIT)
-#define I915_VMA_GGTT_WRITE BIT(15)
+#define I915_VMA_GGTT_WRITE BIT(16)
struct i915_active active;
struct i915_active_request last_fence;
--
2.20.1
More information about the Intel-gfx-trybot
mailing list