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>
Subject: [PATCH v2 2/3] drm/i915/gt: Allow user to set up the CSS mode
Date: Thu, 4 Jan 2024 15:35:56 +0100 [thread overview]
Message-ID: <20240104143558.193694-3-andi.shyti@linux.intel.com> (raw)
In-Reply-To: <20240104143558.193694-1-andi.shyti@linux.intel.com>
Now that the CCS mode is configurable, an interface has been
exposed in the GT's sysfs set of files, allowing users to set the
mode.
Additionally, another interface has been added to display the
number of available slices, named 'num_slices.'
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
Cc: Chris Wilson <chris.p.wilson@linux.intel.com>
Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
Cc: Niranjana Vishwanathapura <niranjana.vishwanathapura@intel.com>
Cc: Tejas Upadhyay <tejas.upadhyay@intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c | 68 +++++++++++++++++++++
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h | 1 +
drivers/gpu/drm/i915/gt/intel_gt_sysfs.c | 2 +
3 files changed, 71 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 fab8a77bded2..88663698eb1f 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
@@ -7,6 +7,7 @@
#include "intel_gt.h"
#include "intel_gt_ccs_mode.h"
+#include "intel_gt_print.h"
#include "intel_gt_regs.h"
#include "intel_gt_types.h"
@@ -79,3 +80,70 @@ void intel_gt_fini_ccs_mode(struct intel_gt *gt)
{
mutex_destroy(>->ccs.mutex);
}
+
+static ssize_t
+ccs_mode_show(struct kobject *kobj, struct kobj_attribute *attr, char *buff)
+{
+ struct intel_gt *gt = container_of(kobj, struct intel_gt, sysfs_gt);
+
+ return sysfs_emit(buff, "%u\n", gt->ccs.mode);
+}
+
+static ssize_t
+ccs_mode_store(struct kobject *kobj, struct kobj_attribute *attr,
+ const char *buff, size_t count)
+{
+ struct intel_gt *gt = container_of(kobj, struct intel_gt, sysfs_gt);
+ int num_slices = hweight32(CCS_MASK(gt));
+ int err;
+ u32 val;
+
+ err = kstrtou32(buff, 0, &val);
+ if (err)
+ return err;
+
+ if ((!val) || (val > num_slices) || (val % num_slices))
+ return -EINVAL;
+
+ mutex_lock(>->ccs.mutex);
+
+ if (val == gt->ccs.mode)
+ goto out;
+
+ gt->ccs.mode = val;
+ intel_gt_apply_ccs_mode(gt);
+
+out:
+ mutex_unlock(>->ccs.mutex);
+
+ return count;
+}
+
+static ssize_t
+num_slices_show(struct kobject *kobj, struct kobj_attribute *attr, char *buff)
+{
+ struct intel_gt *gt = container_of(kobj, struct intel_gt, sysfs_gt);
+ u32 num_slices;
+
+ num_slices = hweight32(CCS_MASK(gt));
+
+ return sysfs_emit(buff, "%u\n", num_slices);
+}
+
+static struct kobj_attribute ccs_mode = __ATTR_RW(ccs_mode);
+static struct kobj_attribute num_slices = __ATTR_RO(num_slices);
+
+static const struct attribute * const ccs_mode_attrs[] = {
+ &ccs_mode.attr,
+ &num_slices.attr,
+ NULL
+};
+
+void intel_gt_sysfs_ccs_mode(struct intel_gt *gt)
+{
+ int ret;
+
+ ret = sysfs_create_files(>->sysfs_gt, ccs_mode_attrs);
+ if (ret)
+ gt_warn(gt, "Failed to create ccs mode sysfs files");
+}
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h
index 751c5700944b..ae96de1b36c5 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h
@@ -12,5 +12,6 @@ void intel_gt_init_ccs_mode(struct intel_gt *gt);
void intel_gt_fini_ccs_mode(struct intel_gt *gt);
void intel_gt_apply_ccs_mode(struct intel_gt *gt);
+void intel_gt_sysfs_ccs_mode(struct intel_gt *gt);
#endif /* INTEL_GT_CCS_MODE_H */
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c b/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
index 33cba406b569..a0290347938d 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_sysfs.c
@@ -12,6 +12,7 @@
#include "i915_drv.h"
#include "i915_sysfs.h"
#include "intel_gt.h"
+#include "intel_gt_ccs_mode.h"
#include "intel_gt_print.h"
#include "intel_gt_sysfs.h"
#include "intel_gt_sysfs_pm.h"
@@ -101,6 +102,7 @@ void intel_gt_sysfs_register(struct intel_gt *gt)
goto exit_fail;
intel_gt_sysfs_pm_init(gt, >->sysfs_gt);
+ intel_gt_sysfs_ccs_mode(gt);
return;
--
2.43.0
next prev parent reply other threads:[~2024-01-04 14:36 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-01-04 14:35 [PATCH v2 0/3] Disable dynamic load balancing and support fixed balancing Andi Shyti
2024-01-04 14:35 ` [PATCH v2 1/3] drm/i915/gt: Support fixed CCS mode Andi Shyti
2024-01-04 15:07 ` Tvrtko Ursulin
2024-01-04 21:23 ` Andi Shyti
2024-01-05 10:39 ` Tvrtko Ursulin
2024-01-08 15:13 ` Joonas Lahtinen
2024-01-09 8:46 ` Tvrtko Ursulin
2024-01-04 14:35 ` Andi Shyti [this message]
2024-01-04 14:35 ` [PATCH v2 3/3] drm/i915/gt: Disable HW load balancing for CCS Andi Shyti
2024-01-04 15:04 ` ✗ Fi.CI.CHECKPATCH: warning for Disable dynamic load balancing and support fixed balancing Patchwork
2024-01-04 15:04 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-01-04 15:23 ` ✗ 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=20240104143558.193694-3-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