aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/i915/i915_vma.h
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2019-08-20 11:05:31 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2019-08-20 14:23:45 +0100
commit2833ddccbdb4a23d79070603eb271acb680818e2 (patch)
tree194052224b99a31d52fd12e3d20e92b9f22a68a2 /drivers/gpu/drm/i915/i915_vma.h
parentdrm/i915: Serialize insertion into the file->mm.request_list (diff)
downloadlinux-dev-2833ddccbdb4a23d79070603eb271acb680818e2.tar.xz
linux-dev-2833ddccbdb4a23d79070603eb271acb680818e2.zip
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: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20190820100531.8430-1-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/i915/i915_vma.h')
-rw-r--r--drivers/gpu/drm/i915/i915_vma.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/drivers/gpu/drm/i915/i915_vma.h b/drivers/gpu/drm/i915/i915_vma.h
index b3d2121be947..59dfe5246001 100644
--- a/drivers/gpu/drm/i915/i915_vma.h
+++ b/drivers/gpu/drm/i915/i915_vma.h
@@ -231,6 +231,14 @@ static inline struct i915_vma *i915_vma_get(struct i915_vma *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)
{
i915_gem_object_put(vma->obj);