drm/i915: Order assert forcewake test

Submitted by Chris Wilson on July 4, 2019, 7:26 p.m.

Details

Message ID 20190704192615.15855-1-chris@chris-wilson.co.uk
State New
Headers show
Series "drm/i915: Order assert forcewake test" ( rev: 1 ) in Intel GFX

Browsing this patch as part of:
"drm/i915: Order assert forcewake test" rev 1 in Intel GFX
<< prev patch [1/1] next patch >>

Commit Message

Chris Wilson July 4, 2019, 7:26 p.m.
Read the current value before computing the expected to ensure that if
the timer does complete early (against our will), it should not cause a
false positive.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/intel_uncore.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Patch hide | download patch | download mbox

diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 2042c94c9cc9..c83bfaae377f 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -760,14 +760,15 @@  void assert_forcewakes_active(struct intel_uncore *uncore,
 	 */
 	local_irq_disable();
 	for_each_fw_domain_masked(domain, fw_domains, uncore, tmp) {
+		unsigned int actual = READ_ONCE(domain->wake_count);
 		unsigned int expect = 1;
 
 		if (hrtimer_active(&domain->timer) && READ_ONCE(domain->active))
 			expect++; /* pending automatic release */
 
-		if (WARN(domain->wake_count < expect,
+		if (WARN(actual < expect,
 			 "Expected domain %d to be held awake by caller, count=%d\n",
-			 domain->id, domain->wake_count))
+			 domain->id, actual))
 			break;
 	}
 	local_irq_enable();