Skip to contentSkip to conversation

drm/i915/icl: new context descriptor support

PATCH Superseded Daniele Ceraolo Spurio 4 participants 8 messages Feb 9, 2018 – Feb 13, 2018

Subsystems (2)

v4 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

PATCH v4 1/2 drm/i915/icl: new context descriptor support

From: "Ceraolo Spurio, Daniele" <[email protected]>

Starting from Gen11 the context descriptor format has been updated in the HW. The hw_id field has been considerably reduced in size and engine class and instance fields have been added.

There is a slight name clashing issue because the field that we call hw_id is actually called SW Context ID in the specs for Gen11+.

With the current size of the hw_id field we can have a maximum of 2k contexts at any time, but we could use the sw_counter field (which is sw defined) to increase that because the HW requirement is that engine_id + sw id + sw_counter is a unique number.
GuC uses a similar method to support more contexts but does its tracking at lrc level. To avoid doing an implementation that will need to be reworked once GuC support lands, defer it for now and mark it as TODO.

v2: rebased, add documentation, fix GEN11_ENGINE_INSTANCE_SHIFT
v3: rebased, bring back lost code from i915_gem_context.c
v4: make TODO comment more generic

---
 drivers/gpu/drm/i915/i915_drv.h         |  1 +
 drivers/gpu/drm/i915/i915_gem_context.c | 11 +++++++++--
 drivers/gpu/drm/i915/i915_reg.h         |  4 ++++
 drivers/gpu/drm/i915/intel_lrc.c        | 28 +++++++++++++++++++++++++++-
 4 files changed, 41 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 7db3557b945c..acaa63f8237d 100644
@@ -2093,6 +2093,7 @@ struct drm_i915_private {
 		 */
 		struct ida hw_ida;
 #define MAX_CONTEXT_HW_ID (1<<21) /* exclusive */
+#define GEN11_MAX_CONTEXT_HW_ID (1<<11) /* exclusive */
 	} contexts;
 
 	u32 fdi_rx_config;
drivers/gpu/drm/i915/i915_gem_context.c +9 -2
index 3d75f484f6e5..45b0b78aca3f 100644
@@ -211,9 +211,15 @@ static void context_close(struct i915_gem_context *ctx)
 static int assign_hw_id(struct drm_i915_private *dev_priv, unsigned *out)
 {
 	int ret;
+	unsigned int max;
+
+	if (INTEL_GEN(dev_priv) >= 11)
+		max = GEN11_MAX_CONTEXT_HW_ID;
+	else
+		max = MAX_CONTEXT_HW_ID;
 
 	ret = ida_simple_get(&dev_priv->contexts.hw_ida,
-			     0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+			     0, max, GFP_KERNEL);
 	if (ret < 0) {
 		/* Contexts are only released when no longer active.
 		 * Flush any pending retires to hopefully release some
@@ -221,7 +227,7 @@ static int assign_hw_id(struct drm_i915_private *dev_priv, unsigned *out)
 		 */
 		i915_gem_retire_requests(dev_priv);
 		ret = ida_simple_get(&dev_priv->contexts.hw_ida,
-				     0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+				     0, max, GFP_KERNEL);
 		if (ret < 0)
 			return ret;
 	}
@@ -463,6 +469,7 @@ int i915_gem_contexts_init(struct drm_i915_private *dev_priv)
 
 	/* Using the simple ida interface, the max is limited by sizeof(int) */
 	BUILD_BUG_ON(MAX_CONTEXT_HW_ID > INT_MAX);
+	BUILD_BUG_ON(GEN11_MAX_CONTEXT_HW_ID > INT_MAX);
 	ida_init(&dev_priv->contexts.hw_ida);
 
 	/* lowest priority; idle task */
drivers/gpu/drm/i915/i915_reg.h +4 -0
index e9c79b560823..bd84e29d5399 100644
@@ -3869,6 +3869,10 @@ enum {
 
 #define GEN8_CTX_ID_SHIFT 32
 #define GEN8_CTX_ID_WIDTH 21
+#define GEN11_SW_CTX_ID_SHIFT 37
+#define GEN11_SW_CTX_ID_WIDTH 11
+#define GEN11_ENGINE_CLASS_SHIFT 61
+#define GEN11_ENGINE_INSTANCE_SHIFT 48
 
 #define CHV_CLK_CTL1			_MMIO(0x101100)
 #define VLV_CLK_CTL2			_MMIO(0x101104)
drivers/gpu/drm/i915/intel_lrc.c +27 -1
index c2c8380a0121..3305fbba65e9 100644
@@ -187,6 +187,18 @@ static void execlists_init_reg_state(u32 *reg_state,
  *      bits 32-52:    ctx ID, a globally unique tag
  *      bits 53-54:    mbz, reserved for use by hardware
  *      bits 55-63:    group ID, currently unused and set to 0
+ *
+ * Starting from Gen11, the upper dword of the descriptor has a new format:
+ *
+ *      bits 32-36:    reserved
+ *      bits 37-47:    SW context ID
+ *      bits 48:53:    engine instance
+ *      bit 54:        mbz, reserved for use by hardware
+ *      bits 55-60:    SW counter
+ *      bits 61-63:    engine class
+ *
+ * engine info, SW context ID and SW counter need to form a unique number
+ * (Context ID) per lrc.
  */
 static void
 intel_lr_context_descriptor_update(struct i915_gem_context *ctx,
@@ -196,11 +208,25 @@ intel_lr_context_descriptor_update(struct i915_gem_context *ctx,
 	u64 desc;
 
 	BUILD_BUG_ON(MAX_CONTEXT_HW_ID > (1<<GEN8_CTX_ID_WIDTH));
+	BUILD_BUG_ON(GEN11_MAX_CONTEXT_HW_ID > (1<<GEN11_SW_CTX_ID_WIDTH));
 
 	desc = ctx->desc_template;				/* bits  0-11 */
 	desc |= i915_ggtt_offset(ce->state) + LRC_HEADER_PAGES * PAGE_SIZE;
 								/* bits 12-31 */
-	desc |= (u64)ctx->hw_id << GEN8_CTX_ID_SHIFT;		/* bits 32-52 */
+
+	if (INTEL_GEN(ctx->i915) >= 11) {
+		desc |= (u64)engine->class << GEN11_ENGINE_CLASS_SHIFT;
+								/* bits 61-63 */
+
+		/* TODO: decide what to do with SW counter (bits 60-55) */
+
+		desc |= (u64)engine->instance << GEN11_ENGINE_INSTANCE_SHIFT;
+								/* bits 53-48 */
+		desc |= (u64)ctx->hw_id << GEN11_SW_CTX_ID_SHIFT;
+								/* bits 37-47 */
+	} else {
+		desc |= (u64)ctx->hw_id << GEN8_CTX_ID_SHIFT;	/* bits 32-52 */
+	}
 
 	ce->lrc_desc = desc;
 }
Signature · 6 lines
2.16.1

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

PATCH v8 2/2 drm/i915/icl: Enhanced execution list support

From: Thomas Daniel <[email protected]>

Enhanced Execlists is an upgraded version of execlists which supports up to 8 ports. The lrcs to be submitted are written to a submit queue (the ExecLists Submission Queue - ELSQ), which is then loaded on the HW. When writing to the ELSP register, the lrcs are written cyclically in the queue from position 0 to position 7. Alternatively, it is possible to write directly in the individual positions of the queue using the ELSQC registers. To be able to re-use all the existing code we're using the latter method and we're currently limiting ourself to only using 2 elements.

v2: Rebase.
v3: Switch from !IS_GEN11 to GEN < 11 (Daniele Ceraolo Spurio).
v4: Use the elsq registers instead of elsp. (Daniele Ceraolo Spurio)
v5: Reword commit, rename regs to be closer to specs, turn off

    preemption (Daniele), reuse engine->execlists.elsp (Chris)

v6: use has_logical_ring_elsq to differentiate the new paths
v7: add preemption support, rename els to submit_reg (Chris)
v8: save the ctrl register inside the execlists struct, drop CSB
handling updates (superseded by preempt_complete_status) (Chris)

---
 drivers/gpu/drm/i915/i915_drv.h          |  2 ++
 drivers/gpu/drm/i915/i915_pci.c          |  3 +-
 drivers/gpu/drm/i915/intel_device_info.h |  1 +
 drivers/gpu/drm/i915/intel_lrc.c         | 60 ++++++++++++++++++++++++--------
 drivers/gpu/drm/i915/intel_lrc.h         |  3 ++
 drivers/gpu/drm/i915/intel_ringbuffer.h  | 12 +++++--
 6 files changed, 63 insertions(+), 18 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +2 -0
index acaa63f8237d..fca8569edc1e 100644
@@ -2755,6 +2755,8 @@ intel_info(const struct drm_i915_private *dev_priv)
 
 #define HAS_LOGICAL_RING_CONTEXTS(dev_priv) \
 		((dev_priv)->info.has_logical_ring_contexts)
+#define HAS_LOGICAL_RING_ELSQ(dev_priv) \
+		((dev_priv)->info.has_logical_ring_elsq)
 #define HAS_LOGICAL_RING_PREEMPTION(dev_priv) \
 		((dev_priv)->info.has_logical_ring_preemption)
 
drivers/gpu/drm/i915/i915_pci.c +2 -1
index 4e7a10c89782..7d5c99b241a5 100644
@@ -583,7 +583,8 @@ static const struct intel_device_info intel_cannonlake_info = {
 	GEN10_FEATURES, \
 	.gen = 11, \
 	.ddb_size = 2048, \
-	.has_csr = 0
+	.has_csr = 0, \
+	.has_logical_ring_elsq = 1
 
 static const struct intel_device_info intel_icelake_11_info = {
 	GEN11_FEATURES,
drivers/gpu/drm/i915/intel_device_info.h +1 -0
index 71fdfb0451ef..90961aba60d0 100644
@@ -96,6 +96,7 @@ enum intel_platform {
 	func(has_l3_dpf); \
 	func(has_llc); \
 	func(has_logical_ring_contexts); \
+	func(has_logical_ring_elsq); \
 	func(has_logical_ring_preemption); \
 	func(has_overlay); \
 	func(has_pooled_eu); \
drivers/gpu/drm/i915/intel_lrc.c +45 -15

109 lines not on this page · raw message

drivers/gpu/drm/i915/intel_lrc.h +3 -0
index 636ced41225d..59d7b86012e9 100644
@@ -42,6 +42,9 @@
 #define RING_CONTEXT_STATUS_BUF_LO(engine, i)	_MMIO((engine)->mmio_base + 0x370 + (i) * 8)
 #define RING_CONTEXT_STATUS_BUF_HI(engine, i)	_MMIO((engine)->mmio_base + 0x370 + (i) * 8 + 4)
 #define RING_CONTEXT_STATUS_PTR(engine)		_MMIO((engine)->mmio_base + 0x3a0)
+#define RING_EXECLIST_SQ_CONTENTS(engine)	_MMIO((engine)->mmio_base + 0x510)
+#define RING_EXECLIST_CONTROL(engine)		_MMIO((engine)->mmio_base + 0x550)
+#define	  EL_CTRL_LOAD				(1 << 0)
 
 /* The docs specify that the write pointer wraps around after 5h, "After status
  * is written out to the last available status QW at offset 5h, this pointer
drivers/gpu/drm/i915/intel_ringbuffer.h +10 -2
index 8f1a4badf812..eb0d0de1ffc2 100644
@@ -200,9 +200,17 @@ struct intel_engine_execlists {
 	bool no_priolist;
 
 	/**
-	 * @elsp: the ExecList Submission Port register
+	 * @submit_reg: gen-specific execlist submission register
+	 * set to the ExecList Submission Port (elsp) register pre-Gen11 and to
+	 * the ExecList Submission Queue Contents register array for Gen11+
 	 */
-	u32 __iomem *elsp;
+	u32 __iomem *submit_reg;
+
+	/**
+	 * @ctrl_reg: the enhanced execlists control register, used to load the
+	 * submit queue on the HW and to request preemptions to idle
+	 */
+	u32 __iomem *ctrl_reg;
 
 	/**
 	 * @port: execlist port states
Signature · 6 lines
2.16.1

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

Re: [PATCH v8 2/2] drm/i915/icl: Enhanced execution list support

Quoting Daniele Ceraolo Spurio (2018-02-09 23:28:04)

Quoted 22 lines

From: Thomas Daniel <[email protected]>

Enhanced Execlists is an upgraded version of execlists which supports up to 8 ports. The lrcs to be submitted are written to a submit queue (the ExecLists Submission Queue - ELSQ), which is then loaded on the HW. When writing to the ELSP register, the lrcs are written cyclically in the queue from position 0 to position 7. Alternatively, it is possible to write directly in the individual positions of the queue using the ELSQC registers. To be able to re-use all the existing code we're using the latter method and we're currently limiting ourself to only using 2 elements.

v2: Rebase.
v3: Switch from !IS_GEN11 to GEN < 11 (Daniele Ceraolo Spurio).
v4: Use the elsq registers instead of elsp. (Daniele Ceraolo Spurio)
v5: Reword commit, rename regs to be closer to specs, turn off

    preemption (Daniele), reuse engine->execlists.elsp (Chris)

v6: use has_logical_ring_elsq to differentiate the new paths
v7: add preemption support, rename els to submit_reg (Chris)
v8: save the ctrl register inside the execlists struct, drop CSB
handling updates (superseded by preempt_complete_status) (Chris)

Quoted 5 lines

Reads very nicely, makes it look like a neat little extension. Saving the fun for later ;)

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

Reviewed-by on v4 1/2
#3 lore raw
In reply to Daniele Ceraolo Spurio
Quoted 17 lines · Daniele Ceraolo Spurio

From: "Ceraolo Spurio, Daniele" <[email protected]>

Starting from Gen11 the context descriptor format has been updated in the HW. The hw_id field has been considerably reduced in size and engine class and instance fields have been added.

There is a slight name clashing issue because the field that we call hw_id is actually called SW Context ID in the specs for Gen11+.

With the current size of the hw_id field we can have a maximum of 2k contexts at any time, but we could use the sw_counter field (which is sw defined) to increase that because the HW requirement is that engine_id + sw id + sw_counter is a unique number.
GuC uses a similar method to support more contexts but does its tracking at lrc level. To avoid doing an implementation that will need to be reworked once GuC support lands, defer it for now and mark it as TODO.

Quoted 6 lines

v2: rebased, add documentation, fix GEN11_ENGINE_INSTANCE_SHIFT
v3: rebased, bring back lost code from i915_gem_context.c
v4: make TODO comment more generic

Quoted 112 lines
---
  drivers/gpu/drm/i915/i915_drv.h         |  1 +
  drivers/gpu/drm/i915/i915_gem_context.c | 11 +++++++++--
  drivers/gpu/drm/i915/i915_reg.h         |  4 ++++
  drivers/gpu/drm/i915/intel_lrc.c        | 28 +++++++++++++++++++++++++++-
  4 files changed, 41 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 7db3557b945c..acaa63f8237d 100644
@@ -2093,6 +2093,7 @@ struct drm_i915_private {
  		 */
  		struct ida hw_ida;
  #define MAX_CONTEXT_HW_ID (1<<21) /* exclusive */
+#define GEN11_MAX_CONTEXT_HW_ID (1<<11) /* exclusive */
  	} contexts;
 
  	u32 fdi_rx_config;
drivers/gpu/drm/i915/i915_gem_context.c +9 -2
index 3d75f484f6e5..45b0b78aca3f 100644
@@ -211,9 +211,15 @@ static void context_close(struct i915_gem_context *ctx)
  static int assign_hw_id(struct drm_i915_private *dev_priv, unsigned *out)
  {
  	int ret;
+	unsigned int max;
+
+	if (INTEL_GEN(dev_priv) >= 11)
+		max = GEN11_MAX_CONTEXT_HW_ID;
+	else
+		max = MAX_CONTEXT_HW_ID;
 
  	ret = ida_simple_get(&dev_priv->contexts.hw_ida,
-			     0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+			     0, max, GFP_KERNEL);
  	if (ret < 0) {
  		/* Contexts are only released when no longer active.
  		 * Flush any pending retires to hopefully release some
@@ -221,7 +227,7 @@ static int assign_hw_id(struct drm_i915_private *dev_priv, unsigned *out)
  		 */
  		i915_gem_retire_requests(dev_priv);
  		ret = ida_simple_get(&dev_priv->contexts.hw_ida,
-				     0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+				     0, max, GFP_KERNEL);
  		if (ret < 0)
  			return ret;
  	}
@@ -463,6 +469,7 @@ int i915_gem_contexts_init(struct drm_i915_private *dev_priv)
 
  	/* Using the simple ida interface, the max is limited by sizeof(int) */
  	BUILD_BUG_ON(MAX_CONTEXT_HW_ID > INT_MAX);
+	BUILD_BUG_ON(GEN11_MAX_CONTEXT_HW_ID > INT_MAX);
  	ida_init(&dev_priv->contexts.hw_ida);
 
  	/* lowest priority; idle task */
drivers/gpu/drm/i915/i915_reg.h +4 -0
index e9c79b560823..bd84e29d5399 100644
@@ -3869,6 +3869,10 @@ enum {
 
  #define GEN8_CTX_ID_SHIFT 32
  #define GEN8_CTX_ID_WIDTH 21
+#define GEN11_SW_CTX_ID_SHIFT 37
+#define GEN11_SW_CTX_ID_WIDTH 11
+#define GEN11_ENGINE_CLASS_SHIFT 61
+#define GEN11_ENGINE_INSTANCE_SHIFT 48
 
  #define CHV_CLK_CTL1			_MMIO(0x101100)
  #define VLV_CLK_CTL2			_MMIO(0x101104)
drivers/gpu/drm/i915/intel_lrc.c +20 -1
index c2c8380a0121..3305fbba65e9 100644
@@ -187,6 +187,18 @@ static void execlists_init_reg_state(u32 *reg_state,
   *      bits 32-52:    ctx ID, a globally unique tag
   *      bits 53-54:    mbz, reserved for use by hardware
   *      bits 55-63:    group ID, currently unused and set to 0
+ *
+ * Starting from Gen11, the upper dword of the descriptor has a new format:
+ *
+ *      bits 32-36:    reserved
+ *      bits 37-47:    SW context ID
+ *      bits 48:53:    engine instance
+ *      bit 54:        mbz, reserved for use by hardware
+ *      bits 55-60:    SW counter
+ *      bits 61-63:    engine class
+ *
+ * engine info, SW context ID and SW counter need to form a unique number
+ * (Context ID) per lrc.
   */
  static void
  intel_lr_context_descriptor_update(struct i915_gem_context *ctx,
@@ -196,11 +208,25 @@ intel_lr_context_descriptor_update(struct i915_gem_context *ctx,
  	u64 desc;
 
  	BUILD_BUG_ON(MAX_CONTEXT_HW_ID > (1<<GEN8_CTX_ID_WIDTH));
+	BUILD_BUG_ON(GEN11_MAX_CONTEXT_HW_ID > (1<<GEN11_SW_CTX_ID_WIDTH));
 
  	desc = ctx->desc_template;				/* bits  0-11 */
  	desc |= i915_ggtt_offset(ce->state) + LRC_HEADER_PAGES * PAGE_SIZE;
  								/* bits 12-31 */
-	desc |= (u64)ctx->hw_id << GEN8_CTX_ID_SHIFT;		/* bits 32-52 */
+
+	if (INTEL_GEN(ctx->i915) >= 11) {
+		desc |= (u64)engine->class << GEN11_ENGINE_CLASS_SHIFT;
+								/* bits 61-63 */
+
+		/* TODO: decide what to do with SW counter (bits 60-55) */
+

drivers/gpu/drm/i915/intel_lrc.c intel_lr_context_descriptor_update(struct i915_gem_context *ctx, · line 232

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +7 -0
+		desc |= (u64)engine->instance << GEN11_ENGINE_INSTANCE_SHIFT;
+								/* bits 53-48 */
+		desc |= (u64)ctx->hw_id << GEN11_SW_CTX_ID_SHIFT;
+								/* bits 37-47 */
+	} else {
+		desc |= (u64)ctx->hw_id << GEN8_CTX_ID_SHIFT;	/* bits 32-52 */
+	}
 
  	ce->lrc_desc = desc;
  }

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

#4 lore raw

Quoting Oscar Mateo (2018-02-09 23:48:38)

Quoted 110 lines · Daniele Ceraolo Spurio
Quoted 17 lines

From: "Ceraolo Spurio, Daniele" <[email protected]>

Starting from Gen11 the context descriptor format has been updated in the HW. The hw_id field has been considerably reduced in size and engine class and instance fields have been added.

There is a slight name clashing issue because the field that we call hw_id is actually called SW Context ID in the specs for Gen11+.

With the current size of the hw_id field we can have a maximum of 2k contexts at any time, but we could use the sw_counter field (which is sw defined) to increase that because the HW requirement is that engine_id + sw id + sw_counter is a unique number.
GuC uses a similar method to support more contexts but does its tracking at lrc level. To avoid doing an implementation that will need to be reworked once GuC support lands, defer it for now and mark it as TODO.

Quoted 6 lines

v2: rebased, add documentation, fix GEN11_ENGINE_INSTANCE_SHIFT
v3: rebased, bring back lost code from i915_gem_context.c
v4: make TODO comment more generic

Quoted 81 lines
---
  drivers/gpu/drm/i915/i915_drv.h         |  1 +
  drivers/gpu/drm/i915/i915_gem_context.c | 11 +++++++++--
  drivers/gpu/drm/i915/i915_reg.h         |  4 ++++
  drivers/gpu/drm/i915/intel_lrc.c        | 28 +++++++++++++++++++++++++++-
  4 files changed, 41 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 7db3557b945c..acaa63f8237d 100644
@@ -2093,6 +2093,7 @@ struct drm_i915_private {
               */
              struct ida hw_ida;
  #define MAX_CONTEXT_HW_ID (1<<21) /* exclusive */
+#define GEN11_MAX_CONTEXT_HW_ID (1<<11) /* exclusive */
      } contexts;
 
      u32 fdi_rx_config;
drivers/gpu/drm/i915/i915_gem_context.c +9 -2
index 3d75f484f6e5..45b0b78aca3f 100644
@@ -211,9 +211,15 @@ static void context_close(struct i915_gem_context *ctx)
  static int assign_hw_id(struct drm_i915_private *dev_priv, unsigned *out)
  {
      int ret;
+     unsigned int max;
+
+     if (INTEL_GEN(dev_priv) >= 11)
+             max = GEN11_MAX_CONTEXT_HW_ID;
+     else
+             max = MAX_CONTEXT_HW_ID;
 
      ret = ida_simple_get(&dev_priv->contexts.hw_ida,
-                          0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+                          0, max, GFP_KERNEL);
      if (ret < 0) {
              /* Contexts are only released when no longer active.
               * Flush any pending retires to hopefully release some
@@ -221,7 +227,7 @@ static int assign_hw_id(struct drm_i915_private *dev_priv, unsigned *out)
               */
              i915_gem_retire_requests(dev_priv);
              ret = ida_simple_get(&dev_priv->contexts.hw_ida,
-                                  0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+                                  0, max, GFP_KERNEL);
              if (ret < 0)
                      return ret;
      }
@@ -463,6 +469,7 @@ int i915_gem_contexts_init(struct drm_i915_private *dev_priv)
 
      /* Using the simple ida interface, the max is limited by sizeof(int) */
      BUILD_BUG_ON(MAX_CONTEXT_HW_ID > INT_MAX);
+     BUILD_BUG_ON(GEN11_MAX_CONTEXT_HW_ID > INT_MAX);
      ida_init(&dev_priv->contexts.hw_ida);
 
      /* lowest priority; idle task */
drivers/gpu/drm/i915/i915_reg.h +4 -0
index e9c79b560823..bd84e29d5399 100644
@@ -3869,6 +3869,10 @@ enum {
 
  #define GEN8_CTX_ID_SHIFT 32
  #define GEN8_CTX_ID_WIDTH 21
+#define GEN11_SW_CTX_ID_SHIFT 37
+#define GEN11_SW_CTX_ID_WIDTH 11
+#define GEN11_ENGINE_CLASS_SHIFT 61
+#define GEN11_ENGINE_INSTANCE_SHIFT 48
 
  #define CHV_CLK_CTL1                        _MMIO(0x101100)
  #define VLV_CLK_CTL2                        _MMIO(0x101104)
drivers/gpu/drm/i915/intel_lrc.c +1 -0
index c2c8380a0121..3305fbba65e9 100644
@@ -187,6 +187,18 @@ static void execlists_init_reg_state(u32 *reg_state,
   *      bits 32-52:    ctx ID, a globally unique tag
   *      bits 53-54:    mbz, reserved for use by hardware
   *      bits 55-63:    group ID, currently unused and set to 0
+ *
Quoted 8 lines

drivers/gpu/drm/i915/intel_lrc.c static void execlists_init_reg_state(u32 *reg_state, · line 198

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +8 -0
+ * Starting from Gen11, the upper dword of the descriptor has a new format:
+ *
+ *      bits 32-36:    reserved
+ *      bits 37-47:    SW context ID
+ *      bits 48:53:    engine instance
+ *      bit 54:        mbz, reserved for use by hardware
+ *      bits 55-60:    SW counter
+ *      bits 61-63:    engine class

Ascending ^

Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -0
+ *
+ * engine info, SW context ID and SW counter need to form a unique number
+ * (Context ID) per lrc.
   */
  static void
  intel_lr_context_descriptor_update(struct i915_gem_context *ctx,
@@ -196,11 +208,25 @@ intel_lr_context_descriptor_update(struct i915_gem_context *ctx,
      u64 desc;
 
Quoted 4 lines

drivers/gpu/drm/i915/intel_lrc.c intel_lr_context_descriptor_update(struct i915_gem_context *ctx, · line 213

Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
      BUILD_BUG_ON(MAX_CONTEXT_HW_ID > (1<<GEN8_CTX_ID_WIDTH));
+     BUILD_BUG_ON(GEN11_MAX_CONTEXT_HW_ID > (1<<GEN11_SW_CTX_ID_WIDTH));
 
      desc = ctx->desc_template;                              /* bits  0-11 */

Should we add GEM_BUG_ON(desc & GENMASK_ULL(12, 63); ?

Quoted 2 lines

drivers/gpu/drm/i915/intel_lrc.c intel_lr_context_descriptor_update(struct i915_gem_context *ctx, · line 215

Quoted 2 lines
drivers/gpu/drm/i915/intel_lrc.c +0 -0
      desc |= i915_ggtt_offset(ce->state) + LRC_HEADER_PAGES * PAGE_SIZE;
                                                              /* bits 12-31 */

GEM_BUG_ON(desc & GENMASK_ULL(32, 63);

Ascending ^

Quoted 3 lines

drivers/gpu/drm/i915/intel_lrc.c intel_lr_context_descriptor_update(struct i915_gem_context *ctx, · line 217

Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -1
-     desc |= (u64)ctx->hw_id << GEN8_CTX_ID_SHIFT;           /* bits 32-52 */
+
+     if (INTEL_GEN(ctx->i915) >= 11) {

Descending v

GEM_BUG_ON(engine->class >= BIT(3)); ?

Quoted 9 lines

drivers/gpu/drm/i915/intel_lrc.c intel_lr_context_descriptor_update(struct i915_gem_context *ctx, · line 226

Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +9 -0
+             desc |= (u64)engine->class << GEN11_ENGINE_CLASS_SHIFT;
+                                                             /* bits 61-63 */
+
+             /* TODO: decide what to do with SW counter (bits 60-55) */
+
+             desc |= (u64)engine->instance << GEN11_ENGINE_INSTANCE_SHIFT;
+                                                             /* bits 53-48 */
+             desc |= (u64)ctx->hw_id << GEN11_SW_CTX_ID_SHIFT;
+                                                             /* bits 37-47 */

GEM_BUG_ON(ctx->hw_id >= BIT(GEN11_SW_CTX_ID_WIDTH)); etc? -Chris
_______________________________________________
Intel-gfx mailing list [email protected]
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

#5 lore raw
Quoted 145 lines · Chris Wilson

Quoting Oscar Mateo (2018-02-09 23:48:38)

Quoted 110 lines · Daniele Ceraolo Spurio
Quoted 17 lines

From: "Ceraolo Spurio, Daniele" <[email protected]>

Starting from Gen11 the context descriptor format has been updated in the HW. The hw_id field has been considerably reduced in size and engine class and instance fields have been added.

There is a slight name clashing issue because the field that we call hw_id is actually called SW Context ID in the specs for Gen11+.

With the current size of the hw_id field we can have a maximum of 2k contexts at any time, but we could use the sw_counter field (which is sw defined) to increase that because the HW requirement is that engine_id + sw id + sw_counter is a unique number.
GuC uses a similar method to support more contexts but does its tracking at lrc level. To avoid doing an implementation that will need to be reworked once GuC support lands, defer it for now and mark it as TODO.

Quoted 6 lines

v2: rebased, add documentation, fix GEN11_ENGINE_INSTANCE_SHIFT
v3: rebased, bring back lost code from i915_gem_context.c
v4: make TODO comment more generic

Quoted 81 lines
---
   drivers/gpu/drm/i915/i915_drv.h         |  1 +
   drivers/gpu/drm/i915/i915_gem_context.c | 11 +++++++++--
   drivers/gpu/drm/i915/i915_reg.h         |  4 ++++
   drivers/gpu/drm/i915/intel_lrc.c        | 28 +++++++++++++++++++++++++++-
   4 files changed, 41 insertions(+), 3 deletions(-)
drivers/gpu/drm/i915/i915_drv.h +1 -0
index 7db3557b945c..acaa63f8237d 100644
@@ -2093,6 +2093,7 @@ struct drm_i915_private {
                */
               struct ida hw_ida;
   #define MAX_CONTEXT_HW_ID (1<<21) /* exclusive */
+#define GEN11_MAX_CONTEXT_HW_ID (1<<11) /* exclusive */
       } contexts;
 
       u32 fdi_rx_config;
drivers/gpu/drm/i915/i915_gem_context.c +9 -2
index 3d75f484f6e5..45b0b78aca3f 100644
@@ -211,9 +211,15 @@ static void context_close(struct i915_gem_context *ctx)
   static int assign_hw_id(struct drm_i915_private *dev_priv, unsigned *out)
   {
       int ret;
+     unsigned int max;
+
+     if (INTEL_GEN(dev_priv) >= 11)
+             max = GEN11_MAX_CONTEXT_HW_ID;
+     else
+             max = MAX_CONTEXT_HW_ID;
 
       ret = ida_simple_get(&dev_priv->contexts.hw_ida,
-                          0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+                          0, max, GFP_KERNEL);
       if (ret < 0) {
               /* Contexts are only released when no longer active.
                * Flush any pending retires to hopefully release some
@@ -221,7 +227,7 @@ static int assign_hw_id(struct drm_i915_private *dev_priv, unsigned *out)
                */
               i915_gem_retire_requests(dev_priv);
               ret = ida_simple_get(&dev_priv->contexts.hw_ida,
-                                  0, MAX_CONTEXT_HW_ID, GFP_KERNEL);
+                                  0, max, GFP_KERNEL);
               if (ret < 0)
                       return ret;
       }
@@ -463,6 +469,7 @@ int i915_gem_contexts_init(struct drm_i915_private *dev_priv)
 
       /* Using the simple ida interface, the max is limited by sizeof(int) */
       BUILD_BUG_ON(MAX_CONTEXT_HW_ID > INT_MAX);
+     BUILD_BUG_ON(GEN11_MAX_CONTEXT_HW_ID > INT_MAX);
       ida_init(&dev_priv->contexts.hw_ida);
 
       /* lowest priority; idle task */
drivers/gpu/drm/i915/i915_reg.h +4 -0
index e9c79b560823..bd84e29d5399 100644
@@ -3869,6 +3869,10 @@ enum {
 
   #define GEN8_CTX_ID_SHIFT 32
   #define GEN8_CTX_ID_WIDTH 21
+#define GEN11_SW_CTX_ID_SHIFT 37
+#define GEN11_SW_CTX_ID_WIDTH 11
+#define GEN11_ENGINE_CLASS_SHIFT 61
+#define GEN11_ENGINE_INSTANCE_SHIFT 48
 
   #define CHV_CLK_CTL1                        _MMIO(0x101100)
   #define VLV_CLK_CTL2                        _MMIO(0x101104)
drivers/gpu/drm/i915/intel_lrc.c +1 -0
index c2c8380a0121..3305fbba65e9 100644
@@ -187,6 +187,18 @@ static void execlists_init_reg_state(u32 *reg_state,
    *      bits 32-52:    ctx ID, a globally unique tag
    *      bits 53-54:    mbz, reserved for use by hardware
    *      bits 55-63:    group ID, currently unused and set to 0
+ *
Quoted 8 lines

drivers/gpu/drm/i915/intel_lrc.c static void execlists_init_reg_state(u32 *reg_state, · line 198

Quoted 8 lines
drivers/gpu/drm/i915/intel_lrc.c +8 -0
+ * Starting from Gen11, the upper dword of the descriptor has a new format:
+ *
+ *      bits 32-36:    reserved
+ *      bits 37-47:    SW context ID
+ *      bits 48:53:    engine instance
+ *      bit 54:        mbz, reserved for use by hardware
+ *      bits 55-60:    SW counter
+ *      bits 61-63:    engine class

Ascending ^

Quoted 9 lines
Quoted 9 lines
drivers/gpu/drm/i915/intel_lrc.c +3 -0
+ *
+ * engine info, SW context ID and SW counter need to form a unique number
+ * (Context ID) per lrc.
    */
   static void
   intel_lr_context_descriptor_update(struct i915_gem_context *ctx,
@@ -196,11 +208,25 @@ intel_lr_context_descriptor_update(struct i915_gem_context *ctx,
       u64 desc;
 
Quoted 4 lines

drivers/gpu/drm/i915/intel_lrc.c intel_lr_context_descriptor_update(struct i915_gem_context *ctx, · line 213

Quoted 4 lines
drivers/gpu/drm/i915/intel_lrc.c +1 -0
       BUILD_BUG_ON(MAX_CONTEXT_HW_ID > (1<<GEN8_CTX_ID_WIDTH));
+     BUILD_BUG_ON(GEN11_MAX_CONTEXT_HW_ID > (1<<GEN11_SW_CTX_ID_WIDTH));
 
       desc = ctx->desc_template;                              /* bits  0-11 */

Should we add GEM_BUG_ON(desc & GENMASK_ULL(12, 63); ?

Quoted 2 lines

drivers/gpu/drm/i915/intel_lrc.c intel_lr_context_descriptor_update(struct i915_gem_context *ctx, · line 215

Quoted 2 lines
drivers/gpu/drm/i915/intel_lrc.c +0 -0
       desc |= i915_ggtt_offset(ce->state) + LRC_HEADER_PAGES * PAGE_SIZE;
                                                               /* bits 12-31 */

GEM_BUG_ON(desc & GENMASK_ULL(32, 63);

Ascending ^

Quoted 7 lines
Quoted 3 lines

drivers/gpu/drm/i915/intel_lrc.c intel_lr_context_descriptor_update(struct i915_gem_context *ctx, · line 217

Quoted 3 lines
drivers/gpu/drm/i915/intel_lrc.c +2 -1
-     desc |= (u64)ctx->hw_id << GEN8_CTX_ID_SHIFT;           /* bits 32-52 */
+
+     if (INTEL_GEN(ctx->i915) >= 11) {

Descending v

GEM_BUG_ON(engine->class >= BIT(3)); ?

Would it make more sense to add the check where engine->class is assigned, since it doesn't change during the lifetime of the object? since we already check for engine->class > MAX_ENGINE_CLASS, we could just add:

	BUILD_BUG_ON(MAX_ENGINE_CLASS >= BIT(GEN11_ENGINE_CLASS_WIDTH));

And the same thing for engine->instance. Or were you worried of corrupted values?

Daniele

Quoted 13 lines
Quoted 10 lines

drivers/gpu/drm/i915/intel_lrc.c intel_lr_context_descriptor_update(struct i915_gem_context *ctx, · line 226

Quoted 10 lines
drivers/gpu/drm/i915/intel_lrc.c +9 -0
+             desc |= (u64)engine->class << GEN11_ENGINE_CLASS_SHIFT;
+                                                             /* bits 61-63 */
+
+             /* TODO: decide what to do with SW counter (bits 60-55) */
+
+             desc |= (u64)engine->instance << GEN11_ENGINE_INSTANCE_SHIFT;
+                                                             /* bits 53-48 */
+             desc |= (u64)ctx->hw_id << GEN11_SW_CTX_ID_SHIFT;
+                                                             /* bits 37-47 */

GEM_BUG_ON(ctx->hw_id >= BIT(GEN11_SW_CTX_ID_WIDTH)); etc? > -Chris

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

#6 lore raw

✓ Fi.CI.BAT: success for series starting with [v4,1/2] drm/i915/icl: new context descriptor support

In reply to Daniele Ceraolo Spurio
== Series Details ==

== Series Details ==

Series: series starting with [v4,1/2] drm/i915/icl: new context descriptor support
URL : https://patchwork.freedesktop.org/series/38031/
State : success

== Summary ==

Series 38031v1 series starting with [v4,1/2] drm/i915/icl: new context descriptor support
https://patchwork.freedesktop.org/api/1.0/series/38031/revisions/1/mbox/

Test debugfs_test:

        Subgroup read_all_entries:
                incomplete -> PASS       (fi-snb-2520m) fdo#103713
Test kms_psr_sink_crc:
        Subgroup psr_basic:
                incomplete -> SKIP       (fi-elk-e7500)

fdo#103713 https://bugs.freedesktop.org/show_bug.cgi?id=103713

fi-bdw-5557u     total:288  pass:267  dwarn:0   dfail:0   fail:0   skip:21  time:418s
fi-bdw-gvtdvm    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:423s
fi-blb-e6850     total:288  pass:223  dwarn:1   dfail:0   fail:0   skip:64  time:375s
fi-bsw-n3050     total:288  pass:242  dwarn:0   dfail:0   fail:0   skip:46  time:484s
fi-bwr-2160      total:288  pass:183  dwarn:0   dfail:0   fail:0   skip:105 time:286s
fi-bxt-dsi       total:288  pass:258  dwarn:0   dfail:0   fail:0   skip:30  time:480s
fi-bxt-j4205     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:482s
fi-byt-j1900     total:288  pass:253  dwarn:0   dfail:0   fail:0   skip:35  time:468s
fi-byt-n2820     total:288  pass:249  dwarn:0   dfail:0   fail:0   skip:39  time:457s
fi-cfl-s2        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:566s
fi-cnl-y3        total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:577s
fi-elk-e7500     total:288  pass:229  dwarn:0   dfail:0   fail:0   skip:59  time:421s
fi-gdg-551       total:288  pass:179  dwarn:0   dfail:0   fail:1   skip:108 time:285s
fi-glk-1         total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:511s
fi-hsw-4770      total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:390s
fi-ilk-650       total:288  pass:228  dwarn:0   dfail:0   fail:0   skip:60  time:410s
fi-ivb-3520m     total:288  pass:259  dwarn:0   dfail:0   fail:0   skip:29  time:455s
fi-ivb-3770      total:288  pass:255  dwarn:0   dfail:0   fail:0   skip:33  time:415s
fi-kbl-7500u     total:288  pass:263  dwarn:1   dfail:0   fail:0   skip:24  time:455s
fi-kbl-7560u     total:288  pass:269  dwarn:0   dfail:0   fail:0   skip:19  time:493s
fi-kbl-r         total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:503s
fi-pnv-d510      total:288  pass:222  dwarn:1   dfail:0   fail:0   skip:65  time:602s
fi-skl-6260u     total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:423s
fi-skl-6600u     total:288  pass:261  dwarn:0   dfail:0   fail:0   skip:27  time:509s
fi-skl-6700hq    total:288  pass:262  dwarn:0   dfail:0   fail:0   skip:26  time:525s
fi-skl-6700k2    total:288  pass:264  dwarn:0   dfail:0   fail:0   skip:24  time:484s
fi-skl-6770hq    total:288  pass:268  dwarn:0   dfail:0   fail:0   skip:20  time:474s
fi-skl-guc       total:288  pass:260  dwarn:0   dfail:0   fail:0   skip:28  time:415s
fi-skl-gvtdvm    total:288  pass:265  dwarn:0   dfail:0   fail:0   skip:23  time:428s
fi-snb-2520m     total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:523s
fi-snb-2600      total:288  pass:248  dwarn:0   dfail:0   fail:0   skip:40  time:398s

Blacklisted hosts:
fi-glk-dsi total:87 pass:76 dwarn:0 dfail:0 fail:0 skip:10

2bea3467efbacf91c06fb231d066d05507a5b453 drm-tip: 2018y-02m-09d-22h-30m-41s UTC integration manifest 4294938cd757 drm/i915/icl: Enhanced execution list support
ccaec47711a8 drm/i915/icl: new context descriptor support

== Logs ==

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

#7 lore raw

✓ Fi.CI.IGT: success for series starting with [v4,1/2] drm/i915/icl: new context descriptor support

In reply to Daniele Ceraolo Spurio
== Series Details ==

== Series Details ==

Series: series starting with [v4,1/2] drm/i915/icl: new context descriptor support
URL : https://patchwork.freedesktop.org/series/38031/
State : success

== Summary ==

Test perf_pmu:

        Subgroup rc6:
                skip       -> PASS       (shard-hsw)
Test kms_setmode:
        Subgroup basic:
                fail       -> PASS       (shard-apl) fdo#99912
Test perf:
        Subgroup buffer-fill:
                pass       -> FAIL       (shard-apl) fdo#103755
Test kms_plane:
        Subgroup plane-panning-bottom-right-suspend-pipe-c-planes:
                incomplete -> PASS       (shard-hsw) fdo#103375
Test kms_vblank:
        Subgroup pipe-b-accuracy-idle:
                fail       -> PASS       (shard-snb)
Test kms_cursor_legacy:
        Subgroup flip-vs-cursor-varying-size:
                fail       -> PASS       (shard-hsw) fdo#102670

fdo#99912 https://bugs.freedesktop.org/show_bug.cgi?id=99912
fdo#103755 https://bugs.freedesktop.org/show_bug.cgi?id=103755
fdo#103375 https://bugs.freedesktop.org/show_bug.cgi?id=103375
fdo#102670 https://bugs.freedesktop.org/show_bug.cgi?id=102670

shard-apl        total:3439 pass:1785 dwarn:1   dfail:0   fail:20  skip:1632 time:12516s
shard-hsw        total:3444 pass:1761 dwarn:1   dfail:0   fail:10  skip:1671 time:11825s
shard-snb        total:3444 pass:1350 dwarn:1   dfail:0   fail:10  skip:2083 time:6591s

Blacklisted hosts:
shard-kbl total:3444 pass:1915 dwarn:1 dfail:0 fail:22 skip:1506 time:9637s

== Logs ==

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