All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v8 0/8] drm/i915: per context slice/subslice powergating
@ 2018-05-29 19:16 Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 1/8] drm/i915: Program RPCS for Broadwell Lionel Landwerlin
                   ` (11 more replies)
  0 siblings, 12 replies; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 19:16 UTC (permalink / raw)
  To: intel-gfx

Hi all,

Another iteration that takes into account :

   - Tvrtko's nits from v7 on patch 8

   - Tvrtko's suggestion not to return EPERM when dynamic sseu is
     disabled through sysfs. Instead store the requested value and
     apply it when/if dynamic sseu becomes enabled.

   - A pretty important fix that prevented the MI_SDRI to be applied.
     We were writting into a GGTT offset which didn't work (tests have
     been updated to catch this). To address this, this iteration adds
     patch 6 that creates a view of the context images into the kernel
     context's PPGTT so that we can properly modify them from the
     kernel context.

Many thanks to Chris & Tvrtko for review & discussions.

Cheers,

Chris Wilson (3):
  drm/i915: Program RPCS for Broadwell
  drm/i915: Record the sseu configuration per-context & engine
  drm/i915: Expose RPCS (SSEU) configuration to userspace

Lionel Landwerlin (5):
  drm/i915/perf: simplify configure all context function
  drm/i915/perf: reuse intel_lrc ctx regs macro
  drm/i915/perf: lock powergating configuration to default when active
  drm/i915: create context image vma in kernel context
  drm/i915: add a sysfs entry to let users set sseu configs

 drivers/gpu/drm/i915/i915_drv.h         |  50 ++++++
 drivers/gpu/drm/i915/i915_gem.c         |   2 +
 drivers/gpu/drm/i915/i915_gem_context.c | 216 ++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_gem_context.h |   5 +
 drivers/gpu/drm/i915/i915_perf.c        |  68 ++++----
 drivers/gpu/drm/i915/i915_request.c     |  20 +++
 drivers/gpu/drm/i915/i915_request.h     |  10 ++
 drivers/gpu/drm/i915/i915_sysfs.c       |  40 +++++
 drivers/gpu/drm/i915/intel_lrc.c        | 146 ++++++++++------
 drivers/gpu/drm/i915/intel_lrc.h        |   3 +
 drivers/gpu/drm/i915/intel_ringbuffer.c |   2 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |   4 +
 include/uapi/drm/i915_drm.h             |  43 +++++
 13 files changed, 530 insertions(+), 79 deletions(-)

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

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

* [PATCH v8 1/8] drm/i915: Program RPCS for Broadwell
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
@ 2018-05-29 19:16 ` Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 2/8] drm/i915: Record the sseu configuration per-context & engine Lionel Landwerlin
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 19:16 UTC (permalink / raw)
  To: intel-gfx

From: Chris Wilson <chris@chris-wilson.co.uk>

Currently we only configure the power gating for Skylake and above, but
the configuration should equally apply to Broadwell and Braswell. Even
though, there is not as much variation as for later generations, we want
to expose control over the configuration to userspace and may want to
opt out of the "always-enabled" setting.

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_lrc.c | 7 -------
 1 file changed, 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 8a6058b4102f..05e069a5c836 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -2517,13 +2517,6 @@ make_rpcs(struct drm_i915_private *dev_priv)
 {
 	u32 rpcs = 0;
 
-	/*
-	 * No explicit RPCS request is needed to ensure full
-	 * slice/subslice/EU enablement prior to Gen9.
-	*/
-	if (INTEL_GEN(dev_priv) < 9)
-		return 0;
-
 	/*
 	 * Starting in Gen9, render power gating can leave
 	 * slice/subslice/EU in a partially enabled state. We
-- 
2.17.0

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

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

* [PATCH v8 2/8] drm/i915: Record the sseu configuration per-context & engine
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 1/8] drm/i915: Program RPCS for Broadwell Lionel Landwerlin
@ 2018-05-29 19:16 ` Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 3/8] drm/i915/perf: simplify configure all context function Lionel Landwerlin
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 19:16 UTC (permalink / raw)
  To: intel-gfx

From: Chris Wilson <chris@chris-wilson.co.uk>

We want to expose the ability to reconfigure the slices, subslice and
eu per context and per engine. To facilitate that, store the current
configuration on the context for each engine, which is initially set
to the device default upon creation.

v2: record sseu configuration per context & engine (Chris)

v3: introduce the i915_gem_context_sseu to store powergating
    programming, sseu_dev_info has grown quite a bit (Lionel)

v4: rename i915_gem_sseu into intel_sseu (Chris)
    use to_intel_context() (Chris)

v5: More to_intel_context() (Tvrtko)
    Switch intel_sseu from union to struct (Tvrtko)
    Move context default sseu in existing loop (Chris)

v6: s/intel_sseu_from_device_sseu/intel_device_default_sseu/ (Tvrtko)

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h         | 14 ++++++++++++++
 drivers/gpu/drm/i915/i915_gem_context.c |  2 ++
 drivers/gpu/drm/i915/i915_gem_context.h |  4 ++++
 drivers/gpu/drm/i915/i915_request.h     | 10 ++++++++++
 drivers/gpu/drm/i915/intel_lrc.c        | 22 +++++++++++-----------
 5 files changed, 41 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 487922f88b76..62ababfd39aa 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3427,6 +3427,20 @@ mkwrite_device_info(struct drm_i915_private *dev_priv)
 	return (struct intel_device_info *)&dev_priv->info;
 }
 
+static inline struct intel_sseu
+intel_device_default_sseu(struct drm_i915_private *i915)
+{
+	const struct sseu_dev_info *sseu = &INTEL_INFO(i915)->sseu;
+	struct intel_sseu value = {
+		.slice_mask = sseu->slice_mask,
+		.subslice_mask = sseu->subslice_mask[0],
+		.min_eus_per_subslice = sseu->max_eus_per_subslice,
+		.max_eus_per_subslice = sseu->max_eus_per_subslice,
+	};
+
+	return value;
+}
+
 /* modesetting */
 extern void intel_modeset_init_hw(struct drm_device *dev);
 extern int intel_modeset_init(struct drm_device *dev);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 45393f6e0208..ee2ee6b4e5b0 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -282,6 +282,8 @@ __create_hw_context(struct drm_i915_private *dev_priv,
 		struct intel_context *ce = &ctx->__engine[n];
 
 		ce->gem_context = ctx;
+		/* Use the whole device by default */
+		ce->sseu = intel_device_default_sseu(dev_priv);
 	}
 
 	INIT_RADIX_TREE(&ctx->handles_vma, GFP_KERNEL);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.h b/drivers/gpu/drm/i915/i915_gem_context.h
index b116e4942c10..f40d85448a28 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.h
+++ b/drivers/gpu/drm/i915/i915_gem_context.h
@@ -31,6 +31,7 @@
 
 #include "i915_gem.h"
 #include "i915_scheduler.h"
+#include "intel_device_info.h"
 
 struct pid;
 
@@ -160,6 +161,9 @@ struct i915_gem_context {
 		int pin_count;
 
 		const struct intel_context_ops *ops;
+
+		/** sseu: Control eu/slice partitioning */
+		struct intel_sseu sseu;
 	} __engine[I915_NUM_ENGINES];
 
 	/** ring_size: size for allocating the per-engine ring buffer */
diff --git a/drivers/gpu/drm/i915/i915_request.h b/drivers/gpu/drm/i915/i915_request.h
index 1bbbb7a9fa03..82c5dd153bfd 100644
--- a/drivers/gpu/drm/i915/i915_request.h
+++ b/drivers/gpu/drm/i915/i915_request.h
@@ -39,6 +39,16 @@ struct drm_i915_gem_object;
 struct i915_request;
 struct i915_timeline;
 
+/*
+ * Powergating configuration for a particular (context,engine).
+ */
+struct intel_sseu {
+	u8 slice_mask;
+	u8 subslice_mask;
+	u8 min_eus_per_subslice;
+	u8 max_eus_per_subslice;
+};
+
 struct intel_wait {
 	struct rb_node node;
 	struct task_struct *tsk;
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 05e069a5c836..8bac0483e784 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -2512,8 +2512,8 @@ int logical_xcs_ring_init(struct intel_engine_cs *engine)
 	return logical_ring_init(engine);
 }
 
-static u32
-make_rpcs(struct drm_i915_private *dev_priv)
+static u32 make_rpcs(const struct sseu_dev_info *sseu,
+		     struct intel_sseu ctx_sseu)
 {
 	u32 rpcs = 0;
 
@@ -2523,24 +2523,23 @@ make_rpcs(struct drm_i915_private *dev_priv)
 	 * must make an explicit request through RPCS for full
 	 * enablement.
 	*/
-	if (INTEL_INFO(dev_priv)->sseu.has_slice_pg) {
+	if (sseu->has_slice_pg) {
 		rpcs |= GEN8_RPCS_S_CNT_ENABLE;
-		rpcs |= hweight8(INTEL_INFO(dev_priv)->sseu.slice_mask) <<
-			GEN8_RPCS_S_CNT_SHIFT;
+		rpcs |= hweight8(ctx_sseu.slice_mask) << GEN8_RPCS_S_CNT_SHIFT;
 		rpcs |= GEN8_RPCS_ENABLE;
 	}
 
-	if (INTEL_INFO(dev_priv)->sseu.has_subslice_pg) {
+	if (sseu->has_subslice_pg) {
 		rpcs |= GEN8_RPCS_SS_CNT_ENABLE;
-		rpcs |= hweight8(INTEL_INFO(dev_priv)->sseu.subslice_mask[0]) <<
+		rpcs |= hweight8(ctx_sseu.subslice_mask) <<
 			GEN8_RPCS_SS_CNT_SHIFT;
 		rpcs |= GEN8_RPCS_ENABLE;
 	}
 
-	if (INTEL_INFO(dev_priv)->sseu.has_eu_pg) {
-		rpcs |= INTEL_INFO(dev_priv)->sseu.eu_per_subslice <<
+	if (sseu->has_eu_pg) {
+		rpcs |= ctx_sseu.min_eus_per_subslice <<
 			GEN8_RPCS_EU_MIN_SHIFT;
-		rpcs |= INTEL_INFO(dev_priv)->sseu.eu_per_subslice <<
+		rpcs |= ctx_sseu.max_eus_per_subslice <<
 			GEN8_RPCS_EU_MAX_SHIFT;
 		rpcs |= GEN8_RPCS_ENABLE;
 	}
@@ -2664,7 +2663,8 @@ static void execlists_init_reg_state(u32 *regs,
 	if (rcs) {
 		regs[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1);
 		CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
-			make_rpcs(dev_priv));
+			make_rpcs(&INTEL_INFO(dev_priv)->sseu,
+				  to_intel_context(ctx, engine)->sseu));
 
 		i915_oa_init_reg_state(engine, ctx, regs);
 	}
-- 
2.17.0

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

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

* [PATCH v8 3/8] drm/i915/perf: simplify configure all context function
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 1/8] drm/i915: Program RPCS for Broadwell Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 2/8] drm/i915: Record the sseu configuration per-context & engine Lionel Landwerlin
@ 2018-05-29 19:16 ` Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 4/8] drm/i915/perf: reuse intel_lrc ctx regs macro Lionel Landwerlin
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 19:16 UTC (permalink / raw)
  To: intel-gfx

We don't need any special treatment on error so just return as soon as
possible.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_perf.c | 11 ++++-------
 1 file changed, 4 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 4f0eb84b3c00..805dfc732bba 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -1762,7 +1762,7 @@ static int gen8_configure_all_contexts(struct drm_i915_private *dev_priv,
 	/* Switch away from any user context. */
 	ret = gen8_switch_to_updated_kernel_context(dev_priv, oa_config);
 	if (ret)
-		goto out;
+		return ret;
 
 	/*
 	 * The OA register config is setup through the context image. This image
@@ -1779,7 +1779,7 @@ static int gen8_configure_all_contexts(struct drm_i915_private *dev_priv,
 	 */
 	ret = i915_gem_wait_for_idle(dev_priv, wait_flags);
 	if (ret)
-		goto out;
+		return ret;
 
 	/* Update all contexts now that we've stalled the submission. */
 	list_for_each_entry(ctx, &dev_priv->contexts.list, link) {
@@ -1791,10 +1791,8 @@ static int gen8_configure_all_contexts(struct drm_i915_private *dev_priv,
 			continue;
 
 		regs = i915_gem_object_pin_map(ce->state->obj, I915_MAP_WB);
-		if (IS_ERR(regs)) {
-			ret = PTR_ERR(regs);
-			goto out;
-		}
+		if (IS_ERR(regs))
+			return PTR_ERR(regs);
 
 		ce->state->obj->mm.dirty = true;
 		regs += LRC_STATE_PN * PAGE_SIZE / sizeof(*regs);
@@ -1804,7 +1802,6 @@ static int gen8_configure_all_contexts(struct drm_i915_private *dev_priv,
 		i915_gem_object_unpin_map(ce->state->obj);
 	}
 
- out:
 	return ret;
 }
 
-- 
2.17.0

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

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

* [PATCH v8 4/8] drm/i915/perf: reuse intel_lrc ctx regs macro
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
                   ` (2 preceding siblings ...)
  2018-05-29 19:16 ` [PATCH v8 3/8] drm/i915/perf: simplify configure all context function Lionel Landwerlin
@ 2018-05-29 19:16 ` Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 5/8] drm/i915/perf: lock powergating configuration to default when active Lionel Landwerlin
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 19:16 UTC (permalink / raw)
  To: intel-gfx

Abstract the context image access a bit.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
Reviewed-by: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
---
 drivers/gpu/drm/i915/i915_perf.c | 34 +++++++++++++++-----------------
 1 file changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index 805dfc732bba..a5d98bda5c2e 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -210,6 +210,7 @@
 #include "i915_oa_cflgt3.h"
 #include "i915_oa_cnl.h"
 #include "i915_oa_icl.h"
+#include "intel_lrc_reg.h"
 
 /* HW requires this to be a power of two, between 128k and 16M, though driver
  * is currently generally designed assuming the largest 16M size is used such
@@ -1579,27 +1580,25 @@ static void gen8_update_reg_state_unlocked(struct i915_gem_context *ctx,
 	u32 ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset;
 	u32 ctx_flexeu0 = dev_priv->perf.oa.ctx_flexeu0_offset;
 	/* The MMIO offsets for Flex EU registers aren't contiguous */
-	u32 flex_mmio[] = {
-		i915_mmio_reg_offset(EU_PERF_CNTL0),
-		i915_mmio_reg_offset(EU_PERF_CNTL1),
-		i915_mmio_reg_offset(EU_PERF_CNTL2),
-		i915_mmio_reg_offset(EU_PERF_CNTL3),
-		i915_mmio_reg_offset(EU_PERF_CNTL4),
-		i915_mmio_reg_offset(EU_PERF_CNTL5),
-		i915_mmio_reg_offset(EU_PERF_CNTL6),
+	i915_reg_t flex_regs[] = {
+		EU_PERF_CNTL0,
+		EU_PERF_CNTL1,
+		EU_PERF_CNTL2,
+		EU_PERF_CNTL3,
+		EU_PERF_CNTL4,
+		EU_PERF_CNTL5,
+		EU_PERF_CNTL6,
 	};
 	int i;
 
-	reg_state[ctx_oactxctrl] = i915_mmio_reg_offset(GEN8_OACTXCONTROL);
-	reg_state[ctx_oactxctrl+1] = (dev_priv->perf.oa.period_exponent <<
-				      GEN8_OA_TIMER_PERIOD_SHIFT) |
-				     (dev_priv->perf.oa.periodic ?
-				      GEN8_OA_TIMER_ENABLE : 0) |
-				     GEN8_OA_COUNTER_RESUME;
+	CTX_REG(reg_state, ctx_oactxctrl, GEN8_OACTXCONTROL,
+		(dev_priv->perf.oa.period_exponent << GEN8_OA_TIMER_PERIOD_SHIFT) |
+		(dev_priv->perf.oa.periodic ? GEN8_OA_TIMER_ENABLE : 0) |
+		GEN8_OA_COUNTER_RESUME);
 
-	for (i = 0; i < ARRAY_SIZE(flex_mmio); i++) {
+	for (i = 0; i < ARRAY_SIZE(flex_regs); i++) {
 		u32 state_offset = ctx_flexeu0 + i * 2;
-		u32 mmio = flex_mmio[i];
+		u32 mmio = i915_mmio_reg_offset(flex_regs[i]);
 
 		/*
 		 * This arbitrary default will select the 'EU FPU0 Pipeline
@@ -1619,8 +1618,7 @@ static void gen8_update_reg_state_unlocked(struct i915_gem_context *ctx,
 			}
 		}
 
-		reg_state[state_offset] = mmio;
-		reg_state[state_offset+1] = value;
+		CTX_REG(reg_state, state_offset, flex_regs[i], value);
 	}
 }
 
-- 
2.17.0

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

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

* [PATCH v8 5/8] drm/i915/perf: lock powergating configuration to default when active
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
                   ` (3 preceding siblings ...)
  2018-05-29 19:16 ` [PATCH v8 4/8] drm/i915/perf: reuse intel_lrc ctx regs macro Lionel Landwerlin
@ 2018-05-29 19:16 ` Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 6/8] drm/i915: create context image vma in kernel context Lionel Landwerlin
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 19:16 UTC (permalink / raw)
  To: intel-gfx

If some of the contexts submitting workloads to the GPU have been
configured to shutdown slices/subslices, we might loose the NOA
configurations written in the NOA muxes.

One possible solution to this problem is to reprogram the NOA muxes
when we switch to a new context. We initially tried this in the
workaround batchbuffer but some concerns where raised about the cost
of reprogramming at every context switch. This solution is also not
without consequences from the userspace point of view. Reprogramming
of the muxes can only happen once the powergating configuration has
changed (which happens after context switch). This means for a window
of time during the recording, counters recorded by the OA unit might
be invalid. This requires userspace dealing with OA reports to discard
the invalid values.

Minimizing the reprogramming could be implemented by tracking of the
last programmed configuration somewhere in GGTT and use MI_PREDICATE
to discard some of the programming commands, but the command streamer
would still have to parse all the MI_LRI instructions in the
workaround batchbuffer.

Another solution, which this change implements, is to simply disregard
the user requested configuration for the period of time when i915/perf
is active. There is no known issue with this apart from a performance
penality for some media workloads that benefit from running on a
partially powergated GPU. We already prevent RC6 from affecting the
programming so it doesn't sound completely unreasonable to hold on
powergating for the same reason.

v2: Leave RPCS programming in intel_lrc.c (Lionel)

v3: Update for s/union intel_sseu/struct intel_sseu/ (Lionel)
    More to_intel_context() (Tvrtko)
    s/dev_priv/i915/ (Tvrtko)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h  | 15 +++++++++++++++
 drivers/gpu/drm/i915/i915_perf.c | 23 ++++++++++++++++++-----
 drivers/gpu/drm/i915/intel_lrc.c | 11 +++++++----
 drivers/gpu/drm/i915/intel_lrc.h |  3 +++
 4 files changed, 43 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 62ababfd39aa..25ffadfcd04b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3839,4 +3839,19 @@ static inline int intel_hws_csb_write_index(struct drm_i915_private *i915)
 		return I915_HWS_CSB_WRITE_INDEX;
 }
 
+static inline struct intel_sseu
+intel_engine_prepare_sseu(struct intel_engine_cs *engine,
+			  struct intel_sseu sseu)
+{
+	struct drm_i915_private *i915 = engine->i915;
+
+	/*
+	 * If i915/perf is active, we want a stable powergating configuration
+	 * on the system. The most natural configuration to take in that case
+	 * is the default (i.e maximum the hardware can do).
+	 */
+	return i915->perf.oa.exclusive_stream ?
+		intel_device_default_sseu(i915) : sseu;
+}
+
 #endif
diff --git a/drivers/gpu/drm/i915/i915_perf.c b/drivers/gpu/drm/i915/i915_perf.c
index a5d98bda5c2e..4a62024cbf85 100644
--- a/drivers/gpu/drm/i915/i915_perf.c
+++ b/drivers/gpu/drm/i915/i915_perf.c
@@ -1574,7 +1574,8 @@ static void hsw_disable_metric_set(struct drm_i915_private *dev_priv)
  */
 static void gen8_update_reg_state_unlocked(struct i915_gem_context *ctx,
 					   u32 *reg_state,
-					   const struct i915_oa_config *oa_config)
+					   const struct i915_oa_config *oa_config,
+					   struct intel_sseu sseu)
 {
 	struct drm_i915_private *dev_priv = ctx->i915;
 	u32 ctx_oactxctrl = dev_priv->perf.oa.ctx_oactxctrl_offset;
@@ -1620,6 +1621,9 @@ static void gen8_update_reg_state_unlocked(struct i915_gem_context *ctx,
 
 		CTX_REG(reg_state, state_offset, flex_regs[i], value);
 	}
+
+	CTX_REG(reg_state, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
+		gen8_make_rpcs(&INTEL_INFO(dev_priv)->sseu, sseu));
 }
 
 /*
@@ -1750,6 +1754,7 @@ static int gen8_switch_to_updated_kernel_context(struct drm_i915_private *dev_pr
 static int gen8_configure_all_contexts(struct drm_i915_private *dev_priv,
 				       const struct i915_oa_config *oa_config)
 {
+	struct intel_sseu default_sseu = intel_device_default_sseu(dev_priv);
 	struct intel_engine_cs *engine = dev_priv->engine[RCS];
 	struct i915_gem_context *ctx;
 	int ret;
@@ -1795,7 +1800,8 @@ static int gen8_configure_all_contexts(struct drm_i915_private *dev_priv,
 		ce->state->obj->mm.dirty = true;
 		regs += LRC_STATE_PN * PAGE_SIZE / sizeof(*regs);
 
-		gen8_update_reg_state_unlocked(ctx, regs, oa_config);
+		gen8_update_reg_state_unlocked(ctx, regs, oa_config,
+					       oa_config ? default_sseu : ce->sseu);
 
 		i915_gem_object_unpin_map(ce->state->obj);
 	}
@@ -2167,14 +2173,21 @@ void i915_oa_init_reg_state(struct intel_engine_cs *engine,
 			    struct i915_gem_context *ctx,
 			    u32 *reg_state)
 {
+	struct drm_i915_private *i915 = engine->i915;
 	struct i915_perf_stream *stream;
 
 	if (engine->id != RCS)
 		return;
 
-	stream = engine->i915->perf.oa.exclusive_stream;
-	if (stream)
-		gen8_update_reg_state_unlocked(ctx, reg_state, stream->oa_config);
+	stream = i915->perf.oa.exclusive_stream;
+	if (stream) {
+		struct intel_sseu default_sseu =
+			intel_device_default_sseu(i915);
+
+		gen8_update_reg_state_unlocked(ctx, reg_state,
+					       stream->oa_config,
+					       default_sseu);
+	}
 }
 
 /**
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 8bac0483e784..7314e548fb4e 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -2512,8 +2512,8 @@ int logical_xcs_ring_init(struct intel_engine_cs *engine)
 	return logical_ring_init(engine);
 }
 
-static u32 make_rpcs(const struct sseu_dev_info *sseu,
-		     struct intel_sseu ctx_sseu)
+u32 gen8_make_rpcs(const struct sseu_dev_info *sseu,
+		   struct intel_sseu ctx_sseu)
 {
 	u32 rpcs = 0;
 
@@ -2661,10 +2661,13 @@ static void execlists_init_reg_state(u32 *regs,
 	}
 
 	if (rcs) {
+		struct intel_sseu sseu = to_intel_context(ctx, engine)->sseu;
+
 		regs[CTX_LRI_HEADER_2] = MI_LOAD_REGISTER_IMM(1);
 		CTX_REG(regs, CTX_R_PWR_CLK_STATE, GEN8_R_PWR_CLK_STATE,
-			make_rpcs(&INTEL_INFO(dev_priv)->sseu,
-				  to_intel_context(ctx, engine)->sseu));
+			gen8_make_rpcs(&INTEL_INFO(dev_priv)->sseu,
+				       intel_engine_prepare_sseu(engine,
+								 sseu)));
 
 		i915_oa_init_reg_state(engine, ctx, regs);
 	}
diff --git a/drivers/gpu/drm/i915/intel_lrc.h b/drivers/gpu/drm/i915/intel_lrc.h
index 1593194e930c..6e6b2df95780 100644
--- a/drivers/gpu/drm/i915/intel_lrc.h
+++ b/drivers/gpu/drm/i915/intel_lrc.h
@@ -104,4 +104,7 @@ struct i915_gem_context;
 
 void intel_lr_context_resume(struct drm_i915_private *dev_priv);
 
+u32 gen8_make_rpcs(const struct sseu_dev_info *sseu,
+		   struct intel_sseu ctx_sseu);
+
 #endif /* _INTEL_LRC_H_ */
-- 
2.17.0

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

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

* [PATCH v8 6/8] drm/i915: create context image vma in kernel context
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
                   ` (4 preceding siblings ...)
  2018-05-29 19:16 ` [PATCH v8 5/8] drm/i915/perf: lock powergating configuration to default when active Lionel Landwerlin
@ 2018-05-29 19:16 ` Lionel Landwerlin
  2018-05-29 20:26   ` Michel Thierry
  2018-05-29 19:16 ` [PATCH v8 7/8] drm/i915: Expose RPCS (SSEU) configuration to userspace Lionel Landwerlin
                   ` (5 subsequent siblings)
  11 siblings, 1 reply; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 19:16 UTC (permalink / raw)
  To: intel-gfx

We want to be able to modify other context images from the kernel
context in a following commit. To be able to do this we need to map
the context image into the kernel context's ppgtt.

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 drivers/gpu/drm/i915/i915_gem_context.h |  1 +
 drivers/gpu/drm/i915/intel_lrc.c        | 19 ++++++++++++++-----
 2 files changed, 15 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_gem_context.h b/drivers/gpu/drm/i915/i915_gem_context.h
index f40d85448a28..9c313c2edb09 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.h
+++ b/drivers/gpu/drm/i915/i915_gem_context.h
@@ -155,6 +155,7 @@ struct i915_gem_context {
 	struct intel_context {
 		struct i915_gem_context *gem_context;
 		struct i915_vma *state;
+		struct i915_vma *kernel_state; /**/
 		struct intel_ring *ring;
 		u32 *lrc_reg_state;
 		u64 lrc_desc;
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 7314e548fb4e..8a49323f6672 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -2739,7 +2739,7 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
 					    struct intel_context *ce)
 {
 	struct drm_i915_gem_object *ctx_obj;
-	struct i915_vma *vma;
+	struct i915_vma *ggtt_vma, *ppgtt_vma;
 	uint32_t context_size;
 	struct intel_ring *ring;
 	struct i915_timeline *timeline;
@@ -2762,9 +2762,17 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
 		goto error_deref_obj;
 	}
 
-	vma = i915_vma_instance(ctx_obj, &ctx->i915->ggtt.base, NULL);
-	if (IS_ERR(vma)) {
-		ret = PTR_ERR(vma);
+	ggtt_vma = i915_vma_instance(ctx_obj, &ctx->i915->ggtt.base, NULL);
+	if (IS_ERR(ggtt_vma)) {
+		ret = PTR_ERR(ggtt_vma);
+		goto error_deref_obj;
+	}
+
+	ppgtt_vma = i915_vma_instance(ctx_obj,
+				      &ctx->i915->kernel_context->ppgtt->base,
+				      NULL);
+	if (IS_ERR(ppgtt_vma)) {
+		ret = PTR_ERR(ppgtt_vma);
 		goto error_deref_obj;
 	}
 
@@ -2788,7 +2796,8 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
 	}
 
 	ce->ring = ring;
-	ce->state = vma;
+	ce->state = ggtt_vma;
+	ce->kernel_state = ppgtt_vma;
 
 	return 0;
 
-- 
2.17.0

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

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

* [PATCH v8 7/8] drm/i915: Expose RPCS (SSEU) configuration to userspace
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
                   ` (5 preceding siblings ...)
  2018-05-29 19:16 ` [PATCH v8 6/8] drm/i915: create context image vma in kernel context Lionel Landwerlin
@ 2018-05-29 19:16 ` Lionel Landwerlin
  2018-05-29 19:16 ` [PATCH v8 8/8] drm/i915: add a sysfs entry to let users set sseu configs Lionel Landwerlin
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 19:16 UTC (permalink / raw)
  To: intel-gfx

From: Chris Wilson <chris@chris-wilson.co.uk>

We want to allow userspace to reconfigure the subslice configuration for
its own use case. To do so, we expose a context parameter to allow
adjustment of the RPCS register stored within the context image (and
currently not accessible via LRI). If the context is adjusted before
first use, the adjustment is for "free"; otherwise if the context is
active we flush the context off the GPU (stalling all users) and forcing
the GPU to save the context to memory where we can modify it and so
ensure that the register is reloaded on next execution.

The overhead of managing additional EU subslices can be significant,
especially in multi-context workloads. Non-GPGPU contexts should
preferably disable the subslices it is not using, and others should
fine-tune the number to match their workload.

We expose complete control over the RPCS register, allowing
configuration of slice/subslice, via masks packed into a u64 for
simplicity. For example,

	struct drm_i915_gem_context_param arg;
	struct drm_i915_gem_context_param_sseu sseu = { .class = 0,
	                                                .instance = 0, };

	memset(&arg, 0, sizeof(arg));
	arg.ctx_id = ctx;
	arg.param = I915_CONTEXT_PARAM_SSEU;
	arg.value = (uintptr_t) &sseu;
	if (drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_GETPARAM, &arg) == 0) {
		sseu.packed.subslice_mask = 0;

		drmIoctl(fd, DRM_IOCTL_I915_GEM_CONTEXT_SETPARAM, &arg);
	}

could be used to disable all subslices where supported.

v2: Fix offset of CTX_R_PWR_CLK_STATE in intel_lr_context_set_sseu() (Lionel)

v3: Add ability to program this per engine (Chris)

v4: Move most get_sseu() into i915_gem_context.c (Lionel)

v5: Validate sseu configuration against the device's capabilities (Lionel)

v6: Change context powergating settings through MI_SDM on kernel context (Chris)

v7: Synchronize the requests following a powergating setting change using a global
    dependency (Chris)
    Iterate timelines through dev_priv.gt.active_rings (Tvrtko)
    Disable RPCS configuration setting for non capable users (Lionel/Tvrtko)

v8: s/union intel_sseu/struct intel_sseu/ (Lionel)
    s/dev_priv/i915/ (Tvrtko)
    Change uapi class/instance fields to u16 (Tvrtko)
    Bump mask fields to 64bits (Lionel)
    Don't return EPERM when dynamic sseu is disabled (Tvrtko)

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100899
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
c: Dmitry Rogozhkin <dmitry.v.rogozhkin@intel.com>
CC: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
CC: Zhipeng Gong <zhipeng.gong@intel.com>
CC: Joonas Lahtinen <joonas.lahtinen@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h         |  13 ++
 drivers/gpu/drm/i915/i915_gem.c         |   2 +
 drivers/gpu/drm/i915/i915_gem_context.c | 176 ++++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_request.c     |  20 +++
 drivers/gpu/drm/i915/intel_lrc.c        | 113 ++++++++++-----
 drivers/gpu/drm/i915/intel_ringbuffer.c |   2 +
 drivers/gpu/drm/i915/intel_ringbuffer.h |   4 +
 include/uapi/drm/i915_drm.h             |  43 ++++++
 8 files changed, 338 insertions(+), 35 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 25ffadfcd04b..b2386c37437d 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -2066,6 +2066,12 @@ struct drm_i915_private {
 		u32 active_requests;
 		u32 request_serial;
 
+		/**
+		 * Global barrier to ensuring ordering of sseu transitions
+		 * requests.
+		 */
+		struct i915_gem_active global_barrier;
+
 		/**
 		 * Is the GPU currently considered idle, or busy executing
 		 * userspace requests? Whilst idle, we allow runtime power
@@ -3212,6 +3218,13 @@ i915_vm_to_ppgtt(struct i915_address_space *vm)
 	return container_of(vm, struct i915_hw_ppgtt, base);
 }
 
+static inline void i915_gem_set_global_barrier(struct drm_i915_private *i915,
+					       struct i915_request *rq)
+{
+	lockdep_assert_held(&i915->drm.struct_mutex);
+	i915_gem_active_set(&i915->gt.global_barrier, rq);
+}
+
 /* i915_gem_fence_reg.c */
 struct drm_i915_fence_reg *
 i915_reserve_fence(struct drm_i915_private *dev_priv);
diff --git a/drivers/gpu/drm/i915/i915_gem.c b/drivers/gpu/drm/i915/i915_gem.c
index 05f44ca35a06..3872e4235258 100644
--- a/drivers/gpu/drm/i915/i915_gem.c
+++ b/drivers/gpu/drm/i915/i915_gem.c
@@ -5555,6 +5555,8 @@ int i915_gem_init_early(struct drm_i915_private *dev_priv)
 	if (!dev_priv->priorities)
 		goto err_dependencies;
 
+	init_request_active(&dev_priv->gt.global_barrier, NULL);
+
 	INIT_LIST_HEAD(&dev_priv->gt.timelines);
 	INIT_LIST_HEAD(&dev_priv->gt.active_rings);
 	INIT_LIST_HEAD(&dev_priv->gt.closed_vma);
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index ee2ee6b4e5b0..79029815c21f 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -781,6 +781,79 @@ int i915_gem_context_destroy_ioctl(struct drm_device *dev, void *data,
 	return 0;
 }
 
+static int
+intel_sseu_from_user_sseu(const struct sseu_dev_info *sseu,
+			  const struct drm_i915_gem_context_param_sseu *user_sseu,
+			  struct intel_sseu *ctx_sseu)
+{
+	if ((user_sseu->slice_mask & ~sseu->slice_mask) != 0 ||
+	    user_sseu->slice_mask == 0)
+		return -EINVAL;
+
+	if ((user_sseu->subslice_mask & ~sseu->subslice_mask[0]) != 0 ||
+	    user_sseu->subslice_mask == 0)
+		return -EINVAL;
+
+	if (user_sseu->min_eus_per_subslice > sseu->max_eus_per_subslice)
+		return -EINVAL;
+
+	if (user_sseu->max_eus_per_subslice > sseu->max_eus_per_subslice ||
+	    user_sseu->max_eus_per_subslice < user_sseu->min_eus_per_subslice ||
+	    user_sseu->max_eus_per_subslice == 0)
+		return -EINVAL;
+
+	ctx_sseu->slice_mask = user_sseu->slice_mask;
+	ctx_sseu->subslice_mask = user_sseu->subslice_mask;
+	ctx_sseu->min_eus_per_subslice = user_sseu->min_eus_per_subslice;
+	ctx_sseu->max_eus_per_subslice = user_sseu->max_eus_per_subslice;
+
+	return 0;
+}
+
+static int
+i915_gem_context_reconfigure_sseu(struct i915_gem_context *ctx,
+				  struct intel_engine_cs *engine,
+				  struct intel_sseu sseu)
+{
+	struct drm_i915_private *i915 = ctx->i915;
+	struct i915_request *rq;
+	struct intel_ring *ring;
+	int ret;
+
+	lockdep_assert_held(&i915->drm.struct_mutex);
+
+	i915_retire_requests(i915);
+
+	/* Now use the RCS to actually reconfigure. */
+	engine = i915->engine[RCS];
+
+	rq = i915_request_alloc(engine, i915->kernel_context);
+	if (IS_ERR(rq))
+		return PTR_ERR(rq);
+
+	ret = engine->emit_rpcs_config(rq, ctx, sseu);
+	if (ret) {
+		__i915_request_add(rq, true);
+		return ret;
+	}
+
+	/* Queue this switch after all other activity */
+	list_for_each_entry(ring, &i915->gt.active_rings, active_link) {
+		struct i915_request *prev;
+
+		prev = last_request_on_engine(ring->timeline, engine);
+		if (prev)
+			i915_sw_fence_await_sw_fence_gfp(&rq->submit,
+							 &prev->submit,
+							 I915_FENCE_GFP);
+	}
+
+	i915_gem_set_global_barrier(i915, rq);
+	__i915_request_add(rq, true);
+
+	return 0;
+}
+
 int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,
 				    struct drm_file *file)
 {
@@ -818,6 +891,46 @@ int i915_gem_context_getparam_ioctl(struct drm_device *dev, void *data,
 	case I915_CONTEXT_PARAM_PRIORITY:
 		args->value = ctx->sched.priority;
 		break;
+	case I915_CONTEXT_PARAM_SSEU:
+		{
+			struct drm_i915_gem_context_param_sseu user_sseu;
+			struct intel_engine_cs *engine;
+			struct intel_context *ce;
+
+			if (copy_from_user(&user_sseu,
+					   u64_to_user_ptr(args->value),
+					   sizeof(user_sseu))) {
+				ret = -EFAULT;
+				break;
+			}
+
+			if (user_sseu.rsvd1 != 0 || user_sseu.rsvd2 != 0) {
+				ret = -EINVAL;
+				break;
+			}
+
+			engine = intel_engine_lookup_user(to_i915(dev),
+							  user_sseu.class,
+							  user_sseu.instance);
+			if (!engine) {
+				ret = -EINVAL;
+				break;
+			}
+
+			ce = to_intel_context(ctx, engine);
+
+			user_sseu.slice_mask = ce->sseu.slice_mask;
+			user_sseu.subslice_mask = ce->sseu.subslice_mask;
+			user_sseu.min_eus_per_subslice =
+				ce->sseu.min_eus_per_subslice;
+			user_sseu.max_eus_per_subslice =
+				ce->sseu.max_eus_per_subslice;
+
+			if (copy_to_user(u64_to_user_ptr(args->value),
+					 &user_sseu, sizeof(user_sseu)))
+				ret = -EFAULT;
+			break;
+		}
 	default:
 		ret = -EINVAL;
 		break;
@@ -892,7 +1005,70 @@ int i915_gem_context_setparam_ioctl(struct drm_device *dev, void *data,
 				ctx->sched.priority = priority;
 		}
 		break;
+	case I915_CONTEXT_PARAM_SSEU:
+		{
+			struct drm_i915_private *i915 = to_i915(dev);
+			struct drm_i915_gem_context_param_sseu user_sseu;
+			struct intel_engine_cs *engine;
+			struct intel_sseu ctx_sseu;
+			enum intel_engine_id id;
+
+			if (args->size) {
+				ret = -EINVAL;
+				break;
+			}
+
+			if (copy_from_user(&user_sseu, u64_to_user_ptr(args->value),
+					   sizeof(user_sseu))) {
+				ret = -EFAULT;
+				break;
+			}
 
+			if (user_sseu.rsvd1 != 0 || user_sseu.rsvd2 != 0) {
+				ret = -EINVAL;
+				break;
+			}
+
+			engine = intel_engine_lookup_user(i915,
+							  user_sseu.class,
+							  user_sseu.instance);
+			if (!engine) {
+				ret = -EINVAL;
+				break;
+			}
+
+			if (!engine->emit_rpcs_config) {
+				ret = -ENODEV;
+				break;
+			}
+
+			ret = intel_sseu_from_user_sseu(&INTEL_INFO(i915)->sseu,
+							&user_sseu, &ctx_sseu);
+			if (ret)
+				break;
+
+			if (memcmp(&to_intel_context(ctx, engine)->sseu,
+				   &ctx_sseu, sizeof(ctx_sseu)) != 0) {
+				DRM_ERROR("reconfiguring ctx=%p\n", ctx);
+				ret = i915_gem_context_reconfigure_sseu(ctx,
+									engine,
+									ctx_sseu);
+				if (ret)
+					break;
+			}
+
+			/*
+			 * Apply the configuration to all engine. Our hardware
+			 * doesn't currently support different configurations
+			 * for each engine.
+			 */
+			for_each_engine(engine, i915, id) {
+				struct intel_context *ce = to_intel_context(ctx, engine);
+
+				ce->sseu = ctx_sseu;
+			}
+		}
+		break;
 	default:
 		ret = -EINVAL;
 		break;
diff --git a/drivers/gpu/drm/i915/i915_request.c b/drivers/gpu/drm/i915/i915_request.c
index f187250e60c6..aa2ec0de1cb1 100644
--- a/drivers/gpu/drm/i915/i915_request.c
+++ b/drivers/gpu/drm/i915/i915_request.c
@@ -644,6 +644,22 @@ submit_notify(struct i915_sw_fence *fence, enum i915_sw_fence_notify state)
 	return NOTIFY_DONE;
 }
 
+static int
+i915_request_await_request(struct i915_request *to, struct i915_request *from);
+
+static int add_global_barrier(struct i915_request *rq)
+{
+	struct i915_request *barrier;
+	int ret = 0;
+
+	barrier = i915_gem_active_raw(&rq->i915->gt.global_barrier,
+				      &rq->i915->drm.struct_mutex);
+	if (barrier)
+		ret = i915_request_await_request(rq, barrier);
+
+	return ret;
+}
+
 /**
  * i915_request_alloc - allocate a request structure
  *
@@ -805,6 +821,10 @@ i915_request_alloc(struct intel_engine_cs *engine, struct i915_gem_context *ctx)
 	 */
 	rq->head = rq->ring->emit;
 
+	ret = add_global_barrier(rq);
+	if (ret)
+		goto err_unwind;
+
 	/* Unconditionally invalidate GPU caches and TLBs. */
 	ret = engine->emit_flush(rq, EMIT_INVALIDATE);
 	if (ret)
diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
index 8a49323f6672..dc9929e5ebdc 100644
--- a/drivers/gpu/drm/i915/intel_lrc.c
+++ b/drivers/gpu/drm/i915/intel_lrc.c
@@ -2271,6 +2271,82 @@ static void gen8_emit_breadcrumb_rcs(struct i915_request *request, u32 *cs)
 }
 static const int gen8_emit_breadcrumb_rcs_sz = 8 + WA_TAIL_DWORDS;
 
+u32 gen8_make_rpcs(const struct sseu_dev_info *sseu,
+		   struct intel_sseu ctx_sseu)
+{
+	u32 rpcs = 0;
+
+	/*
+	 * Starting in Gen9, render power gating can leave
+	 * slice/subslice/EU in a partially enabled state. We
+	 * must make an explicit request through RPCS for full
+	 * enablement.
+	 */
+	if (sseu->has_slice_pg) {
+		rpcs |= GEN8_RPCS_S_CNT_ENABLE;
+		rpcs |= hweight8(ctx_sseu.slice_mask) << GEN8_RPCS_S_CNT_SHIFT;
+		rpcs |= GEN8_RPCS_ENABLE;
+	}
+
+	if (sseu->has_subslice_pg) {
+		rpcs |= GEN8_RPCS_SS_CNT_ENABLE;
+		rpcs |= hweight8(ctx_sseu.subslice_mask) <<
+			GEN8_RPCS_SS_CNT_SHIFT;
+		rpcs |= GEN8_RPCS_ENABLE;
+	}
+
+	if (sseu->has_eu_pg) {
+		rpcs |= ctx_sseu.min_eus_per_subslice <<
+			GEN8_RPCS_EU_MIN_SHIFT;
+		rpcs |= ctx_sseu.max_eus_per_subslice <<
+			GEN8_RPCS_EU_MAX_SHIFT;
+		rpcs |= GEN8_RPCS_ENABLE;
+	}
+
+	return rpcs;
+}
+
+static int gen8_emit_rpcs_config(struct i915_request *rq,
+				 struct i915_gem_context *ctx,
+				 struct intel_sseu sseu)
+{
+	struct drm_i915_private *i915 = rq->i915;
+	struct intel_context *ce = to_intel_context(ctx, i915->engine[RCS]);
+	u64 offset;
+	u32 *cs;
+
+	/* Let the deferred state allocation take care of this. */
+	if (!ce->state)
+		return 0;
+
+	if (!i915_vma_is_pinned(ce->kernel_state)) {
+		int ret;
+
+		ret = i915_vma_pin(ce->kernel_state, 0,
+				   GEN8_LR_CONTEXT_ALIGN, PIN_USER);
+		if (ret)
+			return ret;
+	}
+
+	cs = intel_ring_begin(rq, 4);
+	if (IS_ERR(cs))
+		return PTR_ERR(cs);
+
+	offset = ce->kernel_state->node.start +
+		LRC_STATE_PN * PAGE_SIZE +
+		(CTX_R_PWR_CLK_STATE + 1) * 4;
+
+	*cs++ = MI_STORE_DWORD_IMM_GEN4;
+	*cs++ = lower_32_bits(offset);
+	*cs++ = upper_32_bits(offset);
+	*cs++ = gen8_make_rpcs(&INTEL_INFO(i915)->sseu,
+			       intel_engine_prepare_sseu(rq->engine, sseu));
+
+	intel_ring_advance(rq, cs);
+
+	return 0;
+}
+
 static int gen8_init_rcs_context(struct i915_request *rq)
 {
 	int ret;
@@ -2364,6 +2440,8 @@ logical_ring_default_vfuncs(struct intel_engine_cs *engine)
 	engine->emit_breadcrumb = gen8_emit_breadcrumb;
 	engine->emit_breadcrumb_sz = gen8_emit_breadcrumb_sz;
 
+	engine->emit_rpcs_config = gen8_emit_rpcs_config;
+
 	engine->set_default_submission = execlists_set_default_submission;
 
 	if (INTEL_GEN(engine->i915) < 11) {
@@ -2512,41 +2590,6 @@ int logical_xcs_ring_init(struct intel_engine_cs *engine)
 	return logical_ring_init(engine);
 }
 
-u32 gen8_make_rpcs(const struct sseu_dev_info *sseu,
-		   struct intel_sseu ctx_sseu)
-{
-	u32 rpcs = 0;
-
-	/*
-	 * Starting in Gen9, render power gating can leave
-	 * slice/subslice/EU in a partially enabled state. We
-	 * must make an explicit request through RPCS for full
-	 * enablement.
-	*/
-	if (sseu->has_slice_pg) {
-		rpcs |= GEN8_RPCS_S_CNT_ENABLE;
-		rpcs |= hweight8(ctx_sseu.slice_mask) << GEN8_RPCS_S_CNT_SHIFT;
-		rpcs |= GEN8_RPCS_ENABLE;
-	}
-
-	if (sseu->has_subslice_pg) {
-		rpcs |= GEN8_RPCS_SS_CNT_ENABLE;
-		rpcs |= hweight8(ctx_sseu.subslice_mask) <<
-			GEN8_RPCS_SS_CNT_SHIFT;
-		rpcs |= GEN8_RPCS_ENABLE;
-	}
-
-	if (sseu->has_eu_pg) {
-		rpcs |= ctx_sseu.min_eus_per_subslice <<
-			GEN8_RPCS_EU_MIN_SHIFT;
-		rpcs |= ctx_sseu.max_eus_per_subslice <<
-			GEN8_RPCS_EU_MAX_SHIFT;
-		rpcs |= GEN8_RPCS_ENABLE;
-	}
-
-	return rpcs;
-}
-
 static u32 intel_lr_indirect_ctx_offset(struct intel_engine_cs *engine)
 {
 	u32 indirect_ctx_offset;
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.c b/drivers/gpu/drm/i915/intel_ringbuffer.c
index 97b38bbb7ce2..50616d0190e9 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.c
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.c
@@ -2063,6 +2063,8 @@ static void intel_ring_default_vfuncs(struct drm_i915_private *dev_priv,
 			engine->emit_breadcrumb_sz++;
 	}
 
+	engine->emit_rpcs_config = NULL; /* Only supported on Gen8+ */
+
 	engine->set_default_submission = i9xx_set_default_submission;
 
 	if (INTEL_GEN(dev_priv) >= 6)
diff --git a/drivers/gpu/drm/i915/intel_ringbuffer.h b/drivers/gpu/drm/i915/intel_ringbuffer.h
index acef385c4c80..ab75afdc6fd6 100644
--- a/drivers/gpu/drm/i915/intel_ringbuffer.h
+++ b/drivers/gpu/drm/i915/intel_ringbuffer.h
@@ -456,6 +456,10 @@ struct intel_engine_cs {
 	void		(*emit_breadcrumb)(struct i915_request *rq, u32 *cs);
 	int		emit_breadcrumb_sz;
 
+	int		(*emit_rpcs_config)(struct i915_request *rq,
+					    struct i915_gem_context *ctx,
+					    struct intel_sseu sseu);
+
 	/* Pass the request to the hardware queue (e.g. directly into
 	 * the legacy ringbuffer or to the end of an execlist).
 	 *
diff --git a/include/uapi/drm/i915_drm.h b/include/uapi/drm/i915_drm.h
index 7f5634ce8e88..21df158056a2 100644
--- a/include/uapi/drm/i915_drm.h
+++ b/include/uapi/drm/i915_drm.h
@@ -1456,9 +1456,52 @@ struct drm_i915_gem_context_param {
 #define   I915_CONTEXT_MAX_USER_PRIORITY	1023 /* inclusive */
 #define   I915_CONTEXT_DEFAULT_PRIORITY		0
 #define   I915_CONTEXT_MIN_USER_PRIORITY	-1023 /* inclusive */
+	/*
+	 * When using the following param, value should be a pointer to
+	 * drm_i915_gem_context_param_sseu.
+	 */
+#define I915_CONTEXT_PARAM_SSEU		0x7
 	__u64 value;
 };
 
+struct drm_i915_gem_context_param_sseu {
+	/*
+	 * Engine class & instance to be configured or queried.
+	 */
+	__u16 class;
+	__u16 instance;
+
+	/*
+	 * Unused for now. Must be cleared to zero.
+	 */
+	__u32 rsvd1;
+
+	/*
+	 * Mask of slices to enable for the context. Valid values are a subset
+	 * of the bitmask value returned for I915_PARAM_SLICE_MASK.
+	 */
+	__u64 slice_mask;
+
+	/*
+	 * Mask of subslices to enable for the context. Valid values are a
+	 * subset of the bitmask value return by I915_PARAM_SUBSLICE_MASK.
+	 */
+	__u64 subslice_mask;
+
+	/*
+	 * Minimum/Maximum number of EUs to enable per subslice for the
+	 * context. min_eus_per_subslice must be inferior or equal to
+	 * max_eus_per_subslice.
+	 */
+	__u16 min_eus_per_subslice;
+	__u16 max_eus_per_subslice;
+
+	/*
+	 * Unused for now. Must be cleared to zero.
+	 */
+	__u32 rsvd2;
+};
+
 enum drm_i915_oa_format {
 	I915_OA_FORMAT_A13 = 1,	    /* HSW only */
 	I915_OA_FORMAT_A29,	    /* HSW only */
-- 
2.17.0

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

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

* [PATCH v8 8/8] drm/i915: add a sysfs entry to let users set sseu configs
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
                   ` (6 preceding siblings ...)
  2018-05-29 19:16 ` [PATCH v8 7/8] drm/i915: Expose RPCS (SSEU) configuration to userspace Lionel Landwerlin
@ 2018-05-29 19:16 ` Lionel Landwerlin
  2018-05-29 19:29 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: per context slice/subslice powergating (rev7) Patchwork
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 19:16 UTC (permalink / raw)
  To: intel-gfx

There are concerns about denial of service around the per context sseu
configuration capability. In a previous commit introducing the
capability we allowed it only for capable users. This changes adds a
new debugfs entry to let any user configure its own context
powergating setup.

v2: Rename sysfs entry (Tvrtko)
    Lock interruptible the device in sysfs (Tvrtko)
    Fix dropped error code in getting dynamic sseu value (Tvrtko)
    s/dev_priv/i915/ (Tvrtko)

v3: Drop locked function suffix (Tvrtko)

Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h         | 16 +++++++---
 drivers/gpu/drm/i915/i915_gem_context.c | 38 +++++++++++++++++++++++
 drivers/gpu/drm/i915/i915_sysfs.c       | 40 +++++++++++++++++++++++++
 3 files changed, 90 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index b2386c37437d..5aa96a6650b4 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -1842,6 +1842,8 @@ 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 */
+
+		bool dynamic_sseu;
 	} contexts;
 
 	u32 fdi_rx_config;
@@ -3259,6 +3261,10 @@ i915_gem_context_lookup(struct drm_i915_file_private *file_priv, u32 id)
 	return ctx;
 }
 
+int i915_gem_contexts_set_dynamic_sseu(struct drm_i915_private *i915,
+				       bool allowed);
+bool i915_gem_contexts_get_dynamic_sseu(struct drm_i915_private *i915);
+
 int i915_perf_open_ioctl(struct drm_device *dev, void *data,
 			 struct drm_file *file);
 int i915_perf_add_config_ioctl(struct drm_device *dev, void *data,
@@ -3859,11 +3865,13 @@ intel_engine_prepare_sseu(struct intel_engine_cs *engine,
 	struct drm_i915_private *i915 = engine->i915;
 
 	/*
-	 * If i915/perf is active, we want a stable powergating configuration
-	 * on the system. The most natural configuration to take in that case
-	 * is the default (i.e maximum the hardware can do).
+	 * If i915/perf is active or dynamic sseu configuration is not allowed
+	 * (through sysfs), we want a stable powergating configuration on the
+	 * system. The most natural configuration to take in that case is the
+	 * default (i.e maximum the hardware can do).
 	 */
-	return i915->perf.oa.exclusive_stream ?
+	return (i915->perf.oa.exclusive_stream ||
+		!i915->contexts.dynamic_sseu) ?
 		intel_device_default_sseu(i915) : sseu;
 }
 
diff --git a/drivers/gpu/drm/i915/i915_gem_context.c b/drivers/gpu/drm/i915/i915_gem_context.c
index 79029815c21f..453bdc976be3 100644
--- a/drivers/gpu/drm/i915/i915_gem_context.c
+++ b/drivers/gpu/drm/i915/i915_gem_context.c
@@ -1118,6 +1118,44 @@ int i915_gem_context_reset_stats_ioctl(struct drm_device *dev,
 	return ret;
 }
 
+int i915_gem_contexts_set_dynamic_sseu(struct drm_i915_private *i915,
+				       bool allowed)
+{
+	struct intel_engine_cs *engine = i915->engine[RCS];
+	struct i915_gem_context *ctx;
+	int ret = 0;
+
+	lockdep_assert_held(&i915->drm.struct_mutex);
+
+	if (!engine->emit_rpcs_config)
+		return -ENODEV;
+
+	if (allowed == i915->contexts.dynamic_sseu)
+		return 0;
+
+	i915->contexts.dynamic_sseu = allowed;
+
+	list_for_each_entry(ctx, &i915->contexts.list, link) {
+		struct intel_context *ce = to_intel_context(ctx, engine);
+
+		ret = i915_gem_context_reconfigure_sseu(ctx, engine, ce->sseu);
+		if (ret)
+			break;
+	}
+
+	return ret;
+}
+
+bool i915_gem_contexts_get_dynamic_sseu(struct drm_i915_private *i915)
+{
+	struct intel_engine_cs *engine = i915->engine[RCS];
+
+	if (!engine->emit_rpcs_config)
+		return false;
+
+	return i915->contexts.dynamic_sseu;
+}
+
 #if IS_ENABLED(CONFIG_DRM_I915_SELFTEST)
 #include "selftests/mock_context.c"
 #include "selftests/i915_gem_context.c"
diff --git a/drivers/gpu/drm/i915/i915_sysfs.c b/drivers/gpu/drm/i915/i915_sysfs.c
index e5e6f6bb2b05..d895054d245e 100644
--- a/drivers/gpu/drm/i915/i915_sysfs.c
+++ b/drivers/gpu/drm/i915/i915_sysfs.c
@@ -483,6 +483,44 @@ static ssize_t gt_rp_mhz_show(struct device *kdev, struct device_attribute *attr
 	return snprintf(buf, PAGE_SIZE, "%d\n", val);
 }
 
+static ssize_t allow_dynamic_sseu_show(struct device *kdev,
+				       struct device_attribute *attr,
+				       char *buf)
+{
+	struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
+	bool value = i915_gem_contexts_get_dynamic_sseu(i915);
+
+	return snprintf(buf, PAGE_SIZE, "%d\n", value);
+}
+
+static ssize_t allow_dynamic_sseu_store(struct device *kdev,
+					struct device_attribute *attr,
+					const char *buf, size_t count)
+{
+	struct drm_i915_private *i915 = kdev_minor_to_i915(kdev);
+	ssize_t ret;
+	u32 val;
+
+	ret = kstrtou32(buf, 0, &val);
+	if (ret)
+		return ret;
+
+	if (val != 0 && val != 1)
+		return -EINVAL;
+
+	ret = mutex_lock_interruptible(&i915->drm.struct_mutex);
+	if (ret)
+		return ret;
+
+	ret = i915_gem_contexts_set_dynamic_sseu(i915, val != 0);
+
+	mutex_unlock(&i915->drm.struct_mutex);
+
+	return ret ?: count;
+}
+
+static DEVICE_ATTR_RW(allow_dynamic_sseu);
+
 static const struct attribute *gen6_attrs[] = {
 	&dev_attr_gt_act_freq_mhz.attr,
 	&dev_attr_gt_cur_freq_mhz.attr,
@@ -492,6 +530,7 @@ static const struct attribute *gen6_attrs[] = {
 	&dev_attr_gt_RP0_freq_mhz.attr,
 	&dev_attr_gt_RP1_freq_mhz.attr,
 	&dev_attr_gt_RPn_freq_mhz.attr,
+	&dev_attr_allow_dynamic_sseu.attr,
 	NULL,
 };
 
@@ -505,6 +544,7 @@ static const struct attribute *vlv_attrs[] = {
 	&dev_attr_gt_RP1_freq_mhz.attr,
 	&dev_attr_gt_RPn_freq_mhz.attr,
 	&dev_attr_vlv_rpe_freq_mhz.attr,
+	&dev_attr_allow_dynamic_sseu.attr,
 	NULL,
 };
 
-- 
2.17.0

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

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

* ✗ Fi.CI.CHECKPATCH: warning for drm/i915: per context slice/subslice powergating (rev7)
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
                   ` (7 preceding siblings ...)
  2018-05-29 19:16 ` [PATCH v8 8/8] drm/i915: add a sysfs entry to let users set sseu configs Lionel Landwerlin
@ 2018-05-29 19:29 ` Patchwork
  2018-05-29 19:32 ` ✗ Fi.CI.SPARSE: " Patchwork
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 18+ messages in thread
From: Patchwork @ 2018-05-29 19:29 UTC (permalink / raw)
  To: Lionel Landwerlin; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: per context slice/subslice powergating (rev7)
URL   : https://patchwork.freedesktop.org/series/42285/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
d23a6b481d4b drm/i915: Program RPCS for Broadwell
6540acb8de8b drm/i915: Record the sseu configuration per-context & engine
503e849565f5 drm/i915/perf: simplify configure all context function
dee2b69688ad drm/i915/perf: reuse intel_lrc ctx regs macro
7d7e921f0dda drm/i915/perf: lock powergating configuration to default when active
ee4312d23206 drm/i915: create context image vma in kernel context
84fe4b373898 drm/i915: Expose RPCS (SSEU) configuration to userspace
-:40: WARNING:COMMIT_LOG_LONG_LINE: Possible unwrapped commit description (prefer a maximum 75 chars per line)
#40: 
v2: Fix offset of CTX_R_PWR_CLK_STATE in intel_lr_context_set_sseu() (Lionel)

total: 0 errors, 1 warnings, 0 checks, 461 lines checked
69235291e987 drm/i915: add a sysfs entry to let users set sseu configs

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

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

* ✗ Fi.CI.SPARSE: warning for drm/i915: per context slice/subslice powergating (rev7)
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
                   ` (8 preceding siblings ...)
  2018-05-29 19:29 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: per context slice/subslice powergating (rev7) Patchwork
@ 2018-05-29 19:32 ` Patchwork
  2018-05-29 19:45 ` ✓ Fi.CI.BAT: success " Patchwork
  2018-05-29 20:45 ` ✗ Fi.CI.IGT: failure " Patchwork
  11 siblings, 0 replies; 18+ messages in thread
From: Patchwork @ 2018-05-29 19:32 UTC (permalink / raw)
  To: Lionel Landwerlin; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: per context slice/subslice powergating (rev7)
URL   : https://patchwork.freedesktop.org/series/42285/
State : warning

== Summary ==

$ dim sparse origin/drm-tip
Commit: drm/i915: Program RPCS for Broadwell
Okay!

Commit: drm/i915: Record the sseu configuration per-context & engine
-drivers/gpu/drm/i915/selftests/../i915_drv.h:3664:16: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/selftests/../i915_drv.h:3678:16: warning: expression using sizeof(void)

Commit: drm/i915/perf: simplify configure all context function
Okay!

Commit: drm/i915/perf: reuse intel_lrc ctx regs macro
Okay!

Commit: drm/i915/perf: lock powergating configuration to default when active
Okay!

Commit: drm/i915: create context image vma in kernel context
Okay!

Commit: drm/i915: Expose RPCS (SSEU) configuration to userspace
-drivers/gpu/drm/i915/selftests/../i915_drv.h:3678:16: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/selftests/../i915_drv.h:3691:16: warning: expression using sizeof(void)

Commit: drm/i915: add a sysfs entry to let users set sseu configs
-drivers/gpu/drm/i915/selftests/../i915_drv.h:3691:16: warning: expression using sizeof(void)
+drivers/gpu/drm/i915/selftests/../i915_drv.h:3697:16: warning: expression using sizeof(void)

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

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

* ✓ Fi.CI.BAT: success for drm/i915: per context slice/subslice powergating (rev7)
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
                   ` (9 preceding siblings ...)
  2018-05-29 19:32 ` ✗ Fi.CI.SPARSE: " Patchwork
@ 2018-05-29 19:45 ` Patchwork
  2018-05-29 20:45 ` ✗ Fi.CI.IGT: failure " Patchwork
  11 siblings, 0 replies; 18+ messages in thread
From: Patchwork @ 2018-05-29 19:45 UTC (permalink / raw)
  To: Lionel Landwerlin; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: per context slice/subslice powergating (rev7)
URL   : https://patchwork.freedesktop.org/series/42285/
State : success

== Summary ==

= CI Bug Log - changes from CI_DRM_4254 -> Patchwork_9142 =

== Summary - SUCCESS ==

  No regressions found.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/42285/revisions/7/mbox/

== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@kms_flip@basic-flip-vs-wf_vblank:
      fi-glk-j4005:       PASS -> FAIL (fdo#100368)

    igt@kms_pipe_crc_basic@read-crc-pipe-b-frame-sequence:
      fi-glk-j4005:       PASS -> FAIL (fdo#103481)

    
    ==== Possible fixes ====

    igt@drv_module_reload@basic-reload-inject:
      fi-glk-j4005:       DMESG-WARN (fdo#106248) -> PASS

    igt@gem_exec_fence@await-hang-default:
      fi-glk-j4005:       DMESG-WARN (fdo#105719) -> PASS

    igt@gem_exec_suspend@basic-s4-devices:
      fi-kbl-7500u:       DMESG-WARN (fdo#105128) -> PASS

    igt@kms_flip@basic-flip-vs-modeset:
      fi-glk-j4005:       DMESG-WARN (fdo#106000) -> PASS

    igt@kms_pipe_crc_basic@suspend-read-crc-pipe-b:
      fi-cnl-psr:         DMESG-WARN (fdo#104951) -> PASS

    igt@prime_vgem@basic-fence-flip:
      fi-ilk-650:         FAIL (fdo#104008) -> PASS

    
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103481 https://bugs.freedesktop.org/show_bug.cgi?id=103481
  fdo#104008 https://bugs.freedesktop.org/show_bug.cgi?id=104008
  fdo#104951 https://bugs.freedesktop.org/show_bug.cgi?id=104951
  fdo#105128 https://bugs.freedesktop.org/show_bug.cgi?id=105128
  fdo#105719 https://bugs.freedesktop.org/show_bug.cgi?id=105719
  fdo#106000 https://bugs.freedesktop.org/show_bug.cgi?id=106000
  fdo#106248 https://bugs.freedesktop.org/show_bug.cgi?id=106248


== Participating hosts (45 -> 39) ==

  Missing    (6): fi-ilk-m540 fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-cfl-u2 fi-skl-6700hq 


== Build changes ==

    * Linux: CI_DRM_4254 -> Patchwork_9142

  CI_DRM_4254: 59d0ee3539be08fb2551cc59719e79305e3115aa @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4499: f560ae5a464331f03f0a669ed46b8c9e56526187 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_9142: 69235291e9870310ee5dc401c16b71f4a038c940 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

69235291e987 drm/i915: add a sysfs entry to let users set sseu configs
84fe4b373898 drm/i915: Expose RPCS (SSEU) configuration to userspace
ee4312d23206 drm/i915: create context image vma in kernel context
7d7e921f0dda drm/i915/perf: lock powergating configuration to default when active
dee2b69688ad drm/i915/perf: reuse intel_lrc ctx regs macro
503e849565f5 drm/i915/perf: simplify configure all context function
6540acb8de8b drm/i915: Record the sseu configuration per-context & engine
d23a6b481d4b drm/i915: Program RPCS for Broadwell

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9142/issues.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v8 6/8] drm/i915: create context image vma in kernel context
  2018-05-29 19:16 ` [PATCH v8 6/8] drm/i915: create context image vma in kernel context Lionel Landwerlin
@ 2018-05-29 20:26   ` Michel Thierry
  2018-05-29 21:35     ` Lionel Landwerlin
  0 siblings, 1 reply; 18+ messages in thread
From: Michel Thierry @ 2018-05-29 20:26 UTC (permalink / raw)
  To: Lionel Landwerlin, intel-gfx

Hi,

On 5/29/2018 12:16 PM, Lionel Landwerlin wrote:
> We want to be able to modify other context images from the kernel
> context in a following commit. To be able to do this we need to map
> the context image into the kernel context's ppgtt.
> 
> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
> ---
>   drivers/gpu/drm/i915/i915_gem_context.h |  1 +
>   drivers/gpu/drm/i915/intel_lrc.c        | 19 ++++++++++++++-----
>   2 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_gem_context.h b/drivers/gpu/drm/i915/i915_gem_context.h
> index f40d85448a28..9c313c2edb09 100644
> --- a/drivers/gpu/drm/i915/i915_gem_context.h
> +++ b/drivers/gpu/drm/i915/i915_gem_context.h
> @@ -155,6 +155,7 @@ struct i915_gem_context {
>   	struct intel_context {
>   		struct i915_gem_context *gem_context;
>   		struct i915_vma *state;
> +		struct i915_vma *kernel_state; /**/
>   		struct intel_ring *ring;
>   		u32 *lrc_reg_state;
>   		u64 lrc_desc;
> diff --git a/drivers/gpu/drm/i915/intel_lrc.c b/drivers/gpu/drm/i915/intel_lrc.c
> index 7314e548fb4e..8a49323f6672 100644
> --- a/drivers/gpu/drm/i915/intel_lrc.c
> +++ b/drivers/gpu/drm/i915/intel_lrc.c
> @@ -2739,7 +2739,7 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
>   					    struct intel_context *ce)
>   {
>   	struct drm_i915_gem_object *ctx_obj;
> -	struct i915_vma *vma;
> +	struct i915_vma *ggtt_vma, *ppgtt_vma;
>   	uint32_t context_size;
>   	struct intel_ring *ring;
>   	struct i915_timeline *timeline;
> @@ -2762,9 +2762,17 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
>   		goto error_deref_obj;
>   	}
>   
> -	vma = i915_vma_instance(ctx_obj, &ctx->i915->ggtt.base, NULL);
> -	if (IS_ERR(vma)) {
> -		ret = PTR_ERR(vma);
> +	ggtt_vma = i915_vma_instance(ctx_obj, &ctx->i915->ggtt.base, NULL);
> +	if (IS_ERR(ggtt_vma)) {
> +		ret = PTR_ERR(ggtt_vma);
> +		goto error_deref_obj;
> +	}
> +
> +	ppgtt_vma = i915_vma_instance(ctx_obj,
> +				      &ctx->i915->kernel_context->ppgtt->base,
This is dangerous if someone decides to use 'aliasing ppgtt' 
(enable_ppgtt=1 is still a valid option).

You'll need something like this,
struct i915_hw_ppgtt *ppgtt = ctx->i915->kernel_context->ppgtt ?:
					ctx->i915->mm.aliasing_ppgtt;


> +				      NULL);
> +	if (IS_ERR(ppgtt_vma)) {
> +		ret = PTR_ERR(ppgtt_vma);
>   		goto error_deref_obj;
>   	}
>   
> @@ -2788,7 +2796,8 @@ static int execlists_context_deferred_alloc(struct i915_gem_context *ctx,
>   	}
>   
>   	ce->ring = ring;
> -	ce->state = vma;
> +	ce->state = ggtt_vma;
> +	ce->kernel_state = ppgtt_vma;
>   
>   	return 0;
>   
> 
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* ✗ Fi.CI.IGT: failure for drm/i915: per context slice/subslice powergating (rev7)
  2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
                   ` (10 preceding siblings ...)
  2018-05-29 19:45 ` ✓ Fi.CI.BAT: success " Patchwork
@ 2018-05-29 20:45 ` Patchwork
  11 siblings, 0 replies; 18+ messages in thread
From: Patchwork @ 2018-05-29 20:45 UTC (permalink / raw)
  To: Lionel Landwerlin; +Cc: intel-gfx

== Series Details ==

Series: drm/i915: per context slice/subslice powergating (rev7)
URL   : https://patchwork.freedesktop.org/series/42285/
State : failure

== Summary ==

= CI Bug Log - changes from CI_DRM_4254_full -> Patchwork_9142_full =

== Summary - FAILURE ==

  Serious unknown changes coming with Patchwork_9142_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_9142_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  External URL: https://patchwork.freedesktop.org/api/1.0/series/42285/revisions/7/mbox/

== Possible new issues ==

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

  === IGT changes ===

    ==== Possible regressions ====

    igt@gem_ctx_param@invalid-param-get:
      shard-apl:          PASS -> FAIL
      shard-glk:          PASS -> FAIL
      shard-snb:          PASS -> FAIL
      shard-hsw:          PASS -> FAIL
      shard-kbl:          PASS -> FAIL

    igt@gem_ctx_param@invalid-param-set:
      shard-kbl:          PASS -> DMESG-FAIL
      shard-hsw:          PASS -> DMESG-FAIL
      shard-snb:          PASS -> DMESG-FAIL
      shard-glk:          PASS -> DMESG-FAIL
      shard-apl:          PASS -> DMESG-FAIL

    
    ==== Warnings ====

    igt@gem_exec_schedule@deep-bsd2:
      shard-kbl:          PASS -> SKIP +1

    igt@gem_mocs_settings@mocs-rc6-bsd1:
      shard-kbl:          SKIP -> PASS

    
== Known issues ==

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

  === IGT changes ===

    ==== Issues hit ====

    igt@drv_selftest@live_gtt:
      shard-glk:          PASS -> INCOMPLETE (k.org#198133, fdo#103359)

    igt@drv_selftest@live_hangcheck:
      shard-kbl:          PASS -> DMESG-FAIL (fdo#106560)

    igt@drv_selftest@live_workarounds:
      shard-apl:          PASS -> INCOMPLETE (fdo#103927)

    igt@kms_atomic_transition@1x-modeset-transitions-nonblocking-fencing:
      shard-glk:          PASS -> FAIL (fdo#105703)

    igt@kms_flip@modeset-vs-vblank-race-interruptible:
      shard-glk:          PASS -> FAIL (fdo#103060)
      shard-hsw:          PASS -> FAIL (fdo#103060)

    igt@kms_flip_tiling@flip-to-y-tiled:
      shard-glk:          PASS -> FAIL (fdo#103822, fdo#104724)

    
    ==== Possible fixes ====

    igt@kms_cursor_legacy@2x-nonblocking-modeset-vs-cursor-atomic:
      shard-glk:          FAIL (fdo#105454, fdo#106509) -> PASS

    igt@kms_flip@2x-modeset-vs-vblank-race-interruptible:
      shard-glk:          FAIL (fdo#103060) -> PASS

    igt@kms_flip@plain-flip-fb-recreate:
      shard-hsw:          FAIL (fdo#100368) -> PASS

    igt@kms_flip_tiling@flip-to-x-tiled:
      shard-glk:          FAIL (fdo#103822, fdo#104724) -> PASS

    igt@kms_frontbuffer_tracking@fbc-2p-primscrn-shrfb-pgflip-blt:
      shard-glk:          FAIL (fdo#103167, fdo#104724) -> PASS

    
  fdo#100368 https://bugs.freedesktop.org/show_bug.cgi?id=100368
  fdo#103060 https://bugs.freedesktop.org/show_bug.cgi?id=103060
  fdo#103167 https://bugs.freedesktop.org/show_bug.cgi?id=103167
  fdo#103359 https://bugs.freedesktop.org/show_bug.cgi?id=103359
  fdo#103822 https://bugs.freedesktop.org/show_bug.cgi?id=103822
  fdo#103927 https://bugs.freedesktop.org/show_bug.cgi?id=103927
  fdo#104724 https://bugs.freedesktop.org/show_bug.cgi?id=104724
  fdo#105454 https://bugs.freedesktop.org/show_bug.cgi?id=105454
  fdo#105703 https://bugs.freedesktop.org/show_bug.cgi?id=105703
  fdo#106509 https://bugs.freedesktop.org/show_bug.cgi?id=106509
  fdo#106560 https://bugs.freedesktop.org/show_bug.cgi?id=106560
  k.org#198133 https://bugzilla.kernel.org/show_bug.cgi?id=198133


== Participating hosts (5 -> 5) ==

  No changes in participating hosts


== Build changes ==

    * Linux: CI_DRM_4254 -> Patchwork_9142

  CI_DRM_4254: 59d0ee3539be08fb2551cc59719e79305e3115aa @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_4499: f560ae5a464331f03f0a669ed46b8c9e56526187 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_9142: 69235291e9870310ee5dc401c16b71f4a038c940 @ git://anongit.freedesktop.org/gfx-ci/linux

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_9142/shards.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v8 6/8] drm/i915: create context image vma in kernel context
  2018-05-29 20:26   ` Michel Thierry
@ 2018-05-29 21:35     ` Lionel Landwerlin
  2018-05-29 22:08       ` Chris Wilson
  0 siblings, 1 reply; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-29 21:35 UTC (permalink / raw)
  To: Michel Thierry, intel-gfx

On 29/05/18 21:26, Michel Thierry wrote:
> Hi,
>
> On 5/29/2018 12:16 PM, Lionel Landwerlin wrote:
>> We want to be able to modify other context images from the kernel
>> context in a following commit. To be able to do this we need to map
>> the context image into the kernel context's ppgtt.
>>
>> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
>> ---
>>   drivers/gpu/drm/i915/i915_gem_context.h |  1 +
>>   drivers/gpu/drm/i915/intel_lrc.c        | 19 ++++++++++++++-----
>>   2 files changed, 15 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/i915_gem_context.h 
>> b/drivers/gpu/drm/i915/i915_gem_context.h
>> index f40d85448a28..9c313c2edb09 100644
>> --- a/drivers/gpu/drm/i915/i915_gem_context.h
>> +++ b/drivers/gpu/drm/i915/i915_gem_context.h
>> @@ -155,6 +155,7 @@ struct i915_gem_context {
>>       struct intel_context {
>>           struct i915_gem_context *gem_context;
>>           struct i915_vma *state;
>> +        struct i915_vma *kernel_state; /**/
>>           struct intel_ring *ring;
>>           u32 *lrc_reg_state;
>>           u64 lrc_desc;
>> diff --git a/drivers/gpu/drm/i915/intel_lrc.c 
>> b/drivers/gpu/drm/i915/intel_lrc.c
>> index 7314e548fb4e..8a49323f6672 100644
>> --- a/drivers/gpu/drm/i915/intel_lrc.c
>> +++ b/drivers/gpu/drm/i915/intel_lrc.c
>> @@ -2739,7 +2739,7 @@ static int 
>> execlists_context_deferred_alloc(struct i915_gem_context *ctx,
>>                           struct intel_context *ce)
>>   {
>>       struct drm_i915_gem_object *ctx_obj;
>> -    struct i915_vma *vma;
>> +    struct i915_vma *ggtt_vma, *ppgtt_vma;
>>       uint32_t context_size;
>>       struct intel_ring *ring;
>>       struct i915_timeline *timeline;
>> @@ -2762,9 +2762,17 @@ static int 
>> execlists_context_deferred_alloc(struct i915_gem_context *ctx,
>>           goto error_deref_obj;
>>       }
>>   -    vma = i915_vma_instance(ctx_obj, &ctx->i915->ggtt.base, NULL);
>> -    if (IS_ERR(vma)) {
>> -        ret = PTR_ERR(vma);
>> +    ggtt_vma = i915_vma_instance(ctx_obj, &ctx->i915->ggtt.base, NULL);
>> +    if (IS_ERR(ggtt_vma)) {
>> +        ret = PTR_ERR(ggtt_vma);
>> +        goto error_deref_obj;
>> +    }
>> +
>> +    ppgtt_vma = i915_vma_instance(ctx_obj,
>> + &ctx->i915->kernel_context->ppgtt->base,
> This is dangerous if someone decides to use 'aliasing ppgtt' 
> (enable_ppgtt=1 is still a valid option).
>
> You'll need something like this,
> struct i915_hw_ppgtt *ppgtt = ctx->i915->kernel_context->ppgtt ?:
>                     ctx->i915->mm.aliasing_ppgtt;

Thanks a lot of the tip, I'm very much new to this.
Will fix and see if they are tests that can exercise this in igt.

-
Lionel

>
>
>> +                      NULL);
>> +    if (IS_ERR(ppgtt_vma)) {
>> +        ret = PTR_ERR(ppgtt_vma);
>>           goto error_deref_obj;
>>       }
>>   @@ -2788,7 +2796,8 @@ static int 
>> execlists_context_deferred_alloc(struct i915_gem_context *ctx,
>>       }
>>         ce->ring = ring;
>> -    ce->state = vma;
>> +    ce->state = ggtt_vma;
>> +    ce->kernel_state = ppgtt_vma;
>>         return 0;
>>
>

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

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

* Re: [PATCH v8 6/8] drm/i915: create context image vma in kernel context
  2018-05-29 21:35     ` Lionel Landwerlin
@ 2018-05-29 22:08       ` Chris Wilson
  2018-05-30 10:05         ` Lionel Landwerlin
  0 siblings, 1 reply; 18+ messages in thread
From: Chris Wilson @ 2018-05-29 22:08 UTC (permalink / raw)
  To: Lionel Landwerlin, Michel Thierry, intel-gfx

Quoting Lionel Landwerlin (2018-05-29 22:35:08)
> On 29/05/18 21:26, Michel Thierry wrote:
> > Hi,
> >
> > On 5/29/2018 12:16 PM, Lionel Landwerlin wrote:
> >> We want to be able to modify other context images from the kernel
> >> context in a following commit. To be able to do this we need to map
> >> the context image into the kernel context's ppgtt.
> >>
> >> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
> >> ---
> >>   drivers/gpu/drm/i915/i915_gem_context.h |  1 +
> >>   drivers/gpu/drm/i915/intel_lrc.c        | 19 ++++++++++++++-----
> >>   2 files changed, 15 insertions(+), 5 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/i915_gem_context.h 
> >> b/drivers/gpu/drm/i915/i915_gem_context.h
> >> index f40d85448a28..9c313c2edb09 100644
> >> --- a/drivers/gpu/drm/i915/i915_gem_context.h
> >> +++ b/drivers/gpu/drm/i915/i915_gem_context.h
> >> @@ -155,6 +155,7 @@ struct i915_gem_context {
> >>       struct intel_context {
> >>           struct i915_gem_context *gem_context;
> >>           struct i915_vma *state;
> >> +        struct i915_vma *kernel_state; /**/

It's debatable if we want to keep the pointer around.

We have one for the context state vma and ring vma, because we need to
keep a pointer for the object and so choose to keep the vma instead as
we use that more often than the drm_i915_gem_object and can derive it
from vma->obj.

For this piece of code, which should be run that often I don't see a lot
of advantage over using the rbtree search, and since the number of
objects in that tree will not be large (2 at most), quick.

/* Don't forget to declare the dependency tree! */
prev = i915_gem_active_raw(&ce->ring->timeline->last_request,
			  &rq->i915->drm.struct_mutex);
if (prev) {
	err = i915_sw_fence_await_sw_fence_gfp(&rq->submit,
					       &prev->submit,
					       I915_FENCE_GFP);
	if (err < 0)
		return err;
}

vma = i915_vma_instance(ce->state->obj, my_vm, NULL);
if (IS_ERR(vma)) ...

err = i915_vma_pin(vma, 0, PIN_USER);
if (err) ...

err = i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
i915_vma_unpin(vma);
if (err) ... /* not today, but tomorrow */

Now you can

cs = intel_ring_begin(rq, 4);
...
*cs++ = gen8_canonical_addr(vma->node.state + offset);
...
intel_ring_advance(rq, cs);

On error, you will have to submit the request since it has interacted
with the tracking.

Don't bother pushing this into an engine vfunc, if you don't intend to
have multiple implementations. It's only a SDM, nothing that appears the
need to be specialised. Although you might argue the context layout will
require it later? As for the SDM, Joonas might complain about the
proliferation, but I'm not sure if we have a good repeating pattern yet.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v8 6/8] drm/i915: create context image vma in kernel context
  2018-05-29 22:08       ` Chris Wilson
@ 2018-05-30 10:05         ` Lionel Landwerlin
  2018-05-30 10:11           ` Chris Wilson
  0 siblings, 1 reply; 18+ messages in thread
From: Lionel Landwerlin @ 2018-05-30 10:05 UTC (permalink / raw)
  To: Chris Wilson, Michel Thierry, intel-gfx

On 29/05/18 23:08, Chris Wilson wrote:
> Quoting Lionel Landwerlin (2018-05-29 22:35:08)
>> On 29/05/18 21:26, Michel Thierry wrote:
>>> Hi,
>>>
>>> On 5/29/2018 12:16 PM, Lionel Landwerlin wrote:
>>>> We want to be able to modify other context images from the kernel
>>>> context in a following commit. To be able to do this we need to map
>>>> the context image into the kernel context's ppgtt.
>>>>
>>>> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
>>>> ---
>>>>    drivers/gpu/drm/i915/i915_gem_context.h |  1 +
>>>>    drivers/gpu/drm/i915/intel_lrc.c        | 19 ++++++++++++++-----
>>>>    2 files changed, 15 insertions(+), 5 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/i915/i915_gem_context.h
>>>> b/drivers/gpu/drm/i915/i915_gem_context.h
>>>> index f40d85448a28..9c313c2edb09 100644
>>>> --- a/drivers/gpu/drm/i915/i915_gem_context.h
>>>> +++ b/drivers/gpu/drm/i915/i915_gem_context.h
>>>> @@ -155,6 +155,7 @@ struct i915_gem_context {
>>>>        struct intel_context {
>>>>            struct i915_gem_context *gem_context;
>>>>            struct i915_vma *state;
>>>> +        struct i915_vma *kernel_state; /**/
> It's debatable if we want to keep the pointer around.
>
> We have one for the context state vma and ring vma, because we need to
> keep a pointer for the object and so choose to keep the vma instead as
> we use that more often than the drm_i915_gem_object and can derive it
> from vma->obj.
>
> For this piece of code, which should be run that often I don't see a lot
> of advantage over using the rbtree search, and since the number of
> objects in that tree will not be large (2 at most), quick.
>
> /* Don't forget to declare the dependency tree! */
> prev = i915_gem_active_raw(&ce->ring->timeline->last_request,
> 			  &rq->i915->drm.struct_mutex);
> if (prev) {
> 	err = i915_sw_fence_await_sw_fence_gfp(&rq->submit,
> 					       &prev->submit,
> 					       I915_FENCE_GFP);
> 	if (err < 0)
> 		return err;
> }

Thanks, this is done by the caller.

>
> vma = i915_vma_instance(ce->state->obj, my_vm, NULL);
> if (IS_ERR(vma)) ...
>
> err = i915_vma_pin(vma, 0, PIN_USER);
> if (err) ...
>
> err = i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
> i915_vma_unpin(vma);
> if (err) ... /* not today, but tomorrow */
>
> Now you can
>
> cs = intel_ring_begin(rq, 4);
> ...
> *cs++ = gen8_canonical_addr(vma->node.state + offset);
> ...
> intel_ring_advance(rq, cs);
>
> On error, you will have to submit the request since it has interacted
> with the tracking.

Yep, done in the caller too.

> Don't bother pushing this into an engine vfunc, if you don't intend to 
> have multiple implementations. It's only a SDM, nothing that appears 
> the need to be specialised. Although you might argue the context 
> layout will require it later? As for the SDM, Joonas might complain 
> about the proliferation, but I'm not sure if we have a good repeating 
> pattern yet. -Chris
Hmm.. That's kind of useful to detect the ability to change powergating 
configs.

Thanks a lot,

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

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

* Re: [PATCH v8 6/8] drm/i915: create context image vma in kernel context
  2018-05-30 10:05         ` Lionel Landwerlin
@ 2018-05-30 10:11           ` Chris Wilson
  0 siblings, 0 replies; 18+ messages in thread
From: Chris Wilson @ 2018-05-30 10:11 UTC (permalink / raw)
  To: Lionel Landwerlin, Michel Thierry, intel-gfx

Quoting Lionel Landwerlin (2018-05-30 11:05:25)
> On 29/05/18 23:08, Chris Wilson wrote:
> > Quoting Lionel Landwerlin (2018-05-29 22:35:08)
> >> On 29/05/18 21:26, Michel Thierry wrote:
> >>> Hi,
> >>>
> >>> On 5/29/2018 12:16 PM, Lionel Landwerlin wrote:
> >>>> We want to be able to modify other context images from the kernel
> >>>> context in a following commit. To be able to do this we need to map
> >>>> the context image into the kernel context's ppgtt.
> >>>>
> >>>> Signed-off-by: Lionel Landwerlin <lionel.g.landwerlin@intel.com>
> >>>> ---
> >>>>    drivers/gpu/drm/i915/i915_gem_context.h |  1 +
> >>>>    drivers/gpu/drm/i915/intel_lrc.c        | 19 ++++++++++++++-----
> >>>>    2 files changed, 15 insertions(+), 5 deletions(-)
> >>>>
> >>>> diff --git a/drivers/gpu/drm/i915/i915_gem_context.h
> >>>> b/drivers/gpu/drm/i915/i915_gem_context.h
> >>>> index f40d85448a28..9c313c2edb09 100644
> >>>> --- a/drivers/gpu/drm/i915/i915_gem_context.h
> >>>> +++ b/drivers/gpu/drm/i915/i915_gem_context.h
> >>>> @@ -155,6 +155,7 @@ struct i915_gem_context {
> >>>>        struct intel_context {
> >>>>            struct i915_gem_context *gem_context;
> >>>>            struct i915_vma *state;
> >>>> +        struct i915_vma *kernel_state; /**/
> > It's debatable if we want to keep the pointer around.
> >
> > We have one for the context state vma and ring vma, because we need to
> > keep a pointer for the object and so choose to keep the vma instead as
> > we use that more often than the drm_i915_gem_object and can derive it
> > from vma->obj.
> >
> > For this piece of code, which should be run that often I don't see a lot
> > of advantage over using the rbtree search, and since the number of
> > objects in that tree will not be large (2 at most), quick.
> >
> > /* Don't forget to declare the dependency tree! */
> > prev = i915_gem_active_raw(&ce->ring->timeline->last_request,
> >                         &rq->i915->drm.struct_mutex);
> > if (prev) {
> >       err = i915_sw_fence_await_sw_fence_gfp(&rq->submit,
> >                                              &prev->submit,
> >                                              I915_FENCE_GFP);
> >       if (err < 0)
> >               return err;
> > }
> 
> Thanks, this is done by the caller.

It probably shouldn't be, because the fence is related to this write.
(And it should be i915_request_await_request, but that'll require an
export.) The await + move-to-active (hmm, this is before fence export
refactoring, oh well, needs that patch as well) are paired. Ideally we
do all awaits first, checking for errors before touching the global
state as then we can discard the request; but here I think the coupling
is very, very special because the context objects do not follow the
normal rules. So something to be very wary of.

> > vma = i915_vma_instance(ce->state->obj, my_vm, NULL);
> > if (IS_ERR(vma)) ...
> >
> > err = i915_vma_pin(vma, 0, PIN_USER);
> > if (err) ...
> >
> > err = i915_vma_move_to_active(vma, rq, EXEC_OBJECT_WRITE);
> > i915_vma_unpin(vma);
> > if (err) ... /* not today, but tomorrow */
> >
> > Now you can
> >
> > cs = intel_ring_begin(rq, 4);
> > ...
> > *cs++ = gen8_canonical_addr(vma->node.state + offset);
> > ...
> > intel_ring_advance(rq, cs);
> >
> > On error, you will have to submit the request since it has interacted
> > with the tracking.
> 
> Yep, done in the caller too.

Yes, it has to be. I'm just stressing that we can't simply discard this
request part way through because it has manipulated global state.
-Chris
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2018-05-30 10:11 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-29 19:16 [PATCH v8 0/8] drm/i915: per context slice/subslice powergating Lionel Landwerlin
2018-05-29 19:16 ` [PATCH v8 1/8] drm/i915: Program RPCS for Broadwell Lionel Landwerlin
2018-05-29 19:16 ` [PATCH v8 2/8] drm/i915: Record the sseu configuration per-context & engine Lionel Landwerlin
2018-05-29 19:16 ` [PATCH v8 3/8] drm/i915/perf: simplify configure all context function Lionel Landwerlin
2018-05-29 19:16 ` [PATCH v8 4/8] drm/i915/perf: reuse intel_lrc ctx regs macro Lionel Landwerlin
2018-05-29 19:16 ` [PATCH v8 5/8] drm/i915/perf: lock powergating configuration to default when active Lionel Landwerlin
2018-05-29 19:16 ` [PATCH v8 6/8] drm/i915: create context image vma in kernel context Lionel Landwerlin
2018-05-29 20:26   ` Michel Thierry
2018-05-29 21:35     ` Lionel Landwerlin
2018-05-29 22:08       ` Chris Wilson
2018-05-30 10:05         ` Lionel Landwerlin
2018-05-30 10:11           ` Chris Wilson
2018-05-29 19:16 ` [PATCH v8 7/8] drm/i915: Expose RPCS (SSEU) configuration to userspace Lionel Landwerlin
2018-05-29 19:16 ` [PATCH v8 8/8] drm/i915: add a sysfs entry to let users set sseu configs Lionel Landwerlin
2018-05-29 19:29 ` ✗ Fi.CI.CHECKPATCH: warning for drm/i915: per context slice/subslice powergating (rev7) Patchwork
2018-05-29 19:32 ` ✗ Fi.CI.SPARSE: " Patchwork
2018-05-29 19:45 ` ✓ Fi.CI.BAT: success " Patchwork
2018-05-29 20:45 ` ✗ Fi.CI.IGT: failure " Patchwork

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.