drm/i915: Only warn for might_sleep() before a slow wait_for_register
authorChris Wilson <chris@chris-wilson.co.uk>
Thu, 29 Mar 2018 22:45:19 +0000 (23:45 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 30 Mar 2018 09:05:59 +0000 (10:05 +0100)
As intel_wait_for_register_fw() may use, and if successful only use, a
busy-wait loop, the might_sleep() warning is a little over-zealous.
Restrict it to a might_sleep_if() a slow timeout is specified (and so
the caller authorises use of a usleep).

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20180329224519.13598-2-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/intel_uncore.c

index a0d7e0cfbd32f16d07f97b7b16868a1de2b2a223..e7540bb9786cde132a7237b9e54c14aa7dd717cb 100644 (file)
@@ -1996,7 +1996,7 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv,
        u32 reg_value;
        int ret;
 
-       might_sleep();
+       might_sleep_if(slow_timeout_ms);
 
        spin_lock_irq(&dev_priv->uncore.lock);
        intel_uncore_forcewake_get__locked(dev_priv, fw);
@@ -2008,7 +2008,7 @@ int __intel_wait_for_register(struct drm_i915_private *dev_priv,
        intel_uncore_forcewake_put__locked(dev_priv, fw);
        spin_unlock_irq(&dev_priv->uncore.lock);
 
-       if (ret)
+       if (ret && slow_timeout_ms)
                ret = __wait_for(reg_value = I915_READ_NOTRACE(reg),
                                 (reg_value & mask) == value,
                                 slow_timeout_ms * 1000, 10, 1000);