From: Andi Shyti <andi.shyti@linux.intel.com>
To: intel-gfx <intel-gfx@lists.freedesktop.org>,
dri-devel <dri-devel@lists.freedesktop.org>
Cc: Chris Wilson <chris.p.wilson@linux.intel.com>,
Tvrtko Ursulin <tursulin@ursulin.net>,
Andi Shyti <andi.shyti@linux.intel.com>
Subject: [PATCH v1 05/14] drm/i915/gem: Mark and verify UABI engine validity
Date: Wed, 21 Aug 2024 14:43:40 +0200 [thread overview]
Message-ID: <20240821124349.295259-6-andi.shyti@linux.intel.com> (raw)
In-Reply-To: <20240821124349.295259-1-andi.shyti@linux.intel.com>
Mark engines as invalid when they are not added to the UABI list
to prevent accidental assignment of batch buffers.
Currently, this change is mostly precautionary with minimal
impact. However, in the future, when CCS engines will be
dynamically added and removed by the user, this mechanism will
be used for determining engine validity.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
.../gpu/drm/i915/gem/i915_gem_execbuffer.c | 28 +++++++++++++++++--
drivers/gpu/drm/i915/gt/intel_engine_user.c | 9 ++++--
2 files changed, 33 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
index c58290274f97..770875e72056 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_execbuffer.c
@@ -2682,6 +2682,22 @@ eb_select_legacy_ring(struct i915_execbuffer *eb)
return user_ring_map[user_ring_id];
}
+static bool engine_valid(struct intel_context *ce)
+{
+ if (!intel_engine_is_virtual(ce->engine))
+ return !RB_EMPTY_NODE(&ce->engine->uabi_node);
+
+ /*
+ * TODO: check virtual sibilings; we need to walk through all the
+ * virtual engines and ask whether the physical engine where it is based
+ * is still valid. For each of them we need to check with
+ * RB_EMPTY_NODE(...)
+ *
+ * This can be a placed in a new ce_ops.
+ */
+ return true;
+}
+
static int
eb_select_engine(struct i915_execbuffer *eb)
{
@@ -2712,8 +2728,6 @@ eb_select_engine(struct i915_execbuffer *eb)
eb->num_batches = ce->parallel.number_children + 1;
gt = ce->engine->gt;
- for_each_child(ce, child)
- intel_context_get(child);
eb->wakeref = intel_gt_pm_get(ce->engine->gt);
/*
* Keep GT0 active on MTL so that i915_vma_parked() doesn't
@@ -2722,6 +2736,16 @@ eb_select_engine(struct i915_execbuffer *eb)
if (gt->info.id)
eb->wakeref_gt0 = intel_gt_pm_get(to_gt(gt->i915));
+ /* We need to hold the wakeref to stabilize i915->uabi_engines */
+ if (!engine_valid(ce)) {
+ intel_context_put(ce);
+ err = -ENODEV;
+ goto err;
+ }
+
+ for_each_child(ce, child)
+ intel_context_get(child);
+
if (!test_bit(CONTEXT_ALLOC_BIT, &ce->flags)) {
err = intel_context_alloc_state(ce);
if (err)
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index 11cc06c0c785..cd7662b1ad59 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -220,7 +220,7 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
container_of(it, typeof(*engine), uabi_list);
if (intel_gt_has_unrecoverable_error(engine->gt))
- continue; /* ignore incomplete engines */
+ goto clear_node_continue; /* ignore incomplete engines */
GEM_BUG_ON(engine->class >= ARRAY_SIZE(uabi_classes));
engine->uabi_class = uabi_classes[engine->class];
@@ -242,7 +242,7 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
engine->uabi_instance);
if (uabi_class > I915_LAST_UABI_ENGINE_CLASS)
- continue;
+ goto clear_node_continue;
GEM_BUG_ON(uabi_class >=
ARRAY_SIZE(i915->engine_uabi_class_count));
@@ -260,6 +260,11 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
prev = &engine->uabi_node;
p = &prev->rb_right;
+
+ continue;
+
+clear_node_continue:
+ RB_CLEAR_NODE(&engine->uabi_node);
}
if (IS_ENABLED(CONFIG_DRM_I915_SELFTESTS) &&
--
2.45.2
next prev parent reply other threads:[~2024-08-21 12:44 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-21 12:43 [PATCH v1 00/14] CCS static load balance Andi Shyti
2024-08-21 12:43 ` [PATCH v1 01/14] drm/i915/gt: Avoid using masked workaround for CCS_MODE setting Andi Shyti
2024-08-21 12:43 ` [PATCH v1 02/14] drm/i915/gt: Move the CCS mode variable to a global position Andi Shyti
2024-08-21 12:43 ` [PATCH v1 03/14] drm/i915/gt: Allow the creation of multi-mode CCS masks Andi Shyti
2024-08-21 12:43 ` [PATCH v1 04/14] drm/i915/gt: Refactor uabi engine class/instance list creation Andi Shyti
2024-08-21 12:43 ` Andi Shyti [this message]
2024-08-21 12:43 ` [PATCH v1 06/14] drm/i915/gt: Introduce for_each_enabled_engine() and apply it in selftests Andi Shyti
2024-08-21 12:43 ` [PATCH v1 07/14] drm/i915/gt: Manage CCS engine creation within UABI exposure Andi Shyti
2024-08-21 12:43 ` [PATCH v1 08/14] drm/i915/gt: Remove cslices mask value from the CCS structure Andi Shyti
2024-08-21 12:43 ` [PATCH v1 09/14] drm/i915/gt: Expose the number of total CCS slices Andi Shyti
2024-08-21 12:43 ` [PATCH v1 10/14] drm/i915/gt: Store engine-related sysfs kobjects Andi Shyti
2024-08-21 12:43 ` [PATCH v1 11/14] drm/i915/gt: Store active CCS mask Andi Shyti
2024-08-21 12:43 ` [PATCH v1 12/14] drm/i915/gt: Isolate single sysfs engine file creation Andi Shyti
2024-08-21 12:43 ` [PATCH v1 13/14] drm/i915/gt: Implement creation and removal routines for CCS engines Andi Shyti
2024-08-21 12:43 ` [PATCH v1 14/14] drm/i915/gt: Allow the user to change the CCS mode through sysfs Andi Shyti
2024-08-21 13:25 ` ✗ Fi.CI.CHECKPATCH: warning for CCS static load balance (rev3) Patchwork
2024-08-21 13:26 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-08-21 13:33 ` ✓ Fi.CI.BAT: success " Patchwork
2024-08-21 15:59 ` ✗ Fi.CI.IGT: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240821124349.295259-6-andi.shyti@linux.intel.com \
--to=andi.shyti@linux.intel.com \
--cc=chris.p.wilson@linux.intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=tursulin@ursulin.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox