Commit 41037f9f authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm/i915: Add i915_gem_request_unreference__unlocked

We were missing a convenience stub to aquire the right mutex whilst
dropping the request, so add it.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarTvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
parent 6d293983
...@@ -2142,6 +2142,19 @@ i915_gem_request_unreference(struct drm_i915_gem_request *req) ...@@ -2142,6 +2142,19 @@ i915_gem_request_unreference(struct drm_i915_gem_request *req)
kref_put(&req->ref, i915_gem_request_free); kref_put(&req->ref, i915_gem_request_free);
} }
static inline void
i915_gem_request_unreference__unlocked(struct drm_i915_gem_request *req)
{
if (req && !atomic_add_unless(&req->ref.refcount, -1, 1)) {
struct drm_device *dev = req->ring->dev;
mutex_lock(&dev->struct_mutex);
if (likely(atomic_dec_and_test(&req->ref.refcount)))
i915_gem_request_free(&req->ref);
mutex_unlock(&dev->struct_mutex);
}
}
static inline void i915_gem_request_assign(struct drm_i915_gem_request **pdst, static inline void i915_gem_request_assign(struct drm_i915_gem_request **pdst,
struct drm_i915_gem_request *src) struct drm_i915_gem_request *src)
{ {
......
...@@ -2866,9 +2866,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file) ...@@ -2866,9 +2866,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
ret = __i915_wait_request(req, reset_counter, true, ret = __i915_wait_request(req, reset_counter, true,
args->timeout_ns > 0 ? &args->timeout_ns : NULL, args->timeout_ns > 0 ? &args->timeout_ns : NULL,
file->driver_priv); file->driver_priv);
mutex_lock(&dev->struct_mutex); i915_gem_request_unreference__unlocked(req);
i915_gem_request_unreference(req);
mutex_unlock(&dev->struct_mutex);
return ret; return ret;
out: out:
...@@ -4071,9 +4069,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file) ...@@ -4071,9 +4069,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
if (ret == 0) if (ret == 0)
queue_delayed_work(dev_priv->wq, &dev_priv->mm.retire_work, 0); queue_delayed_work(dev_priv->wq, &dev_priv->mm.retire_work, 0);
mutex_lock(&dev->struct_mutex); i915_gem_request_unreference__unlocked(target);
i915_gem_request_unreference(target);
mutex_unlock(&dev->struct_mutex);
return ret; return ret;
} }
......
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