All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 01/19] drm/i915: Fix up the inverse mapping for default ctx->engines[]
@ 2019-08-08  7:41 Chris Wilson
  2019-08-08  7:41 ` [PATCH 02/19] drm/i915: Defer final intel_wakeref_put to process context Chris Wilson
                   ` (19 more replies)
  0 siblings, 20 replies; 27+ messages in thread
From: Chris Wilson @ 2019-08-08  7:41 UTC (permalink / raw)
  To: intel-gfx

The order in which we store the engines inside default_engines() for the
legacy ctx->engines[] has to match the legacy I915_EXEC_RING selector
mapping in execbuf::user_map. If we present VCS2 as being the second
instance of the video engine, legacy userspace calls that I915_EXEC_BSD2
and so we need to insert it into the second video slot.

Fixes: 2edda80db3d0 ("drm/i915: Rename engines to match their user interface")
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_context.c |  5 ++-
 drivers/gpu/drm/i915/gt/intel_engine_user.c | 49 +++++++++++++++++++++
 drivers/gpu/drm/i915/gt/intel_gt_types.h    |  1 +
 3 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_context.c b/drivers/gpu/drm/i915/gem/i915_gem_context.c
index 1c5bc21a80ff..fae8ca72e240 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_context.c
@@ -279,6 +279,7 @@ static void free_engines_rcu(struct rcu_head *rcu)
 
 static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx)
 {
+	const struct intel_gt *gt = &ctx->i915->gt;
 	struct intel_engine_cs *engine;
 	struct i915_gem_engines *e;
 	enum intel_engine_id id;
@@ -288,7 +289,7 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx)
 		return ERR_PTR(-ENOMEM);
 
 	init_rcu_head(&e->rcu);
-	for_each_engine(engine, ctx->i915, id) {
+	for_each_engine(engine, gt, id) {
 		struct intel_context *ce;
 
 		ce = intel_context_create(ctx, engine);
@@ -298,8 +299,8 @@ static struct i915_gem_engines *default_engines(struct i915_gem_context *ctx)
 		}
 
 		e->engines[id] = ce;
+		e->num_engines = id + 1;
 	}
-	e->num_engines = id;
 
 	return e;
 }
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index c41ae05988a5..83dbc54c3d2a 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -142,8 +142,54 @@ const char *intel_engine_class_repr(u8 class)
 	return uabi_names[class];
 }
 
+struct legacy_ring {
+	struct intel_gt *gt;
+	u8 class;
+	u8 instance;
+};
+
+static int legacy_ring_id(const struct legacy_ring *ring)
+{
+	static const struct {
+		u8 base, max;
+	} map[] = {
+		[RENDER_CLASS] = { RCS0, 1 },
+		[COPY_ENGINE_CLASS] = { BCS0, 1 },
+		[VIDEO_DECODE_CLASS] = { VCS0, I915_MAX_VCS },
+		[VIDEO_ENHANCEMENT_CLASS] = { VECS0, I915_MAX_VECS },
+	};
+
+	if (GEM_DEBUG_WARN_ON(ring->class >= ARRAY_SIZE(map)))
+		return -1;
+
+	if (GEM_DEBUG_WARN_ON(ring->instance >= map[ring->class].max))
+		return -1;
+
+	return map[ring->class].base + ring->instance;
+}
+
+static void add_legacy_ring(struct legacy_ring *ring,
+			    struct intel_engine_cs *engine)
+{
+	int id;
+
+	if (engine->gt != ring->gt || engine->class != ring->class) {
+		ring->gt = engine->gt;
+		ring->class = engine->class;
+		ring->instance = 0;
+	}
+
+	id = legacy_ring_id(ring);
+	if (unlikely(id == -1))
+		return;
+
+	ring->gt->engine[id] = engine;
+	ring->instance++;
+}
+
 void intel_engines_driver_register(struct drm_i915_private *i915)
 {
+	struct legacy_ring ring = {};
 	u8 uabi_instances[4] = {};
 	struct list_head *it, *next;
 	struct rb_node **p, *prev;
@@ -179,6 +225,9 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
 						    engine->uabi_class,
 						    engine->uabi_instance) != engine);
 
+		/* Fix up the mapping to match default execbuf::user_map[] */
+		add_legacy_ring(&ring, engine);
+
 		prev = &engine->uabi_node;
 		p = &prev->rb_right;
 	}
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_types.h b/drivers/gpu/drm/i915/gt/intel_gt_types.h
index 5fd11e361d03..789102f4f46b 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_types.h
@@ -78,6 +78,7 @@ struct intel_gt {
 
 	u32 pm_guc_events;
 
+	struct intel_engine_cs *engine[I915_NUM_ENGINES];
 	struct intel_engine_cs *engine_class[MAX_ENGINE_CLASS + 1]
 					    [MAX_ENGINE_INSTANCE + 1];
 };
-- 
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] 27+ messages in thread

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

Thread overview: 27+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2019-08-08  7:41 [PATCH 01/19] drm/i915: Fix up the inverse mapping for default ctx->engines[] Chris Wilson
2019-08-08  7:41 ` [PATCH 02/19] drm/i915: Defer final intel_wakeref_put to process context Chris Wilson
2019-08-08 14:47   ` Mika Kuoppala
2019-08-08 15:00     ` Chris Wilson
2019-08-08  7:41 ` [PATCH 03/19] drm/i915/pmu: Use GT parked for estimating RC6 while asleep Chris Wilson
2019-08-08  7:41 ` [PATCH 04/19] drm/i915: Drop the fudge warning on ring restart for ctg/elk Chris Wilson
2019-08-08  7:41 ` [PATCH 05/19] drm/i915/selftests: Pass intel_context to mock_request Chris Wilson
2019-08-08 11:44   ` Matthew Auld
2019-08-08  7:41 ` [PATCH 06/19] drm/i915/gt: Make deferred context allocation explicit Chris Wilson
2019-08-08  7:41 ` [PATCH 07/19] drm/i915: Push the ring creation flags to the backend Chris Wilson
2019-08-08  7:41 ` [PATCH 08/19] drm/i915: Lift timeline into intel_context Chris Wilson
2019-08-08 13:58   ` Matthew Auld
2019-08-08  7:41 ` [PATCH 09/19] drm/i915: Only include active engines in the capture state Chris Wilson
2019-08-08 14:40   ` Matthew Auld
2019-08-08  7:41 ` [PATCH 10/19] drm/i915: Make debugfs/per_file_stats scale better Chris Wilson
2019-08-08 15:23   ` Matthew Auld
2019-08-08  7:41 ` [PATCH 11/19] drm/i915/gt: Track timeline activeness in enter/exit Chris Wilson
2019-08-08  7:42 ` [PATCH 12/19] drm/i915/gt: Convert timeline tracking to spinlock Chris Wilson
2019-08-08  7:42 ` [PATCH 13/19] drm/i915/gt: Guard timeline pinning with its own mutex Chris Wilson
2019-08-08  7:42 ` [PATCH 14/19] drm/i915: Protect request retirement with timeline->mutex Chris Wilson
2019-08-08  7:42 ` [PATCH 15/19] drm/i915/gt: Mark context->active_count as protected by timeline->mutex Chris Wilson
2019-08-08  7:42 ` [PATCH 16/19] drm/i915: Forgo last_fence active request tracking Chris Wilson
2019-08-08  7:42 ` [PATCH 17/19] drm/i915/overlay: Switch to using i915_active tracking Chris Wilson
2019-08-08  7:42 ` [PATCH 18/19] drm/i915: Extract intel_frontbuffer active tracking Chris Wilson
2019-08-08  7:42 ` [PATCH 19/19] drm/i915: Markup expected timeline locks for i915_active Chris Wilson
2019-08-08  8:43 ` ✗ Fi.CI.CHECKPATCH: warning for series starting with [01/19] drm/i915: Fix up the inverse mapping for default ctx->engines[] Patchwork
2019-08-08  8:52 ` ✗ Fi.CI.SPARSE: " 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.