summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/i915_gem_evict.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-08-04 07:52:45 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2016-08-04 08:09:33 +0100
commitb1f788c6acb2f34622dd5f4c3d5210c6e3945e78 (patch)
treea03c247cf86bee1df25f3271b504ad4b036264f5 /drivers/gpu/drm/i915/i915_gem_evict.c
parentb0decaf75bd902a11c932005c88924947ac00b8c (diff)
drm/i915: Release vma when the handle is closed
In order to prevent a leak of the vma on shared objects, we need to hook into the object_close callback to destroy the vma on the object for this file. However, if we destroyed that vma immediately we may cause unexpected application stalls as we try to unbind a busy vma - hence we defer the unbind to when we retire the vma. v2: Keep vma allocated until closed. This is useful for a later optimisation, but it is required now in order to handle potential recursion of i915_vma_unbind() by retiring itself. v3: Comments are important. Testcase: igt/gem_ppggtt/flink-and-close-vma-leak Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Tvrtko Ursulin <tvrtko.ursulin@linux.intel.com> Cc: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1470293567-10811-26-git-send-email-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem_evict.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem_evict.c8
1 files changed, 2 insertions, 6 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c
index 81f7b4383d5e..3437ced76cb6 100644
--- a/drivers/gpu/drm/i915/i915_gem_evict.c
+++ b/drivers/gpu/drm/i915/i915_gem_evict.c
@@ -182,8 +182,8 @@ found:
struct i915_vma,
exec_list);
if (drm_mm_scan_remove_block(&vma->node)) {
+ vma->pin_count++;
list_move(&vma->exec_list, &eviction_list);
- i915_gem_object_get(vma->obj);
continue;
}
list_del_init(&vma->exec_list);
@@ -191,18 +191,14 @@ found:
/* Unbinding will emit any required flushes */
while (!list_empty(&eviction_list)) {
- struct drm_i915_gem_object *obj;
-
vma = list_first_entry(&eviction_list,
struct i915_vma,
exec_list);
- obj = vma->obj;
list_del_init(&vma->exec_list);
+ vma->pin_count--;
if (ret == 0)
ret = i915_vma_unbind(vma);
-
- i915_gem_object_put(obj);
}
return ret;