Re: [PATCH 04/49] drm/i915: Add i915_gem_request_unreference__unlocked

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




Hi,

I've noticed this one is a pre-requisite for read-read optimisation...

On 03/27/2015 11:01 AM, Chris Wilson wrote:
We were missing a convenience stub to aquire the right mutex whilst
dropping the request, so add it.

Signed-off-by: Chris Wilson <chris@xxxxxxxxxxxxxxxxxx>
---
  drivers/gpu/drm/i915/i915_drv.h | 13 +++++++++++++
  drivers/gpu/drm/i915/i915_gem.c |  8 ++------
  2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index c80e2e5e591a..fa91ca33d07c 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2149,6 +2149,19 @@ i915_gem_request_unreference(struct drm_i915_gem_request *req)
  	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,
  					   struct drm_i915_gem_request *src)
  {
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 476687a9d067..a46372ebb3bc 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -2870,9 +2870,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
  	ret = __i915_wait_request(req, reset_counter, true,
  				  args->timeout_ns > 0 ? &args->timeout_ns : NULL,
  				  file->driver_priv);
-	mutex_lock(&dev->struct_mutex);
-	i915_gem_request_unreference(req);
-	mutex_unlock(&dev->struct_mutex);
+	i915_gem_request_unreference__unlocked(req);
  	return ret;

  out:
@@ -4104,9 +4102,7 @@ i915_gem_ring_throttle(struct drm_device *dev, struct drm_file *file)
  	if (ret == 0)
  		queue_delayed_work(dev_priv->wq, &dev_priv->mm.retire_work, 0);

-	mutex_lock(&dev->struct_mutex);
-	i915_gem_request_unreference(target);
-	mutex_unlock(&dev->struct_mutex);
+	i915_gem_request_unreference__unlocked(target);

  	return ret;
  }


Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@xxxxxxxxx>

Regards,

Tvrtko
_______________________________________________
Intel-gfx mailing list
Intel-gfx@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/intel-gfx





[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux