Commit 2833ddcc authored by Chris Wilson's avatar Chris Wilson

drm/i915: Be defensive when starting vma activity

Before we acquire the vma for GPU activity, ensure that the underlying
object is not already in the process of being freed.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarMatthew Auld <matthew.auld@intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20190820100531.8430-1-chris@chris-wilson.co.uk
parent 44c22f3f
...@@ -87,8 +87,7 @@ static inline struct i915_vma *active_to_vma(struct i915_active *ref) ...@@ -87,8 +87,7 @@ static inline struct i915_vma *active_to_vma(struct i915_active *ref)
static int __i915_vma_active(struct i915_active *ref) static int __i915_vma_active(struct i915_active *ref)
{ {
i915_vma_get(active_to_vma(ref)); return i915_vma_tryget(active_to_vma(ref)) ? 0 : -ENOENT;
return 0;
} }
static void __i915_vma_retire(struct i915_active *ref) static void __i915_vma_retire(struct i915_active *ref)
......
...@@ -231,6 +231,14 @@ static inline struct i915_vma *i915_vma_get(struct i915_vma *vma) ...@@ -231,6 +231,14 @@ static inline struct i915_vma *i915_vma_get(struct i915_vma *vma)
return vma; return vma;
} }
static inline struct i915_vma *i915_vma_tryget(struct i915_vma *vma)
{
if (likely(kref_get_unless_zero(&vma->obj->base.refcount)))
return vma;
return NULL;
}
static inline void i915_vma_put(struct i915_vma *vma) static inline void i915_vma_put(struct i915_vma *vma)
{ {
i915_gem_object_put(vma->obj); i915_gem_object_put(vma->obj);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment