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>,
Andi Shyti <andi.shyti@linux.intel.com>
Subject: [RFC PATCH v2 10/11] drm/i915/gt: Implement creation and removal routines for CCS engines
Date: Sat, 17 Aug 2024 23:00:25 +0200 [thread overview]
Message-ID: <20240817210026.310645-11-andi.shyti@linux.intel.com> (raw)
In-Reply-To: <20240817210026.310645-1-andi.shyti@linux.intel.com>
In preparation for upcoming patches, we need routines to
dynamically create and destroy CCS engines based on the CCS mode
that the user wants to set.
The process begins by calculating the engine mask for the engines
that need to be added or removed. We then update the UABI list of
exposed engines and create or destroy the corresponding sysfs
interfaces accordingly.
These functions are not yet in use, so no functional changes are
intended at this stage.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c | 80 +++++++++++++++++++++
1 file changed, 80 insertions(+)
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
index 01ce719cf475..b1c3c9d9bb4f 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
@@ -8,6 +8,7 @@
#include "intel_gt_print.h"
#include "intel_gt_regs.h"
#include "intel_gt_sysfs.h"
+#include "sysfs_engines.h"
static void update_ccs_mask(struct intel_gt *gt, u32 ccs_mode)
{
@@ -113,6 +114,85 @@ void intel_gt_ccs_mode_init(struct intel_gt *gt)
update_ccs_mask(gt, 1);
}
+static void add_uabi_ccs_engines(struct intel_gt *gt, u32 ccs_mode)
+{
+ struct drm_i915_private *i915 = gt->i915;
+ intel_engine_mask_t new_ccs_mask, tmp;
+ struct intel_engine_cs *engine;
+ struct rb_node **p, *prev;
+
+ /* Store the current ccs mask */
+ new_ccs_mask = gt->ccs.ccs_mask;
+ update_ccs_mask(gt, ccs_mode);
+
+ /*
+ * Store only the mask of the CCS engines that need to be added by
+ * removing from the new mask the engines that are already active
+ */
+ new_ccs_mask = gt->ccs.ccs_mask & ~new_ccs_mask;
+ new_ccs_mask <<= CCS0;
+
+ /*
+ * UABI are stored only on the right branch of the rb tree, making it
+ * de facto a double linked list. Get to the bottom of the list and
+ * insert there the new engines.
+ */
+ prev = NULL;
+ p = &i915->uabi_engines.rb_node;
+ for_each_uabi_engine(engine, i915) {
+ prev = &engine->uabi_node;
+ p = &prev->rb_right;
+ }
+
+ for_each_engine_masked(engine, gt, new_ccs_mask, tmp) {
+ int err;
+
+ i915->engine_uabi_class_count[I915_ENGINE_CLASS_COMPUTE]++;
+
+ rb_link_node(&engine->uabi_node, prev, p);
+ rb_insert_color(&engine->uabi_node, &i915->uabi_engines);
+
+ rb_link_node(&engine->uabi_node, prev, p);
+ rb_insert_color(&engine->uabi_node, &i915->uabi_engines);
+
+ prev = &engine->uabi_node;
+ p = &prev->rb_right;
+
+ err = intel_engine_add_single_sysfs(engine);
+ if (err)
+ gt_warn(gt,
+ "Unable to create sysfs entries for %s engine",
+ engine->name);
+ }
+}
+
+static void remove_uabi_ccs_engines(struct intel_gt *gt, u8 ccs_mode)
+{
+ struct drm_i915_private *i915 = gt->i915;
+ intel_engine_mask_t new_ccs_mask, tmp;
+ struct intel_engine_cs *engine;
+
+ /* Store the current ccs mask */
+ new_ccs_mask = gt->ccs.ccs_mask;
+ update_ccs_mask(gt, ccs_mode);
+
+ /*
+ * Store only the mask of the CCS engines that need to be removed by
+ * unmasking them from the new mask the engines that are already active
+ */
+ new_ccs_mask = new_ccs_mask & ~gt->ccs.ccs_mask;
+ new_ccs_mask <<= CCS0;
+
+ for_each_engine_masked(engine, gt, new_ccs_mask, tmp) {
+ i915->engine_uabi_class_count[I915_ENGINE_CLASS_COMPUTE]--;
+
+ rb_erase(&engine->uabi_node, &i915->uabi_engines);
+ /* Remove sysfs entries */
+ kobject_put(engine->kobj_defaults);
+ kobject_put(engine->kobj);
+ }
+}
+
static ssize_t num_cslices_show(struct device *dev,
struct device_attribute *attr,
char *buff)
--
2.45.2
next prev parent reply other threads:[~2024-08-17 21:01 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 01/11] drm/i915/gt: Move the CCS mode variable to a global position Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 02/11] drm/i915/gt: Allow the creation of multi-mode CCS masks Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 03/11] drm/i915/gt: Refactor uabi engine class/instance list creation Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 04/11] drm/i915/gt: Manage CCS engine creation within UABI exposure Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 05/11] drm/i915/gt: Remove cslices mask value from the CCS structure Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 06/11] drm/i915/gt: Expose the number of total CCS slices Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 07/11] drm/i915/gt: Store engine-related sysfs kobjects Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 08/11] drm/i915/gt: Store active CCS mask Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 09/11] drm/i915/gt: Isolate single sysfs engine file creation Andi Shyti
2024-08-17 21:00 ` Andi Shyti [this message]
2024-08-17 21:00 ` [RFC PATCH v2 11/11] drm/i915/gt: Allow the user to change the CCS mode through sysfs Andi Shyti
2024-08-17 22:35 ` ✗ Fi.CI.CHECKPATCH: warning for CCS static load balance (rev2) Patchwork
2024-08-17 22:35 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-08-17 22:41 ` ✗ Fi.CI.BAT: 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=20240817210026.310645-11-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 \
/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