Skip to contentSkip to conversation

Add sysfs interface to control class-of-service

PATCH In review Prathap Kumar Valsan 4 participants 6 messages Oct 15, 2019 – Oct 16, 2019

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

v4 cover Add sysfs interface to control class-of-service

For GEN11 MOCS are part of context register state. This means updating CLOS also needs to update the context state of active contexts.

v4:
- Make it explicit in the commit message that we want to set CLOS global on device (Chris)
- Fixe the Locking (Chris)
- Move the global configuration of contexts away from gt.(Chris)

v3: Rebase

v2:
- Update the interface to use two sysfs files(Joonas)
- Gen12 PCode interface is not ready yet to read the way mask. So removed TGL support and added support for Gen11.
- Updating MOCS in Gen 11 also require changing the context image of existing contexts.
- Referred to gen8_configure_all_contexts() as suggested by Chris.

Prathap Kumar Valsan (1):
drm/i915: Add sysfs interface to control class-of-service

 drivers/gpu/drm/i915/Makefile           |   1 +
 drivers/gpu/drm/i915/gt/intel_lrc.c     |   7 ++
 drivers/gpu/drm/i915/gt/intel_lrc_reg.h |   1 +
 drivers/gpu/drm/i915/gt/intel_mocs.c    | 115 +++++++++++++++++++++
 drivers/gpu/drm/i915/gt/intel_mocs.h    |   7 ++
 drivers/gpu/drm/i915/i915_clos.c        | 128 ++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_clos.h        |  15 +++
 drivers/gpu/drm/i915/i915_drv.h         |  10 ++
 drivers/gpu/drm/i915/i915_gem.c         |   3 +
 drivers/gpu/drm/i915/i915_reg.h         |   1 +
 drivers/gpu/drm/i915/i915_sysfs.c       | 105 +++++++++++++++++++
 11 files changed, 393 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/i915_clos.c
 create mode 100644 drivers/gpu/drm/i915/i915_clos.h
Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw

PATCH v4 1/1 drm/i915: Add sysfs interface to control class-of-service

Real-Time clients running on CPU may want to run on its own partition of Last-Level-Cache(LLC) to achieve isolation and to be more deterministic. The Intel Cache-Allocation-Technology exist on CPU to partition LLC in to ways and dedicate a partition to an application.

However, when LLC is shared between CPU and GPU, the workloads running on GPU has no notion about this partition and can thrash the cache lines dedicated to a Real Time task running on CPU. To avoid this, Real-Time clients wants a mechanism to read the existing cache ways that GPU can allocate, which depends on a class-of-service(CLOS) and its associated cache way mask and to restrict the GPU device globally to one of the supported CLOS levels.

Currently GPU hardware supports four CLOS levels and there is an associated way-mask for each CLOS. Each LLC MOCS register has a field to select the CLOS level. So in-order to globally set the GPU to a CLOS level, driver needs to program entire MOCS table.

Hardware supports reading supported way-mask configuration for GPU using a bios PCode interface. The sysfs interface has two files--llc_clos_modes and llc_clos. The file llc_clos_modes is read only file and will list the available way masks. The file llc_clos is read/write and will show the currently active way mask and writing a new way mask will update the active way mask of the GPU.

Note of Caution: Restricting cache ways using this mechanism presents a larger attack surface for side-channel attacks.

Example usage:

Quoted 1 line

cat /sys/class/drm/card0/llc_clos_modes

0xfff 0xfc0 0xc00 0x800

Quoted 1 line

cat /sys/class/drm/card0/llc_clos

0xfff

Update to new clos
echo "0x800" > /sys/class/drm/card0/llc_clos

---
 drivers/gpu/drm/i915/Makefile           |   1 +
 drivers/gpu/drm/i915/gt/intel_lrc.c     |   7 ++
 drivers/gpu/drm/i915/gt/intel_lrc_reg.h |   1 +
 drivers/gpu/drm/i915/gt/intel_mocs.c    | 115 +++++++++++++++++++++
 drivers/gpu/drm/i915/gt/intel_mocs.h    |   7 ++
 drivers/gpu/drm/i915/i915_clos.c        | 128 ++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_clos.h        |  15 +++
 drivers/gpu/drm/i915/i915_drv.h         |  10 ++
 drivers/gpu/drm/i915/i915_gem.c         |   3 +
 drivers/gpu/drm/i915/i915_reg.h         |   1 +
 drivers/gpu/drm/i915/i915_sysfs.c       | 105 +++++++++++++++++++
 11 files changed, 393 insertions(+)
 create mode 100644 drivers/gpu/drm/i915/i915_clos.c
 create mode 100644 drivers/gpu/drm/i915/i915_clos.h
drivers/gpu/drm/i915/Makefile +1 -0
index e791d9323b51..5b8769fb7540 100644
@@ -135,6 +135,7 @@ i915-y += \
 	  $(gem-y) \
 	  i915_active.o \
 	  i915_buddy.o \
+	  i915_clos.o \
 	  i915_cmd_parser.o \
 	  i915_gem_evict.o \
 	  i915_gem_fence_reg.o \
drivers/gpu/drm/i915/gt/intel_lrc.c +7 -0
index 484efe3b4273..0191c10486e4 100644
@@ -2130,6 +2130,13 @@ __execlists_update_reg_state(const struct intel_context *ce,
 			intel_sseu_make_rpcs(engine->i915, &ce->sseu);
 
 		i915_oa_init_reg_state(ce, engine);
+		/*
+		 * Gen11+ wants to support update of LLC class-of-service via
+		 * sysfs interface. CLOS is defined in MOCS registers and for
+		 * Gen11, MOCS is part of context resgister state.
+		 */
+		if (IS_GEN(engine->i915, 11))
+			intel_mocs_init_reg_state(ce);
 	}
 }
 
drivers/gpu/drm/i915/gt/intel_lrc_reg.h +1 -0
index 06ab0276e10e..f07a6262217c 100644
@@ -28,6 +28,7 @@
 #define CTX_R_PWR_CLK_STATE		(0x42 + 1)
 
 #define GEN9_CTX_RING_MI_MODE		0x54
+#define GEN11_CTX_GFX_MOCS_BASE		0x4F2
 
 /* GEN12+ Reg State Context */
 #define GEN12_CTX_BB_PER_CTX_PTR		(0x12 + 1)
drivers/gpu/drm/i915/gt/intel_mocs.c +115 -0

175 lines not on this page · raw message

drivers/gpu/drm/i915/gt/intel_mocs.h +7 -0
index 2ae816b7ca19..6a584aa36370 100644
@@ -49,13 +49,20 @@
  * context handling keep the MOCS in step.
  */
 
+#include <linux/types.h>
+
 struct i915_request;
 struct intel_engine_cs;
+struct intel_context;
 struct intel_gt;
 
 void intel_mocs_init(struct intel_gt *gt);
 void intel_mocs_init_engine(struct intel_engine_cs *engine);
+void intel_mocs_init_reg_state(const struct intel_context *ce);
 
 int intel_mocs_emit(struct i915_request *rq);
+int intel_mocs_emit_all_engines(struct intel_gt *gt);
+
+int intel_mocs_store_clos(struct i915_request *rq, struct intel_context *ce);
 
 #endif
drivers/gpu/drm/i915/i915_clos.c new file +128 -0

128 lines not on this page · raw message

drivers/gpu/drm/i915/i915_clos.h new file +15 -0
new file mode 100644
index 000000000000..02bfbdaf0ca3
@@ -0,0 +1,15 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __I915_CLOS_H__
+#define __I915_CLOS_H__
+
+struct drm_i915_private;
+
+int i915_mocs_update_clos(struct drm_i915_private *i915);
+void i915_read_clos_way_mask(struct drm_i915_private *i915);
+
+#endif /* __I915_CLOS_H__ */
drivers/gpu/drm/i915/i915_drv.h +10 -0
index c46b339064c0..73d1f79f347e 100644
@@ -1313,6 +1313,16 @@ struct drm_i915_private {
 		bool distrust_bios_wm;
 	} wm;
 
+	/* Last Level Cache  Class of Service */
+	struct {
+		bool support_way_mask_read;
+		u32 active_clos;
+#define NUM_OF_CLOS 4
+		u16 way_mask[NUM_OF_CLOS];
+		/* Lock to serialize updating device clos via sysfs interface.*/
+		struct mutex lock;
+	} clos;
+
 	struct dram_info {
 		bool valid;
 		bool is_16gb_dimm;
drivers/gpu/drm/i915/i915_gem.c +3 -0
index 0ddbd3a5fb8d..b2b89ca8c726 100644
@@ -54,6 +54,7 @@
 #include "gt/intel_renderstate.h"
 #include "gt/intel_workarounds.h"
 
+#include "i915_clos.h"
 #include "i915_drv.h"
 #include "i915_scatterlist.h"
 #include "i915_trace.h"
@@ -1281,6 +1282,8 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
 
 	intel_uc_init(&dev_priv->gt.uc);
 
+	i915_read_clos_way_mask(dev_priv);
+
 	ret = intel_gt_init_hw(&dev_priv->gt);
 	if (ret)
 		goto err_uc_init;
drivers/gpu/drm/i915/i915_reg.h +1 -0
index e24991e54897..d9689a494910 100644
@@ -8869,6 +8869,7 @@ enum {
 #define   ICL_PCODE_MEM_SUBSYSYSTEM_INFO	0xd
 #define     ICL_PCODE_MEM_SS_READ_GLOBAL_INFO	(0x0 << 8)
 #define     ICL_PCODE_MEM_SS_READ_QGV_POINT_INFO(point)	(((point) << 16) | (0x1 << 8))
+#define   ICL_PCODE_LLC_COS_WAY_MASK_INFO	0x1d
 #define   GEN6_PCODE_READ_D_COMP		0x10
 #define   GEN6_PCODE_WRITE_D_COMP		0x11
 #define   HSW_PCODE_DE_WRITE_FREQ_REQ		0x17
drivers/gpu/drm/i915/i915_sysfs.c +105 -0

133 lines not on this page · raw message

Signature · 6 lines
2.20.1

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

Re: [PATCH v4 1/1] drm/i915: Add sysfs interface to control class-of-service

Quoting Prathap Kumar Valsan (2019-10-15 08:31:29)

drivers/gpu/drm/i915/gt/intel_mocs.c int intel_mocs_emit(struct i915_request *rq) · line 721

Quoted 8 lines
drivers/gpu/drm/i915/gt/intel_mocs.c +8 -0
+int intel_mocs_emit_all_engines(struct intel_gt *gt)
+{
+       struct drm_i915_private *i915 = gt->i915;
+       struct intel_engine_cs *engine;
+       enum intel_engine_id id;
+       int err;
+
+       for_each_engine(engine, i915, id) {

Pass i915, and use for_each_uabi_engine(engine, i915) instead.

Quoted 124 lines
drivers/gpu/drm/i915/gt/intel_mocs.c +21 -0
+               struct i915_request *rq;
+               struct drm_i915_mocs_table t;
+
+               rq = i915_request_create(engine->kernel_context);
+               if (IS_ERR(rq))
+                       return PTR_ERR(rq);
+
+               get_mocs_settings(rq->engine->gt, &t);
+               err = emit_mocs_control_table(rq, &t);
+               if (err) {
+                       i915_request_skip(rq, err);
+                       i915_request_add(rq);
+                       return err;
+               }
+
+               i915_request_add(rq);
+       }
+
+       return 0;
+}
+
 void intel_mocs_init(struct intel_gt *gt)
 {
        intel_mocs_init_l3cc_table(gt);
drivers/gpu/drm/i915/gt/intel_mocs.h +7 -0
index 2ae816b7ca19..6a584aa36370 100644
@@ -49,13 +49,20 @@
  * context handling keep the MOCS in step.
  */
 
+#include <linux/types.h>
+
 struct i915_request;
 struct intel_engine_cs;
+struct intel_context;
 struct intel_gt;
 
 void intel_mocs_init(struct intel_gt *gt);
 void intel_mocs_init_engine(struct intel_engine_cs *engine);
+void intel_mocs_init_reg_state(const struct intel_context *ce);
 
 int intel_mocs_emit(struct i915_request *rq);
+int intel_mocs_emit_all_engines(struct intel_gt *gt);
+
+int intel_mocs_store_clos(struct i915_request *rq, struct intel_context *ce);
 
 #endif
drivers/gpu/drm/i915/i915_clos.c new file +69 -0
new file mode 100644
index 000000000000..ead6fadcb5b3
@@ -0,0 +1,128 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright © 2019 Intel Corporation
+ */
+
+#include "gem/i915_gem_context.h"
+#include "gt/intel_context.h"
+#include "gt/intel_mocs.h"
+
+#include "i915_clos.h"
+#include "i915_drv.h"
+#include "intel_sideband.h"
+
+#define GEN11_DEFAULT_CLOS 0
+
+static int clos_modify_context(struct intel_context *ce)
+{
+       struct i915_request *rq;
+       int err;
+
+       lockdep_assert_held(&ce->pin_mutex);
+
+       rq = i915_request_create(ce->engine->kernel_context);
+       if (IS_ERR(rq))
+               return PTR_ERR(rq);
+
+       /* Serialise with the remote context */
+       err = intel_context_prepare_remote_request(ce, rq);
+       if (err == 0)
+               err = intel_mocs_store_clos(rq, ce);
+
+       i915_request_add(rq);
+       return err;
+}
+
+static int clos_configure_context(struct i915_gem_context *ctx)
+{
+       struct i915_gem_engines_iter it;
+       struct intel_context *ce;
+       int err = 0;
+
+       for_each_gem_engine(ce, i915_gem_context_lock_engines(ctx), it) {
+               GEM_BUG_ON(ce == ce->engine->kernel_context);
+
+               if (ce->engine->class != RENDER_CLASS)
+                       continue;
+
+               err = intel_context_lock_pinned(ce);
+               if (err)
+                       break;
+
+               if (intel_context_is_pinned(ce))
+                       err = clos_modify_context(ce);
+
+               intel_context_unlock_pinned(ce);
+               if (err)
+                       break;
+       }
+       i915_gem_context_unlock_engines(ctx);
+
+       return err;
+}
+
+static int clos_configure_all_contexts(struct drm_i915_private *i915)
+{
+       struct i915_gem_context *ctx, *cn;
+       int err;
+

drivers/gpu/drm/i915/i915_clos.c line 79

Quoted 10 lines
drivers/gpu/drm/i915/i915_clos.c new file +10 -0
+       /*
+        * MOCS registers of render engine are context saved and restored to and
+        * from a context image.
+        * So for any MOCS update to reflect on the existing contexts requires
+        * updating the context image.
+        */
+       spin_lock(&i915->gem.contexts.lock);
+       list_for_each_entry_safe(ctx, cn, &i915->gem.contexts.list, link) {
+               if (ctx == i915->kernel_context)
+                       continue;

Did you forget something here?

drivers/gpu/drm/i915/i915_clos.c line 89

Quoted 10 lines
drivers/gpu/drm/i915/i915_clos.c new file +10 -0
+
+               spin_unlock(&i915->gem.contexts.lock);
+
+               err = clos_configure_context(ctx);
+               if (err)
+                       return err;
+
+               spin_lock(&i915->gem.contexts.lock);
+               list_safe_reset_next(ctx, cn, link);
+               i915_gem_context_put(ctx);

... Something that pairs with the put?

Quoted 27 lines
drivers/gpu/drm/i915/i915_clos.c new file +27 -0
+       }
+       spin_unlock(&i915->gem.contexts.lock);
+       /*
+        * After updating all other contexts, update render context image of
+        * kernel context. Also update the MOCS of non-render engines.
+        */
+       err = intel_mocs_emit_all_engines(&i915->gt);
+
+       return err;
+}
+
+int i915_mocs_update_clos(struct drm_i915_private *i915)
+{
+       return clos_configure_all_contexts(i915);
+}
+
+void i915_read_clos_way_mask(struct drm_i915_private *i915)
+{
+       int ret, i;
+       u32 val;
+
+       i915->clos.active_clos = GEN11_DEFAULT_CLOS;
+
+       for (i = 0; i < NUM_OF_CLOS; i++) {
+               val = i;
+               ret = sandybridge_pcode_read(i915,
+                                            ICL_PCODE_LLC_COS_WAY_MASK_INFO,

drivers/gpu/drm/i915/i915_clos.c line 126

Quoted 10 lines
drivers/gpu/drm/i915/i915_clos.c new file +10 -0
+                                            &val, NULL);
+               if (ret) {
+                       DRM_ERROR("Mailbox read error = %d\n", ret);
+                       return;
+               }
+
+               i915->clos.way_mask[i] = val;
+       }
+
+       i915->clos.support_way_mask_read = true;

So you opt for boot failure on 10 generations?

Quoted 28 lines
drivers/gpu/drm/i915/i915_clos.c new file +2 -0
+}
+
drivers/gpu/drm/i915/i915_clos.h new file +15 -0
new file mode 100644
index 000000000000..02bfbdaf0ca3
@@ -0,0 +1,15 @@
+/*
+ * SPDX-License-Identifier: MIT
+ *
+ * Copyright © 2019 Intel Corporation
+ */
+
+#ifndef __I915_CLOS_H__
+#define __I915_CLOS_H__
+
+struct drm_i915_private;
+
+int i915_mocs_update_clos(struct drm_i915_private *i915);
+void i915_read_clos_way_mask(struct drm_i915_private *i915);
+
+#endif /* __I915_CLOS_H__ */
drivers/gpu/drm/i915/i915_drv.h +0 -0
index c46b339064c0..73d1f79f347e 100644

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_private { · line 1320

Quoted 8 lines
drivers/gpu/drm/i915/i915_drv.h +5 -0
@@ -1313,6 +1313,16 @@ struct drm_i915_private {
                bool distrust_bios_wm;
        } wm;
 
+       /* Last Level Cache  Class of Service */
+       struct {
+               bool support_way_mask_read;
+               u32 active_clos;
+#define NUM_OF_CLOS 4

We don't use _OF_

drivers/gpu/drm/i915/i915_drv.h struct drm_i915_private { · line 1323

Quoted 3 lines
drivers/gpu/drm/i915/i915_drv.h +3 -0
+               u16 way_mask[NUM_OF_CLOS];
+               /* Lock to serialize updating device clos via sysfs interface.*/
+               struct mutex lock;

At least try to reorder this so the holes are less obvious.

Quoted 18 lines
drivers/gpu/drm/i915/i915_drv.h +2 -0
+       } clos;
+
        struct dram_info {
                bool valid;
                bool is_16gb_dimm;
drivers/gpu/drm/i915/i915_gem.c +1 -0
index 0ddbd3a5fb8d..b2b89ca8c726 100644
@@ -54,6 +54,7 @@
 #include "gt/intel_renderstate.h"
 #include "gt/intel_workarounds.h"
 
+#include "i915_clos.h"
 #include "i915_drv.h"
 #include "i915_scatterlist.h"
 #include "i915_trace.h"

drivers/gpu/drm/i915/i915_gem.c int i915_gem_init(struct drm_i915_private *dev_priv) · line 1285

Quoted 4 lines
drivers/gpu/drm/i915/i915_gem.c +1 -0
@@ -1281,6 +1282,8 @@ int i915_gem_init(struct drm_i915_private *dev_priv)
 
        intel_uc_init(&dev_priv->gt.uc);
 
+       i915_read_clos_way_mask(dev_priv);

This seems very out of place.

Quoted 36 lines
drivers/gpu/drm/i915/i915_gem.c +0 -0
        ret = intel_gt_init_hw(&dev_priv->gt);
        if (ret)
                goto err_uc_init;
drivers/gpu/drm/i915/i915_reg.h +1 -0
index e24991e54897..d9689a494910 100644
@@ -8869,6 +8869,7 @@ enum {
 #define   ICL_PCODE_MEM_SUBSYSYSTEM_INFO       0xd
 #define     ICL_PCODE_MEM_SS_READ_GLOBAL_INFO  (0x0 << 8)
 #define     ICL_PCODE_MEM_SS_READ_QGV_POINT_INFO(point)        (((point) << 16) | (0x1 << 8))
+#define   ICL_PCODE_LLC_COS_WAY_MASK_INFO      0x1d
 #define   GEN6_PCODE_READ_D_COMP               0x10
 #define   GEN6_PCODE_WRITE_D_COMP              0x11
 #define   HSW_PCODE_DE_WRITE_FREQ_REQ          0x17
drivers/gpu/drm/i915/i915_sysfs.c +2 -0
index bf039b8ba593..cb90cee474fb 100644
@@ -32,10 +32,12 @@
 
 #include "gt/intel_rc6.h"
 
+#include "i915_clos.h"
 #include "i915_drv.h"
 #include "i915_sysfs.h"
 #include "intel_pm.h"
 #include "intel_sideband.h"
+#include "gt/intel_mocs.h"
 
 static inline struct drm_i915_private *kdev_minor_to_i915(struct device *kdev)
 {
@@ -255,6 +257,92 @@ static const struct bin_attribute dpf_attrs_1 = {
        .private = (void *)1
 };
 

drivers/gpu/drm/i915/i915_sysfs.c static const struct bin_attribute dpf_attrs_1 = { · line 269

Quoted 10 lines
drivers/gpu/drm/i915/i915_sysfs.c +10 -0
+static ssize_t llc_clos_show(struct device *kdev,
+                            struct device_attribute *attr, char *buf)
+{
+       struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
+       ssize_t len = 0;
+       int active_clos;
+
+       active_clos = dev_priv->clos.active_clos;
+       len += snprintf(buf + len, PAGE_SIZE, "0x%x\n",
+                       dev_priv->clos.way_mask[active_clos]);

Go through this pair with READ/WRITE_ONCE to highlight the races to yourself and work out if they are legal (and prevent the compiler from fouling up your race prevention logic).

Quoted 37 lines
drivers/gpu/drm/i915/i915_sysfs.c +37 -0
+       return len;
+}
+
+/*
+ * This will tie the GPU device to a class-of-service. Each class-of-service
+ * has way_mask associated with it. A way-mask determines the LLC cache ways
+ * that wil be used to allocate cachelines for the GPU memory accesses.
+ */
+static ssize_t llc_clos_store(struct device *kdev,
+                             struct device_attribute *attr,
+                             const char *buf, size_t count)
+{
+       struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
+       u8 active_clos, new_clos, clos_index;
+       bool valid_mask = false;
+       ssize_t ret;
+       u16 way_mask;
+
+       ret = kstrtou16(buf, 0, &way_mask);
+       if (ret)
+               return ret;
+
+       active_clos = dev_priv->clos.active_clos;
+
+       if (dev_priv->clos.way_mask[active_clos] == way_mask)
+               return count;
+
+       for (clos_index = 0; clos_index < NUM_OF_CLOS; clos_index++) {
+               if (dev_priv->clos.way_mask[clos_index] == way_mask) {
+                       new_clos = clos_index;
+                       valid_mask = true;
+                       break;
+               }
+       }
+
+       if (!valid_mask)
+               return -EINVAL;

drivers/gpu/drm/i915/i915_sysfs.c static const struct bin_attribute dpf_attrs_1 = { · line 317

Quoted 10 lines
drivers/gpu/drm/i915/i915_sysfs.c +10 -0
+
+       ret = mutex_lock_interruptible(&dev_priv->clos.lock);
+       if (ret)
+               return ret;
+
+       dev_priv->clos.active_clos = new_clos;
+       ret = i915_mocs_update_clos(dev_priv);
+       if (ret) {
+               DRM_ERROR("Failed to update Class of service\n");
+               dev_priv->clos.active_clos = active_clos;

Half the contexts are using new_clos. One way out might be to set_wedged and burn all the evidence.

Quoted 11 lines
drivers/gpu/drm/i915/i915_sysfs.c +11 -0
+               mutex_unlock(&dev_priv->clos.lock);
+               return ret;
+       }
+
+       mutex_unlock(&dev_priv->clos.lock);
+
+       return count;
+}
+
+static ssize_t llc_clos_modes_show(struct device *kdev,
+                                  struct device_attribute *attr, char *buf)

drivers/gpu/drm/i915/i915_sysfs.c static const struct bin_attribute dpf_attrs_1 = { · line 338

Quoted 10 lines
drivers/gpu/drm/i915/i915_sysfs.c +10 -0
+{
+       struct drm_i915_private *dev_priv = kdev_minor_to_i915(kdev);
+       ssize_t len = 0;
+       int i;
+
+       for (i = 0; i < NUM_OF_CLOS; i++)
+               len += snprintf(buf + len, PAGE_SIZE, "0x%x ",
+                               dev_priv->clos.way_mask[i]);
+
+       len += snprintf(buf + len, PAGE_SIZE, "\n");

One way other sysfs use for a single interface is to show the active mode with an asterisk [*].

Quoted 14 lines
drivers/gpu/drm/i915/i915_sysfs.c +7 -0
+
+       return len;
+}
+
+static DEVICE_ATTR_RW(llc_clos);
+static DEVICE_ATTR_RO(llc_clos_modes);
+
 static ssize_t gt_act_freq_mhz_show(struct device *kdev,
                                    struct device_attribute *attr, char *buf)
 {
@@ -574,6 +662,18 @@ void i915_setup_sysfs(struct drm_i915_private *dev_priv)
        struct device *kdev = dev_priv->drm.primary->kdev;
        int ret;
 

drivers/gpu/drm/i915/i915_sysfs.c void i915_setup_sysfs(struct drm_i915_private *dev_priv) · line 674

Quoted 10 lines
drivers/gpu/drm/i915/i915_sysfs.c +10 -0
+       if (dev_priv->clos.support_way_mask_read) {
+               ret = sysfs_create_file(&kdev->kobj,
+                                       &dev_attr_llc_clos.attr);
+               if (ret)
+                       DRM_ERROR("LLC COS sysfs setup failed\n");
+
+               ret = sysfs_create_file(&kdev->kobj,
+                                       &dev_attr_llc_clos_modes.attr);
+               if (ret)
+                       DRM_ERROR("LLC COS sysfs setup failed\n");

On the scale of 0-9, how serious is this actually?

More like a 4 than 6?

drivers/gpu/drm/i915/i915_sysfs.c void i915_setup_sysfs(struct drm_i915_private *dev_priv) · line 675

Quoted 1 line
drivers/gpu/drm/i915/i915_sysfs.c +1 -0
+       }

---------------------------------------------------------------------
Intel Corporation (UK) Limited
Registered No. 1134945 (England)
Registered Office: Pipers Way, Swindon SN3 1RJ
VAT No: 860 2173 47

This e-mail and any attachments may contain confidential material for the sole use of the intended recipient(s). Any review or distribution by others is strictly prohibited. If you are not the intended recipient, please contact the sender and delete all copies.
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#3 lore raw

Re: [PATCH v4 1/1] drm/i915: Add sysfs interface to control class-of-service

In reply to Prathap Kumar Valsan

Hi Prathap,

Quoted 29 lines · Prathap Kumar Valsan

Real-Time clients running on CPU may want to run on its own partition of Last-Level-Cache(LLC) to achieve isolation and to be more deterministic. The Intel Cache-Allocation-Technology exist on CPU to partition LLC in to ways and dedicate a partition to an application.

However, when LLC is shared between CPU and GPU, the workloads running on GPU has no notion about this partition and can thrash the cache lines dedicated to a Real Time task running on CPU. To avoid this, Real-Time clients wants a mechanism to read the existing cache ways that GPU can allocate, which depends on a class-of-service(CLOS) and its associated cache way mask and to restrict the GPU device globally to one of the supported CLOS levels.

Currently GPU hardware supports four CLOS levels and there is an associated way-mask for each CLOS. Each LLC MOCS register has a field to select the CLOS level. So in-order to globally set the GPU to a CLOS level, driver needs to program entire MOCS table.

Hardware supports reading supported way-mask configuration for GPU using a bios PCode interface. The sysfs interface has two files--llc_clos_modes and llc_clos. The file llc_clos_modes is read only file and will list the available way masks. The file llc_clos is read/write and will show the currently active way mask and writing a new way mask will update the active way mask of the GPU.

Note of Caution: Restricting cache ways using this mechanism presents a larger attack surface for side-channel attacks.

Example usage:

Quoted 8 lines
Quoted 1 line

cat /sys/class/drm/card0/llc_clos_modes

0xfff 0xfc0 0xc00 0x800

Quoted 1 line

cat /sys/class/drm/card0/llc_clos

0xfff

Update to new clos
echo "0x800" > /sys/class/drm/card0/llc_clos

Would it be possible to expose this bitmask associated with the active CLOS internally for the resctrl (kernel subsystem managing IA cache allocation) to consume? The resctrl subsystem already supports discovering (as far as hardware exposes this) cache interference to support cache allocation decisions but at this time the Graphics cache interference is not discoverable. It would be valuable to the resctrl subsystem as well as the applications interacting with it to have more accurate interference information.

Thank you

Reinette
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw

✗ Fi.CI.CHECKPATCH: warning for Add sysfs interface to control class-of-service

In reply to Prathap Kumar Valsan
== Series Details ==

== Series Details ==

Series: Add sysfs interface to control class-of-service
URL : https://patchwork.freedesktop.org/series/68007/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
2e4da329bf04 drm/i915: Add sysfs interface to control class-of-service
-:301: WARNING:FILE_PATH_CHANGES: added, moved or deleted file(s), does MAINTAINERS need updating?
#301: 
new file mode 100644

-:306: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #306: FILE: drivers/gpu/drm/i915/i915_clos.c:1:
+/*

-:307: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use line 1 instead #307: FILE: drivers/gpu/drm/i915/i915_clos.c:2:
+ * SPDX-License-Identifier: MIT

-:440: WARNING:SPDX_LICENSE_TAG: Missing or malformed SPDX-License-Identifier tag in line 1 #440: FILE: drivers/gpu/drm/i915/i915_clos.h:1:
+/*

-:441: WARNING:SPDX_LICENSE_TAG: Misplaced SPDX-License-Identifier tag - use line 1 instead #441: FILE: drivers/gpu/drm/i915/i915_clos.h:2:
+ * SPDX-License-Identifier: MIT

total: 0 errors, 5 warnings, 0 checks, 536 lines checked

_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw

✗ Fi.CI.BAT: failure for Add sysfs interface to control class-of-service

In reply to Prathap Kumar Valsan
== Series Details ==

== Series Details ==

Series: Add sysfs interface to control class-of-service
URL : https://patchwork.freedesktop.org/series/68007/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_7091 -> Patchwork_14804
====================================================

Summary
-------

**FAILURE**

Serious unknown changes coming with Patchwork_14804 absolutely need to be verified manually.

If you think the reported changes have nothing to do with the changes introduced in Patchwork_14804, please notify your bug team 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_14804/index.html

Possible new issues
-------------------

Here are the unknown changes that may have been introduced in Patchwork_14804:

### IGT changes ###

#### Possible regressions ####

* igt@i915_selftest@live_active:
- fi-bdw-5557u: [PASS][1] -> [DMESG-WARN][2] +25 similar issues
[1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-bdw-5557u/igt@i915_selftest@live_active.html
[2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-bdw-5557u/igt@i915_selftest@live_active.html
- fi-snb-2600: [PASS][3] -> [DMESG-WARN][4] +24 similar issues
[3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-snb-2600/igt@i915_selftest@live_active.html
[4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-snb-2600/igt@i915_selftest@live_active.html

* igt@i915_selftest@live_evict:
- fi-ivb-3770: [PASS][5] -> [DMESG-WARN][6] +24 similar issues
[5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-ivb-3770/igt@i915_selftest@live_evict.html
[6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-ivb-3770/igt@i915_selftest@live_evict.html

* igt@i915_selftest@live_guc:
- fi-hsw-4770: [PASS][7] -> [DMESG-WARN][8] +25 similar issues
[7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-hsw-4770/igt@i915_selftest@live_guc.html
[8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-hsw-4770/igt@i915_selftest@live_guc.html
- fi-bdw-gvtdvm: [PASS][9] -> [DMESG-WARN][10] +24 similar issues
[9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-bdw-gvtdvm/igt@i915_selftest@live_guc.html
[10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-bdw-gvtdvm/igt@i915_selftest@live_guc.html

* igt@i915_selftest@live_requests:
- fi-hsw-peppy: [PASS][11] -> [DMESG-WARN][12] +25 similar issues
[11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-hsw-peppy/igt@i915_selftest@live_requests.html
[12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-hsw-peppy/igt@i915_selftest@live_requests.html

* igt@i915_selftest@live_reset:
- fi-snb-2520m: [PASS][13] -> [DMESG-WARN][14] +24 similar issues
[13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-snb-2520m/igt@i915_selftest@live_reset.html
[14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-snb-2520m/igt@i915_selftest@live_reset.html

* igt@i915_selftest@live_workarounds:
- fi-ilk-650: [PASS][15] -> [DMESG-WARN][16] +24 similar issues
[15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-ilk-650/igt@i915_selftest@live_workarounds.html
[16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-ilk-650/igt@i915_selftest@live_workarounds.html

#### Suppressed ####

The following results come from untrusted machines, tests, or statuses. They do not affect the overall result.

* {igt@i915_selftest@live_gt_engines}:
- fi-hsw-peppy: [PASS][17] -> [DMESG-WARN][18] +4 similar issues
[17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-hsw-peppy/igt@i915_selftest@live_gt_engines.html
[18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-hsw-peppy/igt@i915_selftest@live_gt_engines.html
- fi-ivb-3770: [PASS][19] -> [DMESG-WARN][20] +4 similar issues
[19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-ivb-3770/igt@i915_selftest@live_gt_engines.html
[20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-ivb-3770/igt@i915_selftest@live_gt_engines.html
- fi-hsw-4770: [PASS][21] -> [DMESG-WARN][22] +4 similar issues
[21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-hsw-4770/igt@i915_selftest@live_gt_engines.html
[22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-hsw-4770/igt@i915_selftest@live_gt_engines.html
- fi-ilk-650: [PASS][23] -> [DMESG-WARN][24] +4 similar issues
[23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-ilk-650/igt@i915_selftest@live_gt_engines.html
[24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-ilk-650/igt@i915_selftest@live_gt_engines.html

* {igt@i915_selftest@live_gt_lrc}:
- fi-bdw-5557u: [PASS][25] -> [DMESG-WARN][26] +4 similar issues
[25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-bdw-5557u/igt@i915_selftest@live_gt_lrc.html
[26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-bdw-5557u/igt@i915_selftest@live_gt_lrc.html

* {igt@i915_selftest@live_gt_pm}:
- fi-bdw-gvtdvm: [PASS][27] -> [DMESG-WARN][28] +4 similar issues
[27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-bdw-gvtdvm/igt@i915_selftest@live_gt_pm.html
[28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-bdw-gvtdvm/igt@i915_selftest@live_gt_pm.html

* {igt@i915_selftest@live_gt_timelines}:
- fi-snb-2520m: [PASS][29] -> [DMESG-WARN][30] +4 similar issues
[29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-snb-2520m/igt@i915_selftest@live_gt_timelines.html
[30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-snb-2520m/igt@i915_selftest@live_gt_timelines.html
- fi-snb-2600: [PASS][31] -> [DMESG-WARN][32] +4 similar issues
[31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-snb-2600/igt@i915_selftest@live_gt_timelines.html
[32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-snb-2600/igt@i915_selftest@live_gt_timelines.html

Known issues
------------

Here are the changes found in Patchwork_14804 that come from known issues:

### IGT changes ###

#### Issues hit ####

* igt@gem_ctx_switch@rcs0:
- fi-apl-guc: [PASS][33] -> [INCOMPLETE][34] ([fdo#103927])
[33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-apl-guc/igt@[email protected]
[34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-apl-guc/igt@[email protected]

* igt@gem_mmap_gtt@basic-write-gtt-no-prefault:
- fi-icl-u3: [PASS][35] -> [DMESG-WARN][36] ([fdo#107724])
[35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-icl-u3/igt@[email protected]
[36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-icl-u3/igt@[email protected]

* igt@i915_module_load@reload:
- fi-blb-e6850: [PASS][37] -> [INCOMPLETE][38] ([fdo#107718])
[37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-blb-e6850/igt@[email protected]
[38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-blb-e6850/igt@[email protected]
- fi-elk-e7500: [PASS][39] -> [INCOMPLETE][40] ([fdo#103989])
[39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-elk-e7500/igt@[email protected]
[40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-elk-e7500/igt@[email protected]

* igt@i915_selftest@live_hangcheck:
- fi-hsw-4770r: [PASS][41] -> [DMESG-FAIL][42] ([fdo#111991])
[41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-hsw-4770r/igt@i915_selftest@live_hangcheck.html
[42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-hsw-4770r/igt@i915_selftest@live_hangcheck.html

* igt@kms_chamelium@hdmi-hpd-fast:
- fi-kbl-7500u: [PASS][43] -> [FAIL][44] ([fdo#109483])
[43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-kbl-7500u/igt@[email protected]
[44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-kbl-7500u/igt@[email protected]

#### Possible fixes ####

* igt@gem_mmap_gtt@basic-read-no-prefault:
- fi-icl-u3: [DMESG-WARN][45] ([fdo#107724]) -> [PASS][46] +1 similar issue
[45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7091/fi-icl-u3/igt@[email protected]
[46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/fi-icl-u3/igt@[email protected]

{name}: This element is suppressed. This means it is ignored when computing
the status of the difference (SUCCESS, WARNING, or FAILURE).

[fdo#103927]: https://bugs.freedesktop.org/show_bug.cgi?id=103927
[fdo#103989]: https://bugs.freedesktop.org/show_bug.cgi?id=103989
[fdo#107713]: https://bugs.freedesktop.org/show_bug.cgi?id=107713
[fdo#107718]: https://bugs.freedesktop.org/show_bug.cgi?id=107718
[fdo#107724]: https://bugs.freedesktop.org/show_bug.cgi?id=107724
[fdo#109483]: https://bugs.freedesktop.org/show_bug.cgi?id=109483
[fdo#111381]: https://bugs.freedesktop.org/show_bug.cgi?id=111381
[fdo#111600]: https://bugs.freedesktop.org/show_bug.cgi?id=111600
[fdo#111735]: https://bugs.freedesktop.org/show_bug.cgi?id=111735
[fdo#111991]: https://bugs.freedesktop.org/show_bug.cgi?id=111991

Participating hosts (52 -> 43)
------------------------------

Missing (9): fi-kbl-soraka fi-ilk-m540 fi-hsw-4200u fi-byt-j1900 fi-byt-squawks fi-bsw-cyan fi-icl-y fi-byt-n2820 fi-byt-clapper

Build changes
-------------

* CI: CI-20190529 -> None
* Linux: CI_DRM_7091 -> Patchwork_14804

CI-20190529: 20190529
CI_DRM_7091: d88a66d195bcf71e6e05db07ba79c9fab5651f22 @ git://anongit.freedesktop.org/gfx-ci/linux
IGT_5225: 991ce4eede1c52f76378aebf162a13c20d6f6293 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
Patchwork_14804: 2e4da329bf04793107157d697343be2430f3b652 @ git://anongit.freedesktop.org/gfx-ci/linux

== Linux commits ==

2e4da329bf04 drm/i915: Add sysfs interface to control class-of-service

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_14804/index.html
_______________________________________________
Intel-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx