* [RFC PATCH v2 01/11] drm/i915/gt: Move the CCS mode variable to a global position
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
@ 2024-08-17 21:00 ` 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
` (12 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
Store the CCS mode value in the intel_gt->ccs structure to make
it available for future instances that may need to change its
value.
Name it mode_reg_val because it holds the value that will
be written into the CCS_MODE register, determining the CCS
balancing and, consequently, the number of engines generated.
Create a mutex to control access to the mode_reg_val variable.
No functional changes intended.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt.c | 3 +++
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c | 13 ++++++++++---
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h | 3 ++-
drivers/gpu/drm/i915/gt/intel_gt_types.h | 12 ++++++++++++
drivers/gpu/drm/i915/gt/intel_workarounds.c | 7 ++++---
5 files changed, 31 insertions(+), 7 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_gt.c b/drivers/gpu/drm/i915/gt/intel_gt.c
index a6c69a706fd7..5af0527d822d 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt.c
@@ -18,6 +18,7 @@
#include "intel_ggtt_gmch.h"
#include "intel_gt.h"
#include "intel_gt_buffer_pool.h"
+#include "intel_gt_ccs_mode.h"
#include "intel_gt_clock_utils.h"
#include "intel_gt_debugfs.h"
#include "intel_gt_mcr.h"
@@ -136,6 +137,8 @@ int intel_gt_init_mmio(struct intel_gt *gt)
intel_sseu_info_init(gt);
intel_gt_mcr_init(gt);
+ intel_gt_ccs_mode_init(gt);
+
return intel_engines_init_mmio(gt);
}
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 3c62a44e9106..19e0bc359861 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
@@ -8,14 +8,16 @@
#include "intel_gt_ccs_mode.h"
#include "intel_gt_regs.h"
-unsigned int intel_gt_apply_ccs_mode(struct intel_gt *gt)
+void intel_gt_apply_ccs_mode(struct intel_gt *gt)
{
int cslice;
u32 mode = 0;
int first_ccs = __ffs(CCS_MASK(gt));
+ lockdep_assert_held(>->ccs.mutex);
+
if (!IS_DG2(gt->i915))
- return 0;
+ return;
/* Build the value for the fixed CCS load balancing */
for (cslice = 0; cslice < I915_MAX_CCS; cslice++) {
@@ -35,5 +37,10 @@ unsigned int intel_gt_apply_ccs_mode(struct intel_gt *gt)
XEHP_CCS_MODE_CSLICE_MASK);
}
- return mode;
+ gt->ccs.mode_reg_val = mode;
+}
+
+void intel_gt_ccs_mode_init(struct intel_gt *gt)
+{
+ mutex_init(>->ccs.mutex);
}
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 55547f2ff426..e646ab595ded 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h
@@ -8,6 +8,7 @@
struct intel_gt;
-unsigned int intel_gt_apply_ccs_mode(struct intel_gt *gt);
+void intel_gt_apply_ccs_mode(struct intel_gt *gt);
+void intel_gt_ccs_mode_init(struct intel_gt *gt);
#endif /* __INTEL_GT_CCS_MODE_H__ */
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_types.h b/drivers/gpu/drm/i915/gt/intel_gt_types.h
index bcee084b1f27..8df8fac066c0 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_types.h
@@ -207,12 +207,24 @@ struct intel_gt {
[MAX_ENGINE_INSTANCE + 1];
enum intel_submission_method submission_method;
+ /*
+ * Track fixed mapping between CCS engines and compute slices.
+ *
+ * In order to w/a HW that has the inability to dynamically load
+ * balance between CCS engines and EU in the compute slices, we have to
+ * reconfigure a static mapping on the fly.
+ *
+ * The mode variable is set by the user and sets the balancing mode,
+ * i.e. how the CCS streams are distributed amongs the slices.
+ */
struct {
/*
* Mask of the non fused CCS slices
* to be used for the load balancing
*/
intel_engine_mask_t cslices;
+ struct mutex mutex;
+ u32 mode_reg_val;
} ccs;
/*
diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
index bfe6d8fc820f..daa11e11d68f 100644
--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
@@ -2727,7 +2727,6 @@ add_render_compute_tuning_settings(struct intel_gt *gt,
static void ccs_engine_wa_mode(struct intel_engine_cs *engine, struct i915_wa_list *wal)
{
struct intel_gt *gt = engine->gt;
- u32 mode;
if (!IS_DG2(gt->i915))
return;
@@ -2744,8 +2743,10 @@ static void ccs_engine_wa_mode(struct intel_engine_cs *engine, struct i915_wa_li
* After having disabled automatic load balancing we need to
* assign all slices to a single CCS. We will call it CCS mode 1
*/
- mode = intel_gt_apply_ccs_mode(gt);
- wa_masked_en(wal, XEHP_CCS_MODE, mode);
+ mutex_lock(>->ccs.mutex);
+ intel_gt_apply_ccs_mode(gt);
+ wa_masked_en(wal, XEHP_CCS_MODE, gt->ccs.mode_reg_val);
+ mutex_unlock(>->ccs.mutex);
}
/*
--
2.45.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 02/11] drm/i915/gt: Allow the creation of multi-mode CCS masks
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 ` Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 03/11] drm/i915/gt: Refactor uabi engine class/instance list creation Andi Shyti
` (11 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
Until now, we have only set CCS mode balancing to 1, which means
that only one compute engine is exposed to the user. The stream
of compute commands submitted to that engine is then shared among
all the dedicated execution units.
This is done by calling the 'intel_gt_apply_ccs_mode(); function.
With this change, the aforementioned function takes an additional
parameter called 'mode' that specifies the desired mode to be set
for the CCS engines balancing. The mode parameter can have the
following values:
- mode = 0: CCS load balancing mode 1 (1 CCS engine exposed)
- mode = 1: CCS load balancing mode 2 (2 CCS engines exposed)
- mode = 3: CCS load balancing mode 4 (4 CCS engines exposed)
This allows us to generate the appropriate register value to be
written to CCS_MODE, configuring how the exposed engine streams
will be submitted to the execution units.
No functional changes are intended yet, as no mode higher than
'0' is currently being set.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c | 78 ++++++++++++++++-----
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h | 4 +-
drivers/gpu/drm/i915/gt/intel_workarounds.c | 2 +-
3 files changed, 65 insertions(+), 19 deletions(-)
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 19e0bc359861..6afd44ffc358 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
@@ -4,37 +4,83 @@
*/
#include "i915_drv.h"
-#include "intel_gt.h"
#include "intel_gt_ccs_mode.h"
#include "intel_gt_regs.h"
-void intel_gt_apply_ccs_mode(struct intel_gt *gt)
+void intel_gt_apply_ccs_mode(struct intel_gt *gt, u32 mode)
{
+ unsigned long cslices_mask = gt->ccs.cslices;
+ u32 mode_val = 0;
+ u32 m = mode;
+ int ccs_id;
int cslice;
- u32 mode = 0;
- int first_ccs = __ffs(CCS_MASK(gt));
lockdep_assert_held(>->ccs.mutex);
if (!IS_DG2(gt->i915))
return;
- /* Build the value for the fixed CCS load balancing */
- for (cslice = 0; cslice < I915_MAX_CCS; cslice++) {
- if (gt->ccs.cslices & BIT(cslice))
- /*
- * If available, assign the cslice
- * to the first available engine...
- */
- mode |= XEHP_CCS_MODE_CSLICE(cslice, first_ccs);
+ /*
+ * The mode has two bit dedicated for each engine
+ * that will be used for the CCS balancing algorithm:
+ *
+ * BIT | CCS slice
+ * ------------------
+ * 0 | CCS slice
+ * 1 | 0
+ * ------------------
+ * 2 | CCS slice
+ * 3 | 1
+ * ------------------
+ * 4 | CCS slice
+ * 5 | 2
+ * ------------------
+ * 6 | CCS slice
+ * 7 | 3
+ * ------------------
+ *
+ * When a CCS slice is not available, then we will write 0x7,
+ * oterwise we will write the user engine id which load will
+ * be forwarded to that slice.
+ *
+ * The possible configurations are:
+ *
+ * 1 engine (ccs0):
+ * slice 0, 1, 2, 3: ccs0
+ *
+ * 2 engines (ccs0, ccs1):
+ * slice 0, 2: ccs0
+ * slice 1, 3: ccs1
+ *
+ * 4 engines (ccs0, ccs1, ccs2, ccs3):
+ * slice 0: ccs0
+ * slice 1: ccs1
+ * slice 2: ccs2
+ * slice 3: ccs3
+ */
+ ccs_id = __ffs(cslices_mask);
- else
+ for (cslice = 0; cslice < I915_MAX_CCS; cslice++) {
+ if (!(cslices_mask & BIT(cslice))) {
/*
- * ... otherwise, mark the cslice as
- * unavailable if no CCS dispatches here
+ * If not available, mark the slice as unavailable
+ * and no task will be dispatched here.
*/
- mode |= XEHP_CCS_MODE_CSLICE(cslice,
+ mode_val |= XEHP_CCS_MODE_CSLICE(cslice,
XEHP_CCS_MODE_CSLICE_MASK);
+ continue;
+ }
+
+ mode_val |= XEHP_CCS_MODE_CSLICE(cslice, ccs_id);
+
+ if (!m) {
+ m = mode;
+ ccs_id = __ffs(cslices_mask);
+ continue;
+ }
+
+ m--;
+ ccs_id = find_next_bit(&cslices_mask, I915_MAX_CCS, ccs_id + 1);
}
gt->ccs.mode_reg_val = mode;
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 e646ab595ded..0e1c43ea1d54 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h
@@ -6,9 +6,9 @@
#ifndef __INTEL_GT_CCS_MODE_H__
#define __INTEL_GT_CCS_MODE_H__
-struct intel_gt;
+#include "intel_gt.h"
-void intel_gt_apply_ccs_mode(struct intel_gt *gt);
+void intel_gt_apply_ccs_mode(struct intel_gt *gt, u32 mode);
void intel_gt_ccs_mode_init(struct intel_gt *gt);
#endif /* __INTEL_GT_CCS_MODE_H__ */
diff --git a/drivers/gpu/drm/i915/gt/intel_workarounds.c b/drivers/gpu/drm/i915/gt/intel_workarounds.c
index daa11e11d68f..203f2bb00e30 100644
--- a/drivers/gpu/drm/i915/gt/intel_workarounds.c
+++ b/drivers/gpu/drm/i915/gt/intel_workarounds.c
@@ -2744,7 +2744,7 @@ static void ccs_engine_wa_mode(struct intel_engine_cs *engine, struct i915_wa_li
* assign all slices to a single CCS. We will call it CCS mode 1
*/
mutex_lock(>->ccs.mutex);
- intel_gt_apply_ccs_mode(gt);
+ intel_gt_apply_ccs_mode(gt, 0);
wa_masked_en(wal, XEHP_CCS_MODE, gt->ccs.mode_reg_val);
mutex_unlock(>->ccs.mutex);
}
--
2.45.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 03/11] drm/i915/gt: Refactor uabi engine class/instance list creation
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 ` Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 04/11] drm/i915/gt: Manage CCS engine creation within UABI exposure Andi Shyti
` (10 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti, Tvrtko Ursulin
For the upcoming changes we need a cleaner way to build the list
of uabi engines.
Suggested-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_engine_user.c | 29 ++++++++++++---------
1 file changed, 17 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index 833987015b8b..11cc06c0c785 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -203,7 +203,7 @@ static void engine_rename(struct intel_engine_cs *engine, const char *name, u16
void intel_engines_driver_register(struct drm_i915_private *i915)
{
- u16 name_instance, other_instance = 0;
+ u16 class_instance[I915_LAST_UABI_ENGINE_CLASS + 2] = { };
struct legacy_ring ring = {};
struct list_head *it, *next;
struct rb_node **p, *prev;
@@ -214,6 +214,8 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
prev = NULL;
p = &i915->uabi_engines.rb_node;
list_for_each_safe(it, next, &engines) {
+ u16 uabi_class;
+
struct intel_engine_cs *engine =
container_of(it, typeof(*engine), uabi_list);
@@ -222,15 +224,14 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
GEM_BUG_ON(engine->class >= ARRAY_SIZE(uabi_classes));
engine->uabi_class = uabi_classes[engine->class];
- if (engine->uabi_class == I915_NO_UABI_CLASS) {
- name_instance = other_instance++;
- } else {
- GEM_BUG_ON(engine->uabi_class >=
- ARRAY_SIZE(i915->engine_uabi_class_count));
- name_instance =
- i915->engine_uabi_class_count[engine->uabi_class]++;
- }
- engine->uabi_instance = name_instance;
+
+ if (engine->uabi_class == I915_NO_UABI_CLASS)
+ uabi_class = I915_LAST_UABI_ENGINE_CLASS + 1;
+ else
+ uabi_class = engine->uabi_class;
+
+ GEM_BUG_ON(uabi_class >= ARRAY_SIZE(class_instance));
+ engine->uabi_instance = class_instance[uabi_class]++;
/*
* Replace the internal name with the final user and log facing
@@ -238,11 +239,15 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
*/
engine_rename(engine,
intel_engine_class_repr(engine->class),
- name_instance);
+ engine->uabi_instance);
- if (engine->uabi_class == I915_NO_UABI_CLASS)
+ if (uabi_class > I915_LAST_UABI_ENGINE_CLASS)
continue;
+ GEM_BUG_ON(uabi_class >=
+ ARRAY_SIZE(i915->engine_uabi_class_count));
+ i915->engine_uabi_class_count[uabi_class]++;
+
rb_link_node(&engine->uabi_node, prev, p);
rb_insert_color(&engine->uabi_node, &i915->uabi_engines);
--
2.45.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 04/11] drm/i915/gt: Manage CCS engine creation within UABI exposure
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (2 preceding siblings ...)
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 ` 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
` (9 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
In commit ea315f98e5d6 ("drm/i915/gt: Do not generate the command
streamer for all the CCS"), we restricted the creation of
physical CCS engines to only one stream. This allowed the user to
submit a single compute workload, with all CCS slices sharing the
workload from that stream.
This patch removes that limitation but still exposes only one
stream to the user. The physical memory for each engine remains
allocated but unused, however the user will only see one engine
exposed.
Do this by adding only one engine to the UABI list, ensuring that
only one engine is visible to the user.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_engine_cs.c | 23 ---------------------
drivers/gpu/drm/i915/gt/intel_engine_user.c | 20 +++++++++++++++---
2 files changed, 17 insertions(+), 26 deletions(-)
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_cs.c b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
index 4d30a86016f2..def255ee0b96 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_cs.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_cs.c
@@ -876,29 +876,6 @@ static intel_engine_mask_t init_engine_mask(struct intel_gt *gt)
info->engine_mask &= ~BIT(GSC0);
}
- /*
- * Do not create the command streamer for CCS slices beyond the first.
- * All the workload submitted to the first engine will be shared among
- * all the slices.
- *
- * Once the user will be allowed to customize the CCS mode, then this
- * check needs to be removed.
- */
- if (IS_DG2(gt->i915)) {
- u8 first_ccs = __ffs(CCS_MASK(gt));
-
- /*
- * Store the number of active cslices before
- * changing the CCS engine configuration
- */
- gt->ccs.cslices = CCS_MASK(gt);
-
- /* Mask off all the CCS engine */
- info->engine_mask &= ~GENMASK(CCS3, CCS0);
- /* Put back in the first CCS engine */
- info->engine_mask |= BIT(_CCS(first_ccs));
- }
-
return info->engine_mask;
}
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_user.c b/drivers/gpu/drm/i915/gt/intel_engine_user.c
index 11cc06c0c785..c5ccb677ed15 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_user.c
+++ b/drivers/gpu/drm/i915/gt/intel_engine_user.c
@@ -207,6 +207,7 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
struct legacy_ring ring = {};
struct list_head *it, *next;
struct rb_node **p, *prev;
+ u8 uabi_ccs_instance = 0;
LIST_HEAD(engines);
sort_engines(i915, &engines);
@@ -246,6 +247,22 @@ void intel_engines_driver_register(struct drm_i915_private *i915)
GEM_BUG_ON(uabi_class >=
ARRAY_SIZE(i915->engine_uabi_class_count));
+
+ /* Fix up the mapping to match default execbuf::user_map[] */
+ add_legacy_ring(&ring, engine);
+
+ /*
+ * Do not create the command streamer for CCS slices beyond the
+ * first. All the workload submitted to the first engine will be
+ * shared among all the slices.
+ */
+ if (IS_DG2(i915) && uabi_class == I915_ENGINE_CLASS_COMPUTE) {
+ uabi_ccs_instance++;
+
+ if (uabi_ccs_instance > 1)
+ continue;
+ }
+
i915->engine_uabi_class_count[uabi_class]++;
rb_link_node(&engine->uabi_node, prev, p);
@@ -255,9 +272,6 @@ 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;
}
--
2.45.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 05/11] drm/i915/gt: Remove cslices mask value from the CCS structure
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (3 preceding siblings ...)
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 ` Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 06/11] drm/i915/gt: Expose the number of total CCS slices Andi Shyti
` (8 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
Following the decision to manage CCS engine creation within UABI
engines, the "cslices" variable in the "ccs" structure in the
"gt" is no longer needed. Remove it is now redundant.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c | 2 +-
drivers/gpu/drm/i915/gt/intel_gt_types.h | 5 -----
2 files changed, 1 insertion(+), 6 deletions(-)
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 6afd44ffc358..2b6d4ee7445d 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
@@ -9,7 +9,7 @@
void intel_gt_apply_ccs_mode(struct intel_gt *gt, u32 mode)
{
- unsigned long cslices_mask = gt->ccs.cslices;
+ unsigned long cslices_mask = CCS_MASK(gt);
u32 mode_val = 0;
u32 m = mode;
int ccs_id;
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_types.h b/drivers/gpu/drm/i915/gt/intel_gt_types.h
index 8df8fac066c0..a833b395237b 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_types.h
@@ -218,11 +218,6 @@ struct intel_gt {
* i.e. how the CCS streams are distributed amongs the slices.
*/
struct {
- /*
- * Mask of the non fused CCS slices
- * to be used for the load balancing
- */
- intel_engine_mask_t cslices;
struct mutex mutex;
u32 mode_reg_val;
} ccs;
--
2.45.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 06/11] drm/i915/gt: Expose the number of total CCS slices
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (4 preceding siblings ...)
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 ` Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 07/11] drm/i915/gt: Store engine-related sysfs kobjects Andi Shyti
` (7 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
Implement a sysfs interface to show the number of available CCS
slices. The displayed number does not take into account the CCS
balancing mode.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c | 24 +++++++++++++++++++++
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h | 1 +
drivers/gpu/drm/i915/gt/intel_gt_sysfs.c | 2 ++
3 files changed, 27 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 2b6d4ee7445d..49493928f714 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
@@ -5,7 +5,9 @@
#include "i915_drv.h"
#include "intel_gt_ccs_mode.h"
+#include "intel_gt_print.h"
#include "intel_gt_regs.h"
+#include "intel_gt_sysfs.h"
void intel_gt_apply_ccs_mode(struct intel_gt *gt, u32 mode)
{
@@ -90,3 +92,25 @@ void intel_gt_ccs_mode_init(struct intel_gt *gt)
{
mutex_init(>->ccs.mutex);
}
+
+static ssize_t num_cslices_show(struct device *dev,
+ struct device_attribute *attr,
+ char *buff)
+{
+ struct intel_gt *gt = kobj_to_gt(&dev->kobj);
+ u32 num_slices;
+
+ num_slices = hweight32(CCS_MASK(gt));
+
+ return sysfs_emit(buff, "%u\n", num_slices);
+}
+static DEVICE_ATTR_RO(num_cslices);
+
+void intel_gt_sysfs_ccs_init(struct intel_gt *gt)
+{
+ int err;
+
+ err = sysfs_create_file(>->sysfs_gt, &dev_attr_num_cslices.attr);
+ if (err)
+ gt_dbg(gt, "failed to create sysfs num_cslices files\n");
+}
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 0e1c43ea1d54..c60bfdb54e37 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.h
@@ -9,6 +9,7 @@
#include "intel_gt.h"
void intel_gt_apply_ccs_mode(struct intel_gt *gt, u32 mode);
+void intel_gt_sysfs_ccs_init(struct intel_gt *gt);
void intel_gt_ccs_mode_init(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..895eedc402ae 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_init(gt);
return;
--
2.45.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 07/11] drm/i915/gt: Store engine-related sysfs kobjects
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (5 preceding siblings ...)
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 ` Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 08/11] drm/i915/gt: Store active CCS mask Andi Shyti
` (6 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
Upcoming commits will need to access engine-related kobjects to
enable the creation and destruction of sysfs interfaces at
runtime.
For this, store the "engine" directory (i915->sysfs_engine), the
engine files (gt->kobj), and the default data
(gt->kobj_defaults).
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_engine_types.h | 3 +++
drivers/gpu/drm/i915/gt/sysfs_engines.c | 6 ++++++
drivers/gpu/drm/i915/i915_drv.h | 1 +
3 files changed, 10 insertions(+)
diff --git a/drivers/gpu/drm/i915/gt/intel_engine_types.h b/drivers/gpu/drm/i915/gt/intel_engine_types.h
index ba55c059063d..a0f2f5c08388 100644
--- a/drivers/gpu/drm/i915/gt/intel_engine_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_engine_types.h
@@ -388,6 +388,9 @@ struct intel_engine_cs {
u32 context_size;
u32 mmio_base;
+ struct kobject *kobj;
+ struct kobject *kobj_defaults;
+
struct intel_engine_tlb_inv tlb_inv;
/*
diff --git a/drivers/gpu/drm/i915/gt/sysfs_engines.c b/drivers/gpu/drm/i915/gt/sysfs_engines.c
index 021f51d9b456..d0bb2aa561ed 100644
--- a/drivers/gpu/drm/i915/gt/sysfs_engines.c
+++ b/drivers/gpu/drm/i915/gt/sysfs_engines.c
@@ -479,6 +479,8 @@ static void add_defaults(struct kobj_engine *parent)
if (intel_engine_has_preempt_reset(ke->engine) &&
sysfs_create_file(&ke->base, &preempt_timeout_def.attr))
return;
+
+ parent->engine->kobj_defaults = &ke->base;
}
void intel_engines_add_sysfs(struct drm_i915_private *i915)
@@ -506,6 +508,8 @@ void intel_engines_add_sysfs(struct drm_i915_private *i915)
if (!dir)
return;
+ i915->sysfs_engine = dir;
+
for_each_uabi_engine(engine, i915) {
struct kobject *kobj;
@@ -526,6 +530,8 @@ void intel_engines_add_sysfs(struct drm_i915_private *i915)
add_defaults(container_of(kobj, struct kobj_engine, base));
+ engine->kobj = kobj;
+
if (0) {
err_object:
kobject_put(kobj);
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 94f7f6cc444c..3a8a757f5bd5 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -320,6 +320,7 @@ struct drm_i915_private {
struct intel_gt *gt[I915_MAX_GT];
struct kobject *sysfs_gt;
+ struct kobject *sysfs_engine;
/* Quick lookup of media GT (current platforms only have one) */
struct intel_gt *media_gt;
--
2.45.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 08/11] drm/i915/gt: Store active CCS mask
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (6 preceding siblings ...)
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 ` Andi Shyti
2024-08-17 21:00 ` [RFC PATCH v2 09/11] drm/i915/gt: Isolate single sysfs engine file creation Andi Shyti
` (5 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
To support upcoming patches, we need to store the current mask
for active CCS engines.
Active engines refer to those exposed to userspace via the UABI
engine list.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c | 20 ++++++++++++++++++++
drivers/gpu/drm/i915/gt/intel_gt_types.h | 1 +
2 files changed, 21 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 49493928f714..01ce719cf475 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
@@ -9,6 +9,23 @@
#include "intel_gt_regs.h"
#include "intel_gt_sysfs.h"
+static void update_ccs_mask(struct intel_gt *gt, u32 ccs_mode)
+{
+ unsigned long cslices_mask = CCS_MASK(gt);
+ int i;
+
+ /* Mask off all the CCS engines */
+ gt->ccs.ccs_mask = 0;
+
+ for_each_set_bit(i, &cslices_mask, I915_MAX_CCS) {
+ gt->ccs.ccs_mask |= BIT(i);
+
+ ccs_mode--;
+ if (!ccs_mode)
+ break;
+ }
+}
+
void intel_gt_apply_ccs_mode(struct intel_gt *gt, u32 mode)
{
unsigned long cslices_mask = CCS_MASK(gt);
@@ -91,6 +108,9 @@ void intel_gt_apply_ccs_mode(struct intel_gt *gt, u32 mode)
void intel_gt_ccs_mode_init(struct intel_gt *gt)
{
mutex_init(>->ccs.mutex);
+
+ /* Set CCS balance mode 1 in the ccs_mask */
+ update_ccs_mask(gt, 1);
}
static ssize_t num_cslices_show(struct device *dev,
diff --git a/drivers/gpu/drm/i915/gt/intel_gt_types.h b/drivers/gpu/drm/i915/gt/intel_gt_types.h
index a833b395237b..235b4b81eecd 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_types.h
+++ b/drivers/gpu/drm/i915/gt/intel_gt_types.h
@@ -220,6 +220,7 @@ struct intel_gt {
struct {
struct mutex mutex;
u32 mode_reg_val;
+ intel_engine_mask_t ccs_mask;
} ccs;
/*
--
2.45.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 09/11] drm/i915/gt: Isolate single sysfs engine file creation
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (7 preceding siblings ...)
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
2024-08-17 21:00 ` [RFC PATCH v2 10/11] drm/i915/gt: Implement creation and removal routines for CCS engines Andi Shyti
` (4 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
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
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 10/11] drm/i915/gt: Implement creation and removal routines for CCS engines
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (8 preceding siblings ...)
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
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
` (3 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
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
^ permalink raw reply related [flat|nested] 15+ messages in thread* [RFC PATCH v2 11/11] drm/i915/gt: Allow the user to change the CCS mode through sysfs
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (9 preceding siblings ...)
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 ` Andi Shyti
2024-08-17 22:35 ` ✗ Fi.CI.CHECKPATCH: warning for CCS static load balance (rev2) Patchwork
` (2 subsequent siblings)
13 siblings, 0 replies; 15+ messages in thread
From: Andi Shyti @ 2024-08-17 21:00 UTC (permalink / raw)
To: intel-gfx, dri-devel; +Cc: Chris Wilson, Andi Shyti
Create the 'ccs_mode' file under
/sys/class/drm/cardX/gt/gt0/ccs_mode
This file allows the user to read and set the current CCS mode.
- Reading: The user can read the current CCS mode, which can be
1, 2, or 4. This value is derived from the current engine
mask.
- Writing: The user can set the CCS mode to 1, 2, or 4,
depending on the desired number of exposed engines and the
required load balancing.
The interface will return -EBUSY if other clients are connected
to i915, or -EINVAL if an invalid value is set.
Signed-off-by: Andi Shyti <andi.shyti@linux.intel.com>
---
drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c | 74 +++++++++++++++++++++
1 file changed, 74 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 b1c3c9d9bb4f..30393009bc43 100644
--- a/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
+++ b/drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c
@@ -5,6 +5,7 @@
#include "i915_drv.h"
#include "intel_gt_ccs_mode.h"
+#include "intel_gt_pm.h"
#include "intel_gt_print.h"
#include "intel_gt_regs.h"
#include "intel_gt_sysfs.h"
@@ -206,6 +207,68 @@ static ssize_t num_cslices_show(struct device *dev,
}
static DEVICE_ATTR_RO(num_cslices);
+static ssize_t ccs_mode_show(struct device *dev,
+ struct device_attribute *attr, char *buff)
+{
+ struct intel_gt *gt = kobj_to_gt(&dev->kobj);
+ u32 ccs_mode;
+
+ ccs_mode = hweight32(gt->ccs.ccs_mask);
+
+ return sysfs_emit(buff, "%u\n", ccs_mode);
+}
+
+static ssize_t ccs_mode_store(struct device *dev,
+ struct device_attribute *attr,
+ const char *buff, size_t count)
+{
+ struct intel_gt *gt = kobj_to_gt(&dev->kobj);
+ int num_cslices = hweight32(CCS_MASK(gt));
+ int ccs_mode = hweight32(gt->ccs.ccs_mask);
+ ssize_t ret;
+ u32 val;
+
+ ret = kstrtou32(buff, 0, &val);
+ if (ret)
+ return ret;
+
+ /*
+ * As of now possible values to be set are 1, 2, 4,
+ * up to the maximum number of available slices
+ */
+ if ((!val) || (val > num_cslices) || (num_cslices % val))
+ return -EINVAL;
+
+ /*
+ * We don't want to change the CCS
+ * mode while someone is using the GT
+ */
+ if (intel_gt_pm_is_awake(gt))
+ return -EBUSY;
+
+ mutex_lock(>->wakeref.mutex);
+ mutex_lock(>->ccs.mutex);
+
+ /*
+ * Nothing to do if the requested setting
+ * is the same as the current one
+ */
+ if (val == ccs_mode)
+ return count;
+ else if (val > ccs_mode)
+ add_uabi_ccs_engines(gt, val);
+ else
+ remove_uabi_ccs_engines(gt, val);
+
+ intel_gt_apply_ccs_mode(gt, val);
+
+ mutex_unlock(>->ccs.mutex);
+ mutex_unlock(>->wakeref.mutex);
+
+ return count;
+}
+static DEVICE_ATTR_RW(ccs_mode);
+
void intel_gt_sysfs_ccs_init(struct intel_gt *gt)
{
int err;
@@ -213,4 +276,15 @@ void intel_gt_sysfs_ccs_init(struct intel_gt *gt)
err = sysfs_create_file(>->sysfs_gt, &dev_attr_num_cslices.attr);
if (err)
gt_dbg(gt, "failed to create sysfs num_cslices files\n");
+
+ /*
+ * Do not create the ccs_mode file for non DG2 platforms
+ * because they don't need it as they have only one CCS engine
+ */
+ if (!IS_DG2(gt->i915))
+ return;
+
+ err = sysfs_create_file(>->sysfs_gt, &dev_attr_ccs_mode.attr);
+ if (err)
+ gt_dbg(gt, "failed to create sysfs ccs_mode files\n");
}
--
2.45.2
^ permalink raw reply related [flat|nested] 15+ messages in thread* ✗ Fi.CI.CHECKPATCH: warning for CCS static load balance (rev2)
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (10 preceding siblings ...)
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 ` Patchwork
2024-08-17 22:35 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-08-17 22:41 ` ✗ Fi.CI.BAT: failure " Patchwork
13 siblings, 0 replies; 15+ messages in thread
From: Patchwork @ 2024-08-17 22:35 UTC (permalink / raw)
To: Andi Shyti; +Cc: intel-gfx
== Series Details ==
Series: CCS static load balance (rev2)
URL : https://patchwork.freedesktop.org/series/136381/
State : warning
== Summary ==
Error: dim checkpatch failed
84e876cb3a32 drm/i915/gt: Move the CCS mode variable to a global position
-:113: CHECK:UNCOMMENTED_DEFINITION: struct mutex definition without comment
#113: FILE: drivers/gpu/drm/i915/gt/intel_gt_types.h:226:
+ struct mutex mutex;
total: 0 errors, 0 warnings, 1 checks, 95 lines checked
3b0bf8998852 drm/i915/gt: Allow the creation of multi-mode CCS masks
0076ce951e97 drm/i915/gt: Refactor uabi engine class/instance list creation
-:54: WARNING:AVOID_BUG: Do not crash the kernel unless it is absolutely unavoidable--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants
#54: FILE: drivers/gpu/drm/i915/gt/intel_engine_user.c:233:
+ GEM_BUG_ON(uabi_class >= ARRAY_SIZE(class_instance));
-:70: WARNING:AVOID_BUG: Do not crash the kernel unless it is absolutely unavoidable--use WARN_ON_ONCE() plus recovery code (if feasible) instead of BUG() or variants
#70: FILE: drivers/gpu/drm/i915/gt/intel_engine_user.c:247:
+ GEM_BUG_ON(uabi_class >=
total: 0 errors, 2 warnings, 0 checks, 56 lines checked
96ff57617c4a drm/i915/gt: Manage CCS engine creation within UABI exposure
4743af1f0f34 drm/i915/gt: Remove cslices mask value from the CCS structure
12d784cbbf89 drm/i915/gt: Expose the number of total CCS slices
09c8acafca2a drm/i915/gt: Store engine-related sysfs kobjects
e2ea1fbf7f3b drm/i915/gt: Store active CCS mask
9d3afeca2efa drm/i915/gt: Isolate single sysfs engine file creation
-:100: CHECK:PARENTHESIS_ALIGNMENT: Alignment should match open parenthesis
#100: FILE: drivers/gpu/drm/i915/gt/sysfs_engines.c:539:
+ gt_err(engine->gt, "Failed to add sysfs engine '%s'\n",
+ engine->name);
total: 0 errors, 0 warnings, 1 checks, 115 lines checked
54a64c3795dd drm/i915/gt: Implement creation and removal routines for CCS engines
be957e86b979 drm/i915/gt: Allow the user to change the CCS mode through sysfs
-:71: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around '!val'
#71: FILE: drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c:239:
+ if ((!val) || (val > num_cslices) || (num_cslices % val))
-:71: CHECK:UNNECESSARY_PARENTHESES: Unnecessary parentheses around 'val > num_cslices'
#71: FILE: drivers/gpu/drm/i915/gt/intel_gt_ccs_mode.c:239:
+ if ((!val) || (val > num_cslices) || (num_cslices % val))
total: 0 errors, 0 warnings, 2 checks, 90 lines checked
^ permalink raw reply [flat|nested] 15+ messages in thread* ✗ Fi.CI.SPARSE: warning for CCS static load balance (rev2)
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (11 preceding siblings ...)
2024-08-17 22:35 ` ✗ Fi.CI.CHECKPATCH: warning for CCS static load balance (rev2) Patchwork
@ 2024-08-17 22:35 ` Patchwork
2024-08-17 22:41 ` ✗ Fi.CI.BAT: failure " Patchwork
13 siblings, 0 replies; 15+ messages in thread
From: Patchwork @ 2024-08-17 22:35 UTC (permalink / raw)
To: Andi Shyti; +Cc: intel-gfx
== Series Details ==
Series: CCS static load balance (rev2)
URL : https://patchwork.freedesktop.org/series/136381/
State : warning
== Summary ==
Error: dim sparse failed
Sparse version: v0.6.2
Fast mode used, each commit won't be checked separately.
^ permalink raw reply [flat|nested] 15+ messages in thread* ✗ Fi.CI.BAT: failure for CCS static load balance (rev2)
2024-08-17 21:00 [RFC PATCH v2 00/11] CCS static load balance Andi Shyti
` (12 preceding siblings ...)
2024-08-17 22:35 ` ✗ Fi.CI.SPARSE: " Patchwork
@ 2024-08-17 22:41 ` Patchwork
13 siblings, 0 replies; 15+ messages in thread
From: Patchwork @ 2024-08-17 22:41 UTC (permalink / raw)
To: Andi Shyti; +Cc: intel-gfx
[-- Attachment #1: Type: text/plain, Size: 9412 bytes --]
== Series Details ==
Series: CCS static load balance (rev2)
URL : https://patchwork.freedesktop.org/series/136381/
State : failure
== Summary ==
CI Bug Log - changes from CI_DRM_15252 -> Patchwork_136381v2
====================================================
Summary
-------
**FAILURE**
Serious unknown changes coming with Patchwork_136381v2 absolutely need to be
verified manually.
If you think the reported changes have nothing to do with the changes
introduced in Patchwork_136381v2, please notify your bug team (I915-ci-infra@lists.freedesktop.org) to allow them
to document this new failure mode, which will reduce false positives in CI.
External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/index.html
Participating hosts (40 -> 41)
------------------------------
Additional (2): fi-tgl-1115g4 fi-cfl-8109u
Missing (1): fi-kbl-8809g
Possible new issues
-------------------
Here are the unknown changes that may have been introduced in Patchwork_136381v2:
### IGT changes ###
#### Possible regressions ####
* igt@i915_selftest@live@hangcheck:
- bat-atsm-1: [PASS][1] -> [DMESG-FAIL][2]
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15252/bat-atsm-1/igt@i915_selftest@live@hangcheck.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/bat-atsm-1/igt@i915_selftest@live@hangcheck.html
- bat-dg2-9: [PASS][3] -> [DMESG-FAIL][4]
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15252/bat-dg2-9/igt@i915_selftest@live@hangcheck.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/bat-dg2-9/igt@i915_selftest@live@hangcheck.html
- bat-dg2-8: [PASS][5] -> [DMESG-FAIL][6]
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15252/bat-dg2-8/igt@i915_selftest@live@hangcheck.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/bat-dg2-8/igt@i915_selftest@live@hangcheck.html
- bat-dg2-14: [PASS][7] -> [DMESG-FAIL][8]
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15252/bat-dg2-14/igt@i915_selftest@live@hangcheck.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/bat-dg2-14/igt@i915_selftest@live@hangcheck.html
Known issues
------------
Here are the changes found in Patchwork_136381v2 that come from known issues:
### CI changes ###
#### Possible fixes ####
* boot:
- {bat-arlh-3}: [FAIL][9] -> [PASS][10]
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15252/bat-arlh-3/boot.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/bat-arlh-3/boot.html
### IGT changes ###
#### Issues hit ####
* igt@debugfs_test@basic-hwmon:
- fi-tgl-1115g4: NOTRUN -> [SKIP][11] ([i915#9318])
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-tgl-1115g4/igt@debugfs_test@basic-hwmon.html
* igt@gem_huc_copy@huc-copy:
- fi-cfl-8109u: NOTRUN -> [SKIP][12] ([i915#2190])
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-cfl-8109u/igt@gem_huc_copy@huc-copy.html
- fi-tgl-1115g4: NOTRUN -> [SKIP][13] ([i915#2190])
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-tgl-1115g4/igt@gem_huc_copy@huc-copy.html
* igt@gem_lmem_swapping@parallel-random-engines:
- fi-tgl-1115g4: NOTRUN -> [SKIP][14] ([i915#4613]) +3 other tests skip
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-tgl-1115g4/igt@gem_lmem_swapping@parallel-random-engines.html
* igt@gem_lmem_swapping@verify-random:
- fi-cfl-8109u: NOTRUN -> [SKIP][15] ([i915#4613]) +3 other tests skip
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-cfl-8109u/igt@gem_lmem_swapping@verify-random.html
* igt@i915_pm_rpm@module-reload:
- fi-kbl-7567u: [PASS][16] -> [DMESG-WARN][17] ([i915#11888] / [i915#1982])
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15252/fi-kbl-7567u/igt@i915_pm_rpm@module-reload.html
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-kbl-7567u/igt@i915_pm_rpm@module-reload.html
* igt@i915_selftest@live@gt_heartbeat:
- fi-kbl-7567u: [PASS][18] -> [DMESG-WARN][19] ([i915#11621]) +31 other tests dmesg-warn
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15252/fi-kbl-7567u/igt@i915_selftest@live@gt_heartbeat.html
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-kbl-7567u/igt@i915_selftest@live@gt_heartbeat.html
* igt@i915_selftest@live@hangcheck:
- bat-arls-2: [PASS][20] -> [DMESG-WARN][21] ([i915#11349] / [i915#11378])
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15252/bat-arls-2/igt@i915_selftest@live@hangcheck.html
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/bat-arls-2/igt@i915_selftest@live@hangcheck.html
* igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic:
- fi-tgl-1115g4: NOTRUN -> [SKIP][22] ([i915#4103]) +1 other test skip
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-tgl-1115g4/igt@kms_cursor_legacy@basic-busy-flip-before-cursor-atomic.html
* igt@kms_dsc@dsc-basic:
- fi-tgl-1115g4: NOTRUN -> [SKIP][23] ([i915#3555] / [i915#3840])
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-tgl-1115g4/igt@kms_dsc@dsc-basic.html
* igt@kms_force_connector_basic@force-load-detect:
- fi-tgl-1115g4: NOTRUN -> [SKIP][24]
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-tgl-1115g4/igt@kms_force_connector_basic@force-load-detect.html
* igt@kms_pm_backlight@basic-brightness:
- fi-cfl-8109u: NOTRUN -> [SKIP][25] +11 other tests skip
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-cfl-8109u/igt@kms_pm_backlight@basic-brightness.html
- fi-tgl-1115g4: NOTRUN -> [SKIP][26] ([i915#9812])
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-tgl-1115g4/igt@kms_pm_backlight@basic-brightness.html
* igt@kms_pm_rpm@basic-pci-d3-state:
- fi-kbl-7567u: [PASS][27] -> [DMESG-WARN][28] ([i915#11888]) +38 other tests dmesg-warn
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_15252/fi-kbl-7567u/igt@kms_pm_rpm@basic-pci-d3-state.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-kbl-7567u/igt@kms_pm_rpm@basic-pci-d3-state.html
* igt@kms_psr@psr-sprite-plane-onoff:
- fi-tgl-1115g4: NOTRUN -> [SKIP][29] ([i915#9732]) +3 other tests skip
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-tgl-1115g4/igt@kms_psr@psr-sprite-plane-onoff.html
* igt@kms_setmode@basic-clone-single-crtc:
- fi-tgl-1115g4: NOTRUN -> [SKIP][30] ([i915#3555])
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/fi-tgl-1115g4/igt@kms_setmode@basic-clone-single-crtc.html
{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).
[i915#10196]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/10196
[i915#11343]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11343
[i915#11346]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11346
[i915#11349]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11349
[i915#11378]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11378
[i915#11621]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11621
[i915#11666]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11666
[i915#11671]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11671
[i915#11681]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11681
[i915#11723]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11723
[i915#11724]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11724
[i915#11725]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11725
[i915#11726]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11726
[i915#11888]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/11888
[i915#1982]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/1982
[i915#2190]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/2190
[i915#3555]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3555
[i915#3840]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/3840
[i915#4103]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4103
[i915#4613]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/4613
[i915#8809]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/8809
[i915#9318]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9318
[i915#9732]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9732
[i915#9812]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9812
[i915#9886]: https://gitlab.freedesktop.org/drm/i915/kernel/-/issues/9886
Build changes
-------------
* Linux: CI_DRM_15252 -> Patchwork_136381v2
CI-20190529: 20190529
CI_DRM_15252: 867f8f978dc40659fb770105a4e075efc224e121 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_7975: 7975
Patchwork_136381v2: 867f8f978dc40659fb770105a4e075efc224e121 @ git://anongit.freedesktop.org/gfx-ci/linux
== Logs ==
For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_136381v2/index.html
[-- Attachment #2: Type: text/html, Size: 9815 bytes --]
^ permalink raw reply [flat|nested] 15+ messages in thread