[Intel-gfx] [PATCH 5/7] drm/i915: Introduce wait_until_reg
Daniel Vetter
daniel at ffwll.ch
Wed May 18 08:33:23 UTC 2016
On Tue, May 17, 2016 at 06:43:26PM +0300, Mika Kuoppala wrote:
> The most common usage pattern for wait_for() macro is to wait for some
> register value. Instead of bloating all callsites, encapsulate this
> complex wait_for macro into a helper function.
>
> v2: s/for/until, macro readability (Chris)
>
> Signed-off-by: Mika Kuoppala <mika.kuoppala at intel.com>
> ---
> drivers/gpu/drm/i915/i915_drv.h | 25 +++++++++++++++++++++++++
> drivers/gpu/drm/i915/intel_uncore.c | 9 +++++++++
> 2 files changed, 34 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 72f0b02a8372..ccf6747894b1 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -2873,6 +2873,31 @@ static inline bool intel_vgpu_active(struct drm_i915_private *dev_priv)
> return dev_priv->vgpu.active;
> }
>
> +int intel_wait_until_register(struct drm_i915_private *dev_priv,
> + i915_reg_t reg,
> + u32 mask,
> + u32 value,
> + unsigned long timeout_ms);
> +
> +#define wait_until_reg(reg, mask, value, timeout_ms) ({ \
> + if (__builtin_constant_p(timeout_ms)) \
> + BUILD_BUG_ON((timeout_ms) > 60000); \
Why the inconsistent use of __builtin_constant_p? Also the BUILD_BUG_ON
seems not that helpful ...
> + intel_wait_until_register(dev_priv, \
> + (reg), (mask), (value), (timeout_ms)); \
> + })
> +
> +#define wait_until_reg_set(reg, v, timeout_ms) ({ \
> + if (__builtin_constant_p(v)) \
> + BUILD_BUG_ON_NOT_POWER_OF_2((u32)(v)); \
Sometimes you might want to wait for multiple flags to get set. Not sure
this BUG_ON is valid. Same below. But I do see that very often you want to
have explicit value/mask in such a case, so seems ok.
Naming and all that makes sense.
> + wait_until_reg(reg, v, v, timeout_ms); \
> + })
> +
> +#define wait_until_reg_clr(reg, v, timeout_ms) ({ \
> + if (__builtin_constant_p((u32)(v))) \
> + BUILD_BUG_ON_NOT_POWER_OF_2((u32)(v)); \
> + wait_until_reg(reg, v, 0, timeout_ms); \
> + })
> +
> void
> i915_enable_pipestat(struct drm_i915_private *dev_priv, enum pipe pipe,
> u32 status_mask);
> diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
> index 385114bca924..e217997a9fa0 100644
> --- a/drivers/gpu/drm/i915/intel_uncore.c
> +++ b/drivers/gpu/drm/i915/intel_uncore.c
> @@ -1860,3 +1860,12 @@ intel_uncore_forcewake_for_reg(struct drm_i915_private *dev_priv,
>
> return fw_domains;
> }
> +
> +int intel_wait_until_register(struct drm_i915_private *dev_priv,
> + i915_reg_t reg,
> + u32 mask,
> + u32 value,
> + unsigned long timeout_ms)
> +{
> + return wait_for((I915_READ(reg) & mask) == value, timeout_ms);
> +}
> --
> 2.5.0
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
More information about the Intel-gfx
mailing list