All of lore.kernel.org
 help / color / mirror / Atom feed
* [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer
@ 2020-05-06 13:11 Animesh Manna
  2020-05-06 14:02 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/dsb: Pre allocate and late cleanup of cmd buffer (rev4) Patchwork
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Animesh Manna @ 2020-05-06 13:11 UTC (permalink / raw)
  To: intel-gfx; +Cc: Jani Nikula, Daniel Vetter

Pre-allocate command buffer in atomic_commit using intel_dsb_prepare
function which also includes pinning and map in cpu domain.

No change is dsb write/commit functions.

Now dsb get/put function is refactored and currently used only for
reference counting. Below dsb api added to do respective job
mentioned below.

intel_dsb_prepare - Allocate, pin and map the buffer.
intel_dsb_cleanup - Unpin and release the gem object.

RFC: Initial patch for design review.
v2: included _init() part in _prepare(). [Daniel, Ville]
v3: dsb_cleanup called after cleanup_planes. [Daniel]
v4: dsb structure is moved to intel_crtc_state from intel_crtc. [Maarten]
v5: dsb get/put/ref-count mechanism removed. [Maarten]

Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
Cc: Jani Nikula <jani.nikula@intel.com>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: Animesh Manna <animesh.manna@intel.com>
---
 drivers/gpu/drm/i915/display/intel_color.c    |  27 ++-
 drivers/gpu/drm/i915/display/intel_display.c  |  60 ++++-
 .../drm/i915/display/intel_display_types.h    |   6 +-
 drivers/gpu/drm/i915/display/intel_dsb.c      | 207 +++++++++---------
 drivers/gpu/drm/i915/display/intel_dsb.h      |   8 +-
 5 files changed, 178 insertions(+), 130 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
index 98ece9cd7cdd..dba820136106 100644
--- a/drivers/gpu/drm/i915/display/intel_color.c
+++ b/drivers/gpu/drm/i915/display/intel_color.c
@@ -717,7 +717,8 @@ static void bdw_load_lut_10(struct intel_crtc *crtc,
 static void ivb_load_lut_ext_max(struct intel_crtc *crtc)
 {
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
-	struct intel_dsb *dsb = intel_dsb_get(crtc);
+	struct intel_crtc_state *crtc_state = to_intel_crtc_state(crtc->base.state);
+	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
 	enum pipe pipe = crtc->pipe;
 
 	/* Program the max register to clamp values > 1.0. */
@@ -738,8 +739,6 @@ static void ivb_load_lut_ext_max(struct intel_crtc *crtc)
 		intel_dsb_reg_write(dsb, PREC_PAL_EXT2_GC_MAX(pipe, 2),
 				    1 << 16);
 	}
-
-	intel_dsb_put(dsb);
 }
 
 static void ivb_load_luts(const struct intel_crtc_state *crtc_state)
@@ -900,14 +899,13 @@ icl_load_gcmax(const struct intel_crtc_state *crtc_state,
 	       const struct drm_color_lut *color)
 {
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
-	struct intel_dsb *dsb = intel_dsb_get(crtc);
+	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
 	enum pipe pipe = crtc->pipe;
 
 	/* FIXME LUT entries are 16 bit only, so we can prog 0xFFFF max */
 	intel_dsb_reg_write(dsb, PREC_PAL_GC_MAX(pipe, 0), color->red);
 	intel_dsb_reg_write(dsb, PREC_PAL_GC_MAX(pipe, 1), color->green);
 	intel_dsb_reg_write(dsb, PREC_PAL_GC_MAX(pipe, 2), color->blue);
-	intel_dsb_put(dsb);
 }
 
 static void
@@ -916,7 +914,7 @@ icl_program_gamma_superfine_segment(const struct intel_crtc_state *crtc_state)
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	const struct drm_property_blob *blob = crtc_state->hw.gamma_lut;
 	const struct drm_color_lut *lut = blob->data;
-	struct intel_dsb *dsb = intel_dsb_get(crtc);
+	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
 	enum pipe pipe = crtc->pipe;
 	int i;
 
@@ -938,8 +936,6 @@ icl_program_gamma_superfine_segment(const struct intel_crtc_state *crtc_state)
 		intel_dsb_indexed_reg_write(dsb, PREC_PAL_MULTI_SEG_DATA(pipe),
 					    ilk_lut_12p4_udw(entry));
 	}
-
-	intel_dsb_put(dsb);
 }
 
 static void
@@ -949,7 +945,7 @@ icl_program_gamma_multi_segment(const struct intel_crtc_state *crtc_state)
 	const struct drm_property_blob *blob = crtc_state->hw.gamma_lut;
 	const struct drm_color_lut *lut = blob->data;
 	const struct drm_color_lut *entry;
-	struct intel_dsb *dsb = intel_dsb_get(crtc);
+	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
 	enum pipe pipe = crtc->pipe;
 	int i;
 
@@ -996,14 +992,22 @@ icl_program_gamma_multi_segment(const struct intel_crtc_state *crtc_state)
 	entry = &lut[256 * 8 * 128];
 	icl_load_gcmax(crtc_state, entry);
 	ivb_load_lut_ext_max(crtc);
-	intel_dsb_put(dsb);
 }
 
 static void icl_load_luts(const struct intel_crtc_state *crtc_state)
 {
 	const struct drm_property_blob *gamma_lut = crtc_state->hw.gamma_lut;
 	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
-	struct intel_dsb *dsb = intel_dsb_get(crtc);
+	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
+
+	/*
+	 * TODO: Currently dsb buffer filling is done in load_lut() which
+	 * can be done much earlier, like initial stage of atomic_commit().
+	 * As currently replacing the mmio-write with dsb-write so the same
+	 * load_lut() api is used for dsb buffer creation which may not
+	 * fit in initial stage. Need to create a separate interface and
+	 * a different path in color framework while dealing with dsb.
+	 */
 
 	if (crtc_state->hw.degamma_lut)
 		glk_load_degamma_lut(crtc_state);
@@ -1022,7 +1026,6 @@ static void icl_load_luts(const struct intel_crtc_state *crtc_state)
 	}
 
 	intel_dsb_commit(dsb);
-	intel_dsb_put(dsb);
 }
 
 static u32 chv_cgm_degamma_ldw(const struct drm_color_lut *color)
diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
index fd6d63b03489..07670893c1ae 100644
--- a/drivers/gpu/drm/i915/display/intel_display.c
+++ b/drivers/gpu/drm/i915/display/intel_display.c
@@ -14873,8 +14873,28 @@ static int intel_atomic_check(struct drm_device *dev,
 
 static int intel_atomic_prepare_commit(struct intel_atomic_state *state)
 {
-	return drm_atomic_helper_prepare_planes(state->base.dev,
-						&state->base);
+	struct intel_crtc_state *crtc_state;
+	struct intel_crtc *crtc;
+	int i, ret;
+
+	ret = drm_atomic_helper_prepare_planes(state->base.dev, &state->base);
+	if (ret < 0)
+		return ret;
+
+	/*
+	 * In case of DSB buffer creation failure register programming will be
+	 * done by mmio and erroneous path will be handled by dsp-write api.
+	 */
+	for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
+		bool mode_changed = needs_modeset(crtc_state);
+
+		if (mode_changed || crtc_state->update_pipe ||
+		    crtc_state->uapi.color_mgmt_changed) {
+			intel_dsb_prepare(crtc_state);
+		}
+	}
+
+	return 0;
 }
 
 u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc)
@@ -15327,15 +15347,39 @@ static void intel_atomic_commit_fence_wait(struct intel_atomic_state *intel_stat
 		    &wait_reset);
 }
 
+static void intel_cleanup_dsbs(struct intel_atomic_state *state)
+{
+	struct intel_crtc_state *crtc_state, *old_crtc_state, *new_crtc_state;
+	struct intel_crtc *crtc;
+	int i;
+
+	for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
+		bool mode_changed;
+
+		if (old_crtc_state == crtc->config)
+			crtc_state = new_crtc_state;
+		else
+			crtc_state = old_crtc_state;
+
+		mode_changed = needs_modeset(crtc_state);
+		if (mode_changed || crtc_state->update_pipe ||
+		    crtc_state->uapi.color_mgmt_changed) {
+			intel_dsb_cleanup(crtc_state);
+		}
+	}
+}
+
 static void intel_atomic_cleanup_work(struct work_struct *work)
 {
-	struct drm_atomic_state *state =
-		container_of(work, struct drm_atomic_state, commit_work);
-	struct drm_i915_private *i915 = to_i915(state->dev);
+	struct intel_atomic_state *state =
+		container_of(work, struct intel_atomic_state, base.commit_work);
+	struct drm_i915_private *i915 = to_i915(state->base.dev);
 
-	drm_atomic_helper_cleanup_planes(&i915->drm, state);
-	drm_atomic_helper_commit_cleanup_done(state);
-	drm_atomic_state_put(state);
+	if (HAS_DSB(i915))
+		intel_cleanup_dsbs(state);
+	drm_atomic_helper_cleanup_planes(&i915->drm, &state->base);
+	drm_atomic_helper_commit_cleanup_done(&state->base);
+	drm_atomic_state_put(&state->base);
 
 	intel_atomic_helper_free_state(i915);
 }
diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
index 9488449e4b94..805ca774e146 100644
--- a/drivers/gpu/drm/i915/display/intel_display_types.h
+++ b/drivers/gpu/drm/i915/display/intel_display_types.h
@@ -1078,6 +1078,9 @@ struct intel_crtc_state {
 
 	/* Only valid on TGL+ */
 	enum transcoder mst_master_transcoder;
+
+	/* For DSB related info */
+	struct intel_dsb dsb;
 };
 
 enum intel_pipe_crc_source {
@@ -1147,9 +1150,6 @@ struct intel_crtc {
 	/* scalers available on this crtc */
 	int num_scalers;
 
-	/* per pipe DSB related info */
-	struct intel_dsb dsb;
-
 #ifdef CONFIG_DEBUG_FS
 	struct intel_pipe_crc pipe_crc;
 #endif
diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
index 29fec6a92d17..247fd564d394 100644
--- a/drivers/gpu/drm/i915/display/intel_dsb.c
+++ b/drivers/gpu/drm/i915/display/intel_dsb.c
@@ -34,18 +34,22 @@
 #define DSB_BYTE_EN_SHIFT		20
 #define DSB_REG_VALUE_MASK		0xfffff
 
-static bool is_dsb_busy(struct intel_dsb *dsb)
+static inline bool is_dsb_busy(struct intel_dsb *dsb)
 {
-	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
+	struct intel_crtc_state *crtc_state =
+		container_of(dsb, typeof(*crtc_state), dsb);
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
 	enum pipe pipe = crtc->pipe;
 
 	return DSB_STATUS & intel_de_read(dev_priv, DSB_CTRL(pipe, dsb->id));
 }
 
-static bool intel_dsb_enable_engine(struct intel_dsb *dsb)
+static inline bool intel_dsb_enable_engine(struct intel_dsb *dsb)
 {
-	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
+	struct intel_crtc_state *crtc_state =
+		container_of(dsb, typeof(*crtc_state), dsb);
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
 	enum pipe pipe = crtc->pipe;
 	u32 dsb_ctrl;
@@ -63,9 +67,11 @@ static bool intel_dsb_enable_engine(struct intel_dsb *dsb)
 	return true;
 }
 
-static bool intel_dsb_disable_engine(struct intel_dsb *dsb)
+static inline bool intel_dsb_disable_engine(struct intel_dsb *dsb)
 {
-	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
+	struct intel_crtc_state *crtc_state =
+		container_of(dsb, typeof(*crtc_state), dsb);
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
 	enum pipe pipe = crtc->pipe;
 	u32 dsb_ctrl;
@@ -83,99 +89,6 @@ static bool intel_dsb_disable_engine(struct intel_dsb *dsb)
 	return true;
 }
 
-/**
- * intel_dsb_get() - Allocate DSB context and return a DSB instance.
- * @crtc: intel_crtc structure to get pipe info.
- *
- * This function provides handle of a DSB instance, for the further DSB
- * operations.
- *
- * Returns: address of Intel_dsb instance requested for.
- * Failure: Returns the same DSB instance, but without a command buffer.
- */
-
-struct intel_dsb *
-intel_dsb_get(struct intel_crtc *crtc)
-{
-	struct drm_device *dev = crtc->base.dev;
-	struct drm_i915_private *i915 = to_i915(dev);
-	struct intel_dsb *dsb = &crtc->dsb;
-	struct drm_i915_gem_object *obj;
-	struct i915_vma *vma;
-	u32 *buf;
-	intel_wakeref_t wakeref;
-
-	if (!HAS_DSB(i915))
-		return dsb;
-
-	if (dsb->refcount++ != 0)
-		return dsb;
-
-	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
-
-	obj = i915_gem_object_create_internal(i915, DSB_BUF_SIZE);
-	if (IS_ERR(obj)) {
-		drm_err(&i915->drm, "Gem object creation failed\n");
-		goto out;
-	}
-
-	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
-	if (IS_ERR(vma)) {
-		drm_err(&i915->drm, "Vma creation failed\n");
-		i915_gem_object_put(obj);
-		goto out;
-	}
-
-	buf = i915_gem_object_pin_map(vma->obj, I915_MAP_WC);
-	if (IS_ERR(buf)) {
-		drm_err(&i915->drm, "Command buffer creation failed\n");
-		goto out;
-	}
-
-	dsb->id = DSB1;
-	dsb->vma = vma;
-	dsb->cmd_buf = buf;
-
-out:
-	/*
-	 * On error dsb->cmd_buf will continue to be NULL, making the writes
-	 * pass-through. Leave the dangling ref to be removed later by the
-	 * corresponding intel_dsb_put(): the important error message will
-	 * already be logged above.
-	 */
-
-	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
-
-	return dsb;
-}
-
-/**
- * intel_dsb_put() - To destroy DSB context.
- * @dsb: intel_dsb structure.
- *
- * This function destroys the DSB context allocated by a dsb_get(), by
- * unpinning and releasing the VMA object associated with it.
- */
-
-void intel_dsb_put(struct intel_dsb *dsb)
-{
-	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
-	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
-
-	if (!HAS_DSB(i915))
-		return;
-
-	if (drm_WARN_ON(&i915->drm, dsb->refcount == 0))
-		return;
-
-	if (--dsb->refcount == 0) {
-		i915_vma_unpin_and_release(&dsb->vma, I915_VMA_RELEASE_MAP);
-		dsb->cmd_buf = NULL;
-		dsb->free_pos = 0;
-		dsb->ins_start_offset = 0;
-	}
-}
-
 /**
  * intel_dsb_indexed_reg_write() -Write to the DSB context for auto
  * increment register.
@@ -192,7 +105,9 @@ void intel_dsb_put(struct intel_dsb *dsb)
 void intel_dsb_indexed_reg_write(struct intel_dsb *dsb, i915_reg_t reg,
 				 u32 val)
 {
-	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
+	struct intel_crtc_state *crtc_state =
+		container_of(dsb, typeof(*crtc_state), dsb);
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
 	u32 *buf = dsb->cmd_buf;
 	u32 reg_val;
@@ -267,7 +182,9 @@ void intel_dsb_indexed_reg_write(struct intel_dsb *dsb, i915_reg_t reg,
  */
 void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val)
 {
-	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
+	struct intel_crtc_state *crtc_state =
+		container_of(dsb, typeof(*crtc_state), dsb);
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
 	u32 *buf = dsb->cmd_buf;
 
@@ -297,7 +214,9 @@ void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val)
  */
 void intel_dsb_commit(struct intel_dsb *dsb)
 {
-	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
+	struct intel_crtc_state *crtc_state =
+		container_of(dsb, typeof(*crtc_state), dsb);
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
 	struct drm_device *dev = crtc->base.dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
 	enum pipe pipe = crtc->pipe;
@@ -343,3 +262,87 @@ void intel_dsb_commit(struct intel_dsb *dsb)
 	dsb->ins_start_offset = 0;
 	intel_dsb_disable_engine(dsb);
 }
+
+/**
+ * intel_dsb_prepare() - Allocate, pin and map the DSB command buffer.
+ * @crtc_state: intel_crtc_state structure to prepare associated dsb instance.
+ *
+ * This function prepare the command buffer which is used to store dsb
+ * instructions with data.
+ */
+
+void intel_dsb_prepare(struct intel_crtc_state *crtc_state)
+{
+	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
+	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
+	struct intel_dsb *dsb = &crtc_state->dsb;
+	struct drm_i915_gem_object *obj;
+	struct i915_vma *vma;
+	u32 *buf;
+	intel_wakeref_t wakeref;
+
+	if (!HAS_DSB(i915) || dsb->cmd_buf)
+		return;
+
+	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
+
+	obj = i915_gem_object_create_internal(i915, DSB_BUF_SIZE);
+	if (IS_ERR(obj)) {
+		drm_err(&i915->drm, "Gem object creation failed\n");
+		goto out;
+	}
+
+	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
+	if (IS_ERR(vma)) {
+		drm_err(&i915->drm, "Vma creation failed\n");
+		i915_gem_object_put(obj);
+		goto out;
+	}
+
+	buf = i915_gem_object_pin_map(vma->obj, I915_MAP_WC);
+	if (IS_ERR(buf)) {
+		drm_err(&i915->drm, "Command buffer creation failed\n");
+		goto out;
+	}
+
+	dsb->id = DSB1;
+	dsb->vma = vma;
+	dsb->cmd_buf = buf;
+
+out:
+	/*
+	 * On error dsb->cmd_buf will continue to be NULL, making the writes
+	 * pass-through. Leave the dangling ref to be removed later by the
+	 * corresponding intel_dsb_put(): the important error message will
+	 * already be logged above.
+	 */
+
+	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
+}
+
+/**
+ * intel_dsb_cleanup() - To cleanup DSB context.
+ * @crtc_state: intel_crtc_state structure to cleanup associated dsb instance.
+ *
+ * This function cleanup the DSB context by unpinning and releasing
+ * the VMA object associated with it.
+ */
+
+void intel_dsb_cleanup(struct intel_crtc_state *crtc_state)
+{
+	struct intel_dsb *dsb = &crtc_state->dsb;
+	struct i915_vma *p_vma;
+
+	if (dsb->vma) {
+		p_vma = fetch_and_zero(&dsb->vma);
+		if (p_vma) {
+			i915_vma_unpin(p_vma);
+			i915_gem_object_unpin_map(p_vma->obj);
+			i915_gem_object_put(p_vma->obj);
+		}
+		dsb->vma = NULL;
+		dsb->cmd_buf = NULL;
+		dsb->free_pos = 0;
+		dsb->ins_start_offset = 0;
+	}
+}
diff --git a/drivers/gpu/drm/i915/display/intel_dsb.h b/drivers/gpu/drm/i915/display/intel_dsb.h
index 395ef9ce558e..3a20a4388b9a 100644
--- a/drivers/gpu/drm/i915/display/intel_dsb.h
+++ b/drivers/gpu/drm/i915/display/intel_dsb.h
@@ -10,7 +10,7 @@
 
 #include "i915_reg.h"
 
-struct intel_crtc;
+struct intel_crtc_state;
 struct i915_vma;
 
 enum dsb_id {
@@ -22,7 +22,6 @@ enum dsb_id {
 };
 
 struct intel_dsb {
-	long refcount;
 	enum dsb_id id;
 	u32 *cmd_buf;
 	struct i915_vma *vma;
@@ -41,9 +40,8 @@ struct intel_dsb {
 	u32 ins_start_offset;
 };
 
-struct intel_dsb *
-intel_dsb_get(struct intel_crtc *crtc);
-void intel_dsb_put(struct intel_dsb *dsb);
+void intel_dsb_prepare(struct intel_crtc_state *crtc_state);
+void intel_dsb_cleanup(struct intel_crtc_state *crtc_state);
 void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val);
 void intel_dsb_indexed_reg_write(struct intel_dsb *dsb, i915_reg_t reg,
 				 u32 val);
-- 
2.26.0

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

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

* [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/dsb: Pre allocate and late cleanup of cmd buffer (rev4)
  2020-05-06 13:11 [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer Animesh Manna
@ 2020-05-06 14:02 ` Patchwork
  2020-05-06 15:13 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
  2020-05-08 11:14 ` [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer Maarten Lankhorst
  2 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2020-05-06 14:02 UTC (permalink / raw)
  To: Animesh Manna; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/dsb: Pre allocate and late cleanup of cmd buffer (rev4)
URL   : https://patchwork.freedesktop.org/series/73036/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_8433 -> Patchwork_17589
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/index.html

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

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

### IGT changes ###

#### Suppressed ####

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

  * igt@i915_module_load@reload:
    - {fi-tgl-dsi}:       [PASS][1] -> [INCOMPLETE][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/fi-tgl-dsi/igt@i915_module_load@reload.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/fi-tgl-dsi/igt@i915_module_load@reload.html
    - {fi-tgl-u}:         [PASS][3] -> [INCOMPLETE][4]
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/fi-tgl-u/igt@i915_module_load@reload.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/fi-tgl-u/igt@i915_module_load@reload.html

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

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

### IGT changes ###

#### Issues hit ####

  * igt@i915_selftest@live@perf:
    - fi-bwr-2160:        [PASS][5] -> [INCOMPLETE][6] ([i915#489])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/fi-bwr-2160/igt@i915_selftest@live@perf.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/fi-bwr-2160/igt@i915_selftest@live@perf.html

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

  [i915#489]: https://gitlab.freedesktop.org/drm/intel/issues/489


Participating hosts (51 -> 43)
------------------------------

  Missing    (8): fi-ilk-m540 fi-hsw-4200u fi-byt-squawks fi-bsw-cyan fi-ctg-p8600 fi-kbl-7560u fi-byt-clapper fi-bdw-samus 


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

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8433 -> Patchwork_17589

  CI-20190529: 20190529
  CI_DRM_8433: db68fed086f2ddcdc30e0d9ca5faaba5e55d0d01 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5633: c8c2e5ed5cd8e4b7a69a903f3f1653612086abcc @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17589: 6353a74d2b4ce9736369c905a92f0d2ec45651e6 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

6353a74d2b4c drm/i915/dsb: Pre allocate and late cleanup of cmd buffer

== Logs ==

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

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

* [Intel-gfx] ✗ Fi.CI.IGT: failure for drm/i915/dsb: Pre allocate and late cleanup of cmd buffer (rev4)
  2020-05-06 13:11 [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer Animesh Manna
  2020-05-06 14:02 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/dsb: Pre allocate and late cleanup of cmd buffer (rev4) Patchwork
@ 2020-05-06 15:13 ` Patchwork
  2020-05-08 11:14 ` [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer Maarten Lankhorst
  2 siblings, 0 replies; 7+ messages in thread
From: Patchwork @ 2020-05-06 15:13 UTC (permalink / raw)
  To: Animesh Manna; +Cc: intel-gfx

== Series Details ==

Series: drm/i915/dsb: Pre allocate and late cleanup of cmd buffer (rev4)
URL   : https://patchwork.freedesktop.org/series/73036/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_8433_full -> Patchwork_17589_full
====================================================

Summary
-------

  **FAILURE**

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

  

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

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

### IGT changes ###

#### Possible regressions ####

  * igt@i915_module_load@reload:
    - shard-tglb:         [PASS][1] -> [INCOMPLETE][2] +3 similar issues
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-tglb8/igt@i915_module_load@reload.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb7/igt@i915_module_load@reload.html

  * igt@runner@aborted:
    - shard-tglb:         NOTRUN -> ([FAIL][3], [FAIL][4], [FAIL][5], [FAIL][6], [FAIL][7], [FAIL][8], [FAIL][9], [FAIL][10], [FAIL][11], [FAIL][12]) ([i915#1764] / [k.org#204565] / [k.org#205379])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb2/igt@runner@aborted.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb7/igt@runner@aborted.html
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb1/igt@runner@aborted.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb3/igt@runner@aborted.html
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb2/igt@runner@aborted.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb6/igt@runner@aborted.html
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb1/igt@runner@aborted.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb6/igt@runner@aborted.html
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb8/igt@runner@aborted.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb7/igt@runner@aborted.html

  
#### Suppressed ####

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

  * {igt@perf_pmu@module-unload}:
    - shard-tglb:         [PASS][13] -> [INCOMPLETE][14]
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-tglb1/igt@perf_pmu@module-unload.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb3/igt@perf_pmu@module-unload.html

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

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

### IGT changes ###

#### Issues hit ####

  * igt@gen9_exec_parse@allowed-all:
    - shard-glk:          [PASS][15] -> [DMESG-WARN][16] ([i915#716])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-glk6/igt@gen9_exec_parse@allowed-all.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-glk5/igt@gen9_exec_parse@allowed-all.html

  * igt@kms_color@pipe-b-gamma:
    - shard-tglb:         [PASS][17] -> [DMESG-WARN][18] ([i915#1149]) +1 similar issue
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-tglb6/igt@kms_color@pipe-b-gamma.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb7/igt@kms_color@pipe-b-gamma.html

  * igt@kms_color@pipe-d-ctm-max:
    - shard-tglb:         [PASS][19] -> [INCOMPLETE][20] ([i915#1149]) +9 similar issues
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-tglb7/igt@kms_color@pipe-d-ctm-max.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb7/igt@kms_color@pipe-d-ctm-max.html

  * igt@kms_flip_tiling@flip-changes-tiling:
    - shard-kbl:          [PASS][21] -> [FAIL][22] ([i915#699] / [i915#93] / [i915#95])
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-kbl4/igt@kms_flip_tiling@flip-changes-tiling.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-kbl3/igt@kms_flip_tiling@flip-changes-tiling.html

  * igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-cpu:
    - shard-snb:          [PASS][23] -> [SKIP][24] ([fdo#109271]) +2 similar issues
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-snb1/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-cpu.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-snb2/igt@kms_frontbuffer_tracking@fbc-1p-offscren-pri-shrfb-draw-mmap-cpu.html

  * igt@kms_hdr@bpc-switch-dpms:
    - shard-skl:          [PASS][25] -> [FAIL][26] ([i915#1188]) +1 similar issue
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-skl1/igt@kms_hdr@bpc-switch-dpms.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-skl4/igt@kms_hdr@bpc-switch-dpms.html

  * igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a:
    - shard-kbl:          [PASS][27] -> [DMESG-WARN][28] ([i915#180]) +1 similar issue
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-kbl2/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-kbl1/igt@kms_pipe_crc_basic@suspend-read-crc-pipe-a.html

  * igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes:
    - shard-apl:          [PASS][29] -> [DMESG-WARN][30] ([i915#180])
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-apl6/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-apl4/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes.html

  * igt@kms_psr@psr2_cursor_plane_onoff:
    - shard-iclb:         [PASS][31] -> [SKIP][32] ([fdo#109441]) +3 similar issues
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-iclb2/igt@kms_psr@psr2_cursor_plane_onoff.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-iclb8/igt@kms_psr@psr2_cursor_plane_onoff.html

  
#### Possible fixes ####

  * igt@gem_ctx_persistence@engines-mixed-process@vecs0:
    - shard-skl:          [FAIL][33] ([i915#1528]) -> [PASS][34]
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-skl4/igt@gem_ctx_persistence@engines-mixed-process@vecs0.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-skl3/igt@gem_ctx_persistence@engines-mixed-process@vecs0.html

  * {igt@kms_flip@flip-vs-suspend-interruptible@a-dp1}:
    - shard-kbl:          [DMESG-WARN][35] ([i915#180]) -> [PASS][36] +3 similar issues
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-kbl1/igt@kms_flip@flip-vs-suspend-interruptible@a-dp1.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-kbl6/igt@kms_flip@flip-vs-suspend-interruptible@a-dp1.html

  * {igt@kms_flip@flip-vs-suspend-interruptible@c-dp1}:
    - shard-apl:          [DMESG-WARN][37] ([i915#180]) -> [PASS][38] +2 similar issues
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-apl2/igt@kms_flip@flip-vs-suspend-interruptible@c-dp1.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-apl7/igt@kms_flip@flip-vs-suspend-interruptible@c-dp1.html

  * igt@kms_frontbuffer_tracking@fbc-suspend:
    - shard-kbl:          [DMESG-WARN][39] ([i915#180] / [i915#93] / [i915#95]) -> [PASS][40]
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-kbl1/igt@kms_frontbuffer_tracking@fbc-suspend.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-kbl2/igt@kms_frontbuffer_tracking@fbc-suspend.html

  * igt@kms_psr2_su@frontbuffer:
    - shard-iclb:         [SKIP][41] ([fdo#109642] / [fdo#111068]) -> [PASS][42]
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-iclb7/igt@kms_psr2_su@frontbuffer.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-iclb2/igt@kms_psr2_su@frontbuffer.html

  * igt@kms_psr@psr2_cursor_mmap_cpu:
    - shard-iclb:         [SKIP][43] ([fdo#109441]) -> [PASS][44] +1 similar issue
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-iclb1/igt@kms_psr@psr2_cursor_mmap_cpu.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-iclb2/igt@kms_psr@psr2_cursor_mmap_cpu.html

  
#### Warnings ####

  * igt@i915_pm_rpm@pm-caching:
    - shard-snb:          [INCOMPLETE][45] ([i915#82]) -> [SKIP][46] ([fdo#109271])
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-snb1/igt@i915_pm_rpm@pm-caching.html
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-snb5/igt@i915_pm_rpm@pm-caching.html

  * igt@kms_color@pipe-a-ctm-0-75:
    - shard-tglb:         [FAIL][47] ([i915#1149] / [i915#315]) -> [INCOMPLETE][48] ([i915#1149]) +2 similar issues
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-tglb5/igt@kms_color@pipe-a-ctm-0-75.html
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb3/igt@kms_color@pipe-a-ctm-0-75.html

  * igt@kms_color@pipe-a-degamma:
    - shard-tglb:         [FAIL][49] ([i915#1149]) -> [INCOMPLETE][50] ([i915#1149])
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-tglb6/igt@kms_color@pipe-a-degamma.html
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-tglb5/igt@kms_color@pipe-a-degamma.html

  * igt@kms_content_protection@atomic:
    - shard-apl:          [TIMEOUT][51] ([i915#1319]) -> [FAIL][52] ([fdo#110321] / [fdo#110336])
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-apl7/igt@kms_content_protection@atomic.html
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-apl6/igt@kms_content_protection@atomic.html

  * igt@kms_content_protection@atomic-dpms:
    - shard-apl:          [FAIL][53] ([fdo#110321] / [fdo#110336] / [i915#95]) -> [TIMEOUT][54] ([i915#1319])
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-apl4/igt@kms_content_protection@atomic-dpms.html
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-apl3/igt@kms_content_protection@atomic-dpms.html

  * igt@kms_content_protection@legacy:
    - shard-apl:          [FAIL][55] ([fdo#110321] / [fdo#110336]) -> [TIMEOUT][56] ([i915#1319])
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_8433/shard-apl7/igt@kms_content_protection@legacy.html
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_17589/shard-apl1/igt@kms_content_protection@legacy.html

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

  [fdo#109271]: https://bugs.freedesktop.org/show_bug.cgi?id=109271
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#109642]: https://bugs.freedesktop.org/show_bug.cgi?id=109642
  [fdo#110321]: https://bugs.freedesktop.org/show_bug.cgi?id=110321
  [fdo#110336]: https://bugs.freedesktop.org/show_bug.cgi?id=110336
  [fdo#111068]: https://bugs.freedesktop.org/show_bug.cgi?id=111068
  [i915#1149]: https://gitlab.freedesktop.org/drm/intel/issues/1149
  [i915#1188]: https://gitlab.freedesktop.org/drm/intel/issues/1188
  [i915#1319]: https://gitlab.freedesktop.org/drm/intel/issues/1319
  [i915#1528]: https://gitlab.freedesktop.org/drm/intel/issues/1528
  [i915#1542]: https://gitlab.freedesktop.org/drm/intel/issues/1542
  [i915#1764]: https://gitlab.freedesktop.org/drm/intel/issues/1764
  [i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
  [i915#315]: https://gitlab.freedesktop.org/drm/intel/issues/315
  [i915#34]: https://gitlab.freedesktop.org/drm/intel/issues/34
  [i915#699]: https://gitlab.freedesktop.org/drm/intel/issues/699
  [i915#716]: https://gitlab.freedesktop.org/drm/intel/issues/716
  [i915#82]: https://gitlab.freedesktop.org/drm/intel/issues/82
  [i915#93]: https://gitlab.freedesktop.org/drm/intel/issues/93
  [i915#95]: https://gitlab.freedesktop.org/drm/intel/issues/95
  [k.org#204565]: https://bugzilla.kernel.org/show_bug.cgi?id=204565
  [k.org#205379]: https://bugzilla.kernel.org/show_bug.cgi?id=205379


Participating hosts (11 -> 10)
------------------------------

  Missing    (1): pig-icl-1065g7 


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

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_8433 -> Patchwork_17589

  CI-20190529: 20190529
  CI_DRM_8433: db68fed086f2ddcdc30e0d9ca5faaba5e55d0d01 @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5633: c8c2e5ed5cd8e4b7a69a903f3f1653612086abcc @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_17589: 6353a74d2b4ce9736369c905a92f0d2ec45651e6 @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

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

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

* Re: [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer
  2020-05-06 13:11 [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer Animesh Manna
  2020-05-06 14:02 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/dsb: Pre allocate and late cleanup of cmd buffer (rev4) Patchwork
  2020-05-06 15:13 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
@ 2020-05-08 11:14 ` Maarten Lankhorst
  2020-05-11  6:01   ` Manna, Animesh
  2 siblings, 1 reply; 7+ messages in thread
From: Maarten Lankhorst @ 2020-05-08 11:14 UTC (permalink / raw)
  To: Animesh Manna, intel-gfx; +Cc: Jani Nikula, Daniel Vetter

Op 06-05-2020 om 15:11 schreef Animesh Manna:
> Pre-allocate command buffer in atomic_commit using intel_dsb_prepare
> function which also includes pinning and map in cpu domain.
>
> No change is dsb write/commit functions.
>
> Now dsb get/put function is refactored and currently used only for
> reference counting. Below dsb api added to do respective job
> mentioned below.
>
> intel_dsb_prepare - Allocate, pin and map the buffer.
> intel_dsb_cleanup - Unpin and release the gem object.
>
> RFC: Initial patch for design review.
> v2: included _init() part in _prepare(). [Daniel, Ville]
> v3: dsb_cleanup called after cleanup_planes. [Daniel]
> v4: dsb structure is moved to intel_crtc_state from intel_crtc. [Maarten]
> v5: dsb get/put/ref-count mechanism removed. [Maarten]
>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Cc: Jani Nikula <jani.nikula@intel.com>
> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
> Signed-off-by: Animesh Manna <animesh.manna@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_color.c    |  27 ++-
>  drivers/gpu/drm/i915/display/intel_display.c  |  60 ++++-
>  .../drm/i915/display/intel_display_types.h    |   6 +-
>  drivers/gpu/drm/i915/display/intel_dsb.c      | 207 +++++++++---------
>  drivers/gpu/drm/i915/display/intel_dsb.h      |   8 +-
>  5 files changed, 178 insertions(+), 130 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
> index 98ece9cd7cdd..dba820136106 100644
> --- a/drivers/gpu/drm/i915/display/intel_color.c
> +++ b/drivers/gpu/drm/i915/display/intel_color.c
> @@ -717,7 +717,8 @@ static void bdw_load_lut_10(struct intel_crtc *crtc,
>  static void ivb_load_lut_ext_max(struct intel_crtc *crtc)
>  {
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
> +	struct intel_crtc_state *crtc_state = to_intel_crtc_state(crtc->base.state);
> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
>  	enum pipe pipe = crtc->pipe;
>  
>  	/* Program the max register to clamp values > 1.0. */
Please pass the crtc_state, as crtc->state should not be used directly.
> @@ -738,8 +739,6 @@ static void ivb_load_lut_ext_max(struct intel_crtc *crtc)
>  		intel_dsb_reg_write(dsb, PREC_PAL_EXT2_GC_MAX(pipe, 2),
>  				    1 << 16);
>  	}
> -
> -	intel_dsb_put(dsb);
>  }
>  
>  static void ivb_load_luts(const struct intel_crtc_state *crtc_state)
> @@ -900,14 +899,13 @@ icl_load_gcmax(const struct intel_crtc_state *crtc_state,
>  	       const struct drm_color_lut *color)
>  {
>  	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;

Why the cast? Unconstify crtc_state as it's obviously not const any more.

>  	enum pipe pipe = crtc->pipe;
>  
>  	/* FIXME LUT entries are 16 bit only, so we can prog 0xFFFF max */
>  	intel_dsb_reg_write(dsb, PREC_PAL_GC_MAX(pipe, 0), color->red);
>  	intel_dsb_reg_write(dsb, PREC_PAL_GC_MAX(pipe, 1), color->green);
>  	intel_dsb_reg_write(dsb, PREC_PAL_GC_MAX(pipe, 2), color->blue);
> -	intel_dsb_put(dsb);
>  }
>  
>  static void
> @@ -916,7 +914,7 @@ icl_program_gamma_superfine_segment(const struct intel_crtc_state *crtc_state)
>  	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>  	const struct drm_property_blob *blob = crtc_state->hw.gamma_lut;
>  	const struct drm_color_lut *lut = blob->data;
> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
Same.
>  	enum pipe pipe = crtc->pipe;
>  	int i;
>  
> @@ -938,8 +936,6 @@ icl_program_gamma_superfine_segment(const struct intel_crtc_state *crtc_state)
>  		intel_dsb_indexed_reg_write(dsb, PREC_PAL_MULTI_SEG_DATA(pipe),
>  					    ilk_lut_12p4_udw(entry));
>  	}
> -
> -	intel_dsb_put(dsb);
>  }
>  
>  static void
> @@ -949,7 +945,7 @@ icl_program_gamma_multi_segment(const struct intel_crtc_state *crtc_state)
>  	const struct drm_property_blob *blob = crtc_state->hw.gamma_lut;
>  	const struct drm_color_lut *lut = blob->data;
>  	const struct drm_color_lut *entry;
> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
>  	enum pipe pipe = crtc->pipe;
>  	int i;
>  
> @@ -996,14 +992,22 @@ icl_program_gamma_multi_segment(const struct intel_crtc_state *crtc_state)
>  	entry = &lut[256 * 8 * 128];
>  	icl_load_gcmax(crtc_state, entry);
>  	ivb_load_lut_ext_max(crtc);
> -	intel_dsb_put(dsb);
>  }
>  
>  static void icl_load_luts(const struct intel_crtc_state *crtc_state)
>  {
>  	const struct drm_property_blob *gamma_lut = crtc_state->hw.gamma_lut;
>  	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
> +
> +	/*
> +	 * TODO: Currently dsb buffer filling is done in load_lut() which
> +	 * can be done much earlier, like initial stage of atomic_commit().
> +	 * As currently replacing the mmio-write with dsb-write so the same
> +	 * load_lut() api is used for dsb buffer creation which may not
> +	 * fit in initial stage. Need to create a separate interface and
> +	 * a different path in color framework while dealing with dsb.
> +	 */
>  
>  	if (crtc_state->hw.degamma_lut)
>  		glk_load_degamma_lut(crtc_state);
> @@ -1022,7 +1026,6 @@ static void icl_load_luts(const struct intel_crtc_state *crtc_state)
>  	}
>  
>  	intel_dsb_commit(dsb);
> -	intel_dsb_put(dsb);
>  }
>  
>  static u32 chv_cgm_degamma_ldw(const struct drm_color_lut *color)
> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
> index fd6d63b03489..07670893c1ae 100644
> --- a/drivers/gpu/drm/i915/display/intel_display.c
> +++ b/drivers/gpu/drm/i915/display/intel_display.c
> @@ -14873,8 +14873,28 @@ static int intel_atomic_check(struct drm_device *dev,
>  
>  static int intel_atomic_prepare_commit(struct intel_atomic_state *state)
>  {
> -	return drm_atomic_helper_prepare_planes(state->base.dev,
> -						&state->base);
> +	struct intel_crtc_state *crtc_state;
> +	struct intel_crtc *crtc;
> +	int i, ret;
> +
> +	ret = drm_atomic_helper_prepare_planes(state->base.dev, &state->base);
> +	if (ret < 0)
> +		return ret;
> +
> +	/*
> +	 * In case of DSB buffer creation failure register programming will be
> +	 * done by mmio and erroneous path will be handled by dsp-write api.
> +	 */
> +	for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
> +		bool mode_changed = needs_modeset(crtc_state);
> +
> +		if (mode_changed || crtc_state->update_pipe ||
> +		    crtc_state->uapi.color_mgmt_changed) {
> +			intel_dsb_prepare(crtc_state);
> +		}
> +	}
> +
> +	return 0;
>  }
>  
>  u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc)
> @@ -15327,15 +15347,39 @@ static void intel_atomic_commit_fence_wait(struct intel_atomic_state *intel_stat
>  		    &wait_reset);
>  }
>  
> +static void intel_cleanup_dsbs(struct intel_atomic_state *state)
> +{
> +	struct intel_crtc_state *crtc_state, *old_crtc_state, *new_crtc_state;
> +	struct intel_crtc *crtc;
> +	int i;
> +
> +	for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
> +		bool mode_changed;
> +
> +		if (old_crtc_state == crtc->config)
> +			crtc_state = new_crtc_state;
> +		else
> +			crtc_state = old_crtc_state;
> +
> +		mode_changed = needs_modeset(crtc_state);
> +		if (mode_changed || crtc_state->update_pipe ||
> +		    crtc_state->uapi.color_mgmt_changed) {
> +			intel_dsb_cleanup(crtc_state);
Just call the cleanup function unconditionally here, the dsb->vma = NULL check is enough.
> +		}
> +	}
> +}
> +
>  static void intel_atomic_cleanup_work(struct work_struct *work)
>  {
> -	struct drm_atomic_state *state =
> -		container_of(work, struct drm_atomic_state, commit_work);
> -	struct drm_i915_private *i915 = to_i915(state->dev);
> +	struct intel_atomic_state *state =
> +		container_of(work, struct intel_atomic_state, base.commit_work);
> +	struct drm_i915_private *i915 = to_i915(state->base.dev);
>  
> -	drm_atomic_helper_cleanup_planes(&i915->drm, state);
> -	drm_atomic_helper_commit_cleanup_done(state);
> -	drm_atomic_state_put(state);
> +	if (HAS_DSB(i915))
> +		intel_cleanup_dsbs(state);
> +	drm_atomic_helper_cleanup_planes(&i915->drm, &state->base);
> +	drm_atomic_helper_commit_cleanup_done(&state->base);
> +	drm_atomic_state_put(&state->base);
>  
>  	intel_atomic_helper_free_state(i915);
>  }
> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
> index 9488449e4b94..805ca774e146 100644
> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
> @@ -1078,6 +1078,9 @@ struct intel_crtc_state {
>  
>  	/* Only valid on TGL+ */
>  	enum transcoder mst_master_transcoder;
> +
> +	/* For DSB related info */
> +	struct intel_dsb dsb;
>  };
>  
>  enum intel_pipe_crc_source {
> @@ -1147,9 +1150,6 @@ struct intel_crtc {
>  	/* scalers available on this crtc */
>  	int num_scalers;
>  
> -	/* per pipe DSB related info */
> -	struct intel_dsb dsb;
> -
>  #ifdef CONFIG_DEBUG_FS
>  	struct intel_pipe_crc pipe_crc;
>  #endif
> diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
> index 29fec6a92d17..247fd564d394 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsb.c
> +++ b/drivers/gpu/drm/i915/display/intel_dsb.c
> @@ -34,18 +34,22 @@
>  #define DSB_BYTE_EN_SHIFT		20
>  #define DSB_REG_VALUE_MASK		0xfffff
>  
> -static bool is_dsb_busy(struct intel_dsb *dsb)
> +static inline bool is_dsb_busy(struct intel_dsb *dsb)
>  {
> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
> +	struct intel_crtc_state *crtc_state =
> +		container_of(dsb, typeof(*crtc_state), dsb);
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>  	enum pipe pipe = crtc->pipe;
>  
>  	return DSB_STATUS & intel_de_read(dev_priv, DSB_CTRL(pipe, dsb->id));
>  }
>  
> -static bool intel_dsb_enable_engine(struct intel_dsb *dsb)
> +static inline bool intel_dsb_enable_engine(struct intel_dsb *dsb)
>  {
> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
> +	struct intel_crtc_state *crtc_state =
> +		container_of(dsb, typeof(*crtc_state), dsb);
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>  	enum pipe pipe = crtc->pipe;
>  	u32 dsb_ctrl;
> @@ -63,9 +67,11 @@ static bool intel_dsb_enable_engine(struct intel_dsb *dsb)
>  	return true;
>  }
>  
> -static bool intel_dsb_disable_engine(struct intel_dsb *dsb)
> +static inline bool intel_dsb_disable_engine(struct intel_dsb *dsb)
>  {
> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
> +	struct intel_crtc_state *crtc_state =
> +		container_of(dsb, typeof(*crtc_state), dsb);
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>  	enum pipe pipe = crtc->pipe;
>  	u32 dsb_ctrl;
> @@ -83,99 +89,6 @@ static bool intel_dsb_disable_engine(struct intel_dsb *dsb)
>  	return true;
>  }
>  
> -/**
> - * intel_dsb_get() - Allocate DSB context and return a DSB instance.
> - * @crtc: intel_crtc structure to get pipe info.
> - *
> - * This function provides handle of a DSB instance, for the further DSB
> - * operations.
> - *
> - * Returns: address of Intel_dsb instance requested for.
> - * Failure: Returns the same DSB instance, but without a command buffer.
> - */
> -
> -struct intel_dsb *
> -intel_dsb_get(struct intel_crtc *crtc)
> -{
> -	struct drm_device *dev = crtc->base.dev;
> -	struct drm_i915_private *i915 = to_i915(dev);
> -	struct intel_dsb *dsb = &crtc->dsb;
> -	struct drm_i915_gem_object *obj;
> -	struct i915_vma *vma;
> -	u32 *buf;
> -	intel_wakeref_t wakeref;
> -
> -	if (!HAS_DSB(i915))
> -		return dsb;
> -
> -	if (dsb->refcount++ != 0)
> -		return dsb;
> -
> -	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
> -
> -	obj = i915_gem_object_create_internal(i915, DSB_BUF_SIZE);
> -	if (IS_ERR(obj)) {
> -		drm_err(&i915->drm, "Gem object creation failed\n");
> -		goto out;
> -	}
> -
> -	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
> -	if (IS_ERR(vma)) {
> -		drm_err(&i915->drm, "Vma creation failed\n");
> -		i915_gem_object_put(obj);
> -		goto out;
> -	}
> -
> -	buf = i915_gem_object_pin_map(vma->obj, I915_MAP_WC);
> -	if (IS_ERR(buf)) {
> -		drm_err(&i915->drm, "Command buffer creation failed\n");
> -		goto out;
> -	}
> -
> -	dsb->id = DSB1;
> -	dsb->vma = vma;
> -	dsb->cmd_buf = buf;
> -
> -out:
> -	/*
> -	 * On error dsb->cmd_buf will continue to be NULL, making the writes
> -	 * pass-through. Leave the dangling ref to be removed later by the
> -	 * corresponding intel_dsb_put(): the important error message will
> -	 * already be logged above.
> -	 */
> -
> -	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
> -
> -	return dsb;
> -}
> -
> -/**
> - * intel_dsb_put() - To destroy DSB context.
> - * @dsb: intel_dsb structure.
> - *
> - * This function destroys the DSB context allocated by a dsb_get(), by
> - * unpinning and releasing the VMA object associated with it.
> - */
> -
> -void intel_dsb_put(struct intel_dsb *dsb)
> -{
> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
> -	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
> -
> -	if (!HAS_DSB(i915))
> -		return;
> -
> -	if (drm_WARN_ON(&i915->drm, dsb->refcount == 0))
> -		return;
> -
> -	if (--dsb->refcount == 0) {
> -		i915_vma_unpin_and_release(&dsb->vma, I915_VMA_RELEASE_MAP);
> -		dsb->cmd_buf = NULL;
> -		dsb->free_pos = 0;
> -		dsb->ins_start_offset = 0;
> -	}
> -}
> -
>  /**
>   * intel_dsb_indexed_reg_write() -Write to the DSB context for auto
>   * increment register.
> @@ -192,7 +105,9 @@ void intel_dsb_put(struct intel_dsb *dsb)
>  void intel_dsb_indexed_reg_write(struct intel_dsb *dsb, i915_reg_t reg,
>  				 u32 val)
>  {
> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
> +	struct intel_crtc_state *crtc_state =
> +		container_of(dsb, typeof(*crtc_state), dsb);
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>  	u32 *buf = dsb->cmd_buf;
>  	u32 reg_val;
> @@ -267,7 +182,9 @@ void intel_dsb_indexed_reg_write(struct intel_dsb *dsb, i915_reg_t reg,
>   */
>  void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val)
>  {
> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
> +	struct intel_crtc_state *crtc_state =
> +		container_of(dsb, typeof(*crtc_state), dsb);
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>  	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>  	u32 *buf = dsb->cmd_buf;
>  
> @@ -297,7 +214,9 @@ void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val)
>   */
>  void intel_dsb_commit(struct intel_dsb *dsb)
>  {
> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
> +	struct intel_crtc_state *crtc_state =
> +		container_of(dsb, typeof(*crtc_state), dsb);
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
Please pass crtc_state instead to all functions above. :)
>  	struct drm_device *dev = crtc->base.dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	enum pipe pipe = crtc->pipe;
> @@ -343,3 +262,87 @@ void intel_dsb_commit(struct intel_dsb *dsb)
>  	dsb->ins_start_offset = 0;
>  	intel_dsb_disable_engine(dsb);
>  }
> +
> +/**
> + * intel_dsb_prepare() - Allocate, pin and map the DSB command buffer.
> + * @crtc_state: intel_crtc_state structure to prepare associated dsb instance.
> + *
> + * This function prepare the command buffer which is used to store dsb
> + * instructions with data.
> + */
> +
> +void intel_dsb_prepare(struct intel_crtc_state *crtc_state)
> +{
> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> +	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
> +	struct intel_dsb *dsb = &crtc_state->dsb;
> +	struct drm_i915_gem_object *obj;
> +	struct i915_vma *vma;
> +	u32 *buf;
> +	intel_wakeref_t wakeref;
> +
> +	if (!HAS_DSB(i915) || dsb->cmd_buf)
> +		return;
> +
> +	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
> +
> +	obj = i915_gem_object_create_internal(i915, DSB_BUF_SIZE);
> +	if (IS_ERR(obj)) {
> +		drm_err(&i915->drm, "Gem object creation failed\n");
> +		goto out;
> +	}
> +
> +	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
> +	if (IS_ERR(vma)) {
> +		drm_err(&i915->drm, "Vma creation failed\n");
> +		i915_gem_object_put(obj);
> +		goto out;
> +	}
> +
> +	buf = i915_gem_object_pin_map(vma->obj, I915_MAP_WC);
> +	if (IS_ERR(buf)) {
> +		drm_err(&i915->drm, "Command buffer creation failed\n");
> +		goto out;
> +	}
> +
> +	dsb->id = DSB1;
> +	dsb->vma = vma;
> +	dsb->cmd_buf = buf;
> +
> +out:
> +	/*
> +	 * On error dsb->cmd_buf will continue to be NULL, making the writes
> +	 * pass-through. Leave the dangling ref to be removed later by the
> +	 * corresponding intel_dsb_put(): the important error message will
> +	 * already be logged above.
> +	 */
> +
> +	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
> +}
> +
> +/**
> + * intel_dsb_cleanup() - To cleanup DSB context.
> + * @crtc_state: intel_crtc_state structure to cleanup associated dsb instance.
> + *
> + * This function cleanup the DSB context by unpinning and releasing
> + * the VMA object associated with it.
> + */
> +
> +void intel_dsb_cleanup(struct intel_crtc_state *crtc_state)
> +{
> +	struct intel_dsb *dsb = &crtc_state->dsb;
> +	struct i915_vma *p_vma;
> +
> +	if (dsb->vma) {
> +		p_vma = fetch_and_zero(&dsb->vma);
> +		if (p_vma) {
> +			i915_vma_unpin(p_vma);
> +			i915_gem_object_unpin_map(p_vma->obj);
> +			i915_gem_object_put(p_vma->obj);
> +		}
> +		dsb->vma = NULL;
> +		dsb->cmd_buf = NULL;
> +		dsb->free_pos = 0;
> +		dsb->ins_start_offset = 0;
> +	}
> +}

I would simplify cleanup to vma = fetch_and_zero(&dsb->vma); if (!vma) return; and then only call the vma/gem functions to clean up. No need to fix the other stuff here as the struct is being freed.

Could probably drop the fetch_and_zero as well, but wouldn't hurt for paranoia. :)

Otherwise looks good now, only few tweaks are needed for the patch to be ready!

~Maarten


> diff --git a/drivers/gpu/drm/i915/display/intel_dsb.h b/drivers/gpu/drm/i915/display/intel_dsb.h
> index 395ef9ce558e..3a20a4388b9a 100644
> --- a/drivers/gpu/drm/i915/display/intel_dsb.h
> +++ b/drivers/gpu/drm/i915/display/intel_dsb.h
> @@ -10,7 +10,7 @@
>  
>  #include "i915_reg.h"
>  
> -struct intel_crtc;
> +struct intel_crtc_state;
>  struct i915_vma;
>  
>  enum dsb_id {
> @@ -22,7 +22,6 @@ enum dsb_id {
>  };
>  
>  struct intel_dsb {
> -	long refcount;
>  	enum dsb_id id;
>  	u32 *cmd_buf;
>  	struct i915_vma *vma;
> @@ -41,9 +40,8 @@ struct intel_dsb {
>  	u32 ins_start_offset;
>  };
>  
> -struct intel_dsb *
> -intel_dsb_get(struct intel_crtc *crtc);
> -void intel_dsb_put(struct intel_dsb *dsb);
> +void intel_dsb_prepare(struct intel_crtc_state *crtc_state);
> +void intel_dsb_cleanup(struct intel_crtc_state *crtc_state);
>  void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val);
>  void intel_dsb_indexed_reg_write(struct intel_dsb *dsb, i915_reg_t reg,
>  				 u32 val);


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

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

* Re: [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer
  2020-05-08 11:14 ` [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer Maarten Lankhorst
@ 2020-05-11  6:01   ` Manna, Animesh
  2020-05-11  8:49     ` Jani Nikula
  0 siblings, 1 reply; 7+ messages in thread
From: Manna, Animesh @ 2020-05-11  6:01 UTC (permalink / raw)
  To: Maarten Lankhorst, intel-gfx; +Cc: Jani Nikula, Daniel Vetter


On 08-05-2020 16:44, Maarten Lankhorst wrote:
> Op 06-05-2020 om 15:11 schreef Animesh Manna:
>> Pre-allocate command buffer in atomic_commit using intel_dsb_prepare
>> function which also includes pinning and map in cpu domain.
>>
>> No change is dsb write/commit functions.
>>
>> Now dsb get/put function is refactored and currently used only for
>> reference counting. Below dsb api added to do respective job
>> mentioned below.
>>
>> intel_dsb_prepare - Allocate, pin and map the buffer.
>> intel_dsb_cleanup - Unpin and release the gem object.
>>
>> RFC: Initial patch for design review.
>> v2: included _init() part in _prepare(). [Daniel, Ville]
>> v3: dsb_cleanup called after cleanup_planes. [Daniel]
>> v4: dsb structure is moved to intel_crtc_state from intel_crtc. [Maarten]
>> v5: dsb get/put/ref-count mechanism removed. [Maarten]
>>
>> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
>> Cc: Jani Nikula <jani.nikula@intel.com>
>> Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
>> Acked-by: Daniel Vetter <daniel.vetter@ffwll.ch>
>> Signed-off-by: Animesh Manna <animesh.manna@intel.com>
>> ---
>>   drivers/gpu/drm/i915/display/intel_color.c    |  27 ++-
>>   drivers/gpu/drm/i915/display/intel_display.c  |  60 ++++-
>>   .../drm/i915/display/intel_display_types.h    |   6 +-
>>   drivers/gpu/drm/i915/display/intel_dsb.c      | 207 +++++++++---------
>>   drivers/gpu/drm/i915/display/intel_dsb.h      |   8 +-
>>   5 files changed, 178 insertions(+), 130 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/display/intel_color.c b/drivers/gpu/drm/i915/display/intel_color.c
>> index 98ece9cd7cdd..dba820136106 100644
>> --- a/drivers/gpu/drm/i915/display/intel_color.c
>> +++ b/drivers/gpu/drm/i915/display/intel_color.c
>> @@ -717,7 +717,8 @@ static void bdw_load_lut_10(struct intel_crtc *crtc,
>>   static void ivb_load_lut_ext_max(struct intel_crtc *crtc)
>>   {
>>   	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
>> +	struct intel_crtc_state *crtc_state = to_intel_crtc_state(crtc->base.state);
>> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
>>   	enum pipe pipe = crtc->pipe;
>>   
>>   	/* Program the max register to clamp values > 1.0. */
> Please pass the crtc_state, as crtc->state should not be used directly.

I am not sure why ivb_load_lut_ext_max() is taking intel_crtc as argument where other load-lut function take crtc-state. Maybe it is done for older platform.

>> @@ -738,8 +739,6 @@ static void ivb_load_lut_ext_max(struct intel_crtc *crtc)
>>   		intel_dsb_reg_write(dsb, PREC_PAL_EXT2_GC_MAX(pipe, 2),
>>   				    1 << 16);
>>   	}
>> -
>> -	intel_dsb_put(dsb);
>>   }
>>   
>>   static void ivb_load_luts(const struct intel_crtc_state *crtc_state)
>> @@ -900,14 +899,13 @@ icl_load_gcmax(const struct intel_crtc_state *crtc_state,
>>   	       const struct drm_color_lut *color)
>>   {
>>   	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
>> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
> Why the cast? Unconstify crtc_state as it's obviously not const any more.

Dsb cmd buffer filling is done in load_lut function, so need to unconstify. Otherwise throwing warning during compilation.

>
>>   	enum pipe pipe = crtc->pipe;
>>   
>>   	/* FIXME LUT entries are 16 bit only, so we can prog 0xFFFF max */
>>   	intel_dsb_reg_write(dsb, PREC_PAL_GC_MAX(pipe, 0), color->red);
>>   	intel_dsb_reg_write(dsb, PREC_PAL_GC_MAX(pipe, 1), color->green);
>>   	intel_dsb_reg_write(dsb, PREC_PAL_GC_MAX(pipe, 2), color->blue);
>> -	intel_dsb_put(dsb);
>>   }
>>   
>>   static void
>> @@ -916,7 +914,7 @@ icl_program_gamma_superfine_segment(const struct intel_crtc_state *crtc_state)
>>   	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>>   	const struct drm_property_blob *blob = crtc_state->hw.gamma_lut;
>>   	const struct drm_color_lut *lut = blob->data;
>> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
>> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
> Same.

Need to unconstify to fill the dsb buffer.

>>   	enum pipe pipe = crtc->pipe;
>>   	int i;
>>   
>> @@ -938,8 +936,6 @@ icl_program_gamma_superfine_segment(const struct intel_crtc_state *crtc_state)
>>   		intel_dsb_indexed_reg_write(dsb, PREC_PAL_MULTI_SEG_DATA(pipe),
>>   					    ilk_lut_12p4_udw(entry));
>>   	}
>> -
>> -	intel_dsb_put(dsb);
>>   }
>>   
>>   static void
>> @@ -949,7 +945,7 @@ icl_program_gamma_multi_segment(const struct intel_crtc_state *crtc_state)
>>   	const struct drm_property_blob *blob = crtc_state->hw.gamma_lut;
>>   	const struct drm_color_lut *lut = blob->data;
>>   	const struct drm_color_lut *entry;
>> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
>> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
>>   	enum pipe pipe = crtc->pipe;
>>   	int i;
>>   
>> @@ -996,14 +992,22 @@ icl_program_gamma_multi_segment(const struct intel_crtc_state *crtc_state)
>>   	entry = &lut[256 * 8 * 128];
>>   	icl_load_gcmax(crtc_state, entry);
>>   	ivb_load_lut_ext_max(crtc);
>> -	intel_dsb_put(dsb);
>>   }
>>   
>>   static void icl_load_luts(const struct intel_crtc_state *crtc_state)
>>   {
>>   	const struct drm_property_blob *gamma_lut = crtc_state->hw.gamma_lut;
>>   	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
>> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
>> +
>> +	/*
>> +	 * TODO: Currently dsb buffer filling is done in load_lut() which
>> +	 * can be done much earlier, like initial stage of atomic_commit().
>> +	 * As currently replacing the mmio-write with dsb-write so the same
>> +	 * load_lut() api is used for dsb buffer creation which may not
>> +	 * fit in initial stage. Need to create a separate interface and
>> +	 * a different path in color framework while dealing with dsb.
>> +	 */
>>   
>>   	if (crtc_state->hw.degamma_lut)
>>   		glk_load_degamma_lut(crtc_state);
>> @@ -1022,7 +1026,6 @@ static void icl_load_luts(const struct intel_crtc_state *crtc_state)
>>   	}
>>   
>>   	intel_dsb_commit(dsb);
>> -	intel_dsb_put(dsb);
>>   }
>>   
>>   static u32 chv_cgm_degamma_ldw(const struct drm_color_lut *color)
>> diff --git a/drivers/gpu/drm/i915/display/intel_display.c b/drivers/gpu/drm/i915/display/intel_display.c
>> index fd6d63b03489..07670893c1ae 100644
>> --- a/drivers/gpu/drm/i915/display/intel_display.c
>> +++ b/drivers/gpu/drm/i915/display/intel_display.c
>> @@ -14873,8 +14873,28 @@ static int intel_atomic_check(struct drm_device *dev,
>>   
>>   static int intel_atomic_prepare_commit(struct intel_atomic_state *state)
>>   {
>> -	return drm_atomic_helper_prepare_planes(state->base.dev,
>> -						&state->base);
>> +	struct intel_crtc_state *crtc_state;
>> +	struct intel_crtc *crtc;
>> +	int i, ret;
>> +
>> +	ret = drm_atomic_helper_prepare_planes(state->base.dev, &state->base);
>> +	if (ret < 0)
>> +		return ret;
>> +
>> +	/*
>> +	 * In case of DSB buffer creation failure register programming will be
>> +	 * done by mmio and erroneous path will be handled by dsp-write api.
>> +	 */
>> +	for_each_new_intel_crtc_in_state(state, crtc, crtc_state, i) {
>> +		bool mode_changed = needs_modeset(crtc_state);
>> +
>> +		if (mode_changed || crtc_state->update_pipe ||
>> +		    crtc_state->uapi.color_mgmt_changed) {
>> +			intel_dsb_prepare(crtc_state);
>> +		}
>> +	}
>> +
>> +	return 0;
>>   }
>>   
>>   u32 intel_crtc_get_vblank_counter(struct intel_crtc *crtc)
>> @@ -15327,15 +15347,39 @@ static void intel_atomic_commit_fence_wait(struct intel_atomic_state *intel_stat
>>   		    &wait_reset);
>>   }
>>   
>> +static void intel_cleanup_dsbs(struct intel_atomic_state *state)
>> +{
>> +	struct intel_crtc_state *crtc_state, *old_crtc_state, *new_crtc_state;
>> +	struct intel_crtc *crtc;
>> +	int i;
>> +
>> +	for_each_oldnew_intel_crtc_in_state(state, crtc, old_crtc_state, new_crtc_state, i) {
>> +		bool mode_changed;
>> +
>> +		if (old_crtc_state == crtc->config)
>> +			crtc_state = new_crtc_state;
>> +		else
>> +			crtc_state = old_crtc_state;
>> +
>> +		mode_changed = needs_modeset(crtc_state);
>> +		if (mode_changed || crtc_state->update_pipe ||
>> +		    crtc_state->uapi.color_mgmt_changed) {
>> +			intel_dsb_cleanup(crtc_state);
> Just call the cleanup function unconditionally here, the dsb->vma = NULL check is enough.

Ok.

>> +		}
>> +	}
>> +}
>> +
>>   static void intel_atomic_cleanup_work(struct work_struct *work)
>>   {
>> -	struct drm_atomic_state *state =
>> -		container_of(work, struct drm_atomic_state, commit_work);
>> -	struct drm_i915_private *i915 = to_i915(state->dev);
>> +	struct intel_atomic_state *state =
>> +		container_of(work, struct intel_atomic_state, base.commit_work);
>> +	struct drm_i915_private *i915 = to_i915(state->base.dev);
>>   
>> -	drm_atomic_helper_cleanup_planes(&i915->drm, state);
>> -	drm_atomic_helper_commit_cleanup_done(state);
>> -	drm_atomic_state_put(state);
>> +	if (HAS_DSB(i915))
>> +		intel_cleanup_dsbs(state);
>> +	drm_atomic_helper_cleanup_planes(&i915->drm, &state->base);
>> +	drm_atomic_helper_commit_cleanup_done(&state->base);
>> +	drm_atomic_state_put(&state->base);
>>   
>>   	intel_atomic_helper_free_state(i915);
>>   }
>> diff --git a/drivers/gpu/drm/i915/display/intel_display_types.h b/drivers/gpu/drm/i915/display/intel_display_types.h
>> index 9488449e4b94..805ca774e146 100644
>> --- a/drivers/gpu/drm/i915/display/intel_display_types.h
>> +++ b/drivers/gpu/drm/i915/display/intel_display_types.h
>> @@ -1078,6 +1078,9 @@ struct intel_crtc_state {
>>   
>>   	/* Only valid on TGL+ */
>>   	enum transcoder mst_master_transcoder;
>> +
>> +	/* For DSB related info */
>> +	struct intel_dsb dsb;
>>   };
>>   
>>   enum intel_pipe_crc_source {
>> @@ -1147,9 +1150,6 @@ struct intel_crtc {
>>   	/* scalers available on this crtc */
>>   	int num_scalers;
>>   
>> -	/* per pipe DSB related info */
>> -	struct intel_dsb dsb;
>> -
>>   #ifdef CONFIG_DEBUG_FS
>>   	struct intel_pipe_crc pipe_crc;
>>   #endif
>> diff --git a/drivers/gpu/drm/i915/display/intel_dsb.c b/drivers/gpu/drm/i915/display/intel_dsb.c
>> index 29fec6a92d17..247fd564d394 100644
>> --- a/drivers/gpu/drm/i915/display/intel_dsb.c
>> +++ b/drivers/gpu/drm/i915/display/intel_dsb.c
>> @@ -34,18 +34,22 @@
>>   #define DSB_BYTE_EN_SHIFT		20
>>   #define DSB_REG_VALUE_MASK		0xfffff
>>   
>> -static bool is_dsb_busy(struct intel_dsb *dsb)
>> +static inline bool is_dsb_busy(struct intel_dsb *dsb)
>>   {
>> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
>> +	struct intel_crtc_state *crtc_state =
>> +		container_of(dsb, typeof(*crtc_state), dsb);
>> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>>   	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>>   	enum pipe pipe = crtc->pipe;
>>   
>>   	return DSB_STATUS & intel_de_read(dev_priv, DSB_CTRL(pipe, dsb->id));
>>   }
>>   
>> -static bool intel_dsb_enable_engine(struct intel_dsb *dsb)
>> +static inline bool intel_dsb_enable_engine(struct intel_dsb *dsb)
>>   {
>> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
>> +	struct intel_crtc_state *crtc_state =
>> +		container_of(dsb, typeof(*crtc_state), dsb);
>> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>>   	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>>   	enum pipe pipe = crtc->pipe;
>>   	u32 dsb_ctrl;
>> @@ -63,9 +67,11 @@ static bool intel_dsb_enable_engine(struct intel_dsb *dsb)
>>   	return true;
>>   }
>>   
>> -static bool intel_dsb_disable_engine(struct intel_dsb *dsb)
>> +static inline bool intel_dsb_disable_engine(struct intel_dsb *dsb)
>>   {
>> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
>> +	struct intel_crtc_state *crtc_state =
>> +		container_of(dsb, typeof(*crtc_state), dsb);
>> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>>   	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>>   	enum pipe pipe = crtc->pipe;
>>   	u32 dsb_ctrl;
>> @@ -83,99 +89,6 @@ static bool intel_dsb_disable_engine(struct intel_dsb *dsb)
>>   	return true;
>>   }
>>   
>> -/**
>> - * intel_dsb_get() - Allocate DSB context and return a DSB instance.
>> - * @crtc: intel_crtc structure to get pipe info.
>> - *
>> - * This function provides handle of a DSB instance, for the further DSB
>> - * operations.
>> - *
>> - * Returns: address of Intel_dsb instance requested for.
>> - * Failure: Returns the same DSB instance, but without a command buffer.
>> - */
>> -
>> -struct intel_dsb *
>> -intel_dsb_get(struct intel_crtc *crtc)
>> -{
>> -	struct drm_device *dev = crtc->base.dev;
>> -	struct drm_i915_private *i915 = to_i915(dev);
>> -	struct intel_dsb *dsb = &crtc->dsb;
>> -	struct drm_i915_gem_object *obj;
>> -	struct i915_vma *vma;
>> -	u32 *buf;
>> -	intel_wakeref_t wakeref;
>> -
>> -	if (!HAS_DSB(i915))
>> -		return dsb;
>> -
>> -	if (dsb->refcount++ != 0)
>> -		return dsb;
>> -
>> -	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
>> -
>> -	obj = i915_gem_object_create_internal(i915, DSB_BUF_SIZE);
>> -	if (IS_ERR(obj)) {
>> -		drm_err(&i915->drm, "Gem object creation failed\n");
>> -		goto out;
>> -	}
>> -
>> -	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
>> -	if (IS_ERR(vma)) {
>> -		drm_err(&i915->drm, "Vma creation failed\n");
>> -		i915_gem_object_put(obj);
>> -		goto out;
>> -	}
>> -
>> -	buf = i915_gem_object_pin_map(vma->obj, I915_MAP_WC);
>> -	if (IS_ERR(buf)) {
>> -		drm_err(&i915->drm, "Command buffer creation failed\n");
>> -		goto out;
>> -	}
>> -
>> -	dsb->id = DSB1;
>> -	dsb->vma = vma;
>> -	dsb->cmd_buf = buf;
>> -
>> -out:
>> -	/*
>> -	 * On error dsb->cmd_buf will continue to be NULL, making the writes
>> -	 * pass-through. Leave the dangling ref to be removed later by the
>> -	 * corresponding intel_dsb_put(): the important error message will
>> -	 * already be logged above.
>> -	 */
>> -
>> -	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
>> -
>> -	return dsb;
>> -}
>> -
>> -/**
>> - * intel_dsb_put() - To destroy DSB context.
>> - * @dsb: intel_dsb structure.
>> - *
>> - * This function destroys the DSB context allocated by a dsb_get(), by
>> - * unpinning and releasing the VMA object associated with it.
>> - */
>> -
>> -void intel_dsb_put(struct intel_dsb *dsb)
>> -{
>> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
>> -	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
>> -
>> -	if (!HAS_DSB(i915))
>> -		return;
>> -
>> -	if (drm_WARN_ON(&i915->drm, dsb->refcount == 0))
>> -		return;
>> -
>> -	if (--dsb->refcount == 0) {
>> -		i915_vma_unpin_and_release(&dsb->vma, I915_VMA_RELEASE_MAP);
>> -		dsb->cmd_buf = NULL;
>> -		dsb->free_pos = 0;
>> -		dsb->ins_start_offset = 0;
>> -	}
>> -}
>> -
>>   /**
>>    * intel_dsb_indexed_reg_write() -Write to the DSB context for auto
>>    * increment register.
>> @@ -192,7 +105,9 @@ void intel_dsb_put(struct intel_dsb *dsb)
>>   void intel_dsb_indexed_reg_write(struct intel_dsb *dsb, i915_reg_t reg,
>>   				 u32 val)
>>   {
>> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
>> +	struct intel_crtc_state *crtc_state =
>> +		container_of(dsb, typeof(*crtc_state), dsb);
>> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>>   	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>>   	u32 *buf = dsb->cmd_buf;
>>   	u32 reg_val;
>> @@ -267,7 +182,9 @@ void intel_dsb_indexed_reg_write(struct intel_dsb *dsb, i915_reg_t reg,
>>    */
>>   void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val)
>>   {
>> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
>> +	struct intel_crtc_state *crtc_state =
>> +		container_of(dsb, typeof(*crtc_state), dsb);
>> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>>   	struct drm_i915_private *dev_priv = to_i915(crtc->base.dev);
>>   	u32 *buf = dsb->cmd_buf;
>>   
>> @@ -297,7 +214,9 @@ void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val)
>>    */
>>   void intel_dsb_commit(struct intel_dsb *dsb)
>>   {
>> -	struct intel_crtc *crtc = container_of(dsb, typeof(*crtc), dsb);
>> +	struct intel_crtc_state *crtc_state =
>> +		container_of(dsb, typeof(*crtc_state), dsb);
>> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
> Please pass crtc_state instead to all functions above. :)

Yes, can be done.

>>   	struct drm_device *dev = crtc->base.dev;
>>   	struct drm_i915_private *dev_priv = to_i915(dev);
>>   	enum pipe pipe = crtc->pipe;
>> @@ -343,3 +262,87 @@ void intel_dsb_commit(struct intel_dsb *dsb)
>>   	dsb->ins_start_offset = 0;
>>   	intel_dsb_disable_engine(dsb);
>>   }
>> +
>> +/**
>> + * intel_dsb_prepare() - Allocate, pin and map the DSB command buffer.
>> + * @crtc_state: intel_crtc_state structure to prepare associated dsb instance.
>> + *
>> + * This function prepare the command buffer which is used to store dsb
>> + * instructions with data.
>> + */
>> +
>> +void intel_dsb_prepare(struct intel_crtc_state *crtc_state)
>> +{
>> +	struct intel_crtc *crtc = to_intel_crtc(crtc_state->uapi.crtc);
>> +	struct drm_i915_private *i915 = to_i915(crtc->base.dev);
>> +	struct intel_dsb *dsb = &crtc_state->dsb;
>> +	struct drm_i915_gem_object *obj;
>> +	struct i915_vma *vma;
>> +	u32 *buf;
>> +	intel_wakeref_t wakeref;
>> +
>> +	if (!HAS_DSB(i915) || dsb->cmd_buf)
>> +		return;
>> +
>> +	wakeref = intel_runtime_pm_get(&i915->runtime_pm);
>> +
>> +	obj = i915_gem_object_create_internal(i915, DSB_BUF_SIZE);
>> +	if (IS_ERR(obj)) {
>> +		drm_err(&i915->drm, "Gem object creation failed\n");
>> +		goto out;
>> +	}
>> +
>> +	vma = i915_gem_object_ggtt_pin(obj, NULL, 0, 0, 0);
>> +	if (IS_ERR(vma)) {
>> +		drm_err(&i915->drm, "Vma creation failed\n");
>> +		i915_gem_object_put(obj);
>> +		goto out;
>> +	}
>> +
>> +	buf = i915_gem_object_pin_map(vma->obj, I915_MAP_WC);
>> +	if (IS_ERR(buf)) {
>> +		drm_err(&i915->drm, "Command buffer creation failed\n");
>> +		goto out;
>> +	}
>> +
>> +	dsb->id = DSB1;
>> +	dsb->vma = vma;
>> +	dsb->cmd_buf = buf;
>> +
>> +out:
>> +	/*
>> +	 * On error dsb->cmd_buf will continue to be NULL, making the writes
>> +	 * pass-through. Leave the dangling ref to be removed later by the
>> +	 * corresponding intel_dsb_put(): the important error message will
>> +	 * already be logged above.
>> +	 */
>> +
>> +	intel_runtime_pm_put(&i915->runtime_pm, wakeref);
>> +}
>> +
>> +/**
>> + * intel_dsb_cleanup() - To cleanup DSB context.
>> + * @crtc_state: intel_crtc_state structure to cleanup associated dsb instance.
>> + *
>> + * This function cleanup the DSB context by unpinning and releasing
>> + * the VMA object associated with it.
>> + */
>> +
>> +void intel_dsb_cleanup(struct intel_crtc_state *crtc_state)
>> +{
>> +	struct intel_dsb *dsb = &crtc_state->dsb;
>> +	struct i915_vma *p_vma;
>> +
>> +	if (dsb->vma) {
>> +		p_vma = fetch_and_zero(&dsb->vma);
>> +		if (p_vma) {
>> +			i915_vma_unpin(p_vma);
>> +			i915_gem_object_unpin_map(p_vma->obj);
>> +			i915_gem_object_put(p_vma->obj);
>> +		}
>> +		dsb->vma = NULL;
>> +		dsb->cmd_buf = NULL;
>> +		dsb->free_pos = 0;
>> +		dsb->ins_start_offset = 0;
>> +	}
>> +}
> I would simplify cleanup to vma = fetch_and_zero(&dsb->vma); if (!vma) return; and then only call the vma/gem functions to clean up. No need to fix the other stuff here as the struct is being freed.

Sure .. do you mean like below?

void intel_dsb_cleanup(struct intel_crtc_state *crtc_state)
{
	struct intel_dsb *dsb = &crtc_state->dsb;
	struct i915_vma *p_vma = fetch_and_zero(&dsb->vma);

	if (!p_vma)
		return;

	i915_vma_unpin(p_vma);
	i915_gem_object_unpin_map(p_vma->obj);
	i915_gem_object_put(p_vma->obj);
	dsb->vma = NULL;
	dsb->cmd_buf = NULL;
	dsb->free_pos = 0;
	dsb->ins_start_offset = 0;
}

>
> Could probably drop the fetch_and_zero as well, but wouldn't hurt for paranoia. :)
>
> Otherwise looks good now, only few tweaks are needed for the patch to be ready!

Thanks for review. :)

Regards,
Animesh

>
> ~Maarten
>
>
>> diff --git a/drivers/gpu/drm/i915/display/intel_dsb.h b/drivers/gpu/drm/i915/display/intel_dsb.h
>> index 395ef9ce558e..3a20a4388b9a 100644
>> --- a/drivers/gpu/drm/i915/display/intel_dsb.h
>> +++ b/drivers/gpu/drm/i915/display/intel_dsb.h
>> @@ -10,7 +10,7 @@
>>   
>>   #include "i915_reg.h"
>>   
>> -struct intel_crtc;
>> +struct intel_crtc_state;
>>   struct i915_vma;
>>   
>>   enum dsb_id {
>> @@ -22,7 +22,6 @@ enum dsb_id {
>>   };
>>   
>>   struct intel_dsb {
>> -	long refcount;
>>   	enum dsb_id id;
>>   	u32 *cmd_buf;
>>   	struct i915_vma *vma;
>> @@ -41,9 +40,8 @@ struct intel_dsb {
>>   	u32 ins_start_offset;
>>   };
>>   
>> -struct intel_dsb *
>> -intel_dsb_get(struct intel_crtc *crtc);
>> -void intel_dsb_put(struct intel_dsb *dsb);
>> +void intel_dsb_prepare(struct intel_crtc_state *crtc_state);
>> +void intel_dsb_cleanup(struct intel_crtc_state *crtc_state);
>>   void intel_dsb_reg_write(struct intel_dsb *dsb, i915_reg_t reg, u32 val);
>>   void intel_dsb_indexed_reg_write(struct intel_dsb *dsb, i915_reg_t reg,
>>   				 u32 val);
>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer
  2020-05-11  6:01   ` Manna, Animesh
@ 2020-05-11  8:49     ` Jani Nikula
  2020-05-11  9:19       ` Manna, Animesh
  0 siblings, 1 reply; 7+ messages in thread
From: Jani Nikula @ 2020-05-11  8:49 UTC (permalink / raw)
  To: Manna, Animesh, Maarten Lankhorst, intel-gfx; +Cc: Daniel Vetter

On Mon, 11 May 2020, "Manna, Animesh" <animesh.manna@intel.com> wrote:
> On 08-05-2020 16:44, Maarten Lankhorst wrote:
>> Op 06-05-2020 om 15:11 schreef Animesh Manna:
>>> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
>>> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
>> Why the cast? Unconstify crtc_state as it's obviously not const any more.
>
> Dsb cmd buffer filling is done in load_lut function, so need to
> unconstify. Otherwise throwing warning during compilation.

You shouldn't just throw the const away like that using a cast. It's a
bad idea. Don't do it.

BR,
Jani.


-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer
  2020-05-11  8:49     ` Jani Nikula
@ 2020-05-11  9:19       ` Manna, Animesh
  0 siblings, 0 replies; 7+ messages in thread
From: Manna, Animesh @ 2020-05-11  9:19 UTC (permalink / raw)
  To: Jani Nikula, Maarten Lankhorst, intel-gfx; +Cc: Daniel Vetter


[-- Attachment #1.1: Type: text/plain, Size: 996 bytes --]


On 11-05-2020 14:19, Jani Nikula wrote:
> On Mon, 11 May 2020, "Manna, Animesh" <animesh.manna@intel.com> wrote:
>> On 08-05-2020 16:44, Maarten Lankhorst wrote:
>>> Op 06-05-2020 om 15:11 schreef Animesh Manna:
>>>> -	struct intel_dsb *dsb = intel_dsb_get(crtc);
>>>> +	struct intel_dsb *dsb = (struct intel_dsb *)&crtc_state->dsb;
>>> Why the cast? Unconstify crtc_state as it's obviously not const any more.
>> Dsb cmd buffer filling is done in load_lut function, so need to
>> unconstify. Otherwise throwing warning during compilation.
> You shouldn't just throw the const away like that using a cast. It's a
> bad idea. Don't do it.

Hi Jani/Maarten,

DSB instance was kept under intel_crtc to avoid typecasting. I do not know a way out to keep dsb-instance in intel_crtc_state and fill the dsb-cmd-buf using load-lut api.
Maybe avoid using current load-lut api and create a separate api to fill the cmd_buf can be a solution. Can you please suggest.

Regards,
Animesh

>
> BR,
> Jani.
>
>

[-- Attachment #1.2: Type: text/html, Size: 1986 bytes --]

[-- Attachment #2: Type: text/plain, Size: 160 bytes --]

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

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

end of thread, other threads:[~2020-05-11  9:19 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-05-06 13:11 [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer Animesh Manna
2020-05-06 14:02 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/i915/dsb: Pre allocate and late cleanup of cmd buffer (rev4) Patchwork
2020-05-06 15:13 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2020-05-08 11:14 ` [Intel-gfx] [PATCH v5] drm/i915/dsb: Pre allocate and late cleanup of cmd buffer Maarten Lankhorst
2020-05-11  6:01   ` Manna, Animesh
2020-05-11  8:49     ` Jani Nikula
2020-05-11  9:19       ` Manna, Animesh

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.