diff mbox

drm/i915: Don't allow overuse of __intel_wait_for_register_fw()

Message ID 20170410121402.107264-1-michal.wajdeczko@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Michal Wajdeczko April 10, 2017, 12:14 p.m. UTC
This function should not be called with long timeouts in atomic context.
Annotate it as might_sleep if timeout is longer than 10us.

Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_uncore.c | 6 ++++++
 1 file changed, 6 insertions(+)

Comments

Michal Wajdeczko April 10, 2017, 12:19 p.m. UTC | #1
On Mon, Apr 10, 2017 at 12:14:02PM +0000, Michal Wajdeczko wrote:
> This function should not be called with long timeouts in atomic context.
> Annotate it as might_sleep if timeout is longer than 10us.
> 
> Signed-off-by: Michal Wajdeczko <michal.wajdeczko@intel.com>
> Suggested-by: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> ---

Please ignore. Review v2 instead.

-Michal
diff mbox

Patch

diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 1deb1a4..9cc9e6f 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -1606,6 +1606,9 @@  static int gen6_reset_engines(struct drm_i915_private *dev_priv,
  * wish to wait without holding forcewake for the duration (i.e. you expect
  * the wait to be slow).
  *
+ * Only @fast_timeout_us < 10us are allowed in atomic context.
+ * Note that @fast_timeout_us >= 50000us are not allowed at all.
+ *
  * Returns 0 if the register matches the desired condition, or -ETIMEOUT.
  */
 int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
@@ -1620,6 +1623,9 @@  int __intel_wait_for_register_fw(struct drm_i915_private *dev_priv,
 #define done (((reg_value = I915_READ_FW(reg)) & mask) == value)
 	int ret;
 
+	/* Catch any overuse of this function */
+	might_sleep_if(fast_timeout_us > 10 || slow_timeout_ms);
+
 	if (fast_timeout_us > 10)
 		ret = _wait_for(done, fast_timeout_us, 10);
 	else