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 05/14] drm/i915: Remove delay for idle_work
Date: Wed,  1 May 2019 12:45:32 +0100	[thread overview]
Message-ID: <20190501114541.10077-5-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20190501114541.10077-1-chris@chris-wilson.co.uk>

The original intent for the delay before running the idle_work was to
provide a hysteresis to avoid ping-ponging the device runtime-pm. Since
then we have also pulled in some memory management and general device
management for parking. But with the inversion of the wakeref handling,
GEM is no longer responsible for the wakeref and by the time we call the
idle_work, the device is asleep. It seems appropriate now to drop the
delay and just run the worker immediately to flush the cached GEM state
before sleeping.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_debugfs.c           |  2 +-
 drivers/gpu/drm/i915/i915_drv.h               |  2 +-
 drivers/gpu/drm/i915/i915_gem_pm.c            | 21 +++++++------------
 .../gpu/drm/i915/selftests/i915_gem_object.c  |  2 +-
 .../gpu/drm/i915/selftests/mock_gem_device.c  |  4 ++--
 5 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 0e4dffcd4da4..7e8898d0b78b 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -3935,8 +3935,8 @@ i915_drop_caches_set(void *data, u64 val)
 	if (val & DROP_IDLE) {
 		do {
 			flush_delayed_work(&i915->gem.retire_work);
-			drain_delayed_work(&i915->gem.idle_work);
 		} while (READ_ONCE(i915->gt.awake));
+		flush_work(&i915->gem.idle_work);
 	}
 
 	if (val & DROP_FREED)
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 13270e19eb87..cbf4a7d8bdae 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2035,7 +2035,7 @@ struct drm_i915_private {
 		 * arrive within a small period of time, we fire
 		 * off the idle_work.
 		 */
-		struct delayed_work idle_work;
+		struct work_struct idle_work;
 	} gem;
 
 	/* For i945gm vblank irq vs. C3 workaround */
diff --git a/drivers/gpu/drm/i915/i915_gem_pm.c b/drivers/gpu/drm/i915/i915_gem_pm.c
index 49b0ce594f20..ae91ad7cb31e 100644
--- a/drivers/gpu/drm/i915/i915_gem_pm.c
+++ b/drivers/gpu/drm/i915/i915_gem_pm.c
@@ -29,12 +29,12 @@ static void i915_gem_park(struct drm_i915_private *i915)
 static void idle_work_handler(struct work_struct *work)
 {
 	struct drm_i915_private *i915 =
-		container_of(work, typeof(*i915), gem.idle_work.work);
+		container_of(work, typeof(*i915), gem.idle_work);
 
 	mutex_lock(&i915->drm.struct_mutex);
 
 	intel_wakeref_lock(&i915->gt.wakeref);
-	if (!intel_wakeref_active(&i915->gt.wakeref))
+	if (!intel_wakeref_active(&i915->gt.wakeref) && !work_pending(work))
 		i915_gem_park(i915);
 	intel_wakeref_unlock(&i915->gt.wakeref);
 
@@ -74,9 +74,7 @@ static int pm_notifier(struct notifier_block *nb,
 		break;
 
 	case INTEL_GT_PARK:
-		mod_delayed_work(i915->wq,
-				 &i915->gem.idle_work,
-				 msecs_to_jiffies(100));
+		queue_work(i915->wq, &i915->gem.idle_work);
 		break;
 	}
 
@@ -142,16 +140,11 @@ void i915_gem_suspend(struct drm_i915_private *i915)
 	 * Assert that we successfully flushed all the work and
 	 * reset the GPU back to its idle, low power state.
 	 */
-	GEM_BUG_ON(i915->gt.awake);
-	cancel_delayed_work_sync(&i915->gpu_error.hangcheck_work);
-
 	drain_delayed_work(&i915->gem.retire_work);
+	GEM_BUG_ON(i915->gt.awake);
+	flush_work(&i915->gem.idle_work);
 
-	/*
-	 * As the idle_work is rearming if it detects a race, play safe and
-	 * repeat the flush until it is definitely idle.
-	 */
-	drain_delayed_work(&i915->gem.idle_work);
+	cancel_delayed_work_sync(&i915->gpu_error.hangcheck_work);
 
 	i915_gem_drain_freed_objects(i915);
 
@@ -242,7 +235,7 @@ void i915_gem_resume(struct drm_i915_private *i915)
 
 void i915_gem_init__pm(struct drm_i915_private *i915)
 {
-	INIT_DELAYED_WORK(&i915->gem.idle_work, idle_work_handler);
+	INIT_WORK(&i915->gem.idle_work, idle_work_handler);
 	INIT_DELAYED_WORK(&i915->gem.retire_work, retire_work_handler);
 
 	i915->gem.pm_notifier.notifier_call = pm_notifier;
diff --git a/drivers/gpu/drm/i915/selftests/i915_gem_object.c b/drivers/gpu/drm/i915/selftests/i915_gem_object.c
index 088b2aa05dcd..b926d1cd165d 100644
--- a/drivers/gpu/drm/i915/selftests/i915_gem_object.c
+++ b/drivers/gpu/drm/i915/selftests/i915_gem_object.c
@@ -509,7 +509,7 @@ static void disable_retire_worker(struct drm_i915_private *i915)
 	intel_gt_pm_get(i915);
 
 	cancel_delayed_work_sync(&i915->gem.retire_work);
-	cancel_delayed_work_sync(&i915->gem.idle_work);
+	flush_work(&i915->gem.idle_work);
 }
 
 static void restore_retire_worker(struct drm_i915_private *i915)
diff --git a/drivers/gpu/drm/i915/selftests/mock_gem_device.c b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
index e4033d0576c4..d919f512042c 100644
--- a/drivers/gpu/drm/i915/selftests/mock_gem_device.c
+++ b/drivers/gpu/drm/i915/selftests/mock_gem_device.c
@@ -59,7 +59,7 @@ static void mock_device_release(struct drm_device *dev)
 	mutex_unlock(&i915->drm.struct_mutex);
 
 	drain_delayed_work(&i915->gem.retire_work);
-	drain_delayed_work(&i915->gem.idle_work);
+	flush_work(&i915->gem.idle_work);
 	i915_gem_drain_workqueue(i915);
 
 	mutex_lock(&i915->drm.struct_mutex);
@@ -195,7 +195,7 @@ struct drm_i915_private *mock_gem_device(void)
 	mock_init_contexts(i915);
 
 	INIT_DELAYED_WORK(&i915->gem.retire_work, mock_retire_work_handler);
-	INIT_DELAYED_WORK(&i915->gem.idle_work, mock_idle_work_handler);
+	INIT_WORK(&i915->gem.idle_work, mock_idle_work_handler);
 
 	i915->gt.awake = true;
 
-- 
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-05-01 11:45 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-05-01 11:45 [PATCH 01/14] drm/i915/hangcheck: Track context changes Chris Wilson
2019-05-01 11:45 ` [PATCH 02/14] drm/i915: Include fence signaled bit in print_request() Chris Wilson
2019-05-02 13:43   ` Tvrtko Ursulin
2019-05-01 11:45 ` [PATCH 03/14] drm/i915/execlists: Flush the tasklet on parking Chris Wilson
2019-05-02 13:48   ` Tvrtko Ursulin
2019-05-02 13:53     ` Chris Wilson
2019-05-02 14:14       ` Tvrtko Ursulin
2019-05-02 14:21         ` Chris Wilson
2019-05-02 14:24           ` Tvrtko Ursulin
2019-05-02 14:33             ` Chris Wilson
2019-05-01 11:45 ` [PATCH 04/14] drm/i915: Leave engine parking to the engines Chris Wilson
2019-05-02 14:18   ` Tvrtko Ursulin
2019-05-01 11:45 ` Chris Wilson [this message]
2019-05-02 13:19   ` [PATCH 05/14] drm/i915: Remove delay for idle_work Tvrtko Ursulin
2019-05-02 13:22     ` Chris Wilson
2019-05-02 13:51       ` Tvrtko Ursulin
2019-05-02 14:23         ` Chris Wilson
2019-05-01 11:45 ` [PATCH 06/14] drm/i915: Cancel retire_worker on parking Chris Wilson
2019-05-02 13:29   ` Tvrtko Ursulin
2019-05-02 13:33     ` Chris Wilson
2019-05-02 14:20       ` Tvrtko Ursulin
2019-05-02 14:26         ` Chris Wilson
2019-05-02 14:29   ` [PATCH v2] " Chris Wilson
2019-05-01 11:45 ` [PATCH 07/14] drm/i915: Stop spinning for DROP_IDLE (debugfs/i915_drop_caches) Chris Wilson
2019-05-02 13:34   ` Tvrtko Ursulin
2019-05-02 14:00     ` Chris Wilson
2019-05-02 14:16       ` Tvrtko Ursulin
2019-05-01 11:45 ` [PATCH 08/14] drm/i915: Only reschedule the submission tasklet if preemption is possible Chris Wilson
2019-05-03 10:53   ` Tvrtko Ursulin
2019-05-03 10:58     ` Chris Wilson
2019-05-01 11:45 ` [PATCH 09/14] drm/i915: Delay semaphore submission until the start of the signaler Chris Wilson
2019-05-03 11:03   ` Tvrtko Ursulin
2019-05-01 11:45 ` [PATCH 10/14] drm/i915/execlists: Don't apply priority boost for resets Chris Wilson
2019-05-01 11:45 ` [PATCH 11/14] drm/i915: Rearrange i915_scheduler.c Chris Wilson
2019-05-01 11:45 ` [PATCH 12/14] drm/i915: Pass i915_sched_node around internally Chris Wilson
2019-05-01 11:45 ` [PATCH 13/14] drm/i915: Bump signaler priority on adding a waiter Chris Wilson
2019-05-01 14:59   ` [PATCH] " Chris Wilson
2019-05-01 16:29   ` [PATCH v2] " Chris Wilson
2019-05-01 16:32   ` Chris Wilson
2019-05-01 11:45 ` [PATCH 14/14] drm/i915: Convert inconsistent static engine tables into an init error Chris Wilson
2019-05-01 12:29 ` ✗ Fi.CI.SPARSE: warning for series starting with [01/14] drm/i915/hangcheck: Track context changes Patchwork
2019-05-01 12:47 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-05-01 15:22 ` ✗ Fi.CI.SPARSE: warning for series starting with [01/14] drm/i915/hangcheck: Track context changes (rev2) Patchwork
2019-05-01 15:35 ` ✓ Fi.CI.BAT: success " Patchwork
2019-05-01 16:42 ` ✗ Fi.CI.SPARSE: warning for series starting with [01/14] drm/i915/hangcheck: Track context changes (rev3) Patchwork
2019-05-01 16:52 ` ✓ Fi.CI.BAT: success " Patchwork
2019-05-01 17:01 ` ✗ Fi.CI.SPARSE: warning for series starting with [01/14] drm/i915/hangcheck: Track context changes (rev4) Patchwork
2019-05-01 17:37 ` ✓ Fi.CI.BAT: success " Patchwork
2019-05-02  9:35 ` ✗ Fi.CI.IGT: failure " Patchwork
2019-05-02 16:45 ` ✗ Fi.CI.BAT: failure for series starting with [01/14] drm/i915/hangcheck: Track context changes (rev5) Patchwork
2019-05-03 10:36 ` [PATCH 01/14] drm/i915/hangcheck: Track context changes Tvrtko Ursulin
2019-05-03 10:43   ` Chris Wilson

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=20190501114541.10077-5-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.