[Intel-gfx] [PATCH v2] drm/i915: Only arm the forcewake release timer on the final put

Chris Wilson chris at chris-wilson.co.uk
Thu Mar 24 13:56:02 UTC 2016

If we arm the release timer on acquiring the forcewake, we will release
the forcewake on the jiffie afterwards. If we only arm the release timer
on the final put, we will release the forcewake slightly later instead.

Much, much worse, we did not acquire a refcount for the armed timing
during the get(), and so unbalanced our forcewake counting.

v2: Only claim the timer refcount if we start the timer.

Reported-by: Tvrtko Ursulin <tvrtko.ursulin at linux.intel.com>
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala at linux.intel.com>
Cc: Tvrtko Ursulin <tvrtko.ursulin at linux.intel.com>
 drivers/gpu/drm/i915/intel_uncore.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 96799392c2c7..b7b373900cb4 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -60,7 +60,8 @@ fw_domain_reset(const struct intel_uncore_forcewake_domain *d)
 static inline void
 fw_domain_arm_timer(struct intel_uncore_forcewake_domain *d)
-	mod_timer_pinned(&d->timer, jiffies + 1);
+	if (!mod_timer_pinned(&d->timer, jiffies + 1))
+		d->wake_count++;
 static inline void
@@ -491,7 +492,6 @@ static void __intel_uncore_forcewake_put(struct drm_i915_private *dev_priv,
 		if (--domain->wake_count)
-		domain->wake_count++;
@@ -733,7 +733,6 @@ static inline void __force_wake_get(struct drm_i915_private *dev_priv,
-		fw_domain_arm_timer(domain);
 	if (fw_domains)

More information about the Intel-gfx mailing list