All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/i915/selftests: add test to verify get/put fw domains
@ 2019-03-19 21:42 Chris Wilson
  2019-03-19 21:42 ` [PATCH 2/3] drm/i915/selftests: Calculate maximum ring size for preemption chain Chris Wilson
                   ` (15 more replies)
  0 siblings, 16 replies; 20+ messages in thread
From: Chris Wilson @ 2019-03-19 21:42 UTC (permalink / raw)
  To: intel-gfx

From: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>

Exercise acquiring and releasing forcewake around register reads. In
order to read a register behind a GT powerwell, we need to instruct that
powerwell to wake up using a forcewake. When we no longer require the GT
powerwell, we tell the GT to release our forcewake. Inside the
forcewake, the register read should work but outside it should just
return garbage, 0 being the most common garbage. Thus we can detect when
we are inside and outside of the forcewake with just a simple register
read, and so can verify that the GT powerwell is released when we say
so.

Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/selftests/intel_uncore.c | 104 +++++++++++++++++-
 1 file changed, 98 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/i915/selftests/intel_uncore.c b/drivers/gpu/drm/i915/selftests/intel_uncore.c
index 81d9d31042a9..10820de209a7 100644
--- a/drivers/gpu/drm/i915/selftests/intel_uncore.c
+++ b/drivers/gpu/drm/i915/selftests/intel_uncore.c
@@ -119,9 +119,100 @@ int intel_uncore_mock_selftests(void)
 	return 0;
 }
 
-static int intel_uncore_check_forcewake_domains(struct drm_i915_private *dev_priv)
+static int live_forcewake_ops(void *arg)
+{
+	struct drm_i915_private *i915 = arg;
+	struct intel_uncore_forcewake_domain *domain;
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+	intel_wakeref_t wakeref;
+	unsigned int tmp;
+	int err = 0;
+
+	GEM_BUG_ON(i915->gt.awake);
+
+	/* vlv/chv with their pcu behave differently wrt reads */
+	if (IS_VALLEYVIEW(i915) || IS_CHERRYVIEW(i915))
+		return 0;
+
+	wakeref = intel_runtime_pm_get(i915);
+
+	for_each_fw_domain(domain, i915, tmp) {
+		smp_store_mb(domain->active, false);
+		if (!hrtimer_cancel(&domain->timer))
+			continue;
+
+		intel_uncore_fw_release_timer(&domain->timer);
+	}
+
+	for_each_engine(engine, i915, id) {
+		i915_reg_t offset = RING_HEAD(engine->mmio_base);
+		u32 *reg = i915->regs + i915_mmio_reg_offset(offset);
+		enum forcewake_domains fw_domains;
+		u32 val;
+
+		if (!engine->default_state)
+			continue;
+
+		fw_domains = intel_uncore_forcewake_for_reg(i915, offset,
+							    FW_REG_READ);
+		if (!fw_domains)
+			continue;
+
+		for_each_fw_domain_masked(domain, fw_domains, i915, tmp) {
+			if (!domain->wake_count)
+				continue;
+
+			pr_err("fw_domain %s still active, aborting test!\n",
+			       intel_uncore_forcewake_domain_to_str(domain->id));
+			err = -EINVAL;
+			goto out_rpm;
+		}
+
+		intel_uncore_forcewake_get(i915, fw_domains);
+		val = readl(reg);
+		intel_uncore_forcewake_put(i915, fw_domains);
+
+		/* Flush the forcewake release (delayed onto a timer) */
+		for_each_fw_domain_masked(domain, fw_domains, i915, tmp) {
+			smp_store_mb(domain->active, false);
+			if (!hrtimer_cancel(&domain->timer))
+				continue;
+
+			intel_uncore_fw_release_timer(&domain->timer);
+			if (wait_ack_clear(domain, FORCEWAKE_KERNEL)) {
+				pr_err("Failed to clear fw_domain %s\n",
+				       intel_uncore_forcewake_domain_to_str(domain->id));
+				err = -EIO;
+				goto out_rpm;
+			}
+		}
+
+		if (!val) {
+			pr_err("%s:RING_HEAD was zero while fw was held!\n",
+			       engine->name);
+			err = -EINVAL;
+			goto out_rpm;
+		}
+
+		/* We then expect the read to return 0 outside of the fw */
+		if (wait_for(readl(reg) == 0, 100)) {
+			pr_err("%s:RING_HEAD=%0x, fw_domains 0x%x still up after 100ms!\n",
+				engine->name, readl(reg), fw_domains);
+			err = -ETIMEDOUT;
+			goto out_rpm;
+		}
+	}
+
+out_rpm:
+	intel_runtime_pm_put(i915, wakeref);
+	return err;
+}
+
+static int live_forcewake_domains(void *arg)
 {
 #define FW_RANGE 0x40000
+	struct drm_i915_private *dev_priv = arg;
 	unsigned long *valid;
 	u32 offset;
 	int err;
@@ -179,6 +270,11 @@ static int intel_uncore_check_forcewake_domains(struct drm_i915_private *dev_pri
 
 int intel_uncore_live_selftests(struct drm_i915_private *i915)
 {
+	static const struct i915_subtest tests[] = {
+		SUBTEST(live_forcewake_ops),
+		SUBTEST(live_forcewake_domains),
+	};
+
 	int err;
 
 	/* Confirm the table we load is still valid */
@@ -188,9 +284,5 @@ int intel_uncore_live_selftests(struct drm_i915_private *i915)
 	if (err)
 		return err;
 
-	err = intel_uncore_check_forcewake_domains(i915);
-	if (err)
-		return err;
-
-	return 0;
+	return i915_subtests(tests, i915);
 }
-- 
2.20.1

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

^ permalink raw reply related	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2019-03-20 11:23 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-03-19 21:42 [PATCH 1/3] drm/i915/selftests: add test to verify get/put fw domains Chris Wilson
2019-03-19 21:42 ` [PATCH 2/3] drm/i915/selftests: Calculate maximum ring size for preemption chain Chris Wilson
2019-03-19 21:42 ` [PATCH 3/3] drm/i915/selftests: Provide stub reset functions Chris Wilson
2019-03-20  8:55   ` Mika Kuoppala
2019-03-19 22:26 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] drm/i915/selftests: add test to verify get/put fw domains Patchwork
2019-03-19 22:27 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-03-19 22:46 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-03-19 22:54 ` [PATCH] " Chris Wilson
2019-03-19 23:11 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with drm/i915/selftests: add test to verify get/put fw domains (rev2) Patchwork
2019-03-19 23:32 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-03-19 23:40 ` [PATCH] drm/i915/selftests: add test to verify get/put fw domains Chris Wilson
2019-03-19 23:55   ` Daniele Ceraolo Spurio
2019-03-20  0:17 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with drm/i915/selftests: add test to verify get/put fw domains (rev3) Patchwork
2019-03-20  0:43 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-03-20  0:45 ` [PATCH] drm/i915/selftests: add test to verify get/put fw domains Chris Wilson
2019-03-20  8:00   ` [PATCH v2] " Chris Wilson
2019-03-20  1:01 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with drm/i915/selftests: add test to verify get/put fw domains (rev4) Patchwork
2019-03-20  1:25 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-03-20 11:00 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [v2] drm/i915/selftests: add test to verify get/put fw domains (rev5) Patchwork
2019-03-20 11:23 ` ✗ Fi.CI.BAT: failure " Patchwork

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.