All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout
@ 2017-04-07 16:01 Michal Wajdeczko
  2017-04-07 16:01 ` [PATCH v2 2/2] drm/i915/guc: Use wait_for_register_fw() while waiting for MMIO response Michal Wajdeczko
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Michal Wajdeczko @ 2017-04-07 16:01 UTC (permalink / raw)
  To: intel-gfx

In some cases we may want to spend more time in atomic wait than
hardcoded 2us. Let's add additional fast timeout parameter to allow
flexible configuration of atomic timeout before switching into heavy wait.
Add also possibility to return registry value to avoid extra read.

v2: use explicit fast timeout (Tvrtko/Chris)
    allow returning register value (Chris)

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_drv.h     | 14 +++++++++++++-
 drivers/gpu/drm/i915/intel_uncore.c | 36 ++++++++++++++++++++++++------------
 2 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 59433df..bb6fc1e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3088,11 +3088,23 @@ int intel_wait_for_register(struct drm_i915_private *dev_priv,
 			    const u32 mask,
 			    const u32 value,
 			    const unsigned long timeout_ms);
+int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
+				 i915_reg_t reg,
+				 const u32 mask,
+				 const u32 value,
+				 const unsigned int fast_timeout_us,
+				 const unsigned int slow_timeout_ms,
+				 u32 *out_value);
+static inline
 int intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
 			       i915_reg_t reg,
 			       const u32 mask,
 			       const u32 value,
-			       const unsigned int timeout_ms);
+			       const unsigned int timeout_ms)
+{
+	return __intel_wait_for_register_fw(dev_priv, reg, mask, value,
+					    2, timeout_ms, NULL);
+}
 
 static inline bool intel_gvt_active(struct drm_i915_private *dev_priv)
 {
diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index bcabf54..ace0993 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -1585,19 +1585,21 @@ static int gen6_reset_engines(struct drm_i915_private *dev_priv,
 }
 
 /**
- * intel_wait_for_register_fw - wait until register matches expected state
+ * __intel_wait_for_register_fw - wait until register matches expected state
  * @dev_priv: the i915 device
  * @reg: the register to read
  * @mask: mask to apply to register value
  * @value: expected value
- * @timeout_ms: timeout in millisecond
+ * @fast_timeout_us: fast timeout in microsecond for atomic/tight wait
+ * @slow_timeout_ms: slow timeout in millisecond
+ * @out_value: optional placeholder to hold registry value
  *
  * This routine waits until the target register @reg contains the expected
  * @value after applying the @mask, i.e. it waits until ::
  *
  *     (I915_READ_FW(reg) & mask) == value
  *
- * Otherwise, the wait will timeout after @timeout_ms milliseconds.
+ * Otherwise, the wait will timeout after @slow_timeout_ms milliseconds.
  *
  * Note that this routine assumes the caller holds forcewake asserted, it is
  * not suitable for very long waits. See intel_wait_for_register() if you
@@ -1606,16 +1608,26 @@ static int gen6_reset_engines(struct drm_i915_private *dev_priv,
  *
  * Returns 0 if the register matches the desired condition, or -ETIMEOUT.
  */
-int intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
-			       i915_reg_t reg,
-			       const u32 mask,
-			       const u32 value,
-			       const unsigned int timeout_ms)
-{
-#define done ((I915_READ_FW(reg) & mask) == value)
-	int ret = wait_for_us(done, 2);
+int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
+				 i915_reg_t reg,
+				 const u32 mask,
+				 const u32 value,
+				 const unsigned int fast_timeout_us,
+				 const unsigned int slow_timeout_ms,
+				 u32 *out_value)
+{
+	u32 reg_value;
+#define done (((reg_value = I915_READ_FW(reg)) & mask) == value)
+	int ret;
+
+	if (fast_timeout_us > 10)
+		ret = _wait_for(done, fast_timeout_us, 10);
+	else
+		ret = _wait_for_atomic(done, fast_timeout_us, 0);
 	if (ret)
-		ret = wait_for(done, timeout_ms);
+		ret = wait_for(done, slow_timeout_ms);
+	if (out_value)
+		*out_value = reg_value;
 	return ret;
 #undef done
 }
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH v2 2/2] drm/i915/guc: Use wait_for_register_fw() while waiting for MMIO response
  2017-04-07 16:01 [PATCH v2 1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout Michal Wajdeczko
@ 2017-04-07 16:01 ` Michal Wajdeczko
  2017-04-07 16:16   ` Chris Wilson
  2017-04-07 16:18 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout Patchwork
  2017-04-07 17:26 ` [PATCH v2 1/2] " Chris Wilson
  2 siblings, 1 reply; 6+ messages in thread
From: Michal Wajdeczko @ 2017-04-07 16:01 UTC (permalink / raw)
  To: intel-gfx

Waiting for the response status in scratch register can be done
using our generic function. Let's use it.

v2: rebased

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_uc.c | 26 +++++++-------------------
 1 file changed, 7 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_uc.c b/drivers/gpu/drm/i915/intel_uc.c
index c117424..4364b1a 100644
--- a/drivers/gpu/drm/i915/intel_uc.c
+++ b/drivers/gpu/drm/i915/intel_uc.c
@@ -360,19 +360,6 @@ void intel_uc_fini_hw(struct drm_i915_private *dev_priv)
 }
 
 /*
- * Read GuC command/status register (SOFT_SCRATCH_0)
- * Return true if it contains a response rather than a command
- */
-static bool guc_recv(struct intel_guc *guc, u32 *status)
-{
-	struct drm_i915_private *dev_priv = guc_to_i915(guc);
-
-	u32 val = I915_READ(SOFT_SCRATCH(0));
-	*status = val;
-	return INTEL_GUC_RECV_IS_RESPONSE(val);
-}
-
-/*
  * This function implements the MMIO based host to GuC interface.
  */
 int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len)
@@ -399,13 +386,14 @@ int intel_guc_send_mmio(struct intel_guc *guc, const u32 *action, u32 len)
 	I915_WRITE(GUC_SEND_INTERRUPT, GUC_SEND_TRIGGER);
 
 	/*
-	 * Fast commands should complete in less than 10us, so sample quickly
-	 * up to that length of time, then switch to a slower sleep-wait loop.
-	 * No inte_guc_send command should ever take longer than 10ms.
+	 * No GuC command should ever take longer than 10ms.
+	 * Fast commands should still complete in 10us.
 	 */
-	ret = wait_for_us(guc_recv(guc, &status), 10);
-	if (ret)
-		ret = wait_for(guc_recv(guc, &status), 10);
+	ret = __intel_wait_for_register_fw(dev_priv,
+					   SOFT_SCRATCH(0),
+					   INTEL_GUC_RECV_MASK,
+					   INTEL_GUC_RECV_MASK,
+					   10, 10, &status);
 	if (status != INTEL_GUC_STATUS_SUCCESS) {
 		/*
 		 * Either the GuC explicitly returned an error (which
-- 
2.7.4

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

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 2/2] drm/i915/guc: Use wait_for_register_fw() while waiting for MMIO response
  2017-04-07 16:01 ` [PATCH v2 2/2] drm/i915/guc: Use wait_for_register_fw() while waiting for MMIO response Michal Wajdeczko
@ 2017-04-07 16:16   ` Chris Wilson
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2017-04-07 16:16 UTC (permalink / raw)
  To: Michal Wajdeczko; +Cc: intel-gfx

On Fri, Apr 07, 2017 at 04:01:45PM +0000, Michal Wajdeczko wrote:
> Waiting for the response status in scratch register can be done
> using our generic function. Let's use it.
> 
> v2: rebased
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
Both Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [v2,1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout
  2017-04-07 16:01 [PATCH v2 1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout Michal Wajdeczko
  2017-04-07 16:01 ` [PATCH v2 2/2] drm/i915/guc: Use wait_for_register_fw() while waiting for MMIO response Michal Wajdeczko
@ 2017-04-07 16:18 ` Patchwork
  2017-04-07 17:26 ` [PATCH v2 1/2] " Chris Wilson
  2 siblings, 0 replies; 6+ messages in thread
From: Patchwork @ 2017-04-07 16:18 UTC (permalink / raw)
  To: Michal Wajdeczko; +Cc: intel-gfx

== Series Details ==

Series: series starting with [v2,1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout
URL   : https://patchwork.freedesktop.org/series/22678/
State : success

== Summary ==

Series 22678v1 Series without cover letter
https://patchwork.freedesktop.org/api/1.0/series/22678/revisions/1/mbox/

Test gem_exec_suspend:
        Subgroup basic-s4-devices:
                dmesg-warn -> PASS       (fi-kbl-7560u) fdo#100125

fdo#100125 https://bugs.freedesktop.org/show_bug.cgi?id=100125

fi-bdw-5557u     total:278  pass:267  dwarn:0   dfail:0   fail:0   skip:11  time:433s
fi-bdw-gvtdvm    total:278  pass:256  dwarn:8   dfail:0   fail:0   skip:14  time:428s
fi-bsw-n3050     total:278  pass:242  dwarn:0   dfail:0   fail:0   skip:36  time:575s
fi-bxt-j4205     total:278  pass:259  dwarn:0   dfail:0   fail:0   skip:19  time:510s
fi-bxt-t5700     total:278  pass:258  dwarn:0   dfail:0   fail:0   skip:20  time:539s
fi-byt-j1900     total:278  pass:254  dwarn:0   dfail:0   fail:0   skip:24  time:491s
fi-byt-n2820     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:481s
fi-hsw-4770      total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:414s
fi-hsw-4770r     total:278  pass:262  dwarn:0   dfail:0   fail:0   skip:16  time:408s
fi-ilk-650       total:278  pass:228  dwarn:0   dfail:0   fail:0   skip:50  time:415s
fi-ivb-3520m     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:492s
fi-ivb-3770      total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:465s
fi-kbl-7500u     total:278  pass:260  dwarn:0   dfail:0   fail:0   skip:18  time:450s
fi-kbl-7560u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:562s
fi-skl-6260u     total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:457s
fi-skl-6700hq    total:278  pass:261  dwarn:0   dfail:0   fail:0   skip:17  time:567s
fi-skl-6700k     total:278  pass:256  dwarn:4   dfail:0   fail:0   skip:18  time:461s
fi-skl-6770hq    total:278  pass:268  dwarn:0   dfail:0   fail:0   skip:10  time:491s
fi-skl-gvtdvm    total:278  pass:265  dwarn:0   dfail:0   fail:0   skip:13  time:431s
fi-snb-2520m     total:278  pass:250  dwarn:0   dfail:0   fail:0   skip:28  time:538s
fi-snb-2600      total:278  pass:249  dwarn:0   dfail:0   fail:0   skip:29  time:399s

5a74def419415233546c4e853a3f02bb31daee82 drm-tip: 2017y-04m-07d-15h-00m-28s UTC integration manifest
4a19668 drm/i915/guc: Use wait_for_register_fw() while waiting for MMIO response
124daca drm/i915: Extend intel_wait_for_register_fw() with fast timeout

== Logs ==

For more details see: https://intel-gfx-ci.01.org/CI/Patchwork_4441/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout
  2017-04-07 16:01 [PATCH v2 1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout Michal Wajdeczko
  2017-04-07 16:01 ` [PATCH v2 2/2] drm/i915/guc: Use wait_for_register_fw() while waiting for MMIO response Michal Wajdeczko
  2017-04-07 16:18 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout Patchwork
@ 2017-04-07 17:26 ` Chris Wilson
  2017-04-07 17:51   ` Chris Wilson
  2 siblings, 1 reply; 6+ messages in thread
From: Chris Wilson @ 2017-04-07 17:26 UTC (permalink / raw)
  To: Michal Wajdeczko; +Cc: intel-gfx

On Fri, Apr 07, 2017 at 04:01:44PM +0000, Michal Wajdeczko wrote:
> In some cases we may want to spend more time in atomic wait than
> hardcoded 2us. Let's add additional fast timeout parameter to allow
> flexible configuration of atomic timeout before switching into heavy wait.
> Add also possibility to return registry value to avoid extra read.
> 
> v2: use explicit fast timeout (Tvrtko/Chris)
>     allow returning register value (Chris)
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>

For fun this causes:

add/remove: 2/1 grow/shrink: 6/2 up/down: 626/-348 (278)
function                                     old     new   delta
__intel_wait_for_register_fw                   -     429    +429
gen6_hw_domain_reset                           -      57     +57
sandybridge_pcode_write                      494     528     +34
sandybridge_pcode_read                       524     554     +30
gen8_reset_engines                           287     313     +26
gen6_bsd_submit_request                      156     178     +22
init_ring_common                            1368    1382     +14
gmbus_wait_idle                              204     218     +14
gen6_reset_engines                           183     160     -23
intel_guc_reset                              140     109     -31
intel_wait_for_register_fw                   294       -    -294

Hmm. Thinking about it more, using _wait_for() at all here is pointless.

You just want to do something like,

if (fast_timeout_us > 10)
	fast_timeout_us = 10;

So

-               ret = _wait_for(done, fast_timeout_us, 10);
-       else
-               ret = _wait_for_atomic(done, fast_timeout_us, 0);
+       if (fast_timeout_us > 50000)
+               fast_timeout_us = 50000;
+       ret = _wait_for_atomic(done, fast_timeout_us, 0);

gives

add/remove: 2/1 grow/shrink: 6/2 up/down: 515/-348 (167)
function                                     old     new   delta
__intel_wait_for_register_fw                   -     318    +318
gen6_hw_domain_reset                           -      57     +57
sandybridge_pcode_write                      494     528     +34
sandybridge_pcode_read                       524     554     +30
gen8_reset_engines                           287     313     +26
gen6_bsd_submit_request                      156     178     +22
init_ring_common                            1368    1382     +14
gmbus_wait_idle                              204     218     +14
gen6_reset_engines                           183     160     -23
intel_guc_reset                              140     109     -31
intel_wait_for_register_fw                   294       -    -294

which is more reasonable, and fits in with the current warnings. Happy?
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout
  2017-04-07 17:26 ` [PATCH v2 1/2] " Chris Wilson
@ 2017-04-07 17:51   ` Chris Wilson
  0 siblings, 0 replies; 6+ messages in thread
From: Chris Wilson @ 2017-04-07 17:51 UTC (permalink / raw)
  To: Michal Wajdeczko, intel-gfx, Tvrtko Ursulin, Joonas Lahtinen

On Fri, Apr 07, 2017 at 06:26:03PM +0100, Chris Wilson wrote:
> Hmm. Thinking about it more, using _wait_for() at all here is pointless.
> 
> You just want to do something like,
> 
> if (fast_timeout_us > 10)
> 	fast_timeout_us = 10;
> 
> So
> 
> -               ret = _wait_for(done, fast_timeout_us, 10);
> -       else
> -               ret = _wait_for_atomic(done, fast_timeout_us, 0);
> +       if (fast_timeout_us > 50000)
> +               fast_timeout_us = 50000;
> +       ret = _wait_for_atomic(done, fast_timeout_us, 0);

After chatting on irc, looking at changing the behaviour here for future
users (those who may want fast timeout > 10, e.g. 100/200) should be
postponed until after they have been converted.

Pushed, thanks for the patches.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2017-04-07 17:51 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-07 16:01 [PATCH v2 1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout Michal Wajdeczko
2017-04-07 16:01 ` [PATCH v2 2/2] drm/i915/guc: Use wait_for_register_fw() while waiting for MMIO response Michal Wajdeczko
2017-04-07 16:16   ` Chris Wilson
2017-04-07 16:18 ` ✓ Fi.CI.BAT: success for series starting with [v2,1/2] drm/i915: Extend intel_wait_for_register_fw() with fast timeout Patchwork
2017-04-07 17:26 ` [PATCH v2 1/2] " Chris Wilson
2017-04-07 17:51   ` Chris Wilson

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.