All of lore.kernel.org
 help / color / mirror / Atom feed
From: Chris Wilson <chris@chris-wilson.co.uk>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2] drm/i915: Check caller held wakerefs in assert_forcewakes_active
Date: Thu,  4 Jul 2019 09:17:33 +0100	[thread overview]
Message-ID: <20190704081733.15816-1-chris@chris-wilson.co.uk> (raw)
In-Reply-To: <20190703155225.9501-1-chris@chris-wilson.co.uk>

The intent of the assert is to document that the caller took the
appropriate wakerefs for the function. However, as Tvrtko pointed out,
we simply check whether the fw_domains are active and may be confused by
the auto wakeref which may be dropped between the check and use. Let's
be more careful in the assert and check that each fw_domain has an
explicit caller wakeref above and beyond the automatic wakeref.

v2: Fix spelling for config DRM_I915_DEBUG_RUNTIME_PM

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

diff --git a/drivers/gpu/drm/i915/intel_uncore.c b/drivers/gpu/drm/i915/intel_uncore.c
index 68d54e126d79..1771e69dbf03 100644
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -738,6 +738,12 @@ void assert_forcewakes_inactive(struct intel_uncore *uncore)
 void assert_forcewakes_active(struct intel_uncore *uncore,
 			      enum forcewake_domains fw_domains)
 {
+	struct intel_uncore_forcewake_domain *domain;
+	unsigned int tmp;
+
+	if (!IS_ENABLED(CONFIG_DRM_I915_DEBUG_RUNTIME_PM))
+		return;
+
 	if (!uncore->funcs.force_wake_get)
 		return;
 
@@ -747,6 +753,24 @@ void assert_forcewakes_active(struct intel_uncore *uncore,
 	WARN(fw_domains & ~uncore->fw_domains_active,
 	     "Expected %08x fw_domains to be active, but %08x are off\n",
 	     fw_domains, fw_domains & ~uncore->fw_domains_active);
+
+	/*
+	 * Check that the caller has an explicit wakeref and we don't mistake
+	 * it for the auto wakeref.
+	 */
+	local_irq_disable();
+	for_each_fw_domain_masked(domain, fw_domains, uncore, tmp) {
+		unsigned int expect = 1;
+
+		if (hrtimer_active(&domain->timer))
+			expect++;
+
+		if (WARN(domain->wake_count < expect,
+			 "Expected domain %d to be held awake by caller\n",
+			 domain->id))
+			break;
+	}
+	local_irq_enable();
 }
 
 /* We give fast paths for the really cool registers */
-- 
2.20.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2019-07-04  8:34 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-03 15:52 [PATCH 1/4] drm/i915: Check caller held wakerefs in assert_forcewakes_active Chris Wilson
2019-07-03 15:52 ` [PATCH 2/4] drm/i915/gt: Use caller provided forcewake for intel_mocs_init_engine Chris Wilson
2019-07-03 15:52 ` [PATCH 3/4] drm/i915/gt: Assume we hold forcewake for execlists resume Chris Wilson
2019-07-03 15:52 ` [PATCH 4/4] drm/i915/gt: Ignore forcewake acquisition for posting_reads Chris Wilson
2019-07-03 18:46 ` ✓ Fi.CI.BAT: success for series starting with [1/4] drm/i915: Check caller held wakerefs in assert_forcewakes_active Patchwork
2019-07-04  8:17 ` Chris Wilson [this message]
2019-07-04  8:38   ` [PATCH v2] " Tvrtko Ursulin
2019-07-04  9:26 ` ✗ Fi.CI.BAT: failure for series starting with [v2] drm/i915: Check caller held wakerefs in assert_forcewakes_active (rev2) Patchwork
2019-07-04  9:37 ` [PATCH v3] drm/i915: Check caller held wakerefs in assert_forcewakes_active Chris Wilson
2019-07-04 10:14 ` ✗ Fi.CI.BAT: failure for series starting with [v3] drm/i915: Check caller held wakerefs in assert_forcewakes_active (rev3) Patchwork
2019-07-04 10:20 ` [PATCH v4] drm/i915: Check caller held wakerefs in assert_forcewakes_active Chris Wilson
2019-07-04 12:12 ` ✓ Fi.CI.BAT: success for series starting with [v4] drm/i915: Check caller held wakerefs in assert_forcewakes_active (rev4) Patchwork
2019-07-04 22:46 ` ✗ Fi.CI.IGT: failure for series starting with [1/4] drm/i915: Check caller held wakerefs in assert_forcewakes_active Patchwork
2019-07-05 15:06 ` ✗ Fi.CI.IGT: failure for series starting with [v4] drm/i915: Check caller held wakerefs in assert_forcewakes_active (rev4) Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190704081733.15816-1-chris@chris-wilson.co.uk \
    --to=chris@chris-wilson.co.uk \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.