All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v3 17/21] drm/i915: Move releasing of the GEM request from free to retire/cancel
Date: Sun, 24 Apr 2016 19:10:15 +0100	[thread overview]
Message-ID: <1461521419-18086-17-git-send-email-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <1461521419-18086-1-git-send-email-chris@chris-wilson.co.uk>

If we move the release of the GEM request (i.e. decoupling it from the
various lists used for client and context tracking) after it is complete
(either by the GPU retiring the request, or by the caller cancelling the
request), we can remove the requirement that the final unreference of
the GEM request need to be under the struct_mutex.

The careful reader may notice that one or two impossible NULL pointer
tests are dropped for readability. These pointers cannot be NULL since
they are assigned during request construction and never unset.

v2,v3: Rebalance execlists by moving the context unpinning.
v4: Rebase onto -nightly
v5: Avoid trying to rebalance execlist/GuC context pinning, leave that
to the next step

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h      | 14 --------------
 drivers/gpu/drm/i915/i915_gem.c      | 23 +++++++++--------------
 drivers/gpu/drm/i915/intel_display.c |  2 +-
 drivers/gpu/drm/i915/intel_pm.c      |  2 +-
 4 files changed, 11 insertions(+), 30 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index e4b510bcee62..a26a026ef8e2 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2370,23 +2370,9 @@ i915_gem_request_reference(struct drm_i915_gem_request *req)
 static inline void
 i915_gem_request_unreference(struct drm_i915_gem_request *req)
 {
-	WARN_ON(!mutex_is_locked(&req->engine->dev->struct_mutex));
 	kref_put(&req->ref, i915_gem_request_free);
 }
 
-static inline void
-i915_gem_request_unreference__unlocked(struct drm_i915_gem_request *req)
-{
-	struct drm_device *dev;
-
-	if (!req)
-		return;
-
-	dev = req->engine->dev;
-	if (kref_put_mutex(&req->ref, i915_gem_request_free, &dev->struct_mutex))
-		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 40e9a0e0f298..7793f0086523 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -1413,6 +1413,13 @@ static void i915_gem_request_retire(struct drm_i915_gem_request *request)
 	list_del_init(&request->list);
 	i915_gem_request_remove_from_client(request);
 
+	if (request->ctx) {
+		if (i915.enable_execlists)
+			intel_lr_context_unpin(request->ctx, request->engine);
+
+		i915_gem_context_unreference(request->ctx);
+	}
+
 	i915_gem_request_unreference(request);
 }
 
@@ -2705,18 +2712,6 @@ void i915_gem_request_free(struct kref *req_ref)
 {
 	struct drm_i915_gem_request *req = container_of(req_ref,
 						 typeof(*req), ref);
-	struct intel_context *ctx = req->ctx;
-
-	if (req->file_priv)
-		i915_gem_request_remove_from_client(req);
-
-	if (ctx) {
-		if (i915.enable_execlists)
-			intel_lr_context_unpin(ctx, req->engine);
-
-		i915_gem_context_unreference(ctx);
-	}
-
 	kmem_cache_free(req->i915->requests, req);
 }
 
@@ -3178,7 +3173,7 @@ i915_gem_wait_ioctl(struct drm_device *dev, void *data, struct drm_file *file)
 			ret = __i915_wait_request(req[i], true,
 						  args->timeout_ns > 0 ? &args->timeout_ns : NULL,
 						  to_rps_client(file));
-		i915_gem_request_unreference__unlocked(req[i]);
+		i915_gem_request_unreference(req[i]);
 	}
 	return ret;
 
@@ -4204,7 +4199,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);
 
-	i915_gem_request_unreference__unlocked(target);
+	i915_gem_request_unreference(target);
 
 	return ret;
 }
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index a59fe7b032b0..4d440eee230a 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11399,7 +11399,7 @@ static void intel_mmio_flip_work_func(struct work_struct *work)
 		WARN_ON(__i915_wait_request(mmio_flip->req,
 					    false, NULL,
 					    &mmio_flip->i915->rps.mmioflips));
-		i915_gem_request_unreference__unlocked(mmio_flip->req);
+		i915_gem_request_unreference(mmio_flip->req);
 	}
 
 	/* For framebuffer backed by dmabuf, wait for fence */
diff --git a/drivers/gpu/drm/i915/intel_pm.c b/drivers/gpu/drm/i915/intel_pm.c
index 695a464a5e64..2422ac38ce5d 100644
--- a/drivers/gpu/drm/i915/intel_pm.c
+++ b/drivers/gpu/drm/i915/intel_pm.c
@@ -7385,7 +7385,7 @@ static void __intel_rps_boost_work(struct work_struct *work)
 		gen6_rps_boost(to_i915(req->engine->dev), NULL,
 			       req->emitted_jiffies);
 
-	i915_gem_request_unreference__unlocked(req);
+	i915_gem_request_unreference(req);
 	kfree(boost);
 }
 
-- 
2.8.1

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

  parent reply	other threads:[~2016-04-24 18:10 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-24 18:09 [PATCH v3 01/21] drm/i915/fbdev: Call intel_unpin_fb_obj() on release Chris Wilson
2016-04-24 18:10 ` [PATCH v3 02/21] drm/i915/overlay: Replace i915_gem_obj_ggtt_offset() with the known flip_addr Chris Wilson
2016-04-24 18:10 ` [PATCH v3 03/21] io-mapping: Specify mapping size for io_mapping_map_wc() Chris Wilson
2016-04-24 18:10   ` Chris Wilson
2016-04-24 18:10   ` Chris Wilson
2016-04-24 18:10 ` [PATCH v3 04/21] drm/i915: Introduce i915_vm_to_ggtt() Chris Wilson
2016-04-24 18:10 ` [PATCH v3 05/21] drm/i915: Move ioremap_wc tracking onto VMA Chris Wilson
2016-04-24 18:10 ` [PATCH v3 06/21] drm/i915: Use i915_vma_pin_iomap on the ringbuffer object Chris Wilson
2016-04-24 18:10 ` [PATCH v3 07/21] drm/i915: Mark the current context as lost on suspend Chris Wilson
2016-04-24 18:10 ` [PATCH v3 08/21] drm/i915: L3 cache remapping is part of context switching Chris Wilson
2016-04-24 18:10 ` [PATCH v3 09/21] drm/i915: Consolidate L3 remapping LRI Chris Wilson
2016-04-24 18:10 ` [PATCH v3 10/21] drm/i915: Remove early l3-remap Chris Wilson
2016-04-24 18:10 ` [PATCH v3 11/21] drm/i915: Rearrange switch_context to load the aliasing ppgtt on first use Chris Wilson
2016-04-24 18:10 ` [PATCH v3 12/21] drm/i915: Assign every HW context a unique ID Chris Wilson
2016-04-24 18:10 ` [PATCH v3 13/21] drm/i915: Replace the pinned context address with its " Chris Wilson
2016-04-25 15:21   ` Dave Gordon
2016-04-25 15:48     ` Chris Wilson
2016-04-26  8:06       ` Dave Gordon
2016-04-26  8:40         ` Chris Wilson
2016-04-24 18:10 ` [PATCH v3 14/21] drm/i915: Refactor execlists default context pinning Chris Wilson
2016-04-24 18:10 ` [PATCH v3 15/21] drm/i915: Move context initialisation to first-use Chris Wilson
2016-04-24 18:10 ` [PATCH v3 16/21] drm/i915: Move the magical deferred context allocation into the request Chris Wilson
2016-04-24 18:10 ` Chris Wilson [this message]
2016-04-24 18:10 ` [PATCH v3 18/21] drm/i915: Track the previous pinned context inside " Chris Wilson
2016-04-24 18:10 ` [PATCH v3 19/21] drm/i915: Store LRC hardware id in " Chris Wilson
2016-04-24 18:10 ` [PATCH v3 20/21] drm/i915: Stop tracking execlists retired requests Chris Wilson
2016-04-24 18:10 ` [PATCH v3 21/21] drm/i915: Unify GPU resets upon shutdown Chris Wilson
2016-04-25  9:42   ` Mika Kuoppala
2016-04-25 17:25   ` Ville Syrjälä
2016-04-25 17:45     ` Chris Wilson
2016-04-25 18:42       ` Ville Syrjälä
2016-04-25  8:20 ` ✗ Fi.CI.BAT: warning for series starting with [v3,01/21] drm/i915/fbdev: Call intel_unpin_fb_obj() on release Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1461521419-18086-17-git-send-email-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.