All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/3] drm/i915: Rename engines with to match their user interface
@ 2019-08-07  8:37 Chris Wilson
  2019-08-07  8:37 ` [PATCH 2/3] drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc Chris Wilson
                   ` (9 more replies)
  0 siblings, 10 replies; 20+ messages in thread
From: Chris Wilson @ 2019-08-07  8:37 UTC (permalink / raw)
  To: intel-gfx

During engine setup, we may find that some engines are fused off causing
a misalignment between internal names and the instances seen by users,
e.g. (I915_ENGINE_CLASS_VIDEO_DECODE, 1) may be vcs2 in hardware.
Normally this is invisible to the user, but a few debug interfaces (and
our own internal tracing) use the original HW name not the name the user
would expect as formed their class:instance tuple. Replace our internal
name with the uabi name for consistency, for example in error states.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111311
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c    | 37 ++++----------------
 drivers/gpu/drm/i915/gt/intel_engine_user.c  | 21 +++++++++++
 drivers/gpu/drm/i915/gt/intel_engine_user.h  |  2 ++
 drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 19 +++++-----
 4 files changed, 37 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index d0befd6c023a..d38c114b0964 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -55,30 +55,6 @@
 
 #define GEN8_LR_CONTEXT_OTHER_SIZE	( 2 * PAGE_SIZE)
 
-struct engine_class_info {
-	const char *name;
-	u8 uabi_class;
-};
-
-static const struct engine_class_info intel_engine_classes[] = {
-	[RENDER_CLASS] = {
-		.name = "rcs",
-		.uabi_class = I915_ENGINE_CLASS_RENDER,
-	},
-	[COPY_ENGINE_CLASS] = {
-		.name = "bcs",
-		.uabi_class = I915_ENGINE_CLASS_COPY,
-	},
-	[VIDEO_DECODE_CLASS] = {
-		.name = "vcs",
-		.uabi_class = I915_ENGINE_CLASS_VIDEO,
-	},
-	[VIDEO_ENHANCEMENT_CLASS] = {
-		.name = "vecs",
-		.uabi_class = I915_ENGINE_CLASS_VIDEO_ENHANCE,
-	},
-};
-
 #define MAX_MMIO_BASES 3
 struct engine_info {
 	unsigned int hw_id;
@@ -259,11 +235,11 @@ static u32 __engine_mmio_base(struct drm_i915_private *i915,
 	return bases[i].base;
 }
 
-static void __sprint_engine_name(char *name, const struct engine_info *info)
+static void __sprint_engine_name(struct intel_engine_cs *engine)
 {
-	WARN_ON(snprintf(name, INTEL_ENGINE_CS_MAX_NAME, "%s%u",
-			 intel_engine_classes[info->class].name,
-			 info->instance) >= INTEL_ENGINE_CS_MAX_NAME);
+	GEM_WARN_ON(snprintf(engine->name, sizeof(engine->name), "%s'%u",
+			     intel_engine_class_repr(engine),
+			     engine->instance) >= sizeof(engine->name));
 }
 
 void intel_engine_set_hwsp_writemask(struct intel_engine_cs *engine, u32 mask)
@@ -292,8 +268,6 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
 	const struct engine_info *info = &intel_engines[id];
 	struct intel_engine_cs *engine;
 
-	GEM_BUG_ON(info->class >= ARRAY_SIZE(intel_engine_classes));
-
 	BUILD_BUG_ON(MAX_ENGINE_CLASS >= BIT(GEN11_ENGINE_CLASS_WIDTH));
 	BUILD_BUG_ON(MAX_ENGINE_INSTANCE >= BIT(GEN11_ENGINE_INSTANCE_WIDTH));
 
@@ -317,11 +291,12 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
 	engine->i915 = gt->i915;
 	engine->gt = gt;
 	engine->uncore = gt->uncore;
-	__sprint_engine_name(engine->name, info);
 	engine->hw_id = engine->guc_id = info->hw_id;
 	engine->mmio_base = __engine_mmio_base(gt->i915, info->mmio_bases);
+
 	engine->class = info->class;
 	engine->instance = info->instance;
+	__sprint_engine_name(engine);
 
 	/*
 	 * To be overridden by the backend on setup. However to facilitate
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index 68fda1ac3c60..03b4ace578d7 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -127,6 +127,22 @@ static void set_scheduler_caps(struct drm_i915_private *i915)
 		i915->caps.scheduler = 0;
 }
 
+const char *intel_engine_class_repr(struct intel_engine_cs *engine)
+{
+	static const char *uabi_names[] = {
+		[RENDER_CLASS] = "rcs",
+		[COPY_ENGINE_CLASS] = "bcs",
+		[VIDEO_DECODE_CLASS] = "vcs",
+		[VIDEO_ENHANCEMENT_CLASS] = "vecs",
+	};
+
+	if (engine->class >= ARRAY_SIZE(uabi_names) ||
+	    !uabi_names[engine->class])
+		return "xxx";
+
+	return uabi_names[engine->class];
+}
+
 void intel_engines_driver_register(struct drm_i915_private *i915)
 {
 	u8 uabi_instances[4] = {};
@@ -149,6 +165,11 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 		GEM_BUG_ON(engine->uabi_class >= ARRAY_SIZE(uabi_instances));
 		engine->uabi_instance = uabi_instances[engine->uabi_class]++;
 
+		/* Replace the internal name with the final user facing name */
+		scnprintf(engine->name, sizeof(engine->name), "%s%u",
+			  intel_engine_class_repr(engine),
+			  engine->uabi_instance);
+
 		rb_link_node(&engine->uabi_node, prev, p);
 		rb_insert_color(&engine->uabi_node, &i915->uabi_engines);
 
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.h b/drivers/gpu/drm/i915/gt/intel_engine_user.h
index 9e5f113e5027..d1a08f336e70 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.h
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.h
@@ -17,6 +17,8 @@ intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance);
 
 unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915);
 
+const char *intel_engine_class_repr(struct intel_engine_cs *engine);
+
 void intel_engine_add_user(struct intel_engine_cs *engine);
 void intel_engines_driver_register(struct drm_i915_private *i915);
 
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
index cfaa6b296835..d0f4217b148a 100644
--- a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
@@ -12,19 +12,16 @@ static int intel_mmio_bases_check(void *arg)
 
 	for (i = 0; i < ARRAY_SIZE(intel_engines); i++) {
 		const struct engine_info *info = &intel_engines[i];
-		char name[INTEL_ENGINE_CS_MAX_NAME];
 		u8 prev = U8_MAX;
 
-		__sprint_engine_name(name, info);
-
 		for (j = 0; j < MAX_MMIO_BASES; j++) {
 			u8 gen = info->mmio_bases[j].gen;
 			u32 base = info->mmio_bases[j].base;
 
 			if (gen >= prev) {
-				pr_err("%s: %s: mmio base for gen %x "
-					"is before the one for gen %x\n",
-				       __func__, name, prev, gen);
+				pr_err("%s(class:%d, instance:%d): mmio base for gen %x is before the one for gen %x\n",
+				       __func__, info->class, info->instance,
+				       prev, gen);
 				return -EINVAL;
 			}
 
@@ -32,17 +29,17 @@ static int intel_mmio_bases_check(void *arg)
 				break;
 
 			if (!base) {
-				pr_err("%s: %s: invalid mmio base (%x) "
-					"for gen %x at entry %u\n",
-				       __func__, name, base, gen, j);
+				pr_err("%s(class:%d, instance:%d): invalid mmio base (%x) for gen %x at entry %u\n",
+				       __func__, info->class, info->instance,
+				       base, gen, j);
 				return -EINVAL;
 			}
 
 			prev = gen;
 		}
 
-		pr_info("%s: min gen supported for %s = %d\n",
-			__func__, name, prev);
+		pr_debug("%s: min gen supported for {class:%d, instance:%d} is %d\n",
+			 __func__, info->class, info->instance, prev);
 	}
 
 	return 0;
-- 
2.23.0.rc1

_______________________________________________
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

* [PATCH 2/3] drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
@ 2019-08-07  8:37 ` Chris Wilson
  2019-08-07 13:16   ` Mika Kuoppala
  2019-08-07  8:37 ` [PATCH 3/3] drm/i915: Defer final intel_wakeref_put to process context Chris Wilson
                   ` (8 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Chris Wilson @ 2019-08-07  8:37 UTC (permalink / raw)
  To: intel-gfx

Use the same mechanism to determine if a backend engine exists for a
uabi mapping as used internally.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/i915_drv.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
index ac5868c12b97..d7bc6e5d5c52 100644
--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -373,16 +373,20 @@ static int i915_getparam_ioctl(struct drm_device *dev, void *data,
 		value = dev_priv->overlay ? 1 : 0;
 		break;
 	case I915_PARAM_HAS_BSD:
-		value = !!dev_priv->engine[VCS0];
+		value = !!intel_engine_lookup_user(dev_priv,
+						   I915_ENGINE_CLASS_VIDEO, 0);
 		break;
 	case I915_PARAM_HAS_BLT:
-		value = !!dev_priv->engine[BCS0];
+		value = !!intel_engine_lookup_user(dev_priv,
+						   I915_ENGINE_CLASS_COPY, 0);
 		break;
 	case I915_PARAM_HAS_VEBOX:
-		value = !!dev_priv->engine[VECS0];
+		value = !!intel_engine_lookup_user(dev_priv,
+						   I915_ENGINE_CLASS_VIDEO_ENHANCE, 0);
 		break;
 	case I915_PARAM_HAS_BSD2:
-		value = !!dev_priv->engine[VCS1];
+		value = !!intel_engine_lookup_user(dev_priv,
+						   I915_ENGINE_CLASS_VIDEO, 1);
 		break;
 	case I915_PARAM_HAS_LLC:
 		value = HAS_LLC(dev_priv);
-- 
2.23.0.rc1

_______________________________________________
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

* [PATCH 3/3] drm/i915: Defer final intel_wakeref_put to process context
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
  2019-08-07  8:37 ` [PATCH 2/3] drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc Chris Wilson
@ 2019-08-07  8:37 ` Chris Wilson
  2019-08-07 15:04   ` Mika Kuoppala
  2019-08-07  9:16 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] drm/i915: Rename engines with to match their user interface Patchwork
                   ` (7 subsequent siblings)
  9 siblings, 1 reply; 20+ messages in thread
From: Chris Wilson @ 2019-08-07  8:37 UTC (permalink / raw)
  To: intel-gfx

As we need to acquire a mutex to serialise the final
intel_wakeref_put, we need to ensure that we are in process context at
that time. However, we want to allow operation on the intel_wakeref from
inside timer and other hardirq context, which means that need to defer
that final put to a workqueue.

Inside the final wakeref puts, we are safe to operate in any context, as
we are simply marking up the HW and state tracking for the potential
sleep. It's only the serialisation with the potential sleeping getting
that requires careful wait avoidance. This allows us to retain the
immediate processing as before (we only need to sleep over the same
races as the current mutex_lock).

v2: Add a selftest to ensure we exercise the code while lockdep watches.
v3: That test was extremely loud and complained about many things!

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111295
References: https://bugs.freedesktop.org/show_bug.cgi?id=111245
References: https://bugs.freedesktop.org/show_bug.cgi?id=111256
Fixes: 18398904ca9e ("drm/i915: Only recover active engines")
Fixes: 51fbd8de87dc ("drm/i915/pmu: Atomically acquire the gt_pm wakeref")
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/gem/i915_gem_pm.c        | 13 +--
 drivers/gpu/drm/i915/gt/intel_engine_cs.c     |  1 +
 drivers/gpu/drm/i915/gt/intel_engine_pm.c     | 38 +++------
 drivers/gpu/drm/i915/gt/intel_engine_pm.h     | 18 ++--
 drivers/gpu/drm/i915/gt/intel_gt_pm.c         | 28 +++----
 drivers/gpu/drm/i915/gt/intel_gt_pm.h         | 22 ++++-
 drivers/gpu/drm/i915/gt/intel_lrc.c           |  4 +-
 drivers/gpu/drm/i915/gt/selftest_engine.c     | 28 +++++++
 drivers/gpu/drm/i915/gt/selftest_engine.h     | 14 ++++
 drivers/gpu/drm/i915/gt/selftest_engine_pm.c  | 83 +++++++++++++++++++
 .../gpu/drm/i915/gt/uc/intel_guc_submission.c |  4 +-
 drivers/gpu/drm/i915/i915_debugfs.c           |  4 +
 drivers/gpu/drm/i915/i915_gem.c               | 26 +-----
 drivers/gpu/drm/i915/intel_wakeref.c          | 82 +++++++++++++-----
 drivers/gpu/drm/i915/intel_wakeref.h          | 62 +++++++++-----
 .../drm/i915/selftests/i915_live_selftests.h  |  5 +-
 16 files changed, 301 insertions(+), 131 deletions(-)
 create mode 100644 drivers/gpu/drm/i915/gt/selftest_engine.c
 create mode 100644 drivers/gpu/drm/i915/gt/selftest_engine.h
 create mode 100644 drivers/gpu/drm/i915/gt/selftest_engine_pm.c

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pm.c b/drivers/gpu/drm/i915/gem/i915_gem_pm.c
index 72922703af49..17e3618241c5 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_pm.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_pm.c
@@ -130,7 +130,9 @@ static bool switch_to_kernel_context_sync(struct intel_gt *gt)
 		}
 	} while (i915_retire_requests(gt->i915) && result);
 
-	GEM_BUG_ON(gt->awake);
+	if (intel_gt_pm_wait_for_idle(gt))
+		result = false;
+
 	return result;
 }
 
@@ -161,13 +163,6 @@ void i915_gem_suspend(struct drm_i915_private *i915)
 
 	mutex_unlock(&i915->drm.struct_mutex);
 
-	/*
-	 * Assert that we successfully flushed all the work and
-	 * reset the GPU back to its idle, low power state.
-	 */
-	GEM_BUG_ON(i915->gt.awake);
-	flush_work(&i915->gem.idle_work);
-
 	cancel_delayed_work_sync(&i915->gt.hangcheck.work);
 
 	i915_gem_drain_freed_objects(i915);
@@ -244,8 +239,6 @@ void i915_gem_resume(struct drm_i915_private *i915)
 {
 	GEM_TRACE("\n");
 
-	WARN_ON(i915->gt.awake);
-
 	mutex_lock(&i915->drm.struct_mutex);
 	intel_uncore_forcewake_get(&i915->uncore, FORCEWAKE_ALL);
 
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index d38c114b0964..b57adc973e2a 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -1568,5 +1568,6 @@ intel_engine_find_active_request(struct intel_engine_cs *engine)
 }
 
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+#include "selftest_engine.c"
 #include "selftest_engine_cs.c"
 #endif
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
index 0336204988d6..6b15e3335dd6 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
@@ -37,28 +37,6 @@ static int __engine_unpark(struct intel_wakeref *wf)
 	return 0;
 }
 
-void intel_engine_pm_get(struct intel_engine_cs *engine)
-{
-	intel_wakeref_get(&engine->i915->runtime_pm, &engine->wakeref, __engine_unpark);
-}
-
-void intel_engine_park(struct intel_engine_cs *engine)
-{
-	/*
-	 * We are committed now to parking this engine, make sure there
-	 * will be no more interrupts arriving later and the engine
-	 * is truly idle.
-	 */
-	if (wait_for(intel_engine_is_idle(engine), 10)) {
-		struct drm_printer p = drm_debug_printer(__func__);
-
-		dev_err(engine->i915->drm.dev,
-			"%s is not idle before parking\n",
-			engine->name);
-		intel_engine_dump(engine, &p, NULL);
-	}
-}
-
 static bool switch_to_kernel_context(struct intel_engine_cs *engine)
 {
 	struct i915_request *rq;
@@ -136,12 +114,18 @@ static int __engine_park(struct intel_wakeref *wf)
 	return 0;
 }
 
-void intel_engine_pm_put(struct intel_engine_cs *engine)
-{
-	intel_wakeref_put(&engine->i915->runtime_pm, &engine->wakeref, __engine_park);
-}
+static const struct intel_wakeref_ops wf_ops = {
+	.get = __engine_unpark,
+	.put = __engine_park,
+};
 
 void intel_engine_init__pm(struct intel_engine_cs *engine)
 {
-	intel_wakeref_init(&engine->wakeref);
+	struct intel_runtime_pm *rpm = &engine->i915->runtime_pm;
+
+	intel_wakeref_init(&engine->wakeref, rpm, &wf_ops);
 }
+
+#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
+#include "selftest_engine_pm.c"
+#endif
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.h b/drivers/gpu/drm/i915/gt/intel_engine_pm.h
index 015ac72d7ad0..739c50fefcef 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_pm.h
+++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.h
@@ -10,24 +10,26 @@
 #include "intel_engine_types.h"
 #include "intel_wakeref.h"
 
-struct drm_i915_private;
-
-void intel_engine_pm_get(struct intel_engine_cs *engine);
-void intel_engine_pm_put(struct intel_engine_cs *engine);
-
 static inline bool
 intel_engine_pm_is_awake(const struct intel_engine_cs *engine)
 {
 	return intel_wakeref_is_active(&engine->wakeref);
 }
 
-static inline bool
-intel_engine_pm_get_if_awake(struct intel_engine_cs *engine)
+static inline void intel_engine_pm_get(struct intel_engine_cs *engine)
+{
+	intel_wakeref_get(&engine->wakeref);
+}
+
+static inline bool intel_engine_pm_get_if_awake(struct intel_engine_cs *engine)
 {
 	return intel_wakeref_get_if_active(&engine->wakeref);
 }
 
-void intel_engine_park(struct intel_engine_cs *engine);
+static inline void intel_engine_pm_put(struct intel_engine_cs *engine)
+{
+	intel_wakeref_put(&engine->wakeref);
+}
 
 void intel_engine_init__pm(struct intel_engine_cs *engine);
 
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
index 6c8970271a7f..1363e069ec83 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_pm.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
@@ -17,7 +17,7 @@ static void pm_notify(struct drm_i915_private *i915, int state)
 	blocking_notifier_call_chain(&i915->gt.pm_notifications, state, i915);
 }
 
-static int intel_gt_unpark(struct intel_wakeref *wf)
+static int __gt_unpark(struct intel_wakeref *wf)
 {
 	struct intel_gt *gt = container_of(wf, typeof(*gt), wakeref);
 	struct drm_i915_private *i915 = gt->i915;
@@ -53,14 +53,7 @@ static int intel_gt_unpark(struct intel_wakeref *wf)
 	return 0;
 }
 
-void intel_gt_pm_get(struct intel_gt *gt)
-{
-	struct intel_runtime_pm *rpm = &gt->i915->runtime_pm;
-
-	intel_wakeref_get(rpm, &gt->wakeref, intel_gt_unpark);
-}
-
-static int intel_gt_park(struct intel_wakeref *wf)
+static int __gt_park(struct intel_wakeref *wf)
 {
 	struct drm_i915_private *i915 =
 		container_of(wf, typeof(*i915), gt.wakeref);
@@ -74,22 +67,25 @@ static int intel_gt_park(struct intel_wakeref *wf)
 	if (INTEL_GEN(i915) >= 6)
 		gen6_rps_idle(i915);
 
+	/* Everything switched off, flush any residual interrupt just in case */
+	intel_synchronize_irq(i915);
+
 	GEM_BUG_ON(!wakeref);
 	intel_display_power_put(i915, POWER_DOMAIN_GT_IRQ, wakeref);
 
 	return 0;
 }
 
-void intel_gt_pm_put(struct intel_gt *gt)
-{
-	struct intel_runtime_pm *rpm = &gt->i915->runtime_pm;
-
-	intel_wakeref_put(rpm, &gt->wakeref, intel_gt_park);
-}
+static const struct intel_wakeref_ops wf_ops = {
+	.get = __gt_unpark,
+	.put = __gt_park,
+	.flags = INTEL_WAKEREF_PUT_ASYNC,
+};
 
 void intel_gt_pm_init_early(struct intel_gt *gt)
 {
-	intel_wakeref_init(&gt->wakeref);
+	intel_wakeref_init(&gt->wakeref, &gt->i915->runtime_pm, &wf_ops);
+
 	BLOCKING_INIT_NOTIFIER_HEAD(&gt->pm_notifications);
 }
 
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
index e8a18d4b27c9..57633f538ddb 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
@@ -17,14 +17,32 @@ enum {
 	INTEL_GT_PARK,
 };
 
-void intel_gt_pm_get(struct intel_gt *gt);
-void intel_gt_pm_put(struct intel_gt *gt);
+static inline bool
+intel_gt_pm_is_awake(const struct intel_gt *gt)
+{
+	return intel_wakeref_is_active(&gt->wakeref);
+}
+
+static inline void intel_gt_pm_get(struct intel_gt *gt)
+{
+	intel_wakeref_get(&gt->wakeref);
+}
 
 static inline bool intel_gt_pm_get_if_awake(struct intel_gt *gt)
 {
 	return intel_wakeref_get_if_active(&gt->wakeref);
 }
 
+static inline void intel_gt_pm_put(struct intel_gt *gt)
+{
+	intel_wakeref_put(&gt->wakeref);
+}
+
+static inline int intel_gt_pm_wait_for_idle(struct intel_gt *gt)
+{
+	return intel_wakeref_wait_for_idle(&gt->wakeref);
+}
+
 void intel_gt_pm_init_early(struct intel_gt *gt);
 
 void intel_gt_sanitize(struct intel_gt *gt, bool force);
diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
index 232f40fcb490..1a0116751d19 100644
--- a/drivers/gpu/drm/i915/gt/intel_lrc.c
+++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
@@ -139,6 +139,7 @@
 #include "i915_vgpu.h"
 #include "intel_engine_pm.h"
 #include "intel_gt.h"
+#include "intel_gt_pm.h"
 #include "intel_lrc_reg.h"
 #include "intel_mocs.h"
 #include "intel_reset.h"
@@ -556,6 +557,7 @@ execlists_schedule_in(struct i915_request *rq, int idx)
 		intel_context_get(ce);
 		ce->inflight = rq->engine;
 
+		intel_gt_pm_get(ce->inflight->gt);
 		execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_IN);
 		intel_engine_context_in(ce->inflight);
 	}
@@ -588,6 +590,7 @@ execlists_schedule_out(struct i915_request *rq)
 	if (!intel_context_inflight_count(ce)) {
 		intel_engine_context_out(ce->inflight);
 		execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_OUT);
+		intel_gt_pm_put(ce->inflight->gt);
 
 		/*
 		 * If this is part of a virtual engine, its next request may
@@ -2719,7 +2722,6 @@ static u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *request, u32 *cs)
 static void execlists_park(struct intel_engine_cs *engine)
 {
 	del_timer_sync(&engine->execlists.timer);
-	intel_engine_park(engine);
 }
 
 void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine.c b/drivers/gpu/drm/i915/gt/selftest_engine.c
new file mode 100644
index 000000000000..f65b118e261d
--- /dev/null
+++ b/drivers/gpu/drm/i915/gt/selftest_engine.c
@@ -0,0 +1,28 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright © 2018 Intel Corporation
+ */
+
+#include "i915_selftest.h"
+#include "selftest_engine.h"
+
+int intel_engine_live_selftests(struct drm_i915_private *i915)
+{
+	static int (* const tests[])(struct intel_gt *) = {
+		live_engine_pm_selftests,
+		NULL,
+	};
+	struct intel_gt *gt = &i915->gt;
+	typeof(*tests) *fn;
+
+	for (fn = tests; *fn; fn++) {
+		int err;
+
+		err = (*fn)(gt);
+		if (err)
+			return err;
+	}
+
+	return 0;
+}
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine.h b/drivers/gpu/drm/i915/gt/selftest_engine.h
new file mode 100644
index 000000000000..ab32d09ec5a1
--- /dev/null
+++ b/drivers/gpu/drm/i915/gt/selftest_engine.h
@@ -0,0 +1,14 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef SELFTEST_ENGINE_H
+#define SELFTEST_ENGINE_H
+
+struct intel_gt;
+
+int live_engine_pm_selftests(struct intel_gt *gt);
+
+#endif
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_pm.c b/drivers/gpu/drm/i915/gt/selftest_engine_pm.c
new file mode 100644
index 000000000000..75c197612705
--- /dev/null
+++ b/drivers/gpu/drm/i915/gt/selftest_engine_pm.c
@@ -0,0 +1,83 @@
+/*
+ * SPDX-License-Identifier: GPL-2.0
+ *
+ * Copyright © 2018 Intel Corporation
+ */
+
+#include "i915_selftest.h"
+#include "selftest_engine.h"
+#include "selftests/igt_atomic.h"
+
+static int live_engine_pm(void *arg)
+{
+	struct intel_gt *gt = arg;
+	struct intel_engine_cs *engine;
+	enum intel_engine_id id;
+
+	/*
+	 * Check we can call intel_engine_pm_put from any context. No
+	 * failures are reported directly, but if we mess up lockdep should
+	 * tell us.
+	 */
+	if (intel_gt_pm_wait_for_idle(gt)) {
+		pr_err("Unable to flush GT pm before test\n");
+		return -EBUSY;
+	}
+
+	GEM_BUG_ON(intel_gt_pm_is_awake(gt));
+	for_each_engine(engine, gt->i915, id) {
+		const typeof(*igt_atomic_phases) *p;
+
+		for (p = igt_atomic_phases; p->name; p++) {
+			/*
+			 * Acquisition is always synchronous, except if we
+			 * know that the engine is already awale, in which
+			 * we should use intel_engine_pm_get_if_awake() to
+			 * atomically grab the wakeref.
+			 *
+			 * In practice,
+			 *    intel_engine_pm_get();
+			 *    intel_engine_pm_put();
+			 * occurs in one thread, while simultaneously
+			 *    intel_engine_pm_get_if_awake();
+			 *    intel_engine_pm_put();
+			 * occurs in atomic context in another.
+			 */
+			GEM_BUG_ON(intel_engine_pm_is_awake(engine));
+			intel_engine_pm_get(engine);
+
+			p->critical_section_begin();
+			if (!intel_engine_pm_get_if_awake(engine))
+				pr_err("intel_engine_pm_get_if_awake(%s) failed under %s\n",
+				       engine->name, p->name);
+			else
+				intel_engine_pm_put(engine);
+			intel_engine_pm_put(engine);
+			p->critical_section_end();
+
+			/* engine wakeref is sync (instant) */
+			if (intel_engine_pm_is_awake(engine)) {
+				pr_err("%s is still awake after flushing pm\n",
+				       engine->name);
+				return -EINVAL;
+			}
+
+			/* gt wakeref is async (deferred to workqueue) */
+			if (intel_gt_pm_wait_for_idle(gt)) {
+				pr_err("GT failed to idle\n");
+				return -EINVAL;
+			}
+		}
+	}
+
+	return 0;
+}
+
+int live_engine_pm_selftests(struct intel_gt *gt)
+{
+	static const struct i915_subtest tests[] = {
+		SUBTEST(live_engine_pm),
+	};
+
+	return intel_gt_live_subtests(tests, gt);
+}
diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
index a78bd99bc6cb..c9119b90d6aa 100644
--- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
+++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
@@ -29,6 +29,7 @@
 #include "gt/intel_context.h"
 #include "gt/intel_engine_pm.h"
 #include "gt/intel_gt.h"
+#include "gt/intel_gt_pm.h"
 #include "gt/intel_lrc_reg.h"
 #include "intel_guc_submission.h"
 
@@ -537,6 +538,7 @@ static struct i915_request *schedule_in(struct i915_request *rq, int idx)
 	if (!rq->hw_context->inflight)
 		rq->hw_context->inflight = rq->engine;
 	intel_context_inflight_inc(rq->hw_context);
+	intel_gt_pm_get(rq->engine->gt);
 
 	return i915_request_get(rq);
 }
@@ -549,6 +551,7 @@ static void schedule_out(struct i915_request *rq)
 	if (!intel_context_inflight_count(rq->hw_context))
 		rq->hw_context->inflight = NULL;
 
+	intel_gt_pm_put(rq->engine->gt);
 	i915_request_put(rq);
 }
 
@@ -1076,7 +1079,6 @@ static void guc_interrupts_release(struct intel_gt *gt)
 
 static void guc_submission_park(struct intel_engine_cs *engine)
 {
-	intel_engine_park(engine);
 	intel_engine_unpin_breadcrumbs_irq(engine);
 	engine->flags &= ~I915_ENGINE_NEEDS_BREADCRUMB_TASKLET;
 }
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 63b599f584db..68a6b002c9ba 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -39,6 +39,7 @@
 #include "display/intel_psr.h"
 
 #include "gem/i915_gem_context.h"
+#include "gt/intel_gt_pm.h"
 #include "gt/intel_reset.h"
 #include "gt/uc/intel_guc_submission.h"
 
@@ -3664,6 +3665,9 @@ i915_drop_caches_set(void *data, u64 val)
 			i915_retire_requests(i915);
 
 		mutex_unlock(&i915->drm.struct_mutex);
+
+		if (ret == 0 && val & DROP_IDLE)
+			ret = intel_gt_pm_wait_for_idle(&i915->gt);
 	}
 
 	if (val & DROP_RESET_ACTIVE && intel_gt_terminally_wedged(&i915->gt))
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 7efff14b9137..f67197336ee7 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -894,19 +894,6 @@ void i915_gem_runtime_suspend(struct drm_i915_private *i915)
 	}
 }
 
-static int wait_for_engines(struct intel_gt *gt)
-{
-	if (wait_for(intel_engines_are_idle(gt), I915_IDLE_ENGINES_TIMEOUT)) {
-		dev_err(gt->i915->drm.dev,
-			"Failed to idle engines, declaring wedged!\n");
-		GEM_TRACE_DUMP();
-		intel_gt_set_wedged(gt);
-		return -EIO;
-	}
-
-	return 0;
-}
-
 static long
 wait_for_timelines(struct drm_i915_private *i915,
 		   unsigned int flags, long timeout)
@@ -954,27 +941,20 @@ int i915_gem_wait_for_idle(struct drm_i915_private *i915,
 			   unsigned int flags, long timeout)
 {
 	/* If the device is asleep, we have no requests outstanding */
-	if (!READ_ONCE(i915->gt.awake))
+	if (!intel_gt_pm_is_awake(&i915->gt))
 		return 0;
 
-	GEM_TRACE("flags=%x (%s), timeout=%ld%s, awake?=%s\n",
+	GEM_TRACE("flags=%x (%s), timeout=%ld%s\n",
 		  flags, flags & I915_WAIT_LOCKED ? "locked" : "unlocked",
-		  timeout, timeout == MAX_SCHEDULE_TIMEOUT ? " (forever)" : "",
-		  yesno(i915->gt.awake));
+		  timeout, timeout == MAX_SCHEDULE_TIMEOUT ? " (forever)" : "");
 
 	timeout = wait_for_timelines(i915, flags, timeout);
 	if (timeout < 0)
 		return timeout;
 
 	if (flags & I915_WAIT_LOCKED) {
-		int err;
-
 		lockdep_assert_held(&i915->drm.struct_mutex);
 
-		err = wait_for_engines(&i915->gt);
-		if (err)
-			return err;
-
 		i915_retire_requests(i915);
 	}
 
diff --git a/drivers/gpu/drm/i915/intel_wakeref.c b/drivers/gpu/drm/i915/intel_wakeref.c
index 06bd8b215cc2..d4443e81c1c8 100644
--- a/drivers/gpu/drm/i915/intel_wakeref.c
+++ b/drivers/gpu/drm/i915/intel_wakeref.c
@@ -4,25 +4,25 @@
  * Copyright © 2019 Intel Corporation
  */
 
+#include <linux/wait_bit.h>
+
 #include "intel_runtime_pm.h"
 #include "intel_wakeref.h"
 
-static void rpm_get(struct intel_runtime_pm *rpm, struct intel_wakeref *wf)
+static void rpm_get(struct intel_wakeref *wf)
 {
-	wf->wakeref = intel_runtime_pm_get(rpm);
+	wf->wakeref = intel_runtime_pm_get(wf->rpm);
 }
 
-static void rpm_put(struct intel_runtime_pm *rpm, struct intel_wakeref *wf)
+static void rpm_put(struct intel_wakeref *wf)
 {
 	intel_wakeref_t wakeref = fetch_and_zero(&wf->wakeref);
 
-	intel_runtime_pm_put(rpm, wakeref);
+	intel_runtime_pm_put(wf->rpm, wakeref);
 	INTEL_WAKEREF_BUG_ON(!wakeref);
 }
 
-int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
-			      struct intel_wakeref *wf,
-			      int (*fn)(struct intel_wakeref *wf))
+int __intel_wakeref_get_first(struct intel_wakeref *wf)
 {
 	/*
 	 * Treat get/put as different subclasses, as we may need to run
@@ -34,11 +34,11 @@ int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
 	if (!atomic_read(&wf->count)) {
 		int err;
 
-		rpm_get(rpm, wf);
+		rpm_get(wf);
 
-		err = fn(wf);
+		err = wf->ops->get(wf);
 		if (unlikely(err)) {
-			rpm_put(rpm, wf);
+			rpm_put(wf);
 			mutex_unlock(&wf->mutex);
 			return err;
 		}
@@ -52,27 +52,67 @@ int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
 	return 0;
 }
 
-int __intel_wakeref_put_last(struct intel_runtime_pm *rpm,
-			     struct intel_wakeref *wf,
-			     int (*fn)(struct intel_wakeref *wf))
+static void ____intel_wakeref_put_last(struct intel_wakeref *wf)
 {
-	int err;
+	if (!atomic_dec_and_test(&wf->count))
+		goto unlock;
+
+	if (likely(!wf->ops->put(wf))) {
+		rpm_put(wf);
+		wake_up_var(&wf->wakeref);
+	} else {
+		/* ops->put() must schedule its own release on deferral */
+		atomic_set_release(&wf->count, 1);
+	}
 
-	err = fn(wf);
-	if (likely(!err))
-		rpm_put(rpm, wf);
-	else
-		atomic_inc(&wf->count);
+unlock:
 	mutex_unlock(&wf->mutex);
+}
+
+void __intel_wakeref_put_last(struct intel_wakeref *wf)
+{
+	INTEL_WAKEREF_BUG_ON(work_pending(&wf->work));
 
-	return err;
+	/* Assume we are not in process context and so cannot sleep. */
+	if (wf->ops->flags & INTEL_WAKEREF_PUT_ASYNC ||
+	    !mutex_trylock(&wf->mutex)) {
+		schedule_work(&wf->work);
+		return;
+	}
+
+	____intel_wakeref_put_last(wf);
 }
 
-void __intel_wakeref_init(struct intel_wakeref *wf, struct lock_class_key *key)
+static void __intel_wakeref_put_work(struct work_struct *wrk)
 {
+	struct intel_wakeref *wf = container_of(wrk, typeof(*wf), work);
+
+	if (atomic_add_unless(&wf->count, -1, 1))
+		return;
+
+	mutex_lock(&wf->mutex);
+	____intel_wakeref_put_last(wf);
+}
+
+void __intel_wakeref_init(struct intel_wakeref *wf,
+			  struct intel_runtime_pm *rpm,
+			  const struct intel_wakeref_ops *ops,
+			  struct lock_class_key *key)
+{
+	wf->rpm = rpm;
+	wf->ops = ops;
+
 	__mutex_init(&wf->mutex, "wakeref", key);
 	atomic_set(&wf->count, 0);
 	wf->wakeref = 0;
+
+	INIT_WORK(&wf->work, __intel_wakeref_put_work);
+}
+
+int intel_wakeref_wait_for_idle(struct intel_wakeref *wf)
+{
+	return wait_var_event_killable(&wf->wakeref,
+				       !intel_wakeref_is_active(wf));
 }
 
 static void wakeref_auto_timeout(struct timer_list *t)
diff --git a/drivers/gpu/drm/i915/intel_wakeref.h b/drivers/gpu/drm/i915/intel_wakeref.h
index 1d6f5986e4e5..535a3a12864b 100644
--- a/drivers/gpu/drm/i915/intel_wakeref.h
+++ b/drivers/gpu/drm/i915/intel_wakeref.h
@@ -8,10 +8,12 @@
 #define INTEL_WAKEREF_H
 
 #include <linux/atomic.h>
+#include <linux/bits.h>
 #include <linux/mutex.h>
 #include <linux/refcount.h>
 #include <linux/stackdepot.h>
 #include <linux/timer.h>
+#include <linux/workqueue.h>
 
 #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
 #define INTEL_WAKEREF_BUG_ON(expr) BUG_ON(expr)
@@ -20,29 +22,42 @@
 #endif
 
 struct intel_runtime_pm;
+struct intel_wakeref;
 
 typedef depot_stack_handle_t intel_wakeref_t;
 
+struct intel_wakeref_ops {
+	int (*get)(struct intel_wakeref *wf);
+	int (*put)(struct intel_wakeref *wf);
+
+	unsigned long flags;
+#define INTEL_WAKEREF_PUT_ASYNC BIT(0)
+};
+
 struct intel_wakeref {
 	atomic_t count;
 	struct mutex mutex;
+
 	intel_wakeref_t wakeref;
+
+	struct intel_runtime_pm *rpm;
+	const struct intel_wakeref_ops *ops;
+
+	struct work_struct work;
 };
 
 void __intel_wakeref_init(struct intel_wakeref *wf,
+			  struct intel_runtime_pm *rpm,
+			  const struct intel_wakeref_ops *ops,
 			  struct lock_class_key *key);
-#define intel_wakeref_init(wf) do {					\
+#define intel_wakeref_init(wf, rpm, ops) do {				\
 	static struct lock_class_key __key;				\
 									\
-	__intel_wakeref_init((wf), &__key);				\
+	__intel_wakeref_init((wf), (rpm), (ops), &__key);		\
 } while (0)
 
-int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
-			      struct intel_wakeref *wf,
-			      int (*fn)(struct intel_wakeref *wf));
-int __intel_wakeref_put_last(struct intel_runtime_pm *rpm,
-			     struct intel_wakeref *wf,
-			     int (*fn)(struct intel_wakeref *wf));
+int __intel_wakeref_get_first(struct intel_wakeref *wf);
+void __intel_wakeref_put_last(struct intel_wakeref *wf);
 
 /**
  * intel_wakeref_get: Acquire the wakeref
@@ -61,12 +76,10 @@ int __intel_wakeref_put_last(struct intel_runtime_pm *rpm,
  * code otherwise.
  */
 static inline int
-intel_wakeref_get(struct intel_runtime_pm *rpm,
-		  struct intel_wakeref *wf,
-		  int (*fn)(struct intel_wakeref *wf))
+intel_wakeref_get(struct intel_wakeref *wf)
 {
 	if (unlikely(!atomic_inc_not_zero(&wf->count)))
-		return __intel_wakeref_get_first(rpm, wf, fn);
+		return __intel_wakeref_get_first(wf);
 
 	return 0;
 }
@@ -102,16 +115,12 @@ intel_wakeref_get_if_active(struct intel_wakeref *wf)
  * Returns: 0 if the wakeref was released successfully, or a negative error
  * code otherwise.
  */
-static inline int
-intel_wakeref_put(struct intel_runtime_pm *rpm,
-		  struct intel_wakeref *wf,
-		  int (*fn)(struct intel_wakeref *wf))
+static inline void
+intel_wakeref_put(struct intel_wakeref *wf)
 {
 	INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count) <= 0);
-	if (atomic_dec_and_mutex_lock(&wf->count, &wf->mutex))
-		return __intel_wakeref_put_last(rpm, wf, fn);
-
-	return 0;
+	if (unlikely(!atomic_add_unless(&wf->count, -1, 1)))
+		__intel_wakeref_put_last(wf);
 }
 
 /**
@@ -154,6 +163,19 @@ intel_wakeref_is_active(const struct intel_wakeref *wf)
 	return READ_ONCE(wf->wakeref);
 }
 
+/**
+ * intel_wakeref_wait_for_idle: Wait until the wakeref is idle
+ * @wf: the wakeref
+ *
+ * Wait for the earlier asynchronous release of the wakeref. Note
+ * this will wait for any third party as well, so make sure you only wait
+ * when you have control over the wakeref and trust no one else is acquiring
+ * it.
+ *
+ * Return: 0 on success, error code if killed.
+ */
+int intel_wakeref_wait_for_idle(struct intel_wakeref *wf);
+
 struct intel_wakeref_auto {
 	struct intel_runtime_pm *rpm;
 	struct timer_list timer;
diff --git a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
index a841d3f9bedc..1ccf0f731ac0 100644
--- a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
+++ b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
@@ -12,10 +12,11 @@
 selftest(sanitycheck, i915_live_sanitycheck) /* keep first (igt selfcheck) */
 selftest(uncore, intel_uncore_live_selftests)
 selftest(workarounds, intel_workarounds_live_selftests)
-selftest(timelines, intel_timeline_live_selftests)
+selftest(gt_engines, intel_engine_live_selftests)
+selftest(gt_timelines, intel_timeline_live_selftests)
+selftest(gt_contexts, intel_context_live_selftests)
 selftest(requests, i915_request_live_selftests)
 selftest(active, i915_active_live_selftests)
-selftest(gt_contexts, intel_context_live_selftests)
 selftest(objects, i915_gem_object_live_selftests)
 selftest(mman, i915_gem_mman_live_selftests)
 selftest(dmabuf, i915_gem_dmabuf_live_selftests)
-- 
2.23.0.rc1

_______________________________________________
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

* ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] drm/i915: Rename engines with to match their user interface
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
  2019-08-07  8:37 ` [PATCH 2/3] drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc Chris Wilson
  2019-08-07  8:37 ` [PATCH 3/3] drm/i915: Defer final intel_wakeref_put to process context Chris Wilson
@ 2019-08-07  9:16 ` Patchwork
  2019-08-07  9:18 ` ✗ Fi.CI.SPARSE: " Patchwork
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-07  9:16 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/3] drm/i915: Rename engines with to match their user interface
URL   : https://patchwork.freedesktop.org/series/64824/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
61e3542a4d4c drm/i915: Rename engines with to match their user interface
-:101: WARNING:STATIC_CONST_CHAR_ARRAY: static const char * array should probably be static const char * const
#101: FILE: drivers/gpu/drm/i915/gt/intel_engine_user.c:132:
+	static const char *uabi_names[] = {

total: 0 errors, 1 warnings, 0 checks, 151 lines checked
48f1729f2f63 drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc
18516f9c1ff9 drm/i915: Defer final intel_wakeref_put to process context
-:314: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#314: 
new file mode 100644

-:319: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1
#319: FILE: drivers/gpu/drm/i915/gt/selftest_engine.c:1:
+/*

-:320: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use line 1 instead
#320: FILE: drivers/gpu/drm/i915/gt/selftest_engine.c:2:
+ * SPDX-License-Identifier: GPL-2.0

-:353: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1
#353: FILE: drivers/gpu/drm/i915/gt/selftest_engine.h:1:
+/*

-:354: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use line 1 instead
#354: FILE: drivers/gpu/drm/i915/gt/selftest_engine.h:2:
+ * SPDX-License-Identifier: GPL-2.0

-:373: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1
#373: FILE: drivers/gpu/drm/i915/gt/selftest_engine_pm.c:1:
+/*

-:374: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use line 1 instead
#374: FILE: drivers/gpu/drm/i915/gt/selftest_engine_pm.c:2:
+ * SPDX-License-Identifier: GPL-2.0

total: 0 errors, 7 warnings, 0 checks, 709 lines checked

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

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

* ✗ Fi.CI.SPARSE: warning for series starting with [1/3] drm/i915: Rename engines with to match their user interface
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
                   ` (2 preceding siblings ...)
  2019-08-07  9:16 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] drm/i915: Rename engines with to match their user interface Patchwork
@ 2019-08-07  9:18 ` Patchwork
  2019-08-07  9:45 ` ✗ Fi.CI.BAT: failure " Patchwork
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-07  9:18 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/3] drm/i915: Rename engines with to match their user interface
URL   : https://patchwork.freedesktop.org/series/64824/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.5.2
Commit: drm/i915: Rename engines with to match their user interface
Okay!

Commit: drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc
Okay!

Commit: drm/i915: Defer final intel_wakeref_put to process context
+drivers/gpu/drm/i915/gt/selftest_engine.c:19:26: error: incorrect type in conditional
+drivers/gpu/drm/i915/gt/selftest_engine.c:19:26:    got unknown type 11 <noident>

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

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

* ✗ Fi.CI.BAT: failure for series starting with [1/3] drm/i915: Rename engines with to match their user interface
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
                   ` (3 preceding siblings ...)
  2019-08-07  9:18 ` ✗ Fi.CI.SPARSE: " Patchwork
@ 2019-08-07  9:45 ` Patchwork
  2019-08-07 10:31 ` [PATCH 1/3] " Mika Kuoppala
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-07  9:45 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/3] drm/i915: Rename engines with to match their user interface
URL   : https://patchwork.freedesktop.org/series/64824/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_6642 -> Patchwork_13895
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_13895 absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_13895, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13895/

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_13895:

### IGT changes ###

#### Possible regressions ####

  * igt@i915_module_load@reload-no-display:
    - fi-bwr-2160:        [PASS][1] -> [INCOMPLETE][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6642/fi-bwr-2160/igt@i915_module_load@reload-no-display.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13895/fi-bwr-2160/igt@i915_module_load@reload-no-display.html

  
New tests
---------

  New tests have been introduced between CI_DRM_6642 and Patchwork_13895:

### New IGT tests (2) ###

  * igt@i915_selftest@live_gt_engines:
    - Statuses : 41 pass(s)
    - Exec time: [0.34, 1.36] s

  * igt@i915_selftest@live_gt_timelines:
    - Statuses : 41 pass(s)
    - Exec time: [1.33, 10.93] s

  

Known issues
------------

  Here are the changes found in Patchwork_13895 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_mmap_gtt@basic-write-gtt:
    - fi-icl-u3:          [PASS][3] -> [DMESG-WARN][4] ([fdo#107724]) +2 similar issues
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6642/fi-icl-u3/igt@gem_mmap_gtt@basic-write-gtt.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13895/fi-icl-u3/igt@gem_mmap_gtt@basic-write-gtt.html

  * igt@i915_selftest@live_execlists:
    - fi-skl-gvtdvm:      [PASS][5] -> [DMESG-FAIL][6] ([fdo#111108])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6642/fi-skl-gvtdvm/igt@i915_selftest@live_execlists.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13895/fi-skl-gvtdvm/igt@i915_selftest@live_execlists.html

  * igt@i915_selftest@live_reset:
    - fi-icl-u3:          [PASS][7] -> [INCOMPLETE][8] ([fdo#107713])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6642/fi-icl-u3/igt@i915_selftest@live_reset.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13895/fi-icl-u3/igt@i915_selftest@live_reset.html

  * igt@kms_busy@basic-flip-c:
    - fi-kbl-7500u:       [PASS][9] -> [SKIP][10] ([fdo#109271] / [fdo#109278]) +2 similar issues
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6642/fi-kbl-7500u/igt@kms_busy@basic-flip-c.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13895/fi-kbl-7500u/igt@kms_busy@basic-flip-c.html

  * igt@prime_vgem@basic-fence-flip:
    - fi-kbl-7500u:       [PASS][11] -> [SKIP][12] ([fdo#109271]) +23 similar issues
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6642/fi-kbl-7500u/igt@prime_vgem@basic-fence-flip.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13895/fi-kbl-7500u/igt@prime_vgem@basic-fence-flip.html

  
#### Possible fixes ####

  * igt@kms_chamelium@dp-edid-read:
    - fi-cml-u2:          [FAIL][13] ([fdo#109483]) -> [PASS][14]
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6642/fi-cml-u2/igt@kms_chamelium@dp-edid-read.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13895/fi-cml-u2/igt@kms_chamelium@dp-edid-read.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#102505]: https://bugs.freedesktop.org/show_bug.cgi?id=102505
  [fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
  [fdo#106107]: https://bugs.freedesktop.org/show_bug.cgi?id=106107
  [fdo#106350]: https://bugs.freedesktop.org/show_bug.cgi?id=106350
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109278]: https://bugs.freedesktop.org/show_bug.cgi?id=109278
  [fdo#109309]: https://bugs.freedesktop.org/show_bug.cgi?id=109309
  [fdo#109483]: https://bugs.freedesktop.org/show_bug.cgi?id=109483
  [fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485
  [fdo#111045]: https://bugs.freedesktop.org/show_bug.cgi?id=111045
  [fdo#111046 ]: https://bugs.freedesktop.org/show_bug.cgi?id=111046 
  [fdo#111108]: https://bugs.freedesktop.org/show_bug.cgi?id=111108


Participating hosts (53 -> 43)
------------------------------

  Missing    (10): fi-kbl-soraka fi-ilk-m540 fi-bsw-n3050 fi-byt-squawks fi-bsw-cyan fi-pnv-d510 fi-icl-y fi-icl-guc fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6642 -> Patchwork_13895

  CI-20190529: 20190529
  CI_DRM_6642: c6985b96f0eec20215e33673ded4fce46ec6293a @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5122: f250ada4946087af668c6b88b3fa372c98e11ede @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_13895: 18516f9c1ff9be79fb03e6211d78ff4569c9b38c @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

18516f9c1ff9 drm/i915: Defer final intel_wakeref_put to process context
48f1729f2f63 drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc
61e3542a4d4c drm/i915: Rename engines with to match their user interface

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13895/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 1/3] drm/i915: Rename engines with to match their user interface
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
                   ` (4 preceding siblings ...)
  2019-08-07  9:45 ` ✗ Fi.CI.BAT: failure " Patchwork
@ 2019-08-07 10:31 ` Mika Kuoppala
  2019-08-07 10:44   ` Chris Wilson
                     ` (2 more replies)
  2019-08-07 12:32 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [v3] drm/i915: Rename engines to match their user interface (rev3) Patchwork
                   ` (3 subsequent siblings)
  9 siblings, 3 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-08-07 10:31 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Chris Wilson <chris@chris-wilson.co.uk> writes:

> During engine setup, we may find that some engines are fused off causing
> a misalignment between internal names and the instances seen by users,
> e.g. (I915_ENGINE_CLASS_VIDEO_DECODE, 1) may be vcs2 in hardware.
> Normally this is invisible to the user, but a few debug interfaces (and
> our own internal tracing) use the original HW name not the name the user
> would expect as formed their class:instance tuple. Replace our internal
> name with the uabi name for consistency, for example in error states.
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111311
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> ---
>  drivers/gpu/drm/i915/gt/intel_engine_cs.c    | 37 ++++----------------
>  drivers/gpu/drm/i915/gt/intel_engine_user.c  | 21 +++++++++++
>  drivers/gpu/drm/i915/gt/intel_engine_user.h  |  2 ++
>  drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 19 +++++-----
>  4 files changed, 37 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> index d0befd6c023a..d38c114b0964 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> @@ -55,30 +55,6 @@
>  
>  #define GEN8_LR_CONTEXT_OTHER_SIZE	( 2 * PAGE_SIZE)
>  
> -struct engine_class_info {
> -	const char *name;
> -	u8 uabi_class;
> -};
> -
> -static const struct engine_class_info intel_engine_classes[] = {
> -	[RENDER_CLASS] = {
> -		.name = "rcs",
> -		.uabi_class = I915_ENGINE_CLASS_RENDER,
> -	},
> -	[COPY_ENGINE_CLASS] = {
> -		.name = "bcs",
> -		.uabi_class = I915_ENGINE_CLASS_COPY,
> -	},
> -	[VIDEO_DECODE_CLASS] = {
> -		.name = "vcs",
> -		.uabi_class = I915_ENGINE_CLASS_VIDEO,
> -	},
> -	[VIDEO_ENHANCEMENT_CLASS] = {
> -		.name = "vecs",
> -		.uabi_class = I915_ENGINE_CLASS_VIDEO_ENHANCE,
> -	},
> -};
> -
>  #define MAX_MMIO_BASES 3
>  struct engine_info {
>  	unsigned int hw_id;
> @@ -259,11 +235,11 @@ static u32 __engine_mmio_base(struct drm_i915_private *i915,
>  	return bases[i].base;
>  }
>  
> -static void __sprint_engine_name(char *name, const struct engine_info *info)
> +static void __sprint_engine_name(struct intel_engine_cs *engine)
>  {
> -	WARN_ON(snprintf(name, INTEL_ENGINE_CS_MAX_NAME, "%s%u",
> -			 intel_engine_classes[info->class].name,
> -			 info->instance) >= INTEL_ENGINE_CS_MAX_NAME);
> +	GEM_WARN_ON(snprintf(engine->name, sizeof(engine->name), "%s'%u",
                                                                    ^ ?

unexpected
                                                                 
> +			     intel_engine_class_repr(engine),
> +			     engine->instance) >= sizeof(engine->name));
>  }
>  
>  void intel_engine_set_hwsp_writemask(struct intel_engine_cs *engine, u32 mask)
> @@ -292,8 +268,6 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
>  	const struct engine_info *info = &intel_engines[id];
>  	struct intel_engine_cs *engine;
>  
> -	GEM_BUG_ON(info->class >= ARRAY_SIZE(intel_engine_classes));
> -
>  	BUILD_BUG_ON(MAX_ENGINE_CLASS >= BIT(GEN11_ENGINE_CLASS_WIDTH));
>  	BUILD_BUG_ON(MAX_ENGINE_INSTANCE >= BIT(GEN11_ENGINE_INSTANCE_WIDTH));
>  
> @@ -317,11 +291,12 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
>  	engine->i915 = gt->i915;
>  	engine->gt = gt;
>  	engine->uncore = gt->uncore;
> -	__sprint_engine_name(engine->name, info);
>  	engine->hw_id = engine->guc_id = info->hw_id;
>  	engine->mmio_base = __engine_mmio_base(gt->i915, info->mmio_bases);
> +
>  	engine->class = info->class;
>  	engine->instance = info->instance;
> +	__sprint_engine_name(engine);
>  
>  	/*
>  	 * To be overridden by the backend on setup. However to facilitate
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
> index 68fda1ac3c60..03b4ace578d7 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
> @@ -127,6 +127,22 @@ static void set_scheduler_caps(struct drm_i915_private *i915)
>  		i915->caps.scheduler = 0;
>  }
>  
> +const char *intel_engine_class_repr(struct intel_engine_cs *engine)

I dont mind the repr, but we have been using _str.

> +{
> +	static const char *uabi_names[] = {
> +		[RENDER_CLASS] = "rcs",
> +		[COPY_ENGINE_CLASS] = "bcs",
> +		[VIDEO_DECODE_CLASS] = "vcs",
> +		[VIDEO_ENHANCEMENT_CLASS] = "vecs",
> +	};
> +
> +	if (engine->class >= ARRAY_SIZE(uabi_names) ||
> +	    !uabi_names[engine->class])
> +		return "xxx";

or "unknown" shrug.

> +
> +	return uabi_names[engine->class];
> +}
> +
>  void intel_engines_driver_register(struct drm_i915_private *i915)
>  {
>  	u8 uabi_instances[4] = {};
> @@ -149,6 +165,11 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
>  		GEM_BUG_ON(engine->uabi_class >= ARRAY_SIZE(uabi_instances));
>  		engine->uabi_instance = uabi_instances[engine->uabi_class]++;
>  
> +		/* Replace the internal name with the final user facing name */
> +		scnprintf(engine->name, sizeof(engine->name), "%s%u",
> +			  intel_engine_class_repr(engine),
> +			  engine->uabi_instance);

Hmm, this was the reason for ' ?
-Mika


> +
>  		rb_link_node(&engine->uabi_node, prev, p);
>  		rb_insert_color(&engine->uabi_node, &i915->uabi_engines);
>  
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.h b/drivers/gpu/drm/i915/gt/intel_engine_user.h
> index 9e5f113e5027..d1a08f336e70 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_user.h
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_user.h
> @@ -17,6 +17,8 @@ intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance);
>  
>  unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915);
>  
> +const char *intel_engine_class_repr(struct intel_engine_cs *engine);
> +
>  void intel_engine_add_user(struct intel_engine_cs *engine);
>  void intel_engines_driver_register(struct drm_i915_private *i915);
>  
> diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
> index cfaa6b296835..d0f4217b148a 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
> @@ -12,19 +12,16 @@ static int intel_mmio_bases_check(void *arg)
>  
>  	for (i = 0; i < ARRAY_SIZE(intel_engines); i++) {
>  		const struct engine_info *info = &intel_engines[i];
> -		char name[INTEL_ENGINE_CS_MAX_NAME];
>  		u8 prev = U8_MAX;
>  
> -		__sprint_engine_name(name, info);
> -
>  		for (j = 0; j < MAX_MMIO_BASES; j++) {
>  			u8 gen = info->mmio_bases[j].gen;
>  			u32 base = info->mmio_bases[j].base;
>  
>  			if (gen >= prev) {
> -				pr_err("%s: %s: mmio base for gen %x "
> -					"is before the one for gen %x\n",
> -				       __func__, name, prev, gen);
> +				pr_err("%s(class:%d, instance:%d): mmio base for gen %x is before the one for gen %x\n",
> +				       __func__, info->class, info->instance,
> +				       prev, gen);
>  				return -EINVAL;
>  			}
>  
> @@ -32,17 +29,17 @@ static int intel_mmio_bases_check(void *arg)
>  				break;
>  
>  			if (!base) {
> -				pr_err("%s: %s: invalid mmio base (%x) "
> -					"for gen %x at entry %u\n",
> -				       __func__, name, base, gen, j);
> +				pr_err("%s(class:%d, instance:%d): invalid mmio base (%x) for gen %x at entry %u\n",
> +				       __func__, info->class, info->instance,
> +				       base, gen, j);
>  				return -EINVAL;
>  			}
>  
>  			prev = gen;
>  		}
>  
> -		pr_info("%s: min gen supported for %s = %d\n",
> -			__func__, name, prev);
> +		pr_debug("%s: min gen supported for {class:%d, instance:%d} is %d\n",
> +			 __func__, info->class, info->instance, prev);
>  	}
>  
>  	return 0;
> -- 
> 2.23.0.rc1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 1/3] drm/i915: Rename engines with to match their user interface
  2019-08-07 10:31 ` [PATCH 1/3] " Mika Kuoppala
@ 2019-08-07 10:44   ` Chris Wilson
  2019-08-07 10:55   ` [PATCH v2] drm/i915: Rename engines " Chris Wilson
  2019-08-07 11:04   ` [PATCH v3] " Chris Wilson
  2 siblings, 0 replies; 20+ messages in thread
From: Chris Wilson @ 2019-08-07 10:44 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-08-07 11:31:14)
> Chris Wilson <chris@chris-wilson.co.uk> writes:
> 
> > During engine setup, we may find that some engines are fused off causing
> > a misalignment between internal names and the instances seen by users,
> > e.g. (I915_ENGINE_CLASS_VIDEO_DECODE, 1) may be vcs2 in hardware.
> > Normally this is invisible to the user, but a few debug interfaces (and
> > our own internal tracing) use the original HW name not the name the user
> > would expect as formed their class:instance tuple. Replace our internal
> > name with the uabi name for consistency, for example in error states.
> >
> > Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111311
> > Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
> > ---
> >  drivers/gpu/drm/i915/gt/intel_engine_cs.c    | 37 ++++----------------
> >  drivers/gpu/drm/i915/gt/intel_engine_user.c  | 21 +++++++++++
> >  drivers/gpu/drm/i915/gt/intel_engine_user.h  |  2 ++
> >  drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 19 +++++-----
> >  4 files changed, 37 insertions(+), 42 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> > index d0befd6c023a..d38c114b0964 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> > @@ -55,30 +55,6 @@
> >  
> >  #define GEN8_LR_CONTEXT_OTHER_SIZE   ( 2 * PAGE_SIZE)
> >  
> > -struct engine_class_info {
> > -     const char *name;
> > -     u8 uabi_class;
> > -};
> > -
> > -static const struct engine_class_info intel_engine_classes[] = {
> > -     [RENDER_CLASS] = {
> > -             .name = "rcs",
> > -             .uabi_class = I915_ENGINE_CLASS_RENDER,
> > -     },
> > -     [COPY_ENGINE_CLASS] = {
> > -             .name = "bcs",
> > -             .uabi_class = I915_ENGINE_CLASS_COPY,
> > -     },
> > -     [VIDEO_DECODE_CLASS] = {
> > -             .name = "vcs",
> > -             .uabi_class = I915_ENGINE_CLASS_VIDEO,
> > -     },
> > -     [VIDEO_ENHANCEMENT_CLASS] = {
> > -             .name = "vecs",
> > -             .uabi_class = I915_ENGINE_CLASS_VIDEO_ENHANCE,
> > -     },
> > -};
> > -
> >  #define MAX_MMIO_BASES 3
> >  struct engine_info {
> >       unsigned int hw_id;
> > @@ -259,11 +235,11 @@ static u32 __engine_mmio_base(struct drm_i915_private *i915,
> >       return bases[i].base;
> >  }
> >  
> > -static void __sprint_engine_name(char *name, const struct engine_info *info)
> > +static void __sprint_engine_name(struct intel_engine_cs *engine)
> >  {
> > -     WARN_ON(snprintf(name, INTEL_ENGINE_CS_MAX_NAME, "%s%u",
> > -                      intel_engine_classes[info->class].name,
> > -                      info->instance) >= INTEL_ENGINE_CS_MAX_NAME);
> > +     GEM_WARN_ON(snprintf(engine->name, sizeof(engine->name), "%s'%u",
>                                                                     ^ ?
> 
> unexpected

I needed some short way of identifying the proto-name from the final
name for debugging. (It has to be kept short to fit inside the small
embedded name[].) After some deliberation, I went with class' as being
easy to distinguish and not likely to match other shorthand.

I thought about keeping engine->name and engine->uabi_name, but I think
that leads to longer term confusion. Our debug traces will say one thing,
but uAPI another, with no clear correlation.

It's only a name and I expect we will revisit the topic again.

> > +                          intel_engine_class_repr(engine),
> > +                          engine->instance) >= sizeof(engine->name));
> >  }
> >  
> >  void intel_engine_set_hwsp_writemask(struct intel_engine_cs *engine, u32 mask)
> > @@ -292,8 +268,6 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
> >       const struct engine_info *info = &intel_engines[id];
> >       struct intel_engine_cs *engine;
> >  
> > -     GEM_BUG_ON(info->class >= ARRAY_SIZE(intel_engine_classes));
> > -
> >       BUILD_BUG_ON(MAX_ENGINE_CLASS >= BIT(GEN11_ENGINE_CLASS_WIDTH));
> >       BUILD_BUG_ON(MAX_ENGINE_INSTANCE >= BIT(GEN11_ENGINE_INSTANCE_WIDTH));
> >  
> > @@ -317,11 +291,12 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
> >       engine->i915 = gt->i915;
> >       engine->gt = gt;
> >       engine->uncore = gt->uncore;
> > -     __sprint_engine_name(engine->name, info);
> >       engine->hw_id = engine->guc_id = info->hw_id;
> >       engine->mmio_base = __engine_mmio_base(gt->i915, info->mmio_bases);
> > +
> >       engine->class = info->class;
> >       engine->instance = info->instance;
> > +     __sprint_engine_name(engine);
> >  
> >       /*
> >        * To be overridden by the backend on setup. However to facilitate
> > diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
> > index 68fda1ac3c60..03b4ace578d7 100644
> > --- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
> > +++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
> > @@ -127,6 +127,22 @@ static void set_scheduler_caps(struct drm_i915_private *i915)
> >               i915->caps.scheduler = 0;
> >  }
> >  
> > +const char *intel_engine_class_repr(struct intel_engine_cs *engine)
> 
> I dont mind the repr, but we have been using _str.
> 
> > +{
> > +     static const char *uabi_names[] = {
> > +             [RENDER_CLASS] = "rcs",
> > +             [COPY_ENGINE_CLASS] = "bcs",
> > +             [VIDEO_DECODE_CLASS] = "vcs",
> > +             [VIDEO_ENHANCEMENT_CLASS] = "vecs",
> > +     };
> > +
> > +     if (engine->class >= ARRAY_SIZE(uabi_names) ||
> > +         !uabi_names[engine->class])
> > +             return "xxx";
> 
> or "unknown" shrug.

We're a bit tight on characters.

> > +
> > +     return uabi_names[engine->class];
> > +}
> > +
> >  void intel_engines_driver_register(struct drm_i915_private *i915)
> >  {
> >       u8 uabi_instances[4] = {};
> > @@ -149,6 +165,11 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
> >               GEM_BUG_ON(engine->uabi_class >= ARRAY_SIZE(uabi_instances));
> >               engine->uabi_instance = uabi_instances[engine->uabi_class]++;
> >  
> > +             /* Replace the internal name with the final user facing name */
> > +             scnprintf(engine->name, sizeof(engine->name), "%s%u",
> > +                       intel_engine_class_repr(engine),
> > +                       engine->uabi_instance);
> 
> Hmm, this was the reason for ' ?

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

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

* [PATCH v2] drm/i915: Rename engines to match their user interface
  2019-08-07 10:31 ` [PATCH 1/3] " Mika Kuoppala
  2019-08-07 10:44   ` Chris Wilson
@ 2019-08-07 10:55   ` Chris Wilson
  2019-08-07 11:04   ` [PATCH v3] " Chris Wilson
  2 siblings, 0 replies; 20+ messages in thread
From: Chris Wilson @ 2019-08-07 10:55 UTC (permalink / raw)
  To: intel-gfx

During engine setup, we may find that some engines are fused off causing
a misalignment between internal names and the instances seen by users,
e.g. (I915_ENGINE_CLASS_VIDEO_DECODE, 1) may be vcs2 in hardware.
Normally this is invisible to the user, but a few debug interfaces (and
our own internal tracing) use the original HW name not the name the user
would expect as formed from their class:instance tuple. Replace our
internal name with the uabi name for consistency with, for example, error
states.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111311
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c    | 42 +++++---------------
 drivers/gpu/drm/i915/gt/intel_engine_user.c  | 24 +++++++++++
 drivers/gpu/drm/i915/gt/intel_engine_user.h  |  2 +
 drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 19 ++++-----
 4 files changed, 45 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index d0befd6c023a..57827fdcf447 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -55,30 +55,6 @@
 
 #define GEN8_LR_CONTEXT_OTHER_SIZE	( 2 * PAGE_SIZE)
 
-struct engine_class_info {
-	const char *name;
-	u8 uabi_class;
-};
-
-static const struct engine_class_info intel_engine_classes[] = {
-	[RENDER_CLASS] = {
-		.name = "rcs",
-		.uabi_class = I915_ENGINE_CLASS_RENDER,
-	},
-	[COPY_ENGINE_CLASS] = {
-		.name = "bcs",
-		.uabi_class = I915_ENGINE_CLASS_COPY,
-	},
-	[VIDEO_DECODE_CLASS] = {
-		.name = "vcs",
-		.uabi_class = I915_ENGINE_CLASS_VIDEO,
-	},
-	[VIDEO_ENHANCEMENT_CLASS] = {
-		.name = "vecs",
-		.uabi_class = I915_ENGINE_CLASS_VIDEO_ENHANCE,
-	},
-};
-
 #define MAX_MMIO_BASES 3
 struct engine_info {
 	unsigned int hw_id;
@@ -259,11 +235,16 @@ static u32 __engine_mmio_base(struct drm_i915_private *i915,
 	return bases[i].base;
 }
 
-static void __sprint_engine_name(char *name, const struct engine_info *info)
+static void __sprint_engine_name(struct intel_engine_cs *engine)
 {
-	WARN_ON(snprintf(name, INTEL_ENGINE_CS_MAX_NAME, "%s%u",
-			 intel_engine_classes[info->class].name,
-			 info->instance) >= INTEL_ENGINE_CS_MAX_NAME);
+	/*
+	 * Before we know what the uABI name for this engine will be,
+	 * we still would like to keep track of this engine in the debug logs.
+	 * We throw in a ' here as a reminder that this isn't it's final name.
+	 */
+	GEM_WARN_ON(snprintf(engine->name, sizeof(engine->name), "%s'%u",
+			     intel_engine_class_repr(engine),
+			     engine->instance) >= sizeof(engine->name));
 }
 
 void intel_engine_set_hwsp_writemask(struct intel_engine_cs *engine, u32 mask)
@@ -292,8 +273,6 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
 	const struct engine_info *info = &intel_engines[id];
 	struct intel_engine_cs *engine;
 
-	GEM_BUG_ON(info->class >= ARRAY_SIZE(intel_engine_classes));
-
 	BUILD_BUG_ON(MAX_ENGINE_CLASS >= BIT(GEN11_ENGINE_CLASS_WIDTH));
 	BUILD_BUG_ON(MAX_ENGINE_INSTANCE >= BIT(GEN11_ENGINE_INSTANCE_WIDTH));
 
@@ -317,11 +296,12 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
 	engine->i915 = gt->i915;
 	engine->gt = gt;
 	engine->uncore = gt->uncore;
-	__sprint_engine_name(engine->name, info);
 	engine->hw_id = engine->guc_id = info->hw_id;
 	engine->mmio_base = __engine_mmio_base(gt->i915, info->mmio_bases);
+
 	engine->class = info->class;
 	engine->instance = info->instance;
+	__sprint_engine_name(engine);
 
 	/*
 	 * To be overridden by the backend on setup. However to facilitate
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index 68fda1ac3c60..c3eecec8b975 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -127,6 +127,22 @@ static void set_scheduler_caps(struct drm_i915_private *i915)
 		i915->caps.scheduler = 0;
 }
 
+const char *intel_engine_class_repr(struct intel_engine_cs *engine)
+{
+	static const char * const uabi_names[] = {
+		[RENDER_CLASS] = "rcs",
+		[COPY_ENGINE_CLASS] = "bcs",
+		[VIDEO_DECODE_CLASS] = "vcs",
+		[VIDEO_ENHANCEMENT_CLASS] = "vecs",
+	};
+
+	if (engine->class >= ARRAY_SIZE(uabi_names) ||
+	    !uabi_names[engine->class])
+		return "xxx";
+
+	return uabi_names[engine->class];
+}
+
 void intel_engines_driver_register(struct drm_i915_private *i915)
 {
 	u8 uabi_instances[4] = {};
@@ -142,6 +158,7 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 		struct intel_engine_cs *engine =
 			container_of((struct rb_node *)it, typeof(*engine),
 				     uabi_node);
+		char old[sizeof(engine->name)];
 
 		GEM_BUG_ON(engine->class >= ARRAY_SIZE(uabi_classes));
 		engine->uabi_class = uabi_classes[engine->class];
@@ -149,6 +166,13 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 		GEM_BUG_ON(engine->uabi_class >= ARRAY_SIZE(uabi_instances));
 		engine->uabi_instance = uabi_instances[engine->uabi_class]++;
 
+		/* Replace the internal name with the final user facing name */
+		memcpy(old, engine->name, sizeof(engine->name));
+		scnprintf(engine->name, sizeof(engine->name), "%s%u",
+			  intel_engine_class_repr(engine),
+			  engine->uabi_instance);
+		DRM_DEBUG_DRIVER("renamed %s to %s\n", old, engine->name);
+
 		rb_link_node(&engine->uabi_node, prev, p);
 		rb_insert_color(&engine->uabi_node, &i915->uabi_engines);
 
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.h b/drivers/gpu/drm/i915/gt/intel_engine_user.h
index 9e5f113e5027..d1a08f336e70 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.h
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.h
@@ -17,6 +17,8 @@ intel_engine_lookup_user(struct drm_i915_private *i915, u8 class, u8 instance);
 
 unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915);
 
+const char *intel_engine_class_repr(struct intel_engine_cs *engine);
+
 void intel_engine_add_user(struct intel_engine_cs *engine);
 void intel_engines_driver_register(struct drm_i915_private *i915);
 
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
index cfaa6b296835..d0f4217b148a 100644
--- a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
@@ -12,19 +12,16 @@ static int intel_mmio_bases_check(void *arg)
 
 	for (i = 0; i < ARRAY_SIZE(intel_engines); i++) {
 		const struct engine_info *info = &intel_engines[i];
-		char name[INTEL_ENGINE_CS_MAX_NAME];
 		u8 prev = U8_MAX;
 
-		__sprint_engine_name(name, info);
-
 		for (j = 0; j < MAX_MMIO_BASES; j++) {
 			u8 gen = info->mmio_bases[j].gen;
 			u32 base = info->mmio_bases[j].base;
 
 			if (gen >= prev) {
-				pr_err("%s: %s: mmio base for gen %x "
-					"is before the one for gen %x\n",
-				       __func__, name, prev, gen);
+				pr_err("%s(class:%d, instance:%d): mmio base for gen %x is before the one for gen %x\n",
+				       __func__, info->class, info->instance,
+				       prev, gen);
 				return -EINVAL;
 			}
 
@@ -32,17 +29,17 @@ static int intel_mmio_bases_check(void *arg)
 				break;
 
 			if (!base) {
-				pr_err("%s: %s: invalid mmio base (%x) "
-					"for gen %x at entry %u\n",
-				       __func__, name, base, gen, j);
+				pr_err("%s(class:%d, instance:%d): invalid mmio base (%x) for gen %x at entry %u\n",
+				       __func__, info->class, info->instance,
+				       base, gen, j);
 				return -EINVAL;
 			}
 
 			prev = gen;
 		}
 
-		pr_info("%s: min gen supported for %s = %d\n",
-			__func__, name, prev);
+		pr_debug("%s: min gen supported for {class:%d, instance:%d} is %d\n",
+			 __func__, info->class, info->instance, prev);
 	}
 
 	return 0;
-- 
2.23.0.rc1

_______________________________________________
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

* [PATCH v3] drm/i915: Rename engines to match their user interface
  2019-08-07 10:31 ` [PATCH 1/3] " Mika Kuoppala
  2019-08-07 10:44   ` Chris Wilson
  2019-08-07 10:55   ` [PATCH v2] drm/i915: Rename engines " Chris Wilson
@ 2019-08-07 11:04   ` Chris Wilson
  2019-08-07 11:53     ` Mika Kuoppala
  2 siblings, 1 reply; 20+ messages in thread
From: Chris Wilson @ 2019-08-07 11:04 UTC (permalink / raw)
  To: intel-gfx

During engine setup, we may find that some engines are fused off causing
a misalignment between internal names and the instances seen by users,
e.g. (I915_ENGINE_CLASS_VIDEO_DECODE, 1) may be vcs2 in hardware.
Normally this is invisible to the user, but a few debug interfaces (and
our own internal tracing) use the original HW name not the name the user
would expect as formed from their class:instance tuple. Replace our
internal name with the uabi name for consistency with, for example, error
states.

v2: Keep the pretty printing of class name in the selftest

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111311
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
---
 drivers/gpu/drm/i915/gt/intel_engine_cs.c    | 42 +++++---------------
 drivers/gpu/drm/i915/gt/intel_engine_user.c  | 23 +++++++++++
 drivers/gpu/drm/i915/gt/intel_engine_user.h  |  2 +
 drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 26 +++++++-----
 4 files changed, 51 insertions(+), 42 deletions(-)

diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index d0befd6c023a..16a405cabc21 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -55,30 +55,6 @@
 
 #define GEN8_LR_CONTEXT_OTHER_SIZE	( 2 * PAGE_SIZE)
 
-struct engine_class_info {
-	const char *name;
-	u8 uabi_class;
-};
-
-static const struct engine_class_info intel_engine_classes[] = {
-	[RENDER_CLASS] = {
-		.name = "rcs",
-		.uabi_class = I915_ENGINE_CLASS_RENDER,
-	},
-	[COPY_ENGINE_CLASS] = {
-		.name = "bcs",
-		.uabi_class = I915_ENGINE_CLASS_COPY,
-	},
-	[VIDEO_DECODE_CLASS] = {
-		.name = "vcs",
-		.uabi_class = I915_ENGINE_CLASS_VIDEO,
-	},
-	[VIDEO_ENHANCEMENT_CLASS] = {
-		.name = "vecs",
-		.uabi_class = I915_ENGINE_CLASS_VIDEO_ENHANCE,
-	},
-};
-
 #define MAX_MMIO_BASES 3
 struct engine_info {
 	unsigned int hw_id;
@@ -259,11 +235,16 @@ static u32 __engine_mmio_base(struct drm_i915_private *i915,
 	return bases[i].base;
 }
 
-static void __sprint_engine_name(char *name, const struct engine_info *info)
+static void __sprint_engine_name(struct intel_engine_cs *engine)
 {
-	WARN_ON(snprintf(name, INTEL_ENGINE_CS_MAX_NAME, "%s%u",
-			 intel_engine_classes[info->class].name,
-			 info->instance) >= INTEL_ENGINE_CS_MAX_NAME);
+	/*
+	 * Before we know what the uABI name for this engine will be,
+	 * we still would like to keep track of this engine in the debug logs.
+	 * We throw in a ' here as a reminder that this isn't it's final name.
+	 */
+	GEM_WARN_ON(snprintf(engine->name, sizeof(engine->name), "%s'%u",
+			     intel_engine_class_repr(engine->class),
+			     engine->instance) >= sizeof(engine->name));
 }
 
 void intel_engine_set_hwsp_writemask(struct intel_engine_cs *engine, u32 mask)
@@ -292,8 +273,6 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
 	const struct engine_info *info = &intel_engines[id];
 	struct intel_engine_cs *engine;
 
-	GEM_BUG_ON(info->class >= ARRAY_SIZE(intel_engine_classes));
-
 	BUILD_BUG_ON(MAX_ENGINE_CLASS >= BIT(GEN11_ENGINE_CLASS_WIDTH));
 	BUILD_BUG_ON(MAX_ENGINE_INSTANCE >= BIT(GEN11_ENGINE_INSTANCE_WIDTH));
 
@@ -317,11 +296,12 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
 	engine->i915 = gt->i915;
 	engine->gt = gt;
 	engine->uncore = gt->uncore;
-	__sprint_engine_name(engine->name, info);
 	engine->hw_id = engine->guc_id = info->hw_id;
 	engine->mmio_base = __engine_mmio_base(gt->i915, info->mmio_bases);
+
 	engine->class = info->class;
 	engine->instance = info->instance;
+	__sprint_engine_name(engine);
 
 	/*
 	 * To be overridden by the backend on setup. However to facilitate
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index 68fda1ac3c60..c41ae05988a5 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -127,6 +127,21 @@ static void set_scheduler_caps(struct drm_i915_private *i915)
 		i915->caps.scheduler = 0;
 }
 
+const char *intel_engine_class_repr(u8 class)
+{
+	static const char * const uabi_names[] = {
+		[RENDER_CLASS] = "rcs",
+		[COPY_ENGINE_CLASS] = "bcs",
+		[VIDEO_DECODE_CLASS] = "vcs",
+		[VIDEO_ENHANCEMENT_CLASS] = "vecs",
+	};
+
+	if (class >= ARRAY_SIZE(uabi_names) || !uabi_names[class])
+		return "xxx";
+
+	return uabi_names[class];
+}
+
 void intel_engines_driver_register(struct drm_i915_private *i915)
 {
 	u8 uabi_instances[4] = {};
@@ -142,6 +157,7 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 		struct intel_engine_cs *engine =
 			container_of((struct rb_node *)it, typeof(*engine),
 				     uabi_node);
+		char old[sizeof(engine->name)];
 
 		GEM_BUG_ON(engine->class >= ARRAY_SIZE(uabi_classes));
 		engine->uabi_class = uabi_classes[engine->class];
@@ -149,6 +165,13 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 		GEM_BUG_ON(engine->uabi_class >= ARRAY_SIZE(uabi_instances));
 		engine->uabi_instance = uabi_instances[engine->uabi_class]++;
 
+		/* Replace the internal name with the final user facing name */
+		memcpy(old, engine->name, sizeof(engine->name));
+		scnprintf(engine->name, sizeof(engine->name), "%s%u",
+			  intel_engine_class_repr(engine->class),
+			  engine->uabi_instance);
+		DRM_DEBUG_DRIVER("renamed %s to %s\n", old, engine->name);
+
 		rb_link_node(&engine->uabi_node, prev, p);
 		rb_insert_color(&engine->uabi_node, &i915->uabi_engines);
 
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.h b/drivers/gpu/drm/i915/gt/intel_engine_user.h
index 9e5f113e5027..f845ea1cbfaa 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.h
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.h
@@ -20,4 +20,6 @@ unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915);
 void intel_engine_add_user(struct intel_engine_cs *engine);
 void intel_engines_driver_register(struct drm_i915_private *i915);
 
+const char *intel_engine_class_repr(u8 class);
+
 #endif /* INTEL_ENGINE_USER_H */
diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
index cfaa6b296835..3880f07c29b8 100644
--- a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
@@ -12,19 +12,18 @@ static int intel_mmio_bases_check(void *arg)
 
 	for (i = 0; i < ARRAY_SIZE(intel_engines); i++) {
 		const struct engine_info *info = &intel_engines[i];
-		char name[INTEL_ENGINE_CS_MAX_NAME];
 		u8 prev = U8_MAX;
 
-		__sprint_engine_name(name, info);
-
 		for (j = 0; j < MAX_MMIO_BASES; j++) {
 			u8 gen = info->mmio_bases[j].gen;
 			u32 base = info->mmio_bases[j].base;
 
 			if (gen >= prev) {
-				pr_err("%s: %s: mmio base for gen %x "
-					"is before the one for gen %x\n",
-				       __func__, name, prev, gen);
+				pr_err("%s(%s, class:%d, instance:%d): mmio base for gen %x is before the one for gen %x\n",
+				       __func__,
+				       intel_engine_class_repr(info->class),
+				       info->class, info->instance,
+				       prev, gen);
 				return -EINVAL;
 			}
 
@@ -32,17 +31,22 @@ static int intel_mmio_bases_check(void *arg)
 				break;
 
 			if (!base) {
-				pr_err("%s: %s: invalid mmio base (%x) "
-					"for gen %x at entry %u\n",
-				       __func__, name, base, gen, j);
+				pr_err("%s(%s, class:%d, instance:%d): invalid mmio base (%x) for gen %x at entry %u\n",
+				       __func__,
+				       intel_engine_class_repr(info->class),
+				       info->class, info->instance,
+				       base, gen, j);
 				return -EINVAL;
 			}
 
 			prev = gen;
 		}
 
-		pr_info("%s: min gen supported for %s = %d\n",
-			__func__, name, prev);
+		pr_debug("%s: min gen supported for %s%d is %d\n",
+			 __func__,
+			 intel_engine_class_repr(info->class),
+			 info->instance,
+			 prev);
 	}
 
 	return 0;
-- 
2.23.0.rc1

_______________________________________________
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

* Re: [PATCH v3] drm/i915: Rename engines to match their user interface
  2019-08-07 11:04   ` [PATCH v3] " Chris Wilson
@ 2019-08-07 11:53     ` Mika Kuoppala
  0 siblings, 0 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-08-07 11:53 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Chris Wilson <chris@chris-wilson.co.uk> writes:

> During engine setup, we may find that some engines are fused off causing
> a misalignment between internal names and the instances seen by users,
> e.g. (I915_ENGINE_CLASS_VIDEO_DECODE, 1) may be vcs2 in hardware.
> Normally this is invisible to the user, but a few debug interfaces (and
> our own internal tracing) use the original HW name not the name the user
> would expect as formed from their class:instance tuple. Replace our
> internal name with the uabi name for consistency with, for example, error
> states.
>
> v2: Keep the pretty printing of class name in the selftest
>
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111311
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/gt/intel_engine_cs.c    | 42 +++++---------------
>  drivers/gpu/drm/i915/gt/intel_engine_user.c  | 23 +++++++++++
>  drivers/gpu/drm/i915/gt/intel_engine_user.h  |  2 +
>  drivers/gpu/drm/i915/gt/selftest_engine_cs.c | 26 +++++++-----
>  4 files changed, 51 insertions(+), 42 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> index d0befd6c023a..16a405cabc21 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> @@ -55,30 +55,6 @@
>  
>  #define GEN8_LR_CONTEXT_OTHER_SIZE	( 2 * PAGE_SIZE)
>  
> -struct engine_class_info {
> -	const char *name;
> -	u8 uabi_class;
> -};
> -
> -static const struct engine_class_info intel_engine_classes[] = {
> -	[RENDER_CLASS] = {
> -		.name = "rcs",
> -		.uabi_class = I915_ENGINE_CLASS_RENDER,
> -	},
> -	[COPY_ENGINE_CLASS] = {
> -		.name = "bcs",
> -		.uabi_class = I915_ENGINE_CLASS_COPY,
> -	},
> -	[VIDEO_DECODE_CLASS] = {
> -		.name = "vcs",
> -		.uabi_class = I915_ENGINE_CLASS_VIDEO,
> -	},
> -	[VIDEO_ENHANCEMENT_CLASS] = {
> -		.name = "vecs",
> -		.uabi_class = I915_ENGINE_CLASS_VIDEO_ENHANCE,
> -	},
> -};
> -
>  #define MAX_MMIO_BASES 3
>  struct engine_info {
>  	unsigned int hw_id;
> @@ -259,11 +235,16 @@ static u32 __engine_mmio_base(struct drm_i915_private *i915,
>  	return bases[i].base;
>  }
>  
> -static void __sprint_engine_name(char *name, const struct engine_info *info)
> +static void __sprint_engine_name(struct intel_engine_cs *engine)
>  {
> -	WARN_ON(snprintf(name, INTEL_ENGINE_CS_MAX_NAME, "%s%u",
> -			 intel_engine_classes[info->class].name,
> -			 info->instance) >= INTEL_ENGINE_CS_MAX_NAME);
> +	/*
> +	 * Before we know what the uABI name for this engine will be,
> +	 * we still would like to keep track of this engine in the debug logs.
> +	 * We throw in a ' here as a reminder that this isn't it's final name.
> +	 */
> +	GEM_WARN_ON(snprintf(engine->name, sizeof(engine->name), "%s'%u",
> +			     intel_engine_class_repr(engine->class),
> +			     engine->instance) >= sizeof(engine->name));
>  }
>  
>  void intel_engine_set_hwsp_writemask(struct intel_engine_cs *engine, u32 mask)
> @@ -292,8 +273,6 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
>  	const struct engine_info *info = &intel_engines[id];
>  	struct intel_engine_cs *engine;
>  
> -	GEM_BUG_ON(info->class >= ARRAY_SIZE(intel_engine_classes));
> -
>  	BUILD_BUG_ON(MAX_ENGINE_CLASS >= BIT(GEN11_ENGINE_CLASS_WIDTH));
>  	BUILD_BUG_ON(MAX_ENGINE_INSTANCE >= BIT(GEN11_ENGINE_INSTANCE_WIDTH));
>  
> @@ -317,11 +296,12 @@ static int intel_engine_setup(struct intel_gt *gt, enum intel_engine_id id)
>  	engine->i915 = gt->i915;
>  	engine->gt = gt;
>  	engine->uncore = gt->uncore;
> -	__sprint_engine_name(engine->name, info);
>  	engine->hw_id = engine->guc_id = info->hw_id;
>  	engine->mmio_base = __engine_mmio_base(gt->i915, info->mmio_bases);
> +
>  	engine->class = info->class;
>  	engine->instance = info->instance;
> +	__sprint_engine_name(engine);
>  
>  	/*
>  	 * To be overridden by the backend on setup. However to facilitate
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
> index 68fda1ac3c60..c41ae05988a5 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
> @@ -127,6 +127,21 @@ static void set_scheduler_caps(struct drm_i915_private *i915)
>  		i915->caps.scheduler = 0;
>  }
>  
> +const char *intel_engine_class_repr(u8 class)
> +{
> +	static const char * const uabi_names[] = {
> +		[RENDER_CLASS] = "rcs",
> +		[COPY_ENGINE_CLASS] = "bcs",
> +		[VIDEO_DECODE_CLASS] = "vcs",
> +		[VIDEO_ENHANCEMENT_CLASS] = "vecs",
> +	};
> +
> +	if (class >= ARRAY_SIZE(uabi_names) || !uabi_names[class])
> +		return "xxx";
> +
> +	return uabi_names[class];
> +}
> +
>  void intel_engines_driver_register(struct drm_i915_private *i915)
>  {
>  	u8 uabi_instances[4] = {};
> @@ -142,6 +157,7 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
>  		struct intel_engine_cs *engine =
>  			container_of((struct rb_node *)it, typeof(*engine),
>  				     uabi_node);
> +		char old[sizeof(engine->name)];
>  
>  		GEM_BUG_ON(engine->class >= ARRAY_SIZE(uabi_classes));
>  		engine->uabi_class = uabi_classes[engine->class];
> @@ -149,6 +165,13 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
>  		GEM_BUG_ON(engine->uabi_class >= ARRAY_SIZE(uabi_instances));
>  		engine->uabi_instance = uabi_instances[engine->uabi_class]++;
>  
> +		/* Replace the internal name with the final user facing name */
> +		memcpy(old, engine->name, sizeof(engine->name));
> +		scnprintf(engine->name, sizeof(engine->name), "%s%u",
> +			  intel_engine_class_repr(engine->class),
> +			  engine->uabi_instance);
> +		DRM_DEBUG_DRIVER("renamed %s to %s\n", old, engine->name);
> +
>  		rb_link_node(&engine->uabi_node, prev, p);
>  		rb_insert_color(&engine->uabi_node, &i915->uabi_engines);
>  
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.h b/drivers/gpu/drm/i915/gt/intel_engine_user.h
> index 9e5f113e5027..f845ea1cbfaa 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_user.h
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_user.h
> @@ -20,4 +20,6 @@ unsigned int intel_engines_has_context_isolation(struct drm_i915_private *i915);
>  void intel_engine_add_user(struct intel_engine_cs *engine);
>  void intel_engines_driver_register(struct drm_i915_private *i915);
>  
> +const char *intel_engine_class_repr(u8 class);
> +
>  #endif /* INTEL_ENGINE_USER_H */
> diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
> index cfaa6b296835..3880f07c29b8 100644
> --- a/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/selftest_engine_cs.c
> @@ -12,19 +12,18 @@ static int intel_mmio_bases_check(void *arg)
>  
>  	for (i = 0; i < ARRAY_SIZE(intel_engines); i++) {
>  		const struct engine_info *info = &intel_engines[i];
> -		char name[INTEL_ENGINE_CS_MAX_NAME];
>  		u8 prev = U8_MAX;
>  
> -		__sprint_engine_name(name, info);
> -
>  		for (j = 0; j < MAX_MMIO_BASES; j++) {
>  			u8 gen = info->mmio_bases[j].gen;
>  			u32 base = info->mmio_bases[j].base;
>  
>  			if (gen >= prev) {
> -				pr_err("%s: %s: mmio base for gen %x "
> -					"is before the one for gen %x\n",
> -				       __func__, name, prev, gen);
> +				pr_err("%s(%s, class:%d, instance:%d): mmio base for gen %x is before the one for gen %x\n",
> +				       __func__,
> +				       intel_engine_class_repr(info->class),
> +				       info->class, info->instance,
> +				       prev, gen);
>  				return -EINVAL;
>  			}
>  
> @@ -32,17 +31,22 @@ static int intel_mmio_bases_check(void *arg)
>  				break;
>  
>  			if (!base) {
> -				pr_err("%s: %s: invalid mmio base (%x) "
> -					"for gen %x at entry %u\n",
> -				       __func__, name, base, gen, j);
> +				pr_err("%s(%s, class:%d, instance:%d): invalid mmio base (%x) for gen %x at entry %u\n",
> +				       __func__,
> +				       intel_engine_class_repr(info->class),
> +				       info->class, info->instance,
> +				       base, gen, j);
>  				return -EINVAL;
>  			}
>  
>  			prev = gen;
>  		}
>  
> -		pr_info("%s: min gen supported for %s = %d\n",
> -			__func__, name, prev);
> +		pr_debug("%s: min gen supported for %s%d is %d\n",
> +			 __func__,
> +			 intel_engine_class_repr(info->class),
> +			 info->instance,
> +			 prev);
>  	}
>  
>  	return 0;
> -- 
> 2.23.0.rc1
>
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✗ Fi.CI.CHECKPATCH: warning for series starting with [v3] drm/i915: Rename engines to match their user interface (rev3)
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
                   ` (5 preceding siblings ...)
  2019-08-07 10:31 ` [PATCH 1/3] " Mika Kuoppala
@ 2019-08-07 12:32 ` Patchwork
  2019-08-07 12:33 ` ✗ Fi.CI.SPARSE: " Patchwork
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-07 12:32 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [v3] drm/i915: Rename engines to match their user interface (rev3)
URL   : https://patchwork.freedesktop.org/series/64824/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
1f16441c8f68 drm/i915: Rename engines to match their user interface
9fd33b8ce0d8 drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc
4a887c6d3293 drm/i915: Defer final intel_wakeref_put to process context
-:314: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#314: 
new file mode 100644

-:319: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1
#319: FILE: drivers/gpu/drm/i915/gt/selftest_engine.c:1:
+/*

-:320: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use line 1 instead
#320: FILE: drivers/gpu/drm/i915/gt/selftest_engine.c:2:
+ * SPDX-License-Identifier: GPL-2.0

-:353: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1
#353: FILE: drivers/gpu/drm/i915/gt/selftest_engine.h:1:
+/*

-:354: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use line 1 instead
#354: FILE: drivers/gpu/drm/i915/gt/selftest_engine.h:2:
+ * SPDX-License-Identifier: GPL-2.0

-:373: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1
#373: FILE: drivers/gpu/drm/i915/gt/selftest_engine_pm.c:1:
+/*

-:374: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use line 1 instead
#374: FILE: drivers/gpu/drm/i915/gt/selftest_engine_pm.c:2:
+ * SPDX-License-Identifier: GPL-2.0

total: 0 errors, 7 warnings, 0 checks, 709 lines checked

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

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

* ✗ Fi.CI.SPARSE: warning for series starting with [v3] drm/i915: Rename engines to match their user interface (rev3)
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
                   ` (6 preceding siblings ...)
  2019-08-07 12:32 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [v3] drm/i915: Rename engines to match their user interface (rev3) Patchwork
@ 2019-08-07 12:33 ` Patchwork
  2019-08-07 12:52 ` ✓ Fi.CI.BAT: success " Patchwork
  2019-08-07 19:23 ` ✗ Fi.CI.IGT: failure " Patchwork
  9 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-07 12:33 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [v3] drm/i915: Rename engines to match their user interface (rev3)
URL   : https://patchwork.freedesktop.org/series/64824/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Sparse version: v0.5.2
Commit: drm/i915: Rename engines to match their user interface
Okay!

Commit: drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc
Okay!

Commit: drm/i915: Defer final intel_wakeref_put to process context
+drivers/gpu/drm/i915/gt/selftest_engine.c:19:26: error: incorrect type in conditional
+drivers/gpu/drm/i915/gt/selftest_engine.c:19:26:    got unknown type 11 <noident>

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

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

* ✓ Fi.CI.BAT: success for series starting with [v3] drm/i915: Rename engines to match their user interface (rev3)
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
                   ` (7 preceding siblings ...)
  2019-08-07 12:33 ` ✗ Fi.CI.SPARSE: " Patchwork
@ 2019-08-07 12:52 ` Patchwork
  2019-08-07 19:23 ` ✗ Fi.CI.IGT: failure " Patchwork
  9 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-07 12:52 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [v3] drm/i915: Rename engines to match their user interface (rev3)
URL   : https://patchwork.freedesktop.org/series/64824/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_6646 -> Patchwork_13897
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/

New tests
---------

  New tests have been introduced between CI_DRM_6646 and Patchwork_13897:

### New IGT tests (2) ###

  * igt@i915_selftest@live_gt_engines:
    - Statuses : 46 pass(s)
    - Exec time: [0.34, 1.29] s

  * igt@i915_selftest@live_gt_timelines:
    - Statuses : 46 pass(s)
    - Exec time: [1.28, 10.65] s

  

Known issues
------------

  Here are the changes found in Patchwork_13897 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@prime_vgem@basic-fence-flip:
    - fi-icl-u3:          [PASS][1] -> [DMESG-WARN][2] ([fdo#107724]) +1 similar issue
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/fi-icl-u3/igt@prime_vgem@basic-fence-flip.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/fi-icl-u3/igt@prime_vgem@basic-fence-flip.html

  
#### Possible fixes ####

  * igt@gem_ctx_param@basic:
    - fi-icl-u3:          [DMESG-WARN][3] ([fdo#107724]) -> [PASS][4] +1 similar issue
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/fi-icl-u3/igt@gem_ctx_param@basic.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/fi-icl-u3/igt@gem_ctx_param@basic.html

  * igt@kms_chamelium@hdmi-hpd-fast:
    - fi-kbl-7500u:       [FAIL][5] ([fdo#109485]) -> [PASS][6]
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/fi-kbl-7500u/igt@kms_chamelium@hdmi-hpd-fast.html

  * igt@prime_vgem@basic-fence-flip:
    - fi-kbl-7500u:       [SKIP][7] ([fdo#109271]) -> [PASS][8] +23 similar issues
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/fi-kbl-7500u/igt@prime_vgem@basic-fence-flip.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/fi-kbl-7500u/igt@prime_vgem@basic-fence-flip.html

  
  {name}: This element is suppressed. This means it is ignored when computing
          the status of the difference (SUCCESS, WARNING, or FAILURE).

  [fdo#105602]: https://bugs.freedesktop.org/show_bug.cgi?id=105602
  [fdo#106107]: https://bugs.freedesktop.org/show_bug.cgi?id=106107
  [fdo#106350]: https://bugs.freedesktop.org/show_bug.cgi?id=106350
  [fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109485]: https://bugs.freedesktop.org/show_bug.cgi?id=109485


Participating hosts (55 -> 47)
------------------------------

  Missing    (8): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-clapper fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6646 -> Patchwork_13897

  CI-20190529: 20190529
  CI_DRM_6646: 9345af1901748aeaed19ac13bf7ec4fb3336fc29 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5125: 35d81d01b1599b4bc4df0e09e25f6f531eed4f8a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_13897: 4a887c6d3293663cecffe83f004d0b5ee9d66af4 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

4a887c6d3293 drm/i915: Defer final intel_wakeref_put to process context
9fd33b8ce0d8 drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc
1f16441c8f68 drm/i915: Rename engines to match their user interface

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 2/3] drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc
  2019-08-07  8:37 ` [PATCH 2/3] drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc Chris Wilson
@ 2019-08-07 13:16   ` Mika Kuoppala
  0 siblings, 0 replies; 20+ messages in thread
From: Mika Kuoppala @ 2019-08-07 13:16 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Chris Wilson <chris@chris-wilson.co.uk> writes:

> Use the same mechanism to determine if a backend engine exists for a
> uabi mapping as used internally.
>
> Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>

Reviewed-by: Mika Kuoppala <mika.kuoppala@linux.intel.com>

> ---
>  drivers/gpu/drm/i915/i915_drv.c | 12 ++++++++----
>  1 file changed, 8 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.c b/drivers/gpu/drm/i915/i915_drv.c
> index ac5868c12b97..d7bc6e5d5c52 100644
> --- a/drivers/gpu/drm/i915/i915_drv.c
> +++ b/drivers/gpu/drm/i915/i915_drv.c
> @@ -373,16 +373,20 @@ static int i915_getparam_ioctl(struct drm_device *dev, void *data,
>  		value = dev_priv->overlay ? 1 : 0;
>  		break;
>  	case I915_PARAM_HAS_BSD:
> -		value = !!dev_priv->engine[VCS0];
> +		value = !!intel_engine_lookup_user(dev_priv,
> +						   I915_ENGINE_CLASS_VIDEO, 0);
>  		break;
>  	case I915_PARAM_HAS_BLT:
> -		value = !!dev_priv->engine[BCS0];
> +		value = !!intel_engine_lookup_user(dev_priv,
> +						   I915_ENGINE_CLASS_COPY, 0);
>  		break;
>  	case I915_PARAM_HAS_VEBOX:
> -		value = !!dev_priv->engine[VECS0];
> +		value = !!intel_engine_lookup_user(dev_priv,
> +						   I915_ENGINE_CLASS_VIDEO_ENHANCE, 0);
>  		break;
>  	case I915_PARAM_HAS_BSD2:
> -		value = !!dev_priv->engine[VCS1];
> +		value = !!intel_engine_lookup_user(dev_priv,
> +						   I915_ENGINE_CLASS_VIDEO, 1);
>  		break;
>  	case I915_PARAM_HAS_LLC:
>  		value = HAS_LLC(dev_priv);
> -- 
> 2.23.0.rc1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 3/3] drm/i915: Defer final intel_wakeref_put to process context
  2019-08-07  8:37 ` [PATCH 3/3] drm/i915: Defer final intel_wakeref_put to process context Chris Wilson
@ 2019-08-07 15:04   ` Mika Kuoppala
  2019-08-07 15:24     ` Chris Wilson
  0 siblings, 1 reply; 20+ messages in thread
From: Mika Kuoppala @ 2019-08-07 15:04 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Chris Wilson <chris@chris-wilson.co.uk> writes:

> As we need to acquire a mutex to serialise the final
> intel_wakeref_put, we need to ensure that we are in process context at
> that time. However, we want to allow operation on the intel_wakeref from
> inside timer and other hardirq context, which means that need to defer
> that final put to a workqueue.
>
> Inside the final wakeref puts, we are safe to operate in any context, as
> we are simply marking up the HW and state tracking for the potential
> sleep. It's only the serialisation with the potential sleeping getting
> that requires careful wait avoidance. This allows us to retain the
> immediate processing as before (we only need to sleep over the same
> races as the current mutex_lock).
>
> v2: Add a selftest to ensure we exercise the code while lockdep watches.
> v3: That test was extremely loud and complained about many things!
>

Loud is good if it did found out something, did it? :)

> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=111295
> References: https://bugs.freedesktop.org/show_bug.cgi?id=111245
> References: https://bugs.freedesktop.org/show_bug.cgi?id=111256
> Fixes: 18398904ca9e ("drm/i915: Only recover active engines")
> Fixes: 51fbd8de87dc ("drm/i915/pmu: Atomically acquire the gt_pm wakeref")
> 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/gem/i915_gem_pm.c        | 13 +--
>  drivers/gpu/drm/i915/gt/intel_engine_cs.c     |  1 +
>  drivers/gpu/drm/i915/gt/intel_engine_pm.c     | 38 +++------
>  drivers/gpu/drm/i915/gt/intel_engine_pm.h     | 18 ++--
>  drivers/gpu/drm/i915/gt/intel_gt_pm.c         | 28 +++----
>  drivers/gpu/drm/i915/gt/intel_gt_pm.h         | 22 ++++-
>  drivers/gpu/drm/i915/gt/intel_lrc.c           |  4 +-
>  drivers/gpu/drm/i915/gt/selftest_engine.c     | 28 +++++++
>  drivers/gpu/drm/i915/gt/selftest_engine.h     | 14 ++++
>  drivers/gpu/drm/i915/gt/selftest_engine_pm.c  | 83 +++++++++++++++++++
>  .../gpu/drm/i915/gt/uc/intel_guc_submission.c |  4 +-
>  drivers/gpu/drm/i915/i915_debugfs.c           |  4 +
>  drivers/gpu/drm/i915/i915_gem.c               | 26 +-----
>  drivers/gpu/drm/i915/intel_wakeref.c          | 82 +++++++++++++-----
>  drivers/gpu/drm/i915/intel_wakeref.h          | 62 +++++++++-----
>  .../drm/i915/selftests/i915_live_selftests.h  |  5 +-
>  16 files changed, 301 insertions(+), 131 deletions(-)
>  create mode 100644 drivers/gpu/drm/i915/gt/selftest_engine.c
>  create mode 100644 drivers/gpu/drm/i915/gt/selftest_engine.h
>  create mode 100644 drivers/gpu/drm/i915/gt/selftest_engine_pm.c
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_pm.c b/drivers/gpu/drm/i915/gem/i915_gem_pm.c
> index 72922703af49..17e3618241c5 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_pm.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_pm.c
> @@ -130,7 +130,9 @@ static bool switch_to_kernel_context_sync(struct intel_gt *gt)
>  		}
>  	} while (i915_retire_requests(gt->i915) && result);
>  
> -	GEM_BUG_ON(gt->awake);
> +	if (intel_gt_pm_wait_for_idle(gt))
> +		result = false;
> +
>  	return result;
>  }
>  
> @@ -161,13 +163,6 @@ void i915_gem_suspend(struct drm_i915_private *i915)
>  
>  	mutex_unlock(&i915->drm.struct_mutex);
>  
> -	/*
> -	 * Assert that we successfully flushed all the work and
> -	 * reset the GPU back to its idle, low power state.
> -	 */
> -	GEM_BUG_ON(i915->gt.awake);
> -	flush_work(&i915->gem.idle_work);
> -
>  	cancel_delayed_work_sync(&i915->gt.hangcheck.work);
>  
>  	i915_gem_drain_freed_objects(i915);
> @@ -244,8 +239,6 @@ void i915_gem_resume(struct drm_i915_private *i915)
>  {
>  	GEM_TRACE("\n");
>  
> -	WARN_ON(i915->gt.awake);
> -
>  	mutex_lock(&i915->drm.struct_mutex);
>  	intel_uncore_forcewake_get(&i915->uncore, FORCEWAKE_ALL);
>  
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> index d38c114b0964..b57adc973e2a 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
> @@ -1568,5 +1568,6 @@ intel_engine_find_active_request(struct intel_engine_cs *engine)
>  }
>  
>  #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
> +#include "selftest_engine.c"
>  #include "selftest_engine_cs.c"
>  #endif
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.c b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
> index 0336204988d6..6b15e3335dd6 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_pm.c
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.c
> @@ -37,28 +37,6 @@ static int __engine_unpark(struct intel_wakeref *wf)
>  	return 0;
>  }
>  
> -void intel_engine_pm_get(struct intel_engine_cs *engine)
> -{
> -	intel_wakeref_get(&engine->i915->runtime_pm, &engine->wakeref, __engine_unpark);
> -}
> -
> -void intel_engine_park(struct intel_engine_cs *engine)
> -{
> -	/*
> -	 * We are committed now to parking this engine, make sure there
> -	 * will be no more interrupts arriving later and the engine
> -	 * is truly idle.
> -	 */
> -	if (wait_for(intel_engine_is_idle(engine), 10)) {
> -		struct drm_printer p = drm_debug_printer(__func__);
> -
> -		dev_err(engine->i915->drm.dev,
> -			"%s is not idle before parking\n",
> -			engine->name);
> -		intel_engine_dump(engine, &p, NULL);
> -	}
> -}
> -
>  static bool switch_to_kernel_context(struct intel_engine_cs *engine)
>  {
>  	struct i915_request *rq;
> @@ -136,12 +114,18 @@ static int __engine_park(struct intel_wakeref *wf)
>  	return 0;
>  }
>  
> -void intel_engine_pm_put(struct intel_engine_cs *engine)
> -{
> -	intel_wakeref_put(&engine->i915->runtime_pm, &engine->wakeref, __engine_park);
> -}
> +static const struct intel_wakeref_ops wf_ops = {
> +	.get = __engine_unpark,
> +	.put = __engine_park,
> +};
>  
>  void intel_engine_init__pm(struct intel_engine_cs *engine)
>  {
> -	intel_wakeref_init(&engine->wakeref);
> +	struct intel_runtime_pm *rpm = &engine->i915->runtime_pm;
> +
> +	intel_wakeref_init(&engine->wakeref, rpm, &wf_ops);
>  }
> +
> +#if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
> +#include "selftest_engine_pm.c"
> +#endif
> diff --git a/drivers/gpu/drm/i915/gt/intel_engine_pm.h b/drivers/gpu/drm/i915/gt/intel_engine_pm.h
> index 015ac72d7ad0..739c50fefcef 100644
> --- a/drivers/gpu/drm/i915/gt/intel_engine_pm.h
> +++ b/drivers/gpu/drm/i915/gt/intel_engine_pm.h
> @@ -10,24 +10,26 @@
>  #include "intel_engine_types.h"
>  #include "intel_wakeref.h"
>  
> -struct drm_i915_private;
> -
> -void intel_engine_pm_get(struct intel_engine_cs *engine);
> -void intel_engine_pm_put(struct intel_engine_cs *engine);
> -
>  static inline bool
>  intel_engine_pm_is_awake(const struct intel_engine_cs *engine)
>  {
>  	return intel_wakeref_is_active(&engine->wakeref);
>  }
>  
> -static inline bool
> -intel_engine_pm_get_if_awake(struct intel_engine_cs *engine)
> +static inline void intel_engine_pm_get(struct intel_engine_cs *engine)
> +{
> +	intel_wakeref_get(&engine->wakeref);
> +}
> +
> +static inline bool intel_engine_pm_get_if_awake(struct intel_engine_cs *engine)
>  {
>  	return intel_wakeref_get_if_active(&engine->wakeref);
>  }
>  
> -void intel_engine_park(struct intel_engine_cs *engine);
> +static inline void intel_engine_pm_put(struct intel_engine_cs *engine)
> +{
> +	intel_wakeref_put(&engine->wakeref);
> +}
>  
>  void intel_engine_init__pm(struct intel_engine_cs *engine);
>  
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.c b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> index 6c8970271a7f..1363e069ec83 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.c
> @@ -17,7 +17,7 @@ static void pm_notify(struct drm_i915_private *i915, int state)
>  	blocking_notifier_call_chain(&i915->gt.pm_notifications, state, i915);
>  }
>  
> -static int intel_gt_unpark(struct intel_wakeref *wf)
> +static int __gt_unpark(struct intel_wakeref *wf)
>  {
>  	struct intel_gt *gt = container_of(wf, typeof(*gt), wakeref);
>  	struct drm_i915_private *i915 = gt->i915;
> @@ -53,14 +53,7 @@ static int intel_gt_unpark(struct intel_wakeref *wf)
>  	return 0;
>  }
>  
> -void intel_gt_pm_get(struct intel_gt *gt)
> -{
> -	struct intel_runtime_pm *rpm = &gt->i915->runtime_pm;
> -
> -	intel_wakeref_get(rpm, &gt->wakeref, intel_gt_unpark);
> -}
> -
> -static int intel_gt_park(struct intel_wakeref *wf)
> +static int __gt_park(struct intel_wakeref *wf)
>  {
>  	struct drm_i915_private *i915 =
>  		container_of(wf, typeof(*i915), gt.wakeref);
> @@ -74,22 +67,25 @@ static int intel_gt_park(struct intel_wakeref *wf)
>  	if (INTEL_GEN(i915) >= 6)
>  		gen6_rps_idle(i915);
>  
> +	/* Everything switched off, flush any residual interrupt just in case */
> +	intel_synchronize_irq(i915);

Do we detect it gracefully if we get one extra afer this flush?

> +
>  	GEM_BUG_ON(!wakeref);
>  	intel_display_power_put(i915, POWER_DOMAIN_GT_IRQ, wakeref);
>  
>  	return 0;
>  }
>  
> -void intel_gt_pm_put(struct intel_gt *gt)
> -{
> -	struct intel_runtime_pm *rpm = &gt->i915->runtime_pm;
> -
> -	intel_wakeref_put(rpm, &gt->wakeref, intel_gt_park);
> -}
> +static const struct intel_wakeref_ops wf_ops = {
> +	.get = __gt_unpark,
> +	.put = __gt_park,
> +	.flags = INTEL_WAKEREF_PUT_ASYNC,
> +};
>  
>  void intel_gt_pm_init_early(struct intel_gt *gt)
>  {
> -	intel_wakeref_init(&gt->wakeref);
> +	intel_wakeref_init(&gt->wakeref, &gt->i915->runtime_pm, &wf_ops);
> +
>  	BLOCKING_INIT_NOTIFIER_HEAD(&gt->pm_notifications);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/gt/intel_gt_pm.h b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> index e8a18d4b27c9..57633f538ddb 100644
> --- a/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> +++ b/drivers/gpu/drm/i915/gt/intel_gt_pm.h
> @@ -17,14 +17,32 @@ enum {
>  	INTEL_GT_PARK,
>  };
>  
> -void intel_gt_pm_get(struct intel_gt *gt);
> -void intel_gt_pm_put(struct intel_gt *gt);
> +static inline bool
> +intel_gt_pm_is_awake(const struct intel_gt *gt)
> +{
> +	return intel_wakeref_is_active(&gt->wakeref);
> +}
> +
> +static inline void intel_gt_pm_get(struct intel_gt *gt)
> +{
> +	intel_wakeref_get(&gt->wakeref);
> +}
>  
>  static inline bool intel_gt_pm_get_if_awake(struct intel_gt *gt)
>  {
>  	return intel_wakeref_get_if_active(&gt->wakeref);
>  }
>  
> +static inline void intel_gt_pm_put(struct intel_gt *gt)
> +{
> +	intel_wakeref_put(&gt->wakeref);
> +}
> +
> +static inline int intel_gt_pm_wait_for_idle(struct intel_gt *gt)
> +{
> +	return intel_wakeref_wait_for_idle(&gt->wakeref);
> +}
> +
>  void intel_gt_pm_init_early(struct intel_gt *gt);
>  
>  void intel_gt_sanitize(struct intel_gt *gt, bool force);
> diff --git a/drivers/gpu/drm/i915/gt/intel_lrc.c b/drivers/gpu/drm/i915/gt/intel_lrc.c
> index 232f40fcb490..1a0116751d19 100644
> --- a/drivers/gpu/drm/i915/gt/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/gt/intel_lrc.c
> @@ -139,6 +139,7 @@
>  #include "i915_vgpu.h"
>  #include "intel_engine_pm.h"
>  #include "intel_gt.h"
> +#include "intel_gt_pm.h"
>  #include "intel_lrc_reg.h"
>  #include "intel_mocs.h"
>  #include "intel_reset.h"
> @@ -556,6 +557,7 @@ execlists_schedule_in(struct i915_request *rq, int idx)
>  		intel_context_get(ce);
>  		ce->inflight = rq->engine;
>  
> +		intel_gt_pm_get(ce->inflight->gt);
>  		execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_IN);
>  		intel_engine_context_in(ce->inflight);
>  	}
> @@ -588,6 +590,7 @@ execlists_schedule_out(struct i915_request *rq)
>  	if (!intel_context_inflight_count(ce)) {
>  		intel_engine_context_out(ce->inflight);
>  		execlists_context_status_change(rq, INTEL_CONTEXT_SCHEDULE_OUT);
> +		intel_gt_pm_put(ce->inflight->gt);
>  
>  		/*
>  		 * If this is part of a virtual engine, its next request may
> @@ -2719,7 +2722,6 @@ static u32 *gen8_emit_fini_breadcrumb_rcs(struct i915_request *request, u32 *cs)
>  static void execlists_park(struct intel_engine_cs *engine)
>  {
>  	del_timer_sync(&engine->execlists.timer);
> -	intel_engine_park(engine);
>  }
>  
>  void intel_execlists_set_default_submission(struct intel_engine_cs *engine)
> diff --git a/drivers/gpu/drm/i915/gt/selftest_engine.c b/drivers/gpu/drm/i915/gt/selftest_engine.c
> new file mode 100644
> index 000000000000..f65b118e261d
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/gt/selftest_engine.c
> @@ -0,0 +1,28 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0
> + *
> + * Copyright © 2018 Intel Corporation
> + */
> +
> +#include "i915_selftest.h"
> +#include "selftest_engine.h"
> +
> +int intel_engine_live_selftests(struct drm_i915_private *i915)
> +{
> +	static int (* const tests[])(struct intel_gt *) = {
> +		live_engine_pm_selftests,
> +		NULL,
> +	};
> +	struct intel_gt *gt = &i915->gt;
> +	typeof(*tests) *fn;
> +
> +	for (fn = tests; *fn; fn++) {
> +		int err;
> +
> +		err = (*fn)(gt);
> +		if (err)
> +			return err;
> +	}
> +
> +	return 0;
> +}
> diff --git a/drivers/gpu/drm/i915/gt/selftest_engine.h b/drivers/gpu/drm/i915/gt/selftest_engine.h
> new file mode 100644
> index 000000000000..ab32d09ec5a1
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/gt/selftest_engine.h
> @@ -0,0 +1,14 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0
> + *
> + * Copyright © 2019 Intel Corporation
> + */
> +
> +#ifndef SELFTEST_ENGINE_H
> +#define SELFTEST_ENGINE_H
> +
> +struct intel_gt;
> +
> +int live_engine_pm_selftests(struct intel_gt *gt);
> +
> +#endif
> diff --git a/drivers/gpu/drm/i915/gt/selftest_engine_pm.c b/drivers/gpu/drm/i915/gt/selftest_engine_pm.c
> new file mode 100644
> index 000000000000..75c197612705
> --- /dev/null
> +++ b/drivers/gpu/drm/i915/gt/selftest_engine_pm.c
> @@ -0,0 +1,83 @@
> +/*
> + * SPDX-License-Identifier: GPL-2.0
> + *
> + * Copyright © 2018 Intel Corporation
> + */
> +
> +#include "i915_selftest.h"
> +#include "selftest_engine.h"
> +#include "selftests/igt_atomic.h"
> +
> +static int live_engine_pm(void *arg)
> +{
> +	struct intel_gt *gt = arg;
> +	struct intel_engine_cs *engine;
> +	enum intel_engine_id id;
> +
> +	/*
> +	 * Check we can call intel_engine_pm_put from any context. No
> +	 * failures are reported directly, but if we mess up lockdep should
> +	 * tell us.
> +	 */
> +	if (intel_gt_pm_wait_for_idle(gt)) {
> +		pr_err("Unable to flush GT pm before test\n");
> +		return -EBUSY;
> +	}
> +
> +	GEM_BUG_ON(intel_gt_pm_is_awake(gt));
> +	for_each_engine(engine, gt->i915, id) {
> +		const typeof(*igt_atomic_phases) *p;
> +
> +		for (p = igt_atomic_phases; p->name; p++) {
> +			/*
> +			 * Acquisition is always synchronous, except if we
> +			 * know that the engine is already awale, in which

s/awale/awake

in which case?

> +			 * we should use intel_engine_pm_get_if_awake() to
> +			 * atomically grab the wakeref.
> +			 *
> +			 * In practice,
> +			 *    intel_engine_pm_get();
> +			 *    intel_engine_pm_put();
> +			 * occurs in one thread, while simultaneously
> +			 *    intel_engine_pm_get_if_awake();
> +			 *    intel_engine_pm_put();
> +			 * occurs in atomic context in another.
> +			 */
> +			GEM_BUG_ON(intel_engine_pm_is_awake(engine));
> +			intel_engine_pm_get(engine);
> +
> +			p->critical_section_begin();
> +			if (!intel_engine_pm_get_if_awake(engine))
> +				pr_err("intel_engine_pm_get_if_awake(%s) failed under %s\n",
> +				       engine->name, p->name);
> +			else
> +				intel_engine_pm_put(engine);
> +			intel_engine_pm_put(engine);
> +			p->critical_section_end();
> +
> +			/* engine wakeref is sync (instant) */
> +			if (intel_engine_pm_is_awake(engine)) {
> +				pr_err("%s is still awake after flushing pm\n",
> +				       engine->name);
> +				return -EINVAL;
> +			}
> +
> +			/* gt wakeref is async (deferred to workqueue) */
> +			if (intel_gt_pm_wait_for_idle(gt)) {
> +				pr_err("GT failed to idle\n");
> +				return -EINVAL;
> +			}
> +		}
> +	}
> +
> +	return 0;
> +}
> +
> +int live_engine_pm_selftests(struct intel_gt *gt)
> +{
> +	static const struct i915_subtest tests[] = {
> +		SUBTEST(live_engine_pm),
> +	};
> +
> +	return intel_gt_live_subtests(tests, gt);
> +}
> diff --git a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> index a78bd99bc6cb..c9119b90d6aa 100644
> --- a/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> +++ b/drivers/gpu/drm/i915/gt/uc/intel_guc_submission.c
> @@ -29,6 +29,7 @@
>  #include "gt/intel_context.h"
>  #include "gt/intel_engine_pm.h"
>  #include "gt/intel_gt.h"
> +#include "gt/intel_gt_pm.h"
>  #include "gt/intel_lrc_reg.h"
>  #include "intel_guc_submission.h"
>  
> @@ -537,6 +538,7 @@ static struct i915_request *schedule_in(struct i915_request *rq, int idx)
>  	if (!rq->hw_context->inflight)
>  		rq->hw_context->inflight = rq->engine;
>  	intel_context_inflight_inc(rq->hw_context);
> +	intel_gt_pm_get(rq->engine->gt);
>  
>  	return i915_request_get(rq);
>  }
> @@ -549,6 +551,7 @@ static void schedule_out(struct i915_request *rq)
>  	if (!intel_context_inflight_count(rq->hw_context))
>  		rq->hw_context->inflight = NULL;
>  
> +	intel_gt_pm_put(rq->engine->gt);
>  	i915_request_put(rq);
>  }
>  
> @@ -1076,7 +1079,6 @@ static void guc_interrupts_release(struct intel_gt *gt)
>  
>  static void guc_submission_park(struct intel_engine_cs *engine)
>  {
> -	intel_engine_park(engine);
>  	intel_engine_unpin_breadcrumbs_irq(engine);
>  	engine->flags &= ~I915_ENGINE_NEEDS_BREADCRUMB_TASKLET;
>  }
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 63b599f584db..68a6b002c9ba 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -39,6 +39,7 @@
>  #include "display/intel_psr.h"
>  
>  #include "gem/i915_gem_context.h"
> +#include "gt/intel_gt_pm.h"
>  #include "gt/intel_reset.h"
>  #include "gt/uc/intel_guc_submission.h"
>  
> @@ -3664,6 +3665,9 @@ i915_drop_caches_set(void *data, u64 val)
>  			i915_retire_requests(i915);
>  
>  		mutex_unlock(&i915->drm.struct_mutex);
> +
> +		if (ret == 0 && val & DROP_IDLE)
> +			ret = intel_gt_pm_wait_for_idle(&i915->gt);
>  	}
>  
>  	if (val & DROP_RESET_ACTIVE && intel_gt_terminally_wedged(&i915->gt))
> diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
> index 7efff14b9137..f67197336ee7 100644
> --- a/drivers/gpu/drm/i915/i915_gem.c
> +++ b/drivers/gpu/drm/i915/i915_gem.c
> @@ -894,19 +894,6 @@ void i915_gem_runtime_suspend(struct drm_i915_private *i915)
>  	}
>  }
>  
> -static int wait_for_engines(struct intel_gt *gt)
> -{
> -	if (wait_for(intel_engines_are_idle(gt), I915_IDLE_ENGINES_TIMEOUT)) {
> -		dev_err(gt->i915->drm.dev,
> -			"Failed to idle engines, declaring wedged!\n");
> -		GEM_TRACE_DUMP();
> -		intel_gt_set_wedged(gt);
> -		return -EIO;
> -	}
> -
> -	return 0;
> -}
> -
>  static long
>  wait_for_timelines(struct drm_i915_private *i915,
>  		   unsigned int flags, long timeout)
> @@ -954,27 +941,20 @@ int i915_gem_wait_for_idle(struct drm_i915_private *i915,
>  			   unsigned int flags, long timeout)
>  {
>  	/* If the device is asleep, we have no requests outstanding */
> -	if (!READ_ONCE(i915->gt.awake))
> +	if (!intel_gt_pm_is_awake(&i915->gt))
>  		return 0;
>  
> -	GEM_TRACE("flags=%x (%s), timeout=%ld%s, awake?=%s\n",
> +	GEM_TRACE("flags=%x (%s), timeout=%ld%s\n",
>  		  flags, flags & I915_WAIT_LOCKED ? "locked" : "unlocked",
> -		  timeout, timeout == MAX_SCHEDULE_TIMEOUT ? " (forever)" : "",
> -		  yesno(i915->gt.awake));
> +		  timeout, timeout == MAX_SCHEDULE_TIMEOUT ? " (forever)" : "");
>  
>  	timeout = wait_for_timelines(i915, flags, timeout);
>  	if (timeout < 0)
>  		return timeout;
>  
>  	if (flags & I915_WAIT_LOCKED) {
> -		int err;
> -
>  		lockdep_assert_held(&i915->drm.struct_mutex);
>  
> -		err = wait_for_engines(&i915->gt);
> -		if (err)
> -			return err;
> -

Hmm where does the implicit wait for idle come from now?

>  		i915_retire_requests(i915);
>  	}
>  
> diff --git a/drivers/gpu/drm/i915/intel_wakeref.c b/drivers/gpu/drm/i915/intel_wakeref.c
> index 06bd8b215cc2..d4443e81c1c8 100644
> --- a/drivers/gpu/drm/i915/intel_wakeref.c
> +++ b/drivers/gpu/drm/i915/intel_wakeref.c
> @@ -4,25 +4,25 @@
>   * Copyright © 2019 Intel Corporation
>   */
>  
> +#include <linux/wait_bit.h>
> +
>  #include "intel_runtime_pm.h"
>  #include "intel_wakeref.h"
>  
> -static void rpm_get(struct intel_runtime_pm *rpm, struct intel_wakeref *wf)
> +static void rpm_get(struct intel_wakeref *wf)
>  {
> -	wf->wakeref = intel_runtime_pm_get(rpm);
> +	wf->wakeref = intel_runtime_pm_get(wf->rpm);
>  }
>  
> -static void rpm_put(struct intel_runtime_pm *rpm, struct intel_wakeref *wf)
> +static void rpm_put(struct intel_wakeref *wf)
>  {
>  	intel_wakeref_t wakeref = fetch_and_zero(&wf->wakeref);
>  
> -	intel_runtime_pm_put(rpm, wakeref);
> +	intel_runtime_pm_put(wf->rpm, wakeref);
>  	INTEL_WAKEREF_BUG_ON(!wakeref);
>  }
>  
> -int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
> -			      struct intel_wakeref *wf,
> -			      int (*fn)(struct intel_wakeref *wf))
> +int __intel_wakeref_get_first(struct intel_wakeref *wf)
>  {
>  	/*
>  	 * Treat get/put as different subclasses, as we may need to run
> @@ -34,11 +34,11 @@ int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
>  	if (!atomic_read(&wf->count)) {
>  		int err;
>  
> -		rpm_get(rpm, wf);
> +		rpm_get(wf);
>  
> -		err = fn(wf);
> +		err = wf->ops->get(wf);
>  		if (unlikely(err)) {
> -			rpm_put(rpm, wf);
> +			rpm_put(wf);
>  			mutex_unlock(&wf->mutex);
>  			return err;
>  		}
> @@ -52,27 +52,67 @@ int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
>  	return 0;
>  }
>  
> -int __intel_wakeref_put_last(struct intel_runtime_pm *rpm,
> -			     struct intel_wakeref *wf,
> -			     int (*fn)(struct intel_wakeref *wf))
> +static void ____intel_wakeref_put_last(struct intel_wakeref *wf)
>  {
> -	int err;
> +	if (!atomic_dec_and_test(&wf->count))
> +		goto unlock;
> +
> +	if (likely(!wf->ops->put(wf))) {
> +		rpm_put(wf);
> +		wake_up_var(&wf->wakeref);
> +	} else {
> +		/* ops->put() must schedule its own release on deferral */
> +		atomic_set_release(&wf->count, 1);

I lose track here. On async call to gt_park we end up leaving
with a count 1. 

> +	}
>  
> -	err = fn(wf);
> -	if (likely(!err))
> -		rpm_put(rpm, wf);
> -	else
> -		atomic_inc(&wf->count);
> +unlock:
>  	mutex_unlock(&wf->mutex);
> +}
> +
> +void __intel_wakeref_put_last(struct intel_wakeref *wf)
> +{
> +	INTEL_WAKEREF_BUG_ON(work_pending(&wf->work));
>  
> -	return err;
> +	/* Assume we are not in process context and so cannot sleep. */
> +	if (wf->ops->flags & INTEL_WAKEREF_PUT_ASYNC ||
> +	    !mutex_trylock(&wf->mutex)) {

Didn't found anything in trylock that would prevent you
from shooting you on your own leg.

So it is up to caller (and eventually lockdep spam) if
the async usage fails to follow the rules?

> +		schedule_work(&wf->work);
> +		return;
> +	}
> +
> +	____intel_wakeref_put_last(wf);
>  }
>  
> -void __intel_wakeref_init(struct intel_wakeref *wf, struct lock_class_key *key)
> +static void __intel_wakeref_put_work(struct work_struct *wrk)

No need for underscore before the name here?
-Mika


>  {
> +	struct intel_wakeref *wf = container_of(wrk, typeof(*wf), work);
> +
> +	if (atomic_add_unless(&wf->count, -1, 1))
> +		return;
> +
> +	mutex_lock(&wf->mutex);
> +	____intel_wakeref_put_last(wf);
> +}
> +
> +void __intel_wakeref_init(struct intel_wakeref *wf,
> +			  struct intel_runtime_pm *rpm,
> +			  const struct intel_wakeref_ops *ops,
> +			  struct lock_class_key *key)
> +{
> +	wf->rpm = rpm;
> +	wf->ops = ops;
> +
>  	__mutex_init(&wf->mutex, "wakeref", key);
>  	atomic_set(&wf->count, 0);
>  	wf->wakeref = 0;
> +
> +	INIT_WORK(&wf->work, __intel_wakeref_put_work);
> +}
> +
> +int intel_wakeref_wait_for_idle(struct intel_wakeref *wf)
> +{
> +	return wait_var_event_killable(&wf->wakeref,
> +				       !intel_wakeref_is_active(wf));
>  }
>  
>  static void wakeref_auto_timeout(struct timer_list *t)
> diff --git a/drivers/gpu/drm/i915/intel_wakeref.h b/drivers/gpu/drm/i915/intel_wakeref.h
> index 1d6f5986e4e5..535a3a12864b 100644
> --- a/drivers/gpu/drm/i915/intel_wakeref.h
> +++ b/drivers/gpu/drm/i915/intel_wakeref.h
> @@ -8,10 +8,12 @@
>  #define INTEL_WAKEREF_H
>  
>  #include <linux/atomic.h>
> +#include <linux/bits.h>
>  #include <linux/mutex.h>
>  #include <linux/refcount.h>
>  #include <linux/stackdepot.h>
>  #include <linux/timer.h>
> +#include <linux/workqueue.h>
>  
>  #if IS_ENABLED(CONFIG_DRM_I915_DEBUG)
>  #define INTEL_WAKEREF_BUG_ON(expr) BUG_ON(expr)
> @@ -20,29 +22,42 @@
>  #endif
>  
>  struct intel_runtime_pm;
> +struct intel_wakeref;
>  
>  typedef depot_stack_handle_t intel_wakeref_t;
>  
> +struct intel_wakeref_ops {
> +	int (*get)(struct intel_wakeref *wf);
> +	int (*put)(struct intel_wakeref *wf);
> +
> +	unsigned long flags;
> +#define INTEL_WAKEREF_PUT_ASYNC BIT(0)
> +};
> +
>  struct intel_wakeref {
>  	atomic_t count;
>  	struct mutex mutex;
> +
>  	intel_wakeref_t wakeref;
> +
> +	struct intel_runtime_pm *rpm;
> +	const struct intel_wakeref_ops *ops;
> +
> +	struct work_struct work;
>  };
>  
>  void __intel_wakeref_init(struct intel_wakeref *wf,
> +			  struct intel_runtime_pm *rpm,
> +			  const struct intel_wakeref_ops *ops,
>  			  struct lock_class_key *key);
> -#define intel_wakeref_init(wf) do {					\
> +#define intel_wakeref_init(wf, rpm, ops) do {				\
>  	static struct lock_class_key __key;				\
>  									\
> -	__intel_wakeref_init((wf), &__key);				\
> +	__intel_wakeref_init((wf), (rpm), (ops), &__key);		\
>  } while (0)
>  
> -int __intel_wakeref_get_first(struct intel_runtime_pm *rpm,
> -			      struct intel_wakeref *wf,
> -			      int (*fn)(struct intel_wakeref *wf));
> -int __intel_wakeref_put_last(struct intel_runtime_pm *rpm,
> -			     struct intel_wakeref *wf,
> -			     int (*fn)(struct intel_wakeref *wf));
> +int __intel_wakeref_get_first(struct intel_wakeref *wf);
> +void __intel_wakeref_put_last(struct intel_wakeref *wf);
>  
>  /**
>   * intel_wakeref_get: Acquire the wakeref
> @@ -61,12 +76,10 @@ int __intel_wakeref_put_last(struct intel_runtime_pm *rpm,
>   * code otherwise.
>   */
>  static inline int
> -intel_wakeref_get(struct intel_runtime_pm *rpm,
> -		  struct intel_wakeref *wf,
> -		  int (*fn)(struct intel_wakeref *wf))
> +intel_wakeref_get(struct intel_wakeref *wf)
>  {
>  	if (unlikely(!atomic_inc_not_zero(&wf->count)))
> -		return __intel_wakeref_get_first(rpm, wf, fn);
> +		return __intel_wakeref_get_first(wf);
>  
>  	return 0;
>  }
> @@ -102,16 +115,12 @@ intel_wakeref_get_if_active(struct intel_wakeref *wf)
>   * Returns: 0 if the wakeref was released successfully, or a negative error
>   * code otherwise.
>   */
> -static inline int
> -intel_wakeref_put(struct intel_runtime_pm *rpm,
> -		  struct intel_wakeref *wf,
> -		  int (*fn)(struct intel_wakeref *wf))
> +static inline void
> +intel_wakeref_put(struct intel_wakeref *wf)
>  {
>  	INTEL_WAKEREF_BUG_ON(atomic_read(&wf->count) <= 0);
> -	if (atomic_dec_and_mutex_lock(&wf->count, &wf->mutex))
> -		return __intel_wakeref_put_last(rpm, wf, fn);
> -
> -	return 0;
> +	if (unlikely(!atomic_add_unless(&wf->count, -1, 1)))
> +		__intel_wakeref_put_last(wf);
>  }
>  
>  /**
> @@ -154,6 +163,19 @@ intel_wakeref_is_active(const struct intel_wakeref *wf)
>  	return READ_ONCE(wf->wakeref);
>  }
>  
> +/**
> + * intel_wakeref_wait_for_idle: Wait until the wakeref is idle
> + * @wf: the wakeref
> + *
> + * Wait for the earlier asynchronous release of the wakeref. Note
> + * this will wait for any third party as well, so make sure you only wait
> + * when you have control over the wakeref and trust no one else is acquiring
> + * it.
> + *
> + * Return: 0 on success, error code if killed.
> + */
> +int intel_wakeref_wait_for_idle(struct intel_wakeref *wf);
> +
>  struct intel_wakeref_auto {
>  	struct intel_runtime_pm *rpm;
>  	struct timer_list timer;
> diff --git a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
> index a841d3f9bedc..1ccf0f731ac0 100644
> --- a/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
> +++ b/drivers/gpu/drm/i915/selftests/i915_live_selftests.h
> @@ -12,10 +12,11 @@
>  selftest(sanitycheck, i915_live_sanitycheck) /* keep first (igt selfcheck) */
>  selftest(uncore, intel_uncore_live_selftests)
>  selftest(workarounds, intel_workarounds_live_selftests)
> -selftest(timelines, intel_timeline_live_selftests)
> +selftest(gt_engines, intel_engine_live_selftests)
> +selftest(gt_timelines, intel_timeline_live_selftests)
> +selftest(gt_contexts, intel_context_live_selftests)
>  selftest(requests, i915_request_live_selftests)
>  selftest(active, i915_active_live_selftests)
> -selftest(gt_contexts, intel_context_live_selftests)
>  selftest(objects, i915_gem_object_live_selftests)
>  selftest(mman, i915_gem_mman_live_selftests)
>  selftest(dmabuf, i915_gem_dmabuf_live_selftests)
> -- 
> 2.23.0.rc1
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 3/3] drm/i915: Defer final intel_wakeref_put to process context
  2019-08-07 15:04   ` Mika Kuoppala
@ 2019-08-07 15:24     ` Chris Wilson
  2019-08-08 13:49       ` Mika Kuoppala
  0 siblings, 1 reply; 20+ messages in thread
From: Chris Wilson @ 2019-08-07 15:24 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-08-07 16:04:56)
> Chris Wilson <chris@chris-wilson.co.uk> writes:
> > -static int intel_gt_park(struct intel_wakeref *wf)
> > +static int __gt_park(struct intel_wakeref *wf)
> >  {
> >       struct drm_i915_private *i915 =
> >               container_of(wf, typeof(*i915), gt.wakeref);
> > @@ -74,22 +67,25 @@ static int intel_gt_park(struct intel_wakeref *wf)
> >       if (INTEL_GEN(i915) >= 6)
> >               gen6_rps_idle(i915);
> >  
> > +     /* Everything switched off, flush any residual interrupt just in case */
> > +     intel_synchronize_irq(i915);
> 
> Do we detect it gracefully if we get one extra afer this flush?

If we make a mistake, we get unclaimed mmio from the interrupt handler.

Given the structure of engine_pm/gt_pm, we should not be generating
either user interrupts nor CS interrupts by this point. The potential is
for the guc/pm interrupts, but I felt it was more prudent to document
this is the final point for GT interrupts of any type.

> > +     GEM_BUG_ON(intel_gt_pm_is_awake(gt));
> > +     for_each_engine(engine, gt->i915, id) {
> > +             const typeof(*igt_atomic_phases) *p;
> > +
> > +             for (p = igt_atomic_phases; p->name; p++) {
> > +                     /*
> > +                      * Acquisition is always synchronous, except if we
> > +                      * know that the engine is already awale, in which
> 
> s/awale/awake

a whale
 
> in which case?

Avast ye blows!
Moby Dick!

> >  static long
> >  wait_for_timelines(struct drm_i915_private *i915,
> >                  unsigned int flags, long timeout)
> > @@ -954,27 +941,20 @@ int i915_gem_wait_for_idle(struct drm_i915_private *i915,
> >                          unsigned int flags, long timeout)
> >  {
> >       /* If the device is asleep, we have no requests outstanding */
> > -     if (!READ_ONCE(i915->gt.awake))
> > +     if (!intel_gt_pm_is_awake(&i915->gt))
> >               return 0;
> >  
> > -     GEM_TRACE("flags=%x (%s), timeout=%ld%s, awake?=%s\n",
> > +     GEM_TRACE("flags=%x (%s), timeout=%ld%s\n",
> >                 flags, flags & I915_WAIT_LOCKED ? "locked" : "unlocked",
> > -               timeout, timeout == MAX_SCHEDULE_TIMEOUT ? " (forever)" : "",
> > -               yesno(i915->gt.awake));
> > +               timeout, timeout == MAX_SCHEDULE_TIMEOUT ? " (forever)" : "");
> >  
> >       timeout = wait_for_timelines(i915, flags, timeout);
> >       if (timeout < 0)
> >               return timeout;
> >  
> >       if (flags & I915_WAIT_LOCKED) {
> > -             int err;
> > -
> >               lockdep_assert_held(&i915->drm.struct_mutex);
> >  
> > -             err = wait_for_engines(&i915->gt);
> > -             if (err)
> > -                     return err;
> > -
> 
> Hmm where does the implicit wait for idle come from now?

Instead of having the wait here, we moved it into the engine/gt pm
tracking and added an intel_gt_pm_wait_for_idle().

> > -int __intel_wakeref_put_last(struct intel_runtime_pm *rpm,
> > -                          struct intel_wakeref *wf,
> > -                          int (*fn)(struct intel_wakeref *wf))
> > +static void ____intel_wakeref_put_last(struct intel_wakeref *wf)
> >  {
> > -     int err;
> > +     if (!atomic_dec_and_test(&wf->count))
> > +             goto unlock;
> > +
> > +     if (likely(!wf->ops->put(wf))) {
> > +             rpm_put(wf);
> > +             wake_up_var(&wf->wakeref);
> > +     } else {
> > +             /* ops->put() must schedule its own release on deferral */
> > +             atomic_set_release(&wf->count, 1);
> 
> I lose track here. On async call to gt_park we end up leaving
> with a count 1. 

So we know wf->count is 0 and that we hold the lock preventing anyone
else raising wf->count back to 1. If we fail in our cleanup task,
knowing that we have exclusive control over the counter, we simply mark
it as 1 again (using _release to unlock anyone concurrently trying to
acquire the wakeref for themselves).

> > +     /* Assume we are not in process context and so cannot sleep. */
> > +     if (wf->ops->flags & INTEL_WAKEREF_PUT_ASYNC ||
> > +         !mutex_trylock(&wf->mutex)) {
> 
> Didn't found anything in trylock that would prevent you
> from shooting you on your own leg.

Yup. It's immorally equivalent to spin_trylock.

> So it is up to caller (and eventually lockdep spam) if
> the async usage fails to follow the rules?

Not the caller, the fault lies in the wakeref. We either mark it that is
has to use the worker (process context) or fix it such that it is quick
and can run in atomic context. engine_pm was simple enough to make
atomic, gt_pm is promising but I needed to make rps waitfree (done) and
make the display pm truly async (which I baulked at!).

> 
> > +             schedule_work(&wf->work);
> > +             return;
> > +     }
> > +
> > +     ____intel_wakeref_put_last(wf);
> >  }
> >  
> > -void __intel_wakeref_init(struct intel_wakeref *wf, struct lock_class_key *key)
> > +static void __intel_wakeref_put_work(struct work_struct *wrk)
> 
> No need for underscore before the name here?

I was just trying to keep it consistent with the 3 functions working
together.

__intel_wakeref_put_last
__intel_wakeref_put_work
____intel_wakeref_put_last

Now, could use

__intel_wakeref_put_last
__wakeref_put_work
____wakeref_put_last

keeping the underscores to underline the games being played with locking
are not for the faint of heart.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✗ Fi.CI.IGT: failure for series starting with [v3] drm/i915: Rename engines to match their user interface (rev3)
  2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
                   ` (8 preceding siblings ...)
  2019-08-07 12:52 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2019-08-07 19:23 ` Patchwork
  9 siblings, 0 replies; 20+ messages in thread
From: Patchwork @ 2019-08-07 19:23 UTC (permalink / raw)
  To: Chris Wilson; +Cc: intel-gfx

== Series Details ==

Series: series starting with [v3] drm/i915: Rename engines to match their user interface (rev3)
URL   : https://patchwork.freedesktop.org/series/64824/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_6646_full -> Patchwork_13897_full
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_13897_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_13897_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_13897_full:

### IGT changes ###

#### Possible regressions ####

  * igt@gem_exec_schedule@reorder-wide-bsd:
    - shard-iclb:         [PASS][1] -> [SKIP][2] +8 similar issues
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb2/igt@gem_exec_schedule@reorder-wide-bsd.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb2/igt@gem_exec_schedule@reorder-wide-bsd.html

  * igt@kms_atomic_transition@1x-modeset-transitions-nonblocking-fencing:
    - shard-kbl:          [PASS][3] -> [FAIL][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-kbl7/igt@kms_atomic_transition@1x-modeset-transitions-nonblocking-fencing.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-kbl6/igt@kms_atomic_transition@1x-modeset-transitions-nonblocking-fencing.html

  
#### Warnings ####

  * igt@gem_mocs_settings@mocs-reset-bsd2:
    - shard-iclb:         [SKIP][5] ([fdo#109276]) -> [FAIL][6] +2 similar issues
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb4/igt@gem_mocs_settings@mocs-reset-bsd2.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb1/igt@gem_mocs_settings@mocs-reset-bsd2.html

  
New tests
---------

  New tests have been introduced between CI_DRM_6646_full and Patchwork_13897_full:

### New IGT tests (2) ###

  * igt@i915_selftest@live_gt_engines:
    - Statuses : 7 pass(s)
    - Exec time: [0.35, 1.95] s

  * igt@i915_selftest@live_gt_timelines:
    - Statuses : 7 pass(s)
    - Exec time: [3.50, 19.37] s

  

Known issues
------------

  Here are the changes found in Patchwork_13897_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_reuse@contexts:
    - shard-iclb:         [PASS][7] -> [INCOMPLETE][8] ([fdo#107713] / [fdo#109100])
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb3/igt@gem_exec_reuse@contexts.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb7/igt@gem_exec_reuse@contexts.html

  * igt@gem_exec_schedule@semaphore-noskip:
    - shard-iclb:         [PASS][9] -> [FAIL][10] ([fdo#110946])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb2/igt@gem_exec_schedule@semaphore-noskip.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb2/igt@gem_exec_schedule@semaphore-noskip.html

  * igt@i915_pm_rps@reset:
    - shard-iclb:         [PASS][11] -> [FAIL][12] ([fdo#102250] / [fdo#108059])
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb7/igt@i915_pm_rps@reset.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb1/igt@i915_pm_rps@reset.html

  * igt@i915_selftest@live_hangcheck:
    - shard-iclb:         [PASS][13] -> [INCOMPLETE][14] ([fdo#107713] / [fdo#108569])
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb6/igt@i915_selftest@live_hangcheck.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb7/igt@i915_selftest@live_hangcheck.html

  * igt@kms_cursor_crc@pipe-b-cursor-suspend:
    - shard-skl:          [PASS][15] -> [INCOMPLETE][16] ([fdo#110741])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-skl3/igt@kms_cursor_crc@pipe-b-cursor-suspend.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-skl7/igt@kms_cursor_crc@pipe-b-cursor-suspend.html

  * igt@kms_cursor_crc@pipe-c-cursor-suspend:
    - shard-kbl:          [PASS][17] -> [INCOMPLETE][18] ([fdo#103665])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-kbl7/igt@kms_cursor_crc@pipe-c-cursor-suspend.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-kbl6/igt@kms_cursor_crc@pipe-c-cursor-suspend.html

  * igt@kms_flip@flip-vs-suspend-interruptible:
    - shard-snb:          [PASS][19] -> [INCOMPLETE][20] ([fdo#105411])
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-snb1/igt@kms_flip@flip-vs-suspend-interruptible.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-snb1/igt@kms_flip@flip-vs-suspend-interruptible.html

  * igt@kms_frontbuffer_tracking@fbc-suspend:
    - shard-kbl:          [PASS][21] -> [DMESG-WARN][22] ([fdo#108566]) +5 similar issues
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-kbl6/igt@kms_frontbuffer_tracking@fbc-suspend.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-kbl3/igt@kms_frontbuffer_tracking@fbc-suspend.html
    - shard-skl:          [PASS][23] -> [INCOMPLETE][24] ([fdo#104108]) +1 similar issue
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-skl1/igt@kms_frontbuffer_tracking@fbc-suspend.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-skl4/igt@kms_frontbuffer_tracking@fbc-suspend.html

  * igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-mmap-gtt:
    - shard-iclb:         [PASS][25] -> [FAIL][26] ([fdo#103167]) +4 similar issues
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-mmap-gtt.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-mmap-gtt.html

  * igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes:
    - shard-apl:          [PASS][27] -> [DMESG-WARN][28] ([fdo#108566]) +2 similar issues
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-apl5/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-apl8/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-b-planes.html

  * igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min:
    - shard-skl:          [PASS][29] -> [FAIL][30] ([fdo#108145])
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-skl8/igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-skl10/igt@kms_plane_alpha_blend@pipe-b-constant-alpha-min.html

  * igt@kms_plane_alpha_blend@pipe-c-coverage-7efc:
    - shard-skl:          [PASS][31] -> [FAIL][32] ([fdo#108145] / [fdo#110403])
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-skl10/igt@kms_plane_alpha_blend@pipe-c-coverage-7efc.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-skl2/igt@kms_plane_alpha_blend@pipe-c-coverage-7efc.html

  * igt@kms_plane_lowres@pipe-a-tiling-x:
    - shard-iclb:         [PASS][33] -> [FAIL][34] ([fdo#103166])
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb4/igt@kms_plane_lowres@pipe-a-tiling-x.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb1/igt@kms_plane_lowres@pipe-a-tiling-x.html

  * igt@kms_psr@psr2_suspend:
    - shard-iclb:         [PASS][35] -> [SKIP][36] ([fdo#109441])
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb2/igt@kms_psr@psr2_suspend.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb4/igt@kms_psr@psr2_suspend.html

  * igt@kms_setmode@basic:
    - shard-apl:          [PASS][37] -> [FAIL][38] ([fdo#99912])
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-apl4/igt@kms_setmode@basic.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-apl8/igt@kms_setmode@basic.html

  * igt@perf_pmu@rc6:
    - shard-kbl:          [PASS][39] -> [SKIP][40] ([fdo#109271])
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-kbl4/igt@perf_pmu@rc6.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-kbl2/igt@perf_pmu@rc6.html

  
#### Possible fixes ####

  * igt@gem_exec_schedule@preempt-contexts-bsd2:
    - shard-iclb:         [SKIP][41] ([fdo#109276]) -> [PASS][42] +27 similar issues
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb6/igt@gem_exec_schedule@preempt-contexts-bsd2.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb4/igt@gem_exec_schedule@preempt-contexts-bsd2.html

  * igt@i915_pm_rps@reset:
    - shard-apl:          [FAIL][43] ([fdo#102250]) -> [PASS][44]
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-apl4/igt@i915_pm_rps@reset.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-apl3/igt@i915_pm_rps@reset.html
    - shard-skl:          [FAIL][45] ([fdo#102250]) -> [PASS][46]
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-skl2/igt@i915_pm_rps@reset.html
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-skl1/igt@i915_pm_rps@reset.html
    - shard-glk:          [FAIL][47] ([fdo#102250]) -> [PASS][48]
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-glk1/igt@i915_pm_rps@reset.html
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-glk3/igt@i915_pm_rps@reset.html

  * igt@i915_query@engine-info:
    - shard-iclb:         [FAIL][49] -> [PASS][50]
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb2/igt@i915_query@engine-info.html
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb2/igt@i915_query@engine-info.html

  * igt@kms_cursor_crc@pipe-a-cursor-suspend:
    - shard-kbl:          [DMESG-WARN][51] ([fdo#108566]) -> [PASS][52] +3 similar issues
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-kbl7/igt@kms_cursor_crc@pipe-a-cursor-suspend.html
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-kbl1/igt@kms_cursor_crc@pipe-a-cursor-suspend.html

  * igt@kms_cursor_crc@pipe-b-cursor-suspend:
    - shard-apl:          [DMESG-WARN][53] ([fdo#108566]) -> [PASS][54] +3 similar issues
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-apl4/igt@kms_cursor_crc@pipe-b-cursor-suspend.html
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-apl8/igt@kms_cursor_crc@pipe-b-cursor-suspend.html

  * igt@kms_flip@2x-flip-vs-expired-vblank:
    - shard-glk:          [FAIL][55] ([fdo#105363]) -> [PASS][56]
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-glk7/igt@kms_flip@2x-flip-vs-expired-vblank.html
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-glk7/igt@kms_flip@2x-flip-vs-expired-vblank.html

  * igt@kms_flip@flip-vs-expired-vblank-interruptible:
    - shard-skl:          [FAIL][57] ([fdo#105363]) -> [PASS][58]
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-skl5/igt@kms_flip@flip-vs-expired-vblank-interruptible.html
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-skl2/igt@kms_flip@flip-vs-expired-vblank-interruptible.html

  * igt@kms_flip@flip-vs-suspend:
    - shard-skl:          [INCOMPLETE][59] ([fdo#109507]) -> [PASS][60]
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-skl6/igt@kms_flip@flip-vs-suspend.html
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-skl10/igt@kms_flip@flip-vs-suspend.html
    - shard-snb:          [INCOMPLETE][61] ([fdo#105411]) -> [PASS][62]
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-snb1/igt@kms_flip@flip-vs-suspend.html
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-snb5/igt@kms_flip@flip-vs-suspend.html

  * igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-indfb-draw-pwrite:
    - shard-hsw:          [SKIP][63] ([fdo#109271]) -> [PASS][64]
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-hsw6/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-indfb-draw-pwrite.html
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-hsw1/igt@kms_frontbuffer_tracking@fbc-2p-scndscrn-pri-indfb-draw-pwrite.html

  * igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-render:
    - shard-iclb:         [FAIL][65] ([fdo#103167]) -> [PASS][66] +5 similar issues
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-render.html
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb2/igt@kms_frontbuffer_tracking@fbcpsr-1p-primscrn-cur-indfb-draw-render.html

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c:
    - shard-skl:          [INCOMPLETE][67] ([fdo#104108]) -> [PASS][68]
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-skl4/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c.html
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-skl9/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-c.html

  * igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
    - shard-skl:          [FAIL][69] ([fdo#108145]) -> [PASS][70]
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-skl2/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-skl3/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html

  * igt@kms_psr@no_drrs:
    - shard-iclb:         [FAIL][71] ([fdo#108341]) -> [PASS][72]
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb1/igt@kms_psr@no_drrs.html
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb8/igt@kms_psr@no_drrs.html

  * igt@kms_psr@psr2_sprite_mmap_gtt:
    - shard-iclb:         [SKIP][73] ([fdo#109441]) -> [PASS][74] +1 similar issue
   [73]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_6646/shard-iclb8/igt@kms_psr@psr2_sprite_mmap_gtt.html
   [74]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/shard-iclb2/igt@kms_psr@psr2_sprite_mmap_gtt.html

  
  [fdo#102250]: https://bugs.freedesktop.org/show_bug.cgi?id=102250
  [fdo#103166]: https://bugs.freedesktop.org/show_bug.cgi?id=103166
  [fdo#103167]: https://bugs.freedesktop.org/show_bug.cgi?id=103167
  [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
  [fdo#104108]: https://bugs.freedesktop.org/show_bug.cgi?id=104108
  [fdo#105363]: https://bugs.freedesktop.org/show_bug.cgi?id=105363
  [fdo#105411]: https://bugs.freedesktop.org/show_bug.cgi?id=105411
  [fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
  [fdo#108059]: https://bugs.freedesktop.org/show_bug.cgi?id=108059
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#108341]: https://bugs.freedesktop.org/show_bug.cgi?id=108341
  [fdo#108566]: https://bugs.freedesktop.org/show_bug.cgi?id=108566
  [fdo#108569]: https://bugs.freedesktop.org/show_bug.cgi?id=108569
  [fdo#109100]: https://bugs.freedesktop.org/show_bug.cgi?id=109100
  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#109507]: https://bugs.freedesktop.org/show_bug.cgi?id=109507
  [fdo#110403]: https://bugs.freedesktop.org/show_bug.cgi?id=110403
  [fdo#110741]: https://bugs.freedesktop.org/show_bug.cgi?id=110741
  [fdo#110946]: https://bugs.freedesktop.org/show_bug.cgi?id=110946
  [fdo#99912]: https://bugs.freedesktop.org/show_bug.cgi?id=99912


Participating hosts (10 -> 10)
------------------------------

  No changes in participating hosts


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_6646 -> Patchwork_13897

  CI-20190529: 20190529
  CI_DRM_6646: 9345af1901748aeaed19ac13bf7ec4fb3336fc29 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5125: 35d81d01b1599b4bc4df0e09e25f6f531eed4f8a @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_13897: 4a887c6d3293663cecffe83f004d0b5ee9d66af4 @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_13897/
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 3/3] drm/i915: Defer final intel_wakeref_put to process context
  2019-08-07 15:24     ` Chris Wilson
@ 2019-08-08 13:49       ` Mika Kuoppala
  2019-08-08 13:59         ` Chris Wilson
  0 siblings, 1 reply; 20+ messages in thread
From: Mika Kuoppala @ 2019-08-08 13:49 UTC (permalink / raw)
  To: Chris Wilson, intel-gfx

Chris Wilson <chris@chris-wilson.co.uk> writes:

> Quoting Mika Kuoppala (2019-08-07 16:04:56)
>> Chris Wilson <chris@chris-wilson.co.uk> writes:
>> > -static int intel_gt_park(struct intel_wakeref *wf)
>> > +static int __gt_park(struct intel_wakeref *wf)
>> >  {
>> >       struct drm_i915_private *i915 =
>> >               container_of(wf, typeof(*i915), gt.wakeref);
>> > @@ -74,22 +67,25 @@ static int intel_gt_park(struct intel_wakeref *wf)
>> >       if (INTEL_GEN(i915) >= 6)
>> >               gen6_rps_idle(i915);
>> >  
>> > +     /* Everything switched off, flush any residual interrupt just in case */
>> > +     intel_synchronize_irq(i915);
>> 
>> Do we detect it gracefully if we get one extra afer this flush?
>
> If we make a mistake, we get unclaimed mmio from the interrupt handler.
>
> Given the structure of engine_pm/gt_pm, we should not be generating
> either user interrupts nor CS interrupts by this point. The potential is
> for the guc/pm interrupts, but I felt it was more prudent to document
> this is the final point for GT interrupts of any type.
>
>> > +     GEM_BUG_ON(intel_gt_pm_is_awake(gt));
>> > +     for_each_engine(engine, gt->i915, id) {
>> > +             const typeof(*igt_atomic_phases) *p;
>> > +
>> > +             for (p = igt_atomic_phases; p->name; p++) {
>> > +                     /*
>> > +                      * Acquisition is always synchronous, except if we
>> > +                      * know that the engine is already awale, in which
>> 
>> s/awale/awake
>
> a whale
>  
>> in which case?
>
> Avast ye blows!
> Moby Dick!
>
>> >  static long
>> >  wait_for_timelines(struct drm_i915_private *i915,
>> >                  unsigned int flags, long timeout)
>> > @@ -954,27 +941,20 @@ int i915_gem_wait_for_idle(struct drm_i915_private *i915,
>> >                          unsigned int flags, long timeout)
>> >  {
>> >       /* If the device is asleep, we have no requests outstanding */
>> > -     if (!READ_ONCE(i915->gt.awake))
>> > +     if (!intel_gt_pm_is_awake(&i915->gt))
>> >               return 0;
>> >  
>> > -     GEM_TRACE("flags=%x (%s), timeout=%ld%s, awake?=%s\n",
>> > +     GEM_TRACE("flags=%x (%s), timeout=%ld%s\n",
>> >                 flags, flags & I915_WAIT_LOCKED ? "locked" : "unlocked",
>> > -               timeout, timeout == MAX_SCHEDULE_TIMEOUT ? " (forever)" : "",
>> > -               yesno(i915->gt.awake));
>> > +               timeout, timeout == MAX_SCHEDULE_TIMEOUT ? " (forever)" : "");
>> >  
>> >       timeout = wait_for_timelines(i915, flags, timeout);
>> >       if (timeout < 0)
>> >               return timeout;
>> >  
>> >       if (flags & I915_WAIT_LOCKED) {
>> > -             int err;
>> > -
>> >               lockdep_assert_held(&i915->drm.struct_mutex);
>> >  
>> > -             err = wait_for_engines(&i915->gt);
>> > -             if (err)
>> > -                     return err;
>> > -
>> 
>> Hmm where does the implicit wait for idle come from now?
>
> Instead of having the wait here, we moved it into the engine/gt pm
> tracking and added an intel_gt_pm_wait_for_idle().

I see that we do wait on switching to kernel context. However
still failing to grasp the way we end up waiting on (implicit?)
releasing of the gt pm (and where)

-Mika

>
>> > -int __intel_wakeref_put_last(struct intel_runtime_pm *rpm,
>> > -                          struct intel_wakeref *wf,
>> > -                          int (*fn)(struct intel_wakeref *wf))
>> > +static void ____intel_wakeref_put_last(struct intel_wakeref *wf)
>> >  {
>> > -     int err;
>> > +     if (!atomic_dec_and_test(&wf->count))
>> > +             goto unlock;
>> > +
>> > +     if (likely(!wf->ops->put(wf))) {
>> > +             rpm_put(wf);
>> > +             wake_up_var(&wf->wakeref);
>> > +     } else {
>> > +             /* ops->put() must schedule its own release on deferral */
>> > +             atomic_set_release(&wf->count, 1);
>> 
>> I lose track here. On async call to gt_park we end up leaving
>> with a count 1. 
>
> So we know wf->count is 0 and that we hold the lock preventing anyone
> else raising wf->count back to 1. If we fail in our cleanup task,
> knowing that we have exclusive control over the counter, we simply mark
> it as 1 again (using _release to unlock anyone concurrently trying to
> acquire the wakeref for themselves).
>
>> > +     /* Assume we are not in process context and so cannot sleep. */
>> > +     if (wf->ops->flags & INTEL_WAKEREF_PUT_ASYNC ||
>> > +         !mutex_trylock(&wf->mutex)) {
>> 
>> Didn't found anything in trylock that would prevent you
>> from shooting you on your own leg.
>
> Yup. It's immorally equivalent to spin_trylock.
>
>> So it is up to caller (and eventually lockdep spam) if
>> the async usage fails to follow the rules?
>
> Not the caller, the fault lies in the wakeref. We either mark it that is
> has to use the worker (process context) or fix it such that it is quick
> and can run in atomic context. engine_pm was simple enough to make
> atomic, gt_pm is promising but I needed to make rps waitfree (done) and
> make the display pm truly async (which I baulked at!).
>
>> 
>> > +             schedule_work(&wf->work);
>> > +             return;
>> > +     }
>> > +
>> > +     ____intel_wakeref_put_last(wf);
>> >  }
>> >  
>> > -void __intel_wakeref_init(struct intel_wakeref *wf, struct lock_class_key *key)
>> > +static void __intel_wakeref_put_work(struct work_struct *wrk)
>> 
>> No need for underscore before the name here?
>
> I was just trying to keep it consistent with the 3 functions working
> together.
>
> __intel_wakeref_put_last
> __intel_wakeref_put_work
> ____intel_wakeref_put_last
>
> Now, could use
>
> __intel_wakeref_put_last
> __wakeref_put_work
> ____wakeref_put_last
>
> keeping the underscores to underline the games being played with locking
> are not for the faint of heart.
> -Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH 3/3] drm/i915: Defer final intel_wakeref_put to process context
  2019-08-08 13:49       ` Mika Kuoppala
@ 2019-08-08 13:59         ` Chris Wilson
  0 siblings, 0 replies; 20+ messages in thread
From: Chris Wilson @ 2019-08-08 13:59 UTC (permalink / raw)
  To: Mika Kuoppala, intel-gfx

Quoting Mika Kuoppala (2019-08-08 14:49:40)
> Chris Wilson <chris@chris-wilson.co.uk> writes:
> 
> > Quoting Mika Kuoppala (2019-08-07 16:04:56)
> >> Chris Wilson <chris@chris-wilson.co.uk> writes:
> >> >       if (flags & I915_WAIT_LOCKED) {
> >> > -             int err;
> >> > -
> >> >               lockdep_assert_held(&i915->drm.struct_mutex);
> >> >  
> >> > -             err = wait_for_engines(&i915->gt);
> >> > -             if (err)
> >> > -                     return err;
> >> > -
> >> 
> >> Hmm where does the implicit wait for idle come from now?
> >
> > Instead of having the wait here, we moved it into the engine/gt pm
> > tracking and added an intel_gt_pm_wait_for_idle().
> 
> I see that we do wait on switching to kernel context. However
> still failing to grasp the way we end up waiting on (implicit?)
> releasing of the gt pm (and where)

Inside the switch-to-kernel context, we call intel_gt_pm_wait_for_idle()
which waits for the intel_wakeref.count to hit 0 and for the wakeref to
be released (that's the wake_up_var() inside
____intel_wakeref_put_last). wait_for_idle is then just

int intel_wakeref_wait_for_idle(struct intel_wakeref *wf)
{
        return wait_var_event_killable(&wf->wakeref,
                                       !intel_wakeref_is_active(wf));
}

Instead of i915_gem_wait_for_idle() ensuring that the pm is idled, we've
lifted that to the two callers that cared.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2019-08-08 13:59 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-07  8:37 [PATCH 1/3] drm/i915: Rename engines with to match their user interface Chris Wilson
2019-08-07  8:37 ` [PATCH 2/3] drm/i915: Use intel_engine_lookup_user for probing HAS_BSD etc Chris Wilson
2019-08-07 13:16   ` Mika Kuoppala
2019-08-07  8:37 ` [PATCH 3/3] drm/i915: Defer final intel_wakeref_put to process context Chris Wilson
2019-08-07 15:04   ` Mika Kuoppala
2019-08-07 15:24     ` Chris Wilson
2019-08-08 13:49       ` Mika Kuoppala
2019-08-08 13:59         ` Chris Wilson
2019-08-07  9:16 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/3] drm/i915: Rename engines with to match their user interface Patchwork
2019-08-07  9:18 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-08-07  9:45 ` ✗ Fi.CI.BAT: failure " Patchwork
2019-08-07 10:31 ` [PATCH 1/3] " Mika Kuoppala
2019-08-07 10:44   ` Chris Wilson
2019-08-07 10:55   ` [PATCH v2] drm/i915: Rename engines " Chris Wilson
2019-08-07 11:04   ` [PATCH v3] " Chris Wilson
2019-08-07 11:53     ` Mika Kuoppala
2019-08-07 12:32 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [v3] drm/i915: Rename engines to match their user interface (rev3) Patchwork
2019-08-07 12:33 ` ✗ Fi.CI.SPARSE: " Patchwork
2019-08-07 12:52 ` ✓ Fi.CI.BAT: success " Patchwork
2019-08-07 19:23 ` ✗ Fi.CI.IGT: 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.