[Intel-gfx] [PATCH 5/7] drm/i915: Introduce wait_until_reg
Mika Kuoppala
mika.kuoppala at linux.intel.com
Tue May 17 15:43:26 UTC 2016
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); \
+ 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)); \
+ 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
More information about the Intel-gfx
mailing list