All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Cc: matthew.auld@intel.com
Subject: [PATCH 10/15] drm/i915: Teach execbuffer to take the engine wakeref not GT
Date: Wed,  3 Jul 2019 10:17:21 +0100	[thread overview]
Message-ID: <20190703091726.11690-10-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20190703091726.11690-1-chris@chris-wilson.co.uk>

In the next patch, we would like to couple into the engine wakeref to
free the batch pool on idling. The caveat here is that we therefore want
to track the engine wakeref more precisely and to hold it instead of the
broader GT wakeref as we process the ioctl.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 .../gpu/drm/i915/gem/i915_gem_execbuffer.c    | 36 ++++++++++++-------
 drivers/gpu/drm/i915/gt/intel_context.h       |  7 ++++
 2 files changed, 31 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index 1c5dfbfad71b..f43eaaa5db5f 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -2143,13 +2143,35 @@ static int eb_pin_context(struct i915_execbuffer *eb, struct intel_context *ce)
 	if (err)
 		return err;
 
+	/*
+	 * Take a local wakeref for preparing to dispatch the execbuf as
+	 * we expect to access the hardware fairly frequently in the
+	 * process. Upon first dispatch, we acquire another prolonged
+	 * wakeref that we hold until the GPU has been idle for at least
+	 * 100ms.
+	 */
+	err = intel_context_timeline_lock(ce);
+	if (err)
+		goto err_unpin;
+
+	intel_context_enter(ce);
+	intel_context_timeline_unlock(ce);
+
 	eb->engine = ce->engine;
 	eb->context = ce;
 	return 0;
+
+err_unpin:
+	intel_context_unpin(ce);
+	return err;
 }
 
 static void eb_unpin_context(struct i915_execbuffer *eb)
 {
+	__intel_context_timeline_lock(eb->context);
+	intel_context_exit(eb->context);
+	intel_context_timeline_unlock(eb->context);
+
 	intel_context_unpin(eb->context);
 }
 
@@ -2430,18 +2452,9 @@ i915_gem_do_execbuffer(struct drm_device *dev,
 	if (unlikely(err))
 		goto err_destroy;
 
-	/*
-	 * Take a local wakeref for preparing to dispatch the execbuf as
-	 * we expect to access the hardware fairly frequently in the
-	 * process. Upon first dispatch, we acquire another prolonged
-	 * wakeref that we hold until the GPU has been idle for at least
-	 * 100ms.
-	 */
-	intel_gt_pm_get(&eb.i915->gt);
-
 	err = i915_mutex_lock_interruptible(dev);
 	if (err)
-		goto err_rpm;
+		goto err_context;
 
 	err = eb_select_engine(&eb, file, args);
 	if (unlikely(err))
@@ -2606,8 +2619,7 @@ i915_gem_do_execbuffer(struct drm_device *dev,
 	eb_unpin_context(&eb);
 err_unlock:
 	mutex_unlock(&dev->struct_mutex);
-err_rpm:
-	intel_gt_pm_put(&eb.i915->gt);
+err_context:
 	i915_gem_context_put(eb.gem_context);
 err_destroy:
 	eb_destroy(&eb);
diff --git a/drivers/gpu/drm/i915/gt/intel_context.h b/drivers/gpu/drm/i915/gt/intel_context.h
index 40cd8320fcc3..065ba4ac4e87 100644
--- a/drivers/gpu/drm/i915/gt/intel_context.h
+++ b/drivers/gpu/drm/i915/gt/intel_context.h
@@ -126,6 +126,13 @@ static inline void intel_context_put(struct intel_context *ce)
 	kref_put(&ce->ref, ce->ops->destroy);
 }
 
+static inline void
+__intel_context_timeline_lock(struct intel_context *ce)
+	__acquires(&ce->ring->timeline->mutex)
+{
+	mutex_lock(&ce->ring->timeline->mutex);
+}
+
 static inline int __must_check
 intel_context_timeline_lock(struct intel_context *ce)
 	__acquires(&ce->ring->timeline->mutex)
-- 
2.20.1

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

  parent reply	other threads:[~2019-07-03  9:19 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03  9:17 [PATCH 01/15] drm/i915/selftests: Common live setup/teardown Chris Wilson
2019-07-03  9:17 ` [PATCH 02/15] drm/i915/selftests: Lock the drm_mm while modifying Chris Wilson
2019-07-03  9:50   ` Matthew Auld
2019-07-03  9:17 ` [PATCH 03/15] drm/i915/gt: Use caller provided forcewake for intel_mocs_init_engine Chris Wilson
2019-07-03 11:23   ` Tvrtko Ursulin
2019-07-03 11:47     ` Chris Wilson
2019-07-03 12:01       ` Tvrtko Ursulin
2019-07-03  9:17 ` [PATCH 04/15] drm/i915/gt: Assume we hold forcewake for execlists resume Chris Wilson
2019-07-03 12:03   ` Tvrtko Ursulin
2019-07-03  9:17 ` [PATCH 05/15] drm/i915/gt: Ignore forcewake acquisition for posting_reads Chris Wilson
2019-07-03 11:26   ` Tvrtko Ursulin
2019-07-03 11:44     ` Chris Wilson
2019-07-03  9:17 ` [PATCH 06/15] drm/i915/gem: Free pages before rcu-freeing the object Chris Wilson
2019-07-03 10:37   ` Matthew Auld
2019-07-03  9:17 ` [PATCH 07/15] drm/i915: Markup potential lock for i915_active Chris Wilson
2019-07-03 10:38   ` Matthew Auld
2019-07-03  9:17 ` [PATCH 08/15] drm/i915: Mark up vma->active as safe for use inside shrinkers Chris Wilson
2019-07-03 10:53   ` Matthew Auld
2019-07-03  9:17 ` [PATCH 09/15] drm/i915/execlists: Hesitate before slicing Chris Wilson
2019-07-03  9:17 ` Chris Wilson [this message]
2019-07-03  9:17 ` [PATCH 11/15] drm/i915/gt: Track timeline activeness in enter/exit Chris Wilson
2019-07-03  9:17 ` [PATCH 12/15] drm/i915/gt: Convert timeline tracking to spinlock Chris Wilson
2019-07-03  9:17 ` [PATCH 13/15] drm/i915/gt: Guard timeline pinning with its own mutex Chris Wilson
2019-07-03  9:17 ` [PATCH 14/15] drm/i915: Protect request retirement with timeline->mutex Chris Wilson
2019-07-03  9:17 ` [PATCH 15/15] drm/i915: Replace struct_mutex for batch pool serialisation Chris Wilson
2019-07-03  9:41 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/15] drm/i915/selftests: Common live setup/teardown Patchwork
2019-07-03  9:47 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-07-03  9:48 ` [PATCH 01/15] " Matthew Auld
2019-07-03 10:04   ` Chris Wilson
2019-07-03  9:59 ` ✓ Fi.CI.BAT: success for series starting with [01/15] " Patchwork
2019-07-04  3:22 ` ✗ Fi.CI.IGT: failure " 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=20190703091726.11690-10-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=matthew.auld@intel.com \
    /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.