Commit 1d1a9774 authored by Michal Wajdeczko's avatar Michal Wajdeczko Committed by Chris Wilson

drm/i915: Extend intel_wait_for_register_fw() with fast timeout

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: default avatarMichal Wajdeczko <michal.wajdeczko@intel.com>
Suggested-by: default avatarTvrtko 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>
Link: http://patchwork.freedesktop.org/patch/msgid/20170407160145.181328-1-michal.wajdeczko@intel.comReviewed-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
parent d769ab18
...@@ -3088,11 +3088,23 @@ int intel_wait_for_register(struct drm_i915_private *dev_priv, ...@@ -3088,11 +3088,23 @@ int intel_wait_for_register(struct drm_i915_private *dev_priv,
const u32 mask, const u32 mask,
const u32 value, const u32 value,
const unsigned long timeout_ms); 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, int intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
i915_reg_t reg, i915_reg_t reg,
const u32 mask, const u32 mask,
const u32 value, 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) static inline bool intel_gvt_active(struct drm_i915_private *dev_priv)
{ {
......
...@@ -1585,19 +1585,21 @@ static int gen6_reset_engines(struct drm_i915_private *dev_priv, ...@@ -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 * @dev_priv: the i915 device
* @reg: the register to read * @reg: the register to read
* @mask: mask to apply to register value * @mask: mask to apply to register value
* @value: expected 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 * This routine waits until the target register @reg contains the expected
* @value after applying the @mask, i.e. it waits until :: * @value after applying the @mask, i.e. it waits until ::
* *
* (I915_READ_FW(reg) & mask) == value * (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 * 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 * 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, ...@@ -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. * Returns 0 if the register matches the desired condition, or -ETIMEOUT.
*/ */
int intel_wait_for_register_fw(struct drm_i915_private *dev_priv, int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
i915_reg_t reg, i915_reg_t reg,
const u32 mask, const u32 mask,
const u32 value, const u32 value,
const unsigned int timeout_ms) const unsigned int fast_timeout_us,
const unsigned int slow_timeout_ms,
u32 *out_value)
{ {
#define done ((I915_READ_FW(reg) & mask) == value) u32 reg_value;
int ret = wait_for_us(done, 2); #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) if (ret)
ret = wait_for(done, timeout_ms); ret = wait_for(done, slow_timeout_ms);
if (out_value)
*out_value = reg_value;
return ret; return ret;
#undef done #undef done
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment