All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 1/2] drm/i915/icl: new context descriptor support
@ 2018-02-09 23:28 Daniele Ceraolo Spurio
  2018-02-09 23:28 ` [PATCH v8 2/2] drm/i915/icl: Enhanced execution list support Daniele Ceraolo Spurio
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Daniele Ceraolo Spurio @ 2018-02-09 23:28 UTC (permalink / raw)
  To: intel-gfx

From: "Ceraolo Spurio, Daniele" <daniele.ceraolospurio@intel.com>

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

Cc: Oscar Mateo <oscar.mateo@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 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(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 7db3557b945c..acaa63f8237d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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;
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 3d75f484f6e5..45b0b78aca3f 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -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 */
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index e9c79b560823..bd84e29d5399 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -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)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index c2c8380a0121..3305fbba65e9 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -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;
 }
-- 
2.16.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [PATCH v8 2/2] drm/i915/icl: Enhanced execution list support
  2018-02-09 23:28 [PATCH v4 1/2] drm/i915/icl: new context descriptor support Daniele Ceraolo Spurio
@ 2018-02-09 23:28 ` Daniele Ceraolo Spurio
  2018-02-10  9:02   ` Chris Wilson
  2018-02-09 23:48 ` [PATCH v4 1/2] drm/i915/icl: new context descriptor support Oscar Mateo
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Daniele Ceraolo Spurio @ 2018-02-09 23:28 UTC (permalink / raw)
  To: intel-gfx; +Cc: Thomas Daniel, Rodrigo Vivi

From: Thomas Daniel <thomas.daniel@intel.com>

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)

Cc: Chris Wilson <chris@chris-wilson.co.uk>
Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
Signed-off-by: Thomas Daniel <thomas.daniel@intel.com>
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 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(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index acaa63f8237d..fca8569edc1e 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -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)
 
diff --git a/drivers/gpu/drm/i915/i915_pci.c b/drivers/gpu/drm/i915/i915_pci.c
index 4e7a10c89782..7d5c99b241a5 100644
--- a/drivers/gpu/drm/i915/i915_pci.c
+++ b/drivers/gpu/drm/i915/i915_pci.c
@@ -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,
diff --git a/drivers/gpu/drm/i915/intel_device_info.h b/drivers/gpu/drm/i915/intel_device_info.h
index 71fdfb0451ef..90961aba60d0 100644
--- a/drivers/gpu/drm/i915/intel_device_info.h
+++ b/drivers/gpu/drm/i915/intel_device_info.h
@@ -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); \
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 3305fbba65e9..ec7eb069a404 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -399,18 +399,30 @@ static u64 execlists_update_context(struct drm_i915_gem_request *rq)
 	return ce->lrc_desc;
 }
 
-static inline void elsp_write(u64 desc, u32 __iomem *elsp)
+static inline void write_desc(struct intel_engine_execlists *execlists, u64 desc, u32 port)
 {
-	writel(upper_32_bits(desc), elsp);
-	writel(lower_32_bits(desc), elsp);
+	if (execlists->ctrl_reg) {
+		writel(lower_32_bits(desc), execlists->submit_reg + port * 2);
+		writel(upper_32_bits(desc), execlists->submit_reg + port * 2 + 1);
+	} else {
+		writel(upper_32_bits(desc), execlists->submit_reg);
+		writel(lower_32_bits(desc), execlists->submit_reg);
+	}
 }
 
 static void execlists_submit_ports(struct intel_engine_cs *engine)
 {
-	struct execlist_port *port = engine->execlists.port;
+	struct intel_engine_execlists *execlists = &engine->execlists;
+	struct execlist_port *port = execlists->port;
 	unsigned int n;
 
-	for (n = execlists_num_ports(&engine->execlists); n--; ) {
+	/*
+	 * ELSQ note: the submit queue is not cleared after being submitted
+	 * to the HW so we need to make sure we always clean it up. This is
+	 * currently ensured by the fact that we always write the same number
+	 * of elsq entries, keep this in mind before changing the loop below.
+	 */
+	for (n = execlists_num_ports(execlists); n--; ) {
 		struct drm_i915_gem_request *rq;
 		unsigned int count;
 		u64 desc;
@@ -433,9 +445,14 @@ static void execlists_submit_ports(struct intel_engine_cs *engine)
 			desc = 0;
 		}
 
-		elsp_write(desc, engine->execlists.elsp);
+		write_desc(execlists, desc, n);
 	}
-	execlists_clear_active(&engine->execlists, EXECLISTS_ACTIVE_HWACK);
+
+	/* we need to manually load the submit queue */
+	if (execlists->ctrl_reg)
+		writel(EL_CTRL_LOAD, execlists->ctrl_reg);
+
+	execlists_clear_active(execlists, EXECLISTS_ACTIVE_HWACK);
 }
 
 static bool ctx_single_port_submission(const struct i915_gem_context *ctx)
@@ -469,11 +486,12 @@ static void port_assign(struct execlist_port *port,
 
 static void inject_preempt_context(struct intel_engine_cs *engine)
 {
+	struct intel_engine_execlists *execlists = &engine->execlists;
 	struct intel_context *ce =
 		&engine->i915->preempt_context->engine[engine->id];
 	unsigned int n;
 
-	GEM_BUG_ON(engine->execlists.preempt_complete_status !=
+	GEM_BUG_ON(execlists->preempt_complete_status !=
 		   upper_32_bits(ce->lrc_desc));
 	GEM_BUG_ON(!IS_ALIGNED(ce->ring->size, WA_TAIL_BYTES));
 
@@ -489,11 +507,16 @@ static void inject_preempt_context(struct intel_engine_cs *engine)
 				      CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT));
 
 	GEM_TRACE("%s\n", engine->name);
-	for (n = execlists_num_ports(&engine->execlists); --n; )
-		elsp_write(0, engine->execlists.elsp);
+	for (n = execlists_num_ports(execlists); --n; )
+		write_desc(execlists, 0, n);
+
+	write_desc(execlists, ce->lrc_desc, n);
+
+	/* we need to manually load the submit queue */
+	if (execlists->ctrl_reg)
+		writel(EL_CTRL_LOAD, execlists->ctrl_reg);
 
-	elsp_write(ce->lrc_desc, engine->execlists.elsp);
-	execlists_clear_active(&engine->execlists, EXECLISTS_ACTIVE_HWACK);
+	execlists_clear_active(execlists, EXECLISTS_ACTIVE_HWACK);
 }
 
 static void execlists_dequeue(struct intel_engine_cs *engine)
@@ -2068,8 +2091,15 @@ static int logical_ring_init(struct intel_engine_cs *engine)
 	if (ret)
 		goto error;
 
-	engine->execlists.elsp =
-		engine->i915->regs + i915_mmio_reg_offset(RING_ELSP(engine));
+	if (HAS_LOGICAL_RING_ELSQ(engine->i915)) {
+		engine->execlists.submit_reg = engine->i915->regs +
+			i915_mmio_reg_offset(RING_EXECLIST_SQ_CONTENTS(engine));
+		engine->execlists.ctrl_reg = engine->i915->regs +
+			i915_mmio_reg_offset(RING_EXECLIST_CONTROL(engine));
+	} else {
+		engine->execlists.submit_reg = engine->i915->regs +
+			i915_mmio_reg_offset(RING_ELSP(engine));
+	}
 
 	engine->execlists.preempt_complete_status = ~0u;
 	if (engine->i915->preempt_context)
@@ -2338,7 +2368,7 @@ populate_lr_context(struct i915_gem_context *ctx,
 	if (!engine->default_state)
 		regs[CTX_CONTEXT_CONTROL + 1] |=
 			_MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT);
-	if (ctx == ctx->i915->preempt_context)
+	if (ctx == ctx->i915->preempt_context && INTEL_GEN(engine->i915) < 11)
 		regs[CTX_CONTEXT_CONTROL + 1] |=
 			_MASKED_BIT_ENABLE(CTX_CTRL_ENGINE_CTX_RESTORE_INHIBIT |
 					   CTX_CTRL_ENGINE_CTX_SAVE_INHIBIT);
diff --git a/drivers/gpu/drm/i915/intel_lrc.h b/drivers/gpu/drm/i915/intel_lrc.h
index 636ced41225d..59d7b86012e9 100644
--- a/drivers/gpu/drm/i915/intel_lrc.h
+++ b/drivers/gpu/drm/i915/intel_lrc.h
@@ -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
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index 8f1a4badf812..eb0d0de1ffc2 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -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
-- 
2.16.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/2] drm/i915/icl: new context descriptor support
  2018-02-09 23:28 [PATCH v4 1/2] drm/i915/icl: new context descriptor support Daniele Ceraolo Spurio
  2018-02-09 23:28 ` [PATCH v8 2/2] drm/i915/icl: Enhanced execution list support Daniele Ceraolo Spurio
@ 2018-02-09 23:48 ` Oscar Mateo
  2018-02-10  8:55   ` Chris Wilson
  2018-02-09 23:50 ` ✓ Fi.CI.BAT: success for series starting with [v4,1/2] " Patchwork
  2018-02-10  1:06 ` ✓ Fi.CI.IGT: " Patchwork
  3 siblings, 1 reply; 9+ messages in thread
From: Oscar Mateo @ 2018-02-09 23:48 UTC (permalink / raw)
  To: Daniele Ceraolo Spurio, intel-gfx



On 02/09/2018 03:28 PM, Daniele Ceraolo Spurio wrote:
> From: "Ceraolo Spurio, Daniele" <daniele.ceraolospurio@intel.com>
>
> 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
>
> Cc: Oscar Mateo <oscar.mateo@intel.com>
> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>

Reviewed-by: Oscar Mateo <oscar.mateo@intel.com>

> ---
>   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(-)
>
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index 7db3557b945c..acaa63f8237d 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -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;
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> index 3d75f484f6e5..45b0b78aca3f 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.c
> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> @@ -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 */
> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> index e9c79b560823..bd84e29d5399 100644
> --- a/drivers/gpu/drm/i915/i915_reg.h
> +++ b/drivers/gpu/drm/i915/i915_reg.h
> @@ -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)
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index c2c8380a0121..3305fbba65e9 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -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;
>   }

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* ✓ Fi.CI.BAT: success for series starting with [v4,1/2] drm/i915/icl: new context descriptor support
  2018-02-09 23:28 [PATCH v4 1/2] drm/i915/icl: new context descriptor support Daniele Ceraolo Spurio
  2018-02-09 23:28 ` [PATCH v8 2/2] drm/i915/icl: Enhanced execution list support Daniele Ceraolo Spurio
  2018-02-09 23:48 ` [PATCH v4 1/2] drm/i915/icl: new context descriptor support Oscar Mateo
@ 2018-02-09 23:50 ` Patchwork
  2018-02-10  1:06 ` ✓ Fi.CI.IGT: " Patchwork
  3 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2018-02-09 23:50 UTC (permalink / raw)
  To: Daniele Ceraolo Spurio; +Cc: intel-gfx

== 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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* ✓ Fi.CI.IGT: success for series starting with [v4,1/2] drm/i915/icl: new context descriptor support
  2018-02-09 23:28 [PATCH v4 1/2] drm/i915/icl: new context descriptor support Daniele Ceraolo Spurio
                   ` (2 preceding siblings ...)
  2018-02-09 23:50 ` ✓ Fi.CI.BAT: success for series starting with [v4,1/2] " Patchwork
@ 2018-02-10  1:06 ` Patchwork
  3 siblings, 0 replies; 9+ messages in thread
From: Patchwork @ 2018-02-10  1:06 UTC (permalink / raw)
  To: Daniele Ceraolo Spurio; +Cc: intel-gfx

== 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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/2] drm/i915/icl: new context descriptor support
  2018-02-09 23:48 ` [PATCH v4 1/2] drm/i915/icl: new context descriptor support Oscar Mateo
@ 2018-02-10  8:55   ` Chris Wilson
  2018-02-13 22:39     ` Daniele Ceraolo Spurio
  0 siblings, 1 reply; 9+ messages in thread
From: Chris Wilson @ 2018-02-10  8:55 UTC (permalink / raw)
  To: Oscar Mateo, Daniele Ceraolo Spurio, intel-gfx

Quoting Oscar Mateo (2018-02-09 23:48:38)
> 
> 
> On 02/09/2018 03:28 PM, Daniele Ceraolo Spurio wrote:
> > From: "Ceraolo Spurio, Daniele" <daniele.ceraolospurio@intel.com>
> >
> > 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
> >
> > Cc: Oscar Mateo <oscar.mateo@intel.com>
> > Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
> 
> Reviewed-by: Oscar Mateo <oscar.mateo@intel.com>
> 
> > ---
> >   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(-)
> >
> > diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> > index 7db3557b945c..acaa63f8237d 100644
> > --- a/drivers/gpu/drm/i915/i915_drv.h
> > +++ b/drivers/gpu/drm/i915/i915_drv.h
> > @@ -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;
> > diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
> > index 3d75f484f6e5..45b0b78aca3f 100644
> > --- a/drivers/gpu/drm/i915/i915_gem_context.c
> > +++ b/drivers/gpu/drm/i915/i915_gem_context.c
> > @@ -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 */
> > diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
> > index e9c79b560823..bd84e29d5399 100644
> > --- a/drivers/gpu/drm/i915/i915_reg.h
> > +++ b/drivers/gpu/drm/i915/i915_reg.h
> > @@ -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)
> > diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> > index c2c8380a0121..3305fbba65e9 100644
> > --- a/drivers/gpu/drm/i915/intel_lrc.c
> > +++ b/drivers/gpu/drm/i915/intel_lrc.c
> > @@ -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

Ascending ^

> > + *
> > + * 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 */

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

> >       desc |= i915_ggtt_offset(ce->state) + LRC_HEADER_PAGES * PAGE_SIZE;
> >                                                               /* bits 12-31 */

GEM_BUG_ON(desc & GENMASK_ULL(32, 63);

Ascending ^

> > -     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)); ?

> > +             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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v8 2/2] drm/i915/icl: Enhanced execution list support
  2018-02-09 23:28 ` [PATCH v8 2/2] drm/i915/icl: Enhanced execution list support Daniele Ceraolo Spurio
@ 2018-02-10  9:02   ` Chris Wilson
  0 siblings, 0 replies; 9+ messages in thread
From: Chris Wilson @ 2018-02-10  9:02 UTC (permalink / raw)
  To: Daniele Ceraolo Spurio, intel-gfx; +Cc: Thomas Daniel, Rodrigo Vivi

Quoting Daniele Ceraolo Spurio (2018-02-09 23:28:04)
> From: Thomas Daniel <thomas.daniel@intel.com>
> 
> 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)
> 
> Cc: Chris Wilson <chris@chris-wilson.co.uk>
> Cc: Mika Kuoppala <mika.kuoppala@linux.intel.com>
> Signed-off-by: Thomas Daniel <thomas.daniel@intel.com>
> Signed-off-by: Rodrigo Vivi <rodrigo.vivi@intel.com>
> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>

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

Reviewed-by: Chris Wilson <chris@chris-wilson.co.uk>
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: [PATCH v4 1/2] drm/i915/icl: new context descriptor support
  2018-02-10  8:55   ` Chris Wilson
@ 2018-02-13 22:39     ` Daniele Ceraolo Spurio
  0 siblings, 0 replies; 9+ messages in thread
From: Daniele Ceraolo Spurio @ 2018-02-13 22:39 UTC (permalink / raw)
  To: Chris Wilson, Oscar Mateo, intel-gfx



On 10/02/18 00:55, Chris Wilson wrote:
> Quoting Oscar Mateo (2018-02-09 23:48:38)
>>
>>
>> On 02/09/2018 03:28 PM, Daniele Ceraolo Spurio wrote:
>>> From: "Ceraolo Spurio, Daniele" <daniele.ceraolospurio@intel.com>
>>>
>>> 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
>>>
>>> Cc: Oscar Mateo <oscar.mateo@intel.com>
>>> Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
>>
>> Reviewed-by: Oscar Mateo <oscar.mateo@intel.com>
>>
>>> ---
>>>    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(-)
>>>
>>> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
>>> index 7db3557b945c..acaa63f8237d 100644
>>> --- a/drivers/gpu/drm/i915/i915_drv.h
>>> +++ b/drivers/gpu/drm/i915/i915_drv.h
>>> @@ -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;
>>> diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
>>> index 3d75f484f6e5..45b0b78aca3f 100644
>>> --- a/drivers/gpu/drm/i915/i915_gem_context.c
>>> +++ b/drivers/gpu/drm/i915/i915_gem_context.c
>>> @@ -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 */
>>> diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
>>> index e9c79b560823..bd84e29d5399 100644
>>> --- a/drivers/gpu/drm/i915/i915_reg.h
>>> +++ b/drivers/gpu/drm/i915/i915_reg.h
>>> @@ -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)
>>> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
>>> index c2c8380a0121..3305fbba65e9 100644
>>> --- a/drivers/gpu/drm/i915/intel_lrc.c
>>> +++ b/drivers/gpu/drm/i915/intel_lrc.c
>>> @@ -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
> 
> Ascending ^
> 
>>> + *
>>> + * 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 */
> 
> Should we add GEM_BUG_ON(desc & GENMASK_ULL(12, 63); ?
> 
>>>        desc |= i915_ggtt_offset(ce->state) + LRC_HEADER_PAGES * PAGE_SIZE;
>>>                                                                /* bits 12-31 */
> 
> GEM_BUG_ON(desc & GENMASK_ULL(32, 63);
> 
> Ascending ^
> 
>>> -     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

> 
>>> +             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
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [PATCH v4 1/2] drm/i915/icl: new context descriptor support
@ 2018-01-26 18:31 Daniele Ceraolo Spurio
  0 siblings, 0 replies; 9+ messages in thread
From: Daniele Ceraolo Spurio @ 2018-01-26 18:31 UTC (permalink / raw)
  To: intel-gfx

From: "Ceraolo Spurio, Daniele" <daniele.ceraolospurio@intel.com>

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 (Oscar)

Cc: Oscar Mateo <oscar.mateo@intel.com>
Signed-off-by: Daniele Ceraolo Spurio <daniele.ceraolospurio@intel.com>
---
 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(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 454d8f9..f48a8ee 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2083,6 +2083,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;
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 648e753..dbc50b9 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -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;
 	}
@@ -462,6 +468,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 */
diff --git a/drivers/gpu/drm/i915/i915_reg.h b/drivers/gpu/drm/i915/i915_reg.h
index 64933fd..2e4e6c7 100644
--- a/drivers/gpu/drm/i915/i915_reg.h
+++ b/drivers/gpu/drm/i915/i915_reg.h
@@ -3840,6 +3840,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)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 2fa328d..ac78fc2 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -188,6 +188,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,
@@ -197,11 +209,25 @@ static void execlists_init_reg_state(u32 *reg_state,
 	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;
 }
-- 
1.9.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-02-13 22:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-09 23:28 [PATCH v4 1/2] drm/i915/icl: new context descriptor support Daniele Ceraolo Spurio
2018-02-09 23:28 ` [PATCH v8 2/2] drm/i915/icl: Enhanced execution list support Daniele Ceraolo Spurio
2018-02-10  9:02   ` Chris Wilson
2018-02-09 23:48 ` [PATCH v4 1/2] drm/i915/icl: new context descriptor support Oscar Mateo
2018-02-10  8:55   ` Chris Wilson
2018-02-13 22:39     ` Daniele Ceraolo Spurio
2018-02-09 23:50 ` ✓ Fi.CI.BAT: success for series starting with [v4,1/2] " Patchwork
2018-02-10  1:06 ` ✓ Fi.CI.IGT: " Patchwork
  -- strict thread matches above, loose matches on Subject: below --
2018-01-26 18:31 [PATCH v4 1/2] " Daniele Ceraolo Spurio

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.