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 09/11] drm/i915/gt: Isolate single sysfs engine file creation
Date: Sat, 17 Aug 2024 23:00:24 +0200 [thread overview]
Message-ID: <20240817210026.310645-10-andi.shyti@linux.intel.com> (raw)
In-Reply-To: <20240817210026.310645-1-andi.shyti@linux.intel.com>
In preparation for upcoming patches, we need the ability to
create and remove individual sysfs files. To facilitate this,
extract from the intel_engines_add_sysfs() function the creation
of individual files.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/sysfs_engines.c | 75 ++++++++++++++++---------
drivers/gpu/drm/i915/gt/sysfs_engines.h | 2 +
2 files changed, 49 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
index d0bb2aa561ed..3356fadce327 100644
--- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
+++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
@@ -9,6 +9,7 @@
#include "i915_drv.h"
#include "intel_engine.h"
#include "intel_engine_heartbeat.h"
+#include "intel_gt_print.h"
#include "sysfs_engines.h"
struct kobj_engine {
@@ -483,7 +484,7 @@ static void add_defaults(struct kobj_engine *parent)
parent->engine->kobj_defaults = &ke->base;
}
-void intel_engines_add_sysfs(struct drm_i915_private *i915)
+int intel_engine_add_single_sysfs(struct intel_engine_cs *engine)
{
static const struct attribute * const files[] = {
&name_attr.attr,
@@ -499,46 +500,64 @@ void intel_engines_add_sysfs(struct drm_i915_private *i915)
#endif
NULL
};
+ struct kobject *dir = engine->i915->sysfs_engine;
+ struct kobject *kobj = engine->kobj;
+ int err;
- struct device *kdev = i915->drm.primary->kdev;
- struct intel_engine_cs *engine;
- struct kobject *dir;
-
- dir = kobject_create_and_add("engine", &kdev->kobj);
- if (!dir)
- return;
-
- i915->sysfs_engine = dir;
-
- for_each_uabi_engine(engine, i915) {
- struct kobject *kobj;
-
+ if (!kobj) {
kobj = kobj_engine(dir, engine);
if (!kobj)
goto err_engine;
+ }
- if (sysfs_create_files(kobj, files))
+ err = sysfs_create_files(kobj, files);
+ if (err)
+ goto err_object;
+
+ if (intel_engine_has_timeslices(engine)) {
+ err = sysfs_create_file(kobj, ×lice_duration_attr.attr);
+ if (err)
goto err_object;
+ }
- if (intel_engine_has_timeslices(engine) &&
- sysfs_create_file(kobj, ×lice_duration_attr.attr))
- goto err_engine;
+ if (intel_engine_has_preempt_reset(engine)) {
+ err = sysfs_create_file(kobj, &preempt_timeout_attr.attr);
+ if (err)
+ goto err_object;
+ }
- if (intel_engine_has_preempt_reset(engine) &&
- sysfs_create_file(kobj, &preempt_timeout_attr.attr))
- goto err_engine;
+ add_defaults(container_of(kobj, struct kobj_engine, base));
- add_defaults(container_of(kobj, struct kobj_engine, base));
+ engine->kobj = kobj;
- engine->kobj = kobj;
+ return 0;
- if (0) {
err_object:
- kobject_put(kobj);
+ kobject_put(kobj);
err_engine:
- dev_err(kdev, "Failed to add sysfs engine '%s'\n",
- engine->name);
+ gt_err(engine->gt, "Failed to add sysfs engine '%s'\n",
+ engine->name);
+
+ return err;
+}
+
+void intel_engines_add_sysfs(struct drm_i915_private *i915)
+{
+ struct device *kdev = i915->drm.primary->kdev;
+ struct intel_engine_cs *engine;
+ struct kobject *dir;
+
+ dir = kobject_create_and_add("engine", &kdev->kobj);
+ if (!dir)
+ return;
+
+ i915->sysfs_engine = dir;
+
+ for_each_uabi_engine(engine, i915) {
+ int err;
+
+ err = intel_engine_add_single_sysfs(engine);
+ if (err)
break;
- }
}
}
diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.h b/drivers/gpu/drm/i915/gt/sysfs_engines.h
index 9546fffe03a7..2e3ec2df14a9 100644
--- a/drivers/gpu/drm/i915/gt/sysfs_engines.h
+++ b/drivers/gpu/drm/i915/gt/sysfs_engines.h
@@ -7,7 +7,9 @@
#define INTEL_ENGINE_SYSFS_H
struct drm_i915_private;
+struct intel_engine_cs;
void intel_engines_add_sysfs(struct drm_i915_private *i915);
+int intel_engine_add_single_sysfs(struct intel_engine_cs *engine);
#endif /* INTEL_ENGINE_SYSFS_H */
--
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 ` Andi Shyti [this message]
2024-08-17 21:00 ` [RFC PATCH v2 10/11] drm/i915/gt: Implement creation and removal routines for CCS engines Andi Shyti
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-10-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