summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/i915/i915_gem.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-12-22 21:02:55 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2019-12-23 12:31:54 +0000
commit76f9764cc3d538435262dea885bf69fac2415402 (patch)
tree480bf43fb3319a28f171f9fbbb23499235814ea3 /drivers/gpu/drm/i915/i915_gem.c
parentf5af1659d809e264d619e5f483fd8f47bced3b6a (diff)
drm/i915: Introduce a vma.kref
Start introducing a kref on i915_vma in order to protect the vma unbind (i915_gem_object_unbind) from a parallel destruction (i915_vma_parked). Later, we will use the refcount to manage all access and turn i915_vma into a first class container. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk> Cc: Imre Deak <imre.deak@intel.com> Acked-by: Imre Deak <imre.deak@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20191222210256.2066451-2-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_gem.c')
-rw-r--r--drivers/gpu/drm/i915/i915_gem.c27
1 files changed, 9 insertions, 18 deletions
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index e9f82e9cb6ff..9ddcf17230e6 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -136,7 +136,6 @@ try_again:
struct i915_vma,
obj_link))) {
struct i915_address_space *vm = vma->vm;
- bool awake = false;
list_move_tail(&vma->obj_link, &still_in_list);
if (!i915_vma_is_bound(vma, I915_VMA_BIND_MASK))
@@ -147,26 +146,18 @@ try_again:
break;
/* Prevent vma being freed by i915_vma_parked as we unbind */
- if (intel_gt_pm_get_if_awake(vm->gt)) {
- awake = true;
- } else {
- if (i915_vma_is_closed(vma)) {
- spin_unlock(&obj->vma.lock);
- i915_vma_parked(vm->gt);
- goto err_vm;
- }
- }
-
+ vma = __i915_vma_get(vma);
spin_unlock(&obj->vma.lock);
- ret = -EBUSY;
- if (flags & I915_GEM_OBJECT_UNBIND_ACTIVE ||
- !i915_vma_is_active(vma))
- ret = i915_vma_unbind(vma);
+ if (vma) {
+ ret = -EBUSY;
+ if (flags & I915_GEM_OBJECT_UNBIND_ACTIVE ||
+ !i915_vma_is_active(vma))
+ ret = i915_vma_unbind(vma);
+
+ __i915_vma_put(vma);
+ }
- if (awake)
- intel_gt_pm_put(vm->gt);
-err_vm:
i915_vm_close(vm);
spin_lock(&obj->vma.lock);
}