]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
drm/i915: Keep the forcewake timer alive for 1ms past the most recent use
authorChris Wilson <chris@chris-wilson.co.uk>
Fri, 26 May 2017 13:22:09 +0000 (14:22 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Fri, 26 May 2017 14:58:21 +0000 (15:58 +0100)
Currently the timer is armed for 1ms after the first use and is killed
immediately, dropping the forcewake as early as possible. However, for
very frequent operations the forcewake dance has a large impact on
latency and keeping the timer alive until we are idle is preferred. To
achieve this, if we call intel_uncore_forcewake_get whilst the timer is
alive (repeated use), then set a flag to restart the timer on expiry
rather than drop the forcewake usage count. The timer is racy, the
consequence of the race is to expire the timer earlier than is now
desired but does not impact on correct behaviour. The offset the race
slightly, we set the active flag again on intel_uncore_forcewake_put.

The effect should be to reduce the jitter of reacquiring the fw every
1ms on a busy system. However, the cost is to keep the timer alive for
an extra 1ms on a nearly idle system. We chose to incur the jitter
previously to keep the timer off for as much as possible.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Link: http://patchwork.freedesktop.org/patch/msgid/20170526132209.14640-1-chris@chris-wilson.co.uk
drivers/gpu/drm/i915/intel_uncore.c
drivers/gpu/drm/i915/intel_uncore.h

index 9269cae5713a83c7d98f8ca7ed1496f07f6f40a5..47d7ee1b5d864c679cea97821d3d2e2f6a1e4915 100644 (file)
@@ -214,6 +214,9 @@ intel_uncore_fw_release_timer(struct hrtimer *timer)
 
        assert_rpm_device_not_suspended(dev_priv);
 
+       if (xchg(&domain->active, false))
+               return HRTIMER_RESTART;
+
        spin_lock_irqsave(&dev_priv->uncore.lock, irqflags);
        if (WARN_ON(domain->wake_count == 0))
                domain->wake_count++;
@@ -244,6 +247,7 @@ static void intel_uncore_forcewake_reset(struct drm_i915_private *dev_priv,
                active_domains = 0;
 
                for_each_fw_domain(domain, dev_priv, tmp) {
+                       smp_store_mb(domain->active, false);
                        if (hrtimer_cancel(&domain->timer) == 0)
                                continue;
 
@@ -451,9 +455,12 @@ static void __intel_uncore_forcewake_get(struct drm_i915_private *dev_priv,
 
        fw_domains &= dev_priv->uncore.fw_domains;
 
-       for_each_fw_domain_masked(domain, fw_domains, dev_priv, tmp)
-               if (domain->wake_count++)
+       for_each_fw_domain_masked(domain, fw_domains, dev_priv, tmp) {
+               if (domain->wake_count++) {
                        fw_domains &= ~domain->mask;
+                       domain->active = true;
+               }
+       }
 
        if (fw_domains)
                dev_priv->uncore.funcs.force_wake_get(dev_priv, fw_domains);
@@ -518,8 +525,10 @@ static void __intel_uncore_forcewake_put(struct drm_i915_private *dev_priv,
                if (WARN_ON(domain->wake_count == 0))
                        continue;
 
-               if (--domain->wake_count)
+               if (--domain->wake_count) {
+                       domain->active = true;
                        continue;
+               }
 
                fw_domain_arm_timer(domain);
        }
index ff6fe2bb0ccf848febec95b2bddffb74cc6b5b8c..5f90278da46121be2cdd5052a402a1523da100fc 100644 (file)
@@ -96,6 +96,7 @@ struct intel_uncore {
                enum forcewake_domain_id id;
                enum forcewake_domains mask;
                unsigned int wake_count;
+               bool active;
                struct hrtimer timer;
                i915_reg_t reg_set;
                i915_reg_t reg_ack;