All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v3 00/19] Convert to atomic, part 3.
@ 2015-06-15 10:33 Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 01/19] drm/i915: Use crtc state in intel_modeset_pipe_config Maarten Lankhorst
                   ` (19 more replies)
  0 siblings, 20 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

Requisites:
- "[PATCH] drm/atomic: pass old crtc state to atomic_begin/flush."

This patch series converts plane updates and cdclk updates to atomic,
but still doesn't touch the hw readout code, which was regressing a lot.

The fixes in this series are needed to support proper hw readout, and can
be applied on top of topic/atomic-conversion.

In particular, this fixes the following bugs:
- https://bugs.freedesktop.org/show_bug.cgi?id=90874
  Needs atomic CDCLK as part of state, before any plane checks,
  or scalers will not work correctly.
- https://bugs.freedesktop.org/show_bug.cgi?id=90868
  It shows a problem with plane visibility on resume.
  This is fixed by calcing plane states correctly across modeset.
  There's also a problem with DPLL 0 failing to lock, I hope that's
  fixed by cdclk changes, but it might have been a bug in the reverted
  atomic hw readout patch too.

Maarten Lankhorst (19):
  drm/i915: Use crtc state in intel_modeset_pipe_config
  drm/i915: Clean up intel_atomic_setup_scalers slightly.
  drm/i915: Add a simple atomic crtc check function, v2.
  drm/i915: Move scaler setup to check crtc function, v2.
  drm/i915: Assign a new pll from the crtc check function, v2.
  drm/i915: Split skl_update_scaler, v3.
  drm/i915: Split plane updates of crtc->atomic into a helper, v2.
  drm/i915: clean up plane commit functions
  drm/i915: clean up atomic plane check functions, v2.
  drm/i915: remove force argument from disable_plane
  drm/i915: move detaching scalers to begin_crtc_commit, v2.
  drm/i915: Move crtc commit updates to separate functions.
  drm/i915: Do not run most checks when there's no modeset.
  drm/i915: Handle disabling planes better, v2.
  drm/i915: atomic plane updates in a nutshell
  drm/i915: Update less state during modeset.
  drm/i915: Make setting color key atomic.
  drm/i915: Remove transitional references from
    intel_plane_atomic_check.
  drm/i915: Make cdclk part of the atomic state.

 drivers/gpu/drm/i915/i915_drv.h           |    3 +-
 drivers/gpu/drm/i915/intel_atomic.c       |   47 +-
 drivers/gpu/drm/i915/intel_atomic_plane.c |   41 +-
 drivers/gpu/drm/i915/intel_display.c      | 1480 +++++++++++++++--------------
 drivers/gpu/drm/i915/intel_dp.c           |    2 +-
 drivers/gpu/drm/i915/intel_drv.h          |   27 +-
 drivers/gpu/drm/i915/intel_sprite.c       |  170 ++--
 7 files changed, 874 insertions(+), 896 deletions(-)

-- 
2.1.0

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

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

* [PATCH v3 01/19] drm/i915: Use crtc state in intel_modeset_pipe_config
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 02/19] drm/i915: Clean up intel_atomic_setup_scalers slightly Maarten Lankhorst
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

Grabbing crtc state from atomic state is a lot more involved,
and make sure connectors are added before calling this function.

Move check_digital_port_conflicts to intel_modeset_checks,
it's only useful to check it on a modeset.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 39 ++++++++++++++----------------------
 1 file changed, 15 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 5974e995676d..d36684080987 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -12044,10 +12044,9 @@ clear_intel_crtc_state(struct intel_crtc_state *crtc_state)
 
 static int
 intel_modeset_pipe_config(struct drm_crtc *crtc,
-			  struct drm_atomic_state *state)
+			  struct intel_crtc_state *pipe_config)
 {
-	struct drm_crtc_state *crtc_state;
-	struct intel_crtc_state *pipe_config;
+	struct drm_atomic_state *state = pipe_config->base.state;
 	struct intel_encoder *encoder;
 	struct drm_connector *connector;
 	struct drm_connector_state *connector_state;
@@ -12060,26 +12059,6 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
 		return -EINVAL;
 	}
 
-	if (!check_digital_port_conflicts(state)) {
-		DRM_DEBUG_KMS("rejecting conflicting digital port configuration\n");
-		return -EINVAL;
-	}
-
-	crtc_state = drm_atomic_get_existing_crtc_state(state, crtc);
-	if (WARN_ON(!crtc_state))
-		return -EINVAL;
-
-	pipe_config = to_intel_crtc_state(crtc_state);
-
-	/*
-	 * XXX: Add all connectors to make the crtc state match the encoders.
-	 */
-	if (!needs_modeset(&pipe_config->base)) {
-		ret = drm_atomic_add_affected_connectors(state, crtc);
-		if (ret)
-			return ret;
-	}
-
 	clear_intel_crtc_state(pipe_config);
 
 	pipe_config->cpu_transcoder =
@@ -12907,6 +12886,11 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
 	struct drm_device *dev = state->dev;
 	int ret;
 
+	if (!check_digital_port_conflicts(state)) {
+		DRM_DEBUG_KMS("rejecting conflicting digital port configuration\n");
+		return -EINVAL;
+	}
+
 	/*
 	 * See if the config requires any additional preparation, e.g.
 	 * to adjust global state with pipes off.  We need to do this
@@ -12953,7 +12937,14 @@ intel_modeset_compute_config(struct drm_atomic_state *state)
 		if (!crtc_state->enable)
 			continue;
 
-		ret = intel_modeset_pipe_config(crtc, state);
+		if (!needs_modeset(crtc_state)) {
+			ret = drm_atomic_add_affected_connectors(state, crtc);
+			if (ret)
+				return ret;
+		}
+
+		ret = intel_modeset_pipe_config(crtc,
+					to_intel_crtc_state(crtc_state));
 		if (ret)
 			return ret;
 
-- 
2.1.0

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

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

* [PATCH v3 02/19] drm/i915: Clean up intel_atomic_setup_scalers slightly.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 01/19] drm/i915: Use crtc state in intel_modeset_pipe_config Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 03/19] drm/i915: Add a simple atomic crtc check function, v2 Maarten Lankhorst
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

Get rid of a whole lot of ternary operators and assign the index
in scaler_id, instead of the id. They're the same thing.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic.c  | 21 +++++++++++----------
 drivers/gpu/drm/i915/intel_display.c |  2 --
 drivers/gpu/drm/i915/intel_drv.h     |  1 -
 3 files changed, 11 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 4df6d2d7a9c8..041bff504629 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -309,15 +309,23 @@ int intel_atomic_setup_scalers(struct drm_device *dev,
 	/* walkthrough scaler_users bits and start assigning scalers */
 	for (i = 0; i < sizeof(scaler_state->scaler_users) * 8; i++) {
 		int *scaler_id;
+		const char *name;
+		int idx;
 
 		/* skip if scaler not required */
 		if (!(scaler_state->scaler_users & (1 << i)))
 			continue;
 
 		if (i == SKL_CRTC_INDEX) {
+			name = "CRTC";
+			idx = intel_crtc->base.base.id;
+
 			/* panel fitter case: assign as a crtc scaler */
 			scaler_id = &scaler_state->scaler_id;
 		} else {
+			name = "PLANE";
+			idx = plane->base.id;
+
 			if (!drm_state)
 				continue;
 
@@ -356,23 +364,16 @@ int intel_atomic_setup_scalers(struct drm_device *dev,
 			for (j = 0; j < intel_crtc->num_scalers; j++) {
 				if (!scaler_state->scalers[j].in_use) {
 					scaler_state->scalers[j].in_use = 1;
-					*scaler_id = scaler_state->scalers[j].id;
+					*scaler_id = j;
 					DRM_DEBUG_KMS("Attached scaler id %u.%u to %s:%d\n",
-						intel_crtc->pipe,
-						i == SKL_CRTC_INDEX ? scaler_state->scaler_id :
-							plane_state->scaler_id,
-						i == SKL_CRTC_INDEX ? "CRTC" : "PLANE",
-						i == SKL_CRTC_INDEX ?  intel_crtc->base.base.id :
-						plane->base.id);
+						intel_crtc->pipe, *scaler_id, name, idx);
 					break;
 				}
 			}
 		}
 
 		if (WARN_ON(*scaler_id < 0)) {
-			DRM_DEBUG_KMS("Cannot find scaler for %s:%d\n",
-				i == SKL_CRTC_INDEX ? "CRTC" : "PLANE",
-				i == SKL_CRTC_INDEX ? intel_crtc->base.base.id:plane->base.id);
+			DRM_DEBUG_KMS("Cannot find scaler for %s:%d\n", name, idx);
 			continue;
 		}
 
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index d36684080987..956fb8423fff 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -14059,8 +14059,6 @@ static void skl_init_scalers(struct drm_device *dev, struct intel_crtc *intel_cr
 	for (i = 0; i < intel_crtc->num_scalers; i++) {
 		intel_scaler = &scaler_state->scalers[i];
 		intel_scaler->in_use = 0;
-		intel_scaler->id = i;
-
 		intel_scaler->mode = PS_SCALER_MODE_DYN;
 	}
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index b28029a1c8f2..29d6031b19d8 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -293,7 +293,6 @@ struct intel_initial_plane_config {
 #define SKL_MAX_DST_H 4096
 
 struct intel_scaler {
-	int id;
 	int in_use;
 	uint32_t mode;
 };
-- 
2.1.0

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

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

* [PATCH v3 03/19] drm/i915: Add a simple atomic crtc check function, v2.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 01/19] drm/i915: Use crtc state in intel_modeset_pipe_config Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 02/19] drm/i915: Clean up intel_atomic_setup_scalers slightly Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 04/19] drm/i915: Move scaler setup to check crtc " Maarten Lankhorst
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

Move the check for encoder cloning here.

Changes since v1:
- Remove was/is crtc_disabled. (mattrope)
- Rename function to intel_crtc_atomic_check. (mattrope)

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic.c  |   5 +-
 drivers/gpu/drm/i915/intel_display.c | 126 ++++++++++++++++++++---------------
 2 files changed, 75 insertions(+), 56 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 041bff504629..6ab71ea92819 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -100,7 +100,10 @@ int intel_atomic_check(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	/* FIXME: move to crtc atomic check function once it is ready */
+	/*
+	 * FIXME: move to crtc atomic check function once this is
+	 * more atomic friendly.
+	 */
 	ret = intel_atomic_setup_scalers(dev, nuclear_crtc, crtc_state);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 956fb8423fff..29e761d9e0ec 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11661,11 +11661,82 @@ retry:
 	return ret;
 }
 
+static bool encoders_cloneable(const struct intel_encoder *a,
+			       const struct intel_encoder *b)
+{
+	/* masks could be asymmetric, so check both ways */
+	return a == b || (a->cloneable & (1 << b->type) &&
+			  b->cloneable & (1 << a->type));
+}
+
+static bool check_single_encoder_cloning(struct drm_atomic_state *state,
+					 struct intel_crtc *crtc,
+					 struct intel_encoder *encoder)
+{
+	struct intel_encoder *source_encoder;
+	struct drm_connector *connector;
+	struct drm_connector_state *connector_state;
+	int i;
+
+	for_each_connector_in_state(state, connector, connector_state, i) {
+		if (connector_state->crtc != &crtc->base)
+			continue;
+
+		source_encoder =
+			to_intel_encoder(connector_state->best_encoder);
+		if (!encoders_cloneable(encoder, source_encoder))
+			return false;
+	}
+
+	return true;
+}
+
+static bool check_encoder_cloning(struct drm_atomic_state *state,
+				  struct intel_crtc *crtc)
+{
+	struct intel_encoder *encoder;
+	struct drm_connector *connector;
+	struct drm_connector_state *connector_state;
+	int i;
+
+	for_each_connector_in_state(state, connector, connector_state, i) {
+		if (connector_state->crtc != &crtc->base)
+			continue;
+
+		encoder = to_intel_encoder(connector_state->best_encoder);
+		if (!check_single_encoder_cloning(state, crtc, encoder))
+			return false;
+	}
+
+	return true;
+}
+
+static int intel_crtc_atomic_check(struct drm_crtc *crtc,
+				   struct drm_crtc_state *crtc_state)
+{
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct drm_atomic_state *state = crtc_state->state;
+	int idx = crtc->base.id;
+	bool mode_changed = needs_modeset(crtc_state);
+
+	if (mode_changed && !check_encoder_cloning(state, intel_crtc)) {
+		DRM_DEBUG_KMS("rejecting invalid cloning configuration\n");
+		return -EINVAL;
+	}
+
+	I915_STATE_WARN(crtc->state->active != intel_crtc->active,
+		"[CRTC:%i] mismatch between state->active(%i) and crtc->active(%i)\n",
+		idx, crtc->state->active, intel_crtc->active);
+
+	return 0;
+}
+
 static const struct drm_crtc_helper_funcs intel_helper_funcs = {
 	.mode_set_base_atomic = intel_pipe_set_base_atomic,
 	.load_lut = intel_crtc_load_lut,
 	.atomic_begin = intel_begin_crtc_commit,
 	.atomic_flush = intel_finish_crtc_commit,
+	.atomic_check = intel_crtc_atomic_check,
 };
 
 /**
@@ -11918,56 +11989,6 @@ static void intel_dump_pipe_config(struct intel_crtc *crtc,
 	}
 }
 
-static bool encoders_cloneable(const struct intel_encoder *a,
-			       const struct intel_encoder *b)
-{
-	/* masks could be asymmetric, so check both ways */
-	return a == b || (a->cloneable & (1 << b->type) &&
-			  b->cloneable & (1 << a->type));
-}
-
-static bool check_single_encoder_cloning(struct drm_atomic_state *state,
-					 struct intel_crtc *crtc,
-					 struct intel_encoder *encoder)
-{
-	struct intel_encoder *source_encoder;
-	struct drm_connector *connector;
-	struct drm_connector_state *connector_state;
-	int i;
-
-	for_each_connector_in_state(state, connector, connector_state, i) {
-		if (connector_state->crtc != &crtc->base)
-			continue;
-
-		source_encoder =
-			to_intel_encoder(connector_state->best_encoder);
-		if (!encoders_cloneable(encoder, source_encoder))
-			return false;
-	}
-
-	return true;
-}
-
-static bool check_encoder_cloning(struct drm_atomic_state *state,
-				  struct intel_crtc *crtc)
-{
-	struct intel_encoder *encoder;
-	struct drm_connector *connector;
-	struct drm_connector_state *connector_state;
-	int i;
-
-	for_each_connector_in_state(state, connector, connector_state, i) {
-		if (connector_state->crtc != &crtc->base)
-			continue;
-
-		encoder = to_intel_encoder(connector_state->best_encoder);
-		if (!check_single_encoder_cloning(state, crtc, encoder))
-			return false;
-	}
-
-	return true;
-}
-
 static bool check_digital_port_conflicts(struct drm_atomic_state *state)
 {
 	struct drm_device *dev = state->dev;
@@ -12054,11 +12075,6 @@ intel_modeset_pipe_config(struct drm_crtc *crtc,
 	int i;
 	bool retry = true;
 
-	if (!check_encoder_cloning(state, to_intel_crtc(crtc))) {
-		DRM_DEBUG_KMS("rejecting invalid cloning configuration\n");
-		return -EINVAL;
-	}
-
 	clear_intel_crtc_state(pipe_config);
 
 	pipe_config->cpu_transcoder =
-- 
2.1.0

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

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

* [PATCH v3 04/19] drm/i915: Move scaler setup to check crtc function, v2.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (2 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 03/19] drm/i915: Add a simple atomic crtc check function, v2 Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 05/19] drm/i915: Assign a new pll from the crtc check " Maarten Lankhorst
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

The scaler setup may add planes, but since they're unchanged we only
have to wait for primary flips. Also set planes_changed to indicate
at least 1 plane is modified.

Changes since v1:
- Instead of removing planes, do minimal validation needed.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic.c  | 17 +++++++++--------
 drivers/gpu/drm/i915/intel_display.c | 15 +++++----------
 2 files changed, 14 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 6ab71ea92819..d5afc2aa4ac7 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -100,14 +100,6 @@ int intel_atomic_check(struct drm_device *dev,
 	if (ret)
 		return ret;
 
-	/*
-	 * FIXME: move to crtc atomic check function once this is
-	 * more atomic friendly.
-	 */
-	ret = intel_atomic_setup_scalers(dev, nuclear_crtc, crtc_state);
-	if (ret)
-		return ret;
-
 	return ret;
 }
 
@@ -349,6 +341,15 @@ int intel_atomic_setup_scalers(struct drm_device *dev,
 						plane->base.id);
 					return PTR_ERR(state);
 				}
+
+				/*
+				 * the plane is added after plane checks are run,
+				 * but since this plane is unchanged just do the
+				 * minimum required validation.
+				 */
+				if (plane->type == DRM_PLANE_TYPE_PRIMARY)
+					intel_crtc->atomic.wait_for_flips = true;
+				crtc_state->base.planes_changed = true;
 			}
 
 			intel_plane = to_intel_plane(plane);
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 29e761d9e0ec..e6837172afaf 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -6574,7 +6574,6 @@ static int intel_crtc_compute_config(struct intel_crtc *crtc,
 	struct drm_device *dev = crtc->base.dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_display_mode *adjusted_mode = &pipe_config->base.adjusted_mode;
-	int ret;
 
 	/* FIXME should check pixel clock limits on all platforms */
 	if (INTEL_INFO(dev)->gen < 4) {
@@ -6620,14 +6619,7 @@ static int intel_crtc_compute_config(struct intel_crtc *crtc,
 	if (pipe_config->has_pch_encoder)
 		return ironlake_fdi_compute_config(crtc, pipe_config);
 
-	/* FIXME: remove below call once atomic mode set is place and all crtc
-	 * related checks called from atomic_crtc_check function */
-	ret = 0;
-	DRM_DEBUG_KMS("intel_crtc = %p drm_state (pipe_config->base.state) = %p\n",
-		crtc, pipe_config->base.state);
-	ret = intel_atomic_setup_scalers(dev, crtc, pipe_config);
-
-	return ret;
+	return 0;
 }
 
 static int skylake_get_display_clock_speed(struct drm_device *dev)
@@ -11714,7 +11706,10 @@ static bool check_encoder_cloning(struct drm_atomic_state *state,
 static int intel_crtc_atomic_check(struct drm_crtc *crtc,
 				   struct drm_crtc_state *crtc_state)
 {
+	struct drm_device *dev = crtc->dev;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct intel_crtc_state *pipe_config =
+		to_intel_crtc_state(crtc_state);
 	struct drm_atomic_state *state = crtc_state->state;
 	int idx = crtc->base.id;
 	bool mode_changed = needs_modeset(crtc_state);
@@ -11728,7 +11723,7 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
 		"[CRTC:%i] mismatch between state->active(%i) and crtc->active(%i)\n",
 		idx, crtc->state->active, intel_crtc->active);
 
-	return 0;
+	return intel_atomic_setup_scalers(dev, intel_crtc, pipe_config);
 }
 
 static const struct drm_crtc_helper_funcs intel_helper_funcs = {
-- 
2.1.0

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

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

* [PATCH v3 05/19] drm/i915: Assign a new pll from the crtc check function, v2.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (3 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 04/19] drm/i915: Move scaler setup to check crtc " Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 06/19] drm/i915: Split skl_update_scaler, v3 Maarten Lankhorst
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

It saves another loop over all crtc's in the state, and computing
clock is more of a per crtc thing.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 60 ++++++++++++++++--------------------
 1 file changed, 26 insertions(+), 34 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index e6837172afaf..0f7652a31c95 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -11707,11 +11707,12 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
 				   struct drm_crtc_state *crtc_state)
 {
 	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_crtc_state *pipe_config =
 		to_intel_crtc_state(crtc_state);
 	struct drm_atomic_state *state = crtc_state->state;
-	int idx = crtc->base.id;
+	int ret, idx = crtc->base.id;
 	bool mode_changed = needs_modeset(crtc_state);
 
 	if (mode_changed && !check_encoder_cloning(state, intel_crtc)) {
@@ -11723,6 +11724,15 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
 		"[CRTC:%i] mismatch between state->active(%i) and crtc->active(%i)\n",
 		idx, crtc->state->active, intel_crtc->active);
 
+	if (mode_changed && crtc_state->enable &&
+	    dev_priv->display.crtc_compute_clock &&
+	    !WARN_ON(pipe_config->shared_dpll != DPLL_ID_PRIVATE)) {
+		ret = dev_priv->display.crtc_compute_clock(intel_crtc,
+							   pipe_config);
+		if (ret)
+			return ret;
+	}
+
 	return intel_atomic_setup_scalers(dev, intel_crtc, pipe_config);
 }
 
@@ -12777,53 +12787,37 @@ static void update_scanline_offset(struct intel_crtc *crtc)
 		crtc->scanline_offset = 1;
 }
 
-static int intel_modeset_setup_plls(struct drm_atomic_state *state)
+static void intel_modeset_clear_plls(struct drm_atomic_state *state)
 {
 	struct drm_device *dev = state->dev;
 	struct drm_i915_private *dev_priv = to_i915(dev);
-	unsigned clear_pipes = 0;
+	struct intel_shared_dpll_config *shared_dpll = NULL;
 	struct intel_crtc *intel_crtc;
 	struct intel_crtc_state *intel_crtc_state;
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *crtc_state;
-	int ret = 0;
 	int i;
 
 	if (!dev_priv->display.crtc_compute_clock)
-		return 0;
+		return;
 
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		int dpll;
+
 		intel_crtc = to_intel_crtc(crtc);
 		intel_crtc_state = to_intel_crtc_state(crtc_state);
+		dpll = intel_crtc_state->shared_dpll;
 
-		if (needs_modeset(crtc_state)) {
-			clear_pipes |= 1 << intel_crtc->pipe;
-			intel_crtc_state->shared_dpll = DPLL_ID_PRIVATE;
-		}
-	}
-
-	if (clear_pipes) {
-		struct intel_shared_dpll_config *shared_dpll =
-			intel_atomic_get_shared_dpll_state(state);
-
-		for (i = 0; i < dev_priv->num_shared_dpll; i++)
-			shared_dpll[i].crtc_mask &= ~clear_pipes;
-	}
-
-	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		if (!needs_modeset(crtc_state) || !crtc_state->enable)
+		if (!needs_modeset(crtc_state) || dpll == DPLL_ID_PRIVATE)
 			continue;
 
-		intel_crtc = to_intel_crtc(crtc);
-		intel_crtc_state = to_intel_crtc_state(crtc_state);
+		intel_crtc_state->shared_dpll = DPLL_ID_PRIVATE;
 
-		ret = dev_priv->display.crtc_compute_clock(intel_crtc,
-							   intel_crtc_state);
-		if (ret)
-			return ret;
-	}
+		if (!shared_dpll)
+			shared_dpll = intel_atomic_get_shared_dpll_state(state);
 
-	return ret;
+		shared_dpll[dpll].crtc_mask &= ~(1 << intel_crtc->pipe);
+	}
 }
 
 /*
@@ -12919,14 +12913,12 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
 			return ret;
 	}
 
-	ret = intel_modeset_setup_plls(state);
-	if (ret)
-		return ret;
+	intel_modeset_clear_plls(state);
 
 	if (IS_HASWELL(dev))
-		ret = haswell_mode_set_planes_workaround(state);
+		return haswell_mode_set_planes_workaround(state);
 
-	return ret;
+	return 0;
 }
 
 static int
-- 
2.1.0

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

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

* [PATCH v3 06/19] drm/i915: Split skl_update_scaler, v3.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (4 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 05/19] drm/i915: Assign a new pll from the crtc check " Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-18  1:48   ` Matt Roper
  2015-06-15 10:33 ` [PATCH v3 07/19] drm/i915: Split plane updates of crtc->atomic into a helper, v2 Maarten Lankhorst
                   ` (13 subsequent siblings)
  19 siblings, 1 reply; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

It's easier to read separate functions for crtc and plane scaler state.

Changes since v1:
 - Update documentation.
Changes since v2:
 - Get rid of parameters to skl_update_scaler only used for traces.
   This avoids needing to document the other parameters.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 211 +++++++++++++++++++----------------
 drivers/gpu/drm/i915/intel_dp.c      |   2 +-
 drivers/gpu/drm/i915/intel_drv.h     |  12 +-
 drivers/gpu/drm/i915/intel_sprite.c  |   3 +-
 4 files changed, 121 insertions(+), 107 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 0f7652a31c95..26d610acb61f 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4303,62 +4303,16 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
 	}
 }
 
-/**
- * skl_update_scaler_users - Stages update to crtc's scaler state
- * @intel_crtc: crtc
- * @crtc_state: crtc_state
- * @plane: plane (NULL indicates crtc is requesting update)
- * @plane_state: plane's state
- * @force_detach: request unconditional detachment of scaler
- *
- * This function updates scaler state for requested plane or crtc.
- * To request scaler usage update for a plane, caller shall pass plane pointer.
- * To request scaler usage update for crtc, caller shall pass plane pointer
- * as NULL.
- *
- * Return
- *     0 - scaler_usage updated successfully
- *    error - requested scaling cannot be supported or other error condition
- */
-int
-skl_update_scaler_users(
-	struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state,
-	struct intel_plane *intel_plane, struct intel_plane_state *plane_state,
-	int force_detach)
+static int
+skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
+		  unsigned scaler_idx, int *scaler_id, unsigned int rotation,
+		  int src_w, int src_h, int dst_w, int dst_h)
 {
+	struct intel_crtc_scaler_state *scaler_state =
+		&crtc_state->scaler_state;
+	struct intel_crtc *intel_crtc =
+		to_intel_crtc(crtc_state->base.crtc);
 	int need_scaling;
-	int idx;
-	int src_w, src_h, dst_w, dst_h;
-	int *scaler_id;
-	struct drm_framebuffer *fb;
-	struct intel_crtc_scaler_state *scaler_state;
-	unsigned int rotation;
-
-	if (!intel_crtc || !crtc_state)
-		return 0;
-
-	scaler_state = &crtc_state->scaler_state;
-
-	idx = intel_plane ? drm_plane_index(&intel_plane->base) : SKL_CRTC_INDEX;
-	fb = intel_plane ? plane_state->base.fb : NULL;
-
-	if (intel_plane) {
-		src_w = drm_rect_width(&plane_state->src) >> 16;
-		src_h = drm_rect_height(&plane_state->src) >> 16;
-		dst_w = drm_rect_width(&plane_state->dst);
-		dst_h = drm_rect_height(&plane_state->dst);
-		scaler_id = &plane_state->scaler_id;
-		rotation = plane_state->base.rotation;
-	} else {
-		struct drm_display_mode *adjusted_mode =
-			&crtc_state->base.adjusted_mode;
-		src_w = crtc_state->pipe_src_w;
-		src_h = crtc_state->pipe_src_h;
-		dst_w = adjusted_mode->hdisplay;
-		dst_h = adjusted_mode->vdisplay;
-		scaler_id = &scaler_state->scaler_id;
-		rotation = DRM_ROTATE_0;
-	}
 
 	need_scaling = intel_rotation_90_or_270(rotation) ?
 		(src_h != dst_w || src_w != dst_h):
@@ -4374,17 +4328,14 @@ skl_update_scaler_users(
 	 * update to free the scaler is done in plane/panel-fit programming.
 	 * For this purpose crtc/plane_state->scaler_id isn't reset here.
 	 */
-	if (force_detach || !need_scaling || (intel_plane &&
-		(!fb || !plane_state->visible))) {
+	if (force_detach || !need_scaling) {
 		if (*scaler_id >= 0) {
-			scaler_state->scaler_users &= ~(1 << idx);
+			scaler_state->scaler_users &= ~(1 << scaler_idx);
 			scaler_state->scalers[*scaler_id].in_use = 0;
 
-			DRM_DEBUG_KMS("Staged freeing scaler id %d.%d from %s:%d "
-				"crtc_state = %p scaler_users = 0x%x\n",
-				intel_crtc->pipe, *scaler_id, intel_plane ? "PLANE" : "CRTC",
-				intel_plane ? intel_plane->base.base.id :
-				intel_crtc->base.base.id, crtc_state,
+			DRM_DEBUG_KMS("scaler_user index %u.%u: "
+				"Staged freeing scaler id %d.%d scaler_users = 0x%x\n",
+				intel_crtc->pipe, scaler_idx, *scaler_id, scaler_idx,
 				scaler_state->scaler_users);
 			*scaler_id = -1;
 		}
@@ -4397,51 +4348,112 @@ skl_update_scaler_users(
 
 		src_w > SKL_MAX_SRC_W || src_h > SKL_MAX_SRC_H ||
 		dst_w > SKL_MAX_DST_W || dst_h > SKL_MAX_DST_H) {
-		DRM_DEBUG_KMS("%s:%d scaler_user index %u.%u: src %ux%u dst %ux%u "
+		DRM_DEBUG_KMS("scaler_user index %u.%u: src %ux%u dst %ux%u "
 			"size is out of scaler range\n",
-			intel_plane ? "PLANE" : "CRTC",
-			intel_plane ? intel_plane->base.base.id : intel_crtc->base.base.id,
-			intel_crtc->pipe, idx, src_w, src_h, dst_w, dst_h);
+			intel_crtc->pipe, scaler_idx, src_w, src_h, dst_w, dst_h);
 		return -EINVAL;
 	}
 
+	/* mark this plane as a scaler user in crtc_state */
+	scaler_state->scaler_users |= (1 << scaler_idx);
+	DRM_DEBUG_KMS("scaler_user index %u.%u: "
+		"staged scaling request for %ux%u->%ux%u scaler_users = 0x%x\n",
+		intel_crtc->pipe, scaler_idx, src_w, src_h, dst_w, dst_h,
+		scaler_state->scaler_users);
+
+	return 0;
+}
+
+/**
+ * skl_update_scaler_crtc - Stages update to scaler state for a given crtc.
+ *
+ * @state: crtc's scaler state
+ * @force_detach: whether to forcibly disable scaler
+ *
+ * Return
+ *     0 - scaler_usage updated successfully
+ *    error - requested scaling cannot be supported or other error condition
+ */
+int skl_update_scaler_crtc(struct intel_crtc_state *state, int force_detach)
+{
+	struct intel_crtc *intel_crtc = to_intel_crtc(state->base.crtc);
+	struct drm_display_mode *adjusted_mode =
+		&state->base.adjusted_mode;
+
+	DRM_DEBUG_KMS("Updating scaler for [CRTC:%i] scaler_user index %u.%u\n",
+		      intel_crtc->base.base.id, intel_crtc->pipe, SKL_CRTC_INDEX);
+
+	return skl_update_scaler(state, force_detach, SKL_CRTC_INDEX,
+		&state->scaler_state.scaler_id, DRM_ROTATE_0,
+		state->pipe_src_w, state->pipe_src_h,
+		adjusted_mode->hdisplay, adjusted_mode->hdisplay);
+}
+
+/**
+ * skl_update_scaler_plane - Stages update to scaler state for a given plane.
+ *
+ * @state: crtc's scaler state
+ * @intel_plane: affected plane
+ * @plane_state: atomic plane state to update
+ *
+ * Return
+ *     0 - scaler_usage updated successfully
+ *    error - requested scaling cannot be supported or other error condition
+ */
+int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
+			    struct intel_plane *intel_plane,
+			    struct intel_plane_state *plane_state)
+{
+
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc);
+	struct drm_framebuffer *fb = plane_state->base.fb;
+	int ret;
+
+	bool force_detach = !fb || !plane_state->visible;
+
+	DRM_DEBUG_KMS("Updating scaler for [PLANE:%d] scaler_user index %u.%u\n",
+		      intel_plane->base.base.id, intel_crtc->pipe,
+		      drm_plane_index(&intel_plane->base));
+
+	ret = skl_update_scaler(crtc_state, force_detach,
+				drm_plane_index(&intel_plane->base),
+				&plane_state->scaler_id,
+				plane_state->base.rotation,
+				drm_rect_width(&plane_state->src) >> 16,
+				drm_rect_height(&plane_state->src) >> 16,
+				drm_rect_width(&plane_state->dst),
+				drm_rect_height(&plane_state->dst));
+
+	if (ret || plane_state->scaler_id < 0)
+		return ret;
+
 	/* check colorkey */
-	if (WARN_ON(intel_plane &&
-		intel_plane->ckey.flags != I915_SET_COLORKEY_NONE)) {
-		DRM_DEBUG_KMS("PLANE:%d scaling %ux%u->%ux%u not allowed with colorkey",
-			intel_plane->base.base.id, src_w, src_h, dst_w, dst_h);
+	if (WARN_ON(intel_plane->ckey.flags != I915_SET_COLORKEY_NONE)) {
+		DRM_DEBUG_KMS("[PLANE:%d] scaling with color key not allowed",
+			intel_plane->base.base.id);
 		return -EINVAL;
 	}
 
 	/* Check src format */
-	if (intel_plane) {
-		switch (fb->pixel_format) {
-		case DRM_FORMAT_RGB565:
-		case DRM_FORMAT_XBGR8888:
-		case DRM_FORMAT_XRGB8888:
-		case DRM_FORMAT_ABGR8888:
-		case DRM_FORMAT_ARGB8888:
-		case DRM_FORMAT_XRGB2101010:
-		case DRM_FORMAT_XBGR2101010:
-		case DRM_FORMAT_YUYV:
-		case DRM_FORMAT_YVYU:
-		case DRM_FORMAT_UYVY:
-		case DRM_FORMAT_VYUY:
-			break;
-		default:
-			DRM_DEBUG_KMS("PLANE:%d FB:%d unsupported scaling format 0x%x\n",
-				intel_plane->base.base.id, fb->base.id, fb->pixel_format);
-			return -EINVAL;
-		}
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_RGB565:
+	case DRM_FORMAT_XBGR8888:
+	case DRM_FORMAT_XRGB8888:
+	case DRM_FORMAT_ABGR8888:
+	case DRM_FORMAT_ARGB8888:
+	case DRM_FORMAT_XRGB2101010:
+	case DRM_FORMAT_XBGR2101010:
+	case DRM_FORMAT_YUYV:
+	case DRM_FORMAT_YVYU:
+	case DRM_FORMAT_UYVY:
+	case DRM_FORMAT_VYUY:
+		break;
+	default:
+		DRM_DEBUG_KMS("[PLANE:%d] FB:%d unsupported scaling format 0x%x\n",
+			intel_plane->base.base.id, fb->base.id, fb->pixel_format);
+		return -EINVAL;
 	}
 
-	/* mark this plane as a scaler user in crtc_state */
-	scaler_state->scaler_users |= (1 << idx);
-	DRM_DEBUG_KMS("%s:%d staged scaling request for %ux%u->%ux%u "
-		"crtc_state = %p scaler_users = 0x%x\n",
-		intel_plane ? "PLANE" : "CRTC",
-		intel_plane ? intel_plane->base.base.id : intel_crtc->base.base.id,
-		src_w, src_h, dst_w, dst_h, crtc_state, scaler_state->scaler_users);
 	return 0;
 }
 
@@ -4456,7 +4468,7 @@ static void skylake_pfit_update(struct intel_crtc *crtc, int enable)
 	DRM_DEBUG_KMS("for crtc_state = %p\n", crtc->config);
 
 	/* To update pfit, first update scaler state */
-	skl_update_scaler_users(crtc, crtc->config, NULL, NULL, !enable);
+	skl_update_scaler_crtc(crtc->config, !enable);
 	intel_atomic_setup_scalers(crtc->base.dev, crtc, crtc->config);
 	skl_detach_scalers(crtc);
 	if (!enable)
@@ -13647,8 +13659,9 @@ intel_check_primary_plane(struct drm_plane *plane,
 	}
 
 	if (INTEL_INFO(dev)->gen >= 9) {
-		ret = skl_update_scaler_users(intel_crtc, crtc_state,
-			to_intel_plane(plane), state, 0);
+		ret = skl_update_scaler_plane(crtc_state,
+					      to_intel_plane(plane),
+					      state);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index fb3d7f15c04b..f5ce8fdc8bf9 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1377,7 +1377,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,
 
 		if (INTEL_INFO(dev)->gen >= 9) {
 			int ret;
-			ret = skl_update_scaler_users(intel_crtc, pipe_config, NULL, NULL, 0);
+			ret = skl_update_scaler_crtc(pipe_config, 0);
 			if (ret)
 				return ret;
 		}
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 29d6031b19d8..b78fa457a780 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -263,7 +263,7 @@ struct intel_plane_state {
 	 * plane requiring a scaler:
 	 *   - During check_plane, its bit is set in
 	 *     crtc_state->scaler_state.scaler_users by calling helper function
-	 *     update_scaler_users.
+	 *     update_scaler_plane.
 	 *   - scaler_id indicates the scaler it got assigned.
 	 *
 	 * plane doesn't require a scaler:
@@ -271,7 +271,7 @@ struct intel_plane_state {
 	 *     got disabled.
 	 *   - During check_plane, corresponding bit is reset in
 	 *     crtc_state->scaler_state.scaler_users by calling helper function
-	 *     update_scaler_users.
+	 *     update_scaler_plane.
 	 */
 	int scaler_id;
 };
@@ -1147,9 +1147,11 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,
 void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
 void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
 void skl_detach_scalers(struct intel_crtc *intel_crtc);
-int skl_update_scaler_users(struct intel_crtc *intel_crtc,
-	struct intel_crtc_state *crtc_state, struct intel_plane *intel_plane,
-	struct intel_plane_state *plane_state, int force_detach);
+int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
+			    struct intel_plane *intel_plane,
+			    struct intel_plane_state *plane_state);
+
+int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state, int force_detach);
 int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
 
 unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 8193a35388d7..fe95f25f019a 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -941,8 +941,7 @@ finish:
 	}
 
 	if (INTEL_INFO(dev)->gen >= 9) {
-		ret = skl_update_scaler_users(intel_crtc, crtc_state, intel_plane,
-			state, 0);
+		ret = skl_update_scaler_plane(crtc_state, intel_plane, state);
 		if (ret)
 			return ret;
 	}
-- 
2.1.0

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

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

* [PATCH v3 07/19] drm/i915: Split plane updates of crtc->atomic into a helper, v2.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (5 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 06/19] drm/i915: Split skl_update_scaler, v3 Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 08/19] drm/i915: clean up plane commit functions Maarten Lankhorst
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

This makes it easier to verify that no changes are done when
calling this from crtc instead.

Changes since v1:
 - Make intel_wm_need_update static and always check it.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic_plane.c |  21 +--
 drivers/gpu/drm/i915/intel_display.c      | 275 ++++++++++++++++++------------
 drivers/gpu/drm/i915/intel_drv.h          |   8 +-
 drivers/gpu/drm/i915/intel_sprite.c       |  32 +---
 4 files changed, 176 insertions(+), 160 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index 86ba4b2c3a65..aa2128369a0a 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -114,6 +114,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 	struct intel_crtc_state *crtc_state;
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 	struct intel_plane_state *intel_state = to_intel_plane_state(state);
+	int ret;
 
 	crtc = crtc ? crtc : plane->crtc;
 	intel_crtc = to_intel_crtc(crtc);
@@ -160,20 +161,6 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 	intel_state->clip.y2 =
 		crtc_state->base.active ? crtc_state->pipe_src_h : 0;
 
-	/*
-	 * Disabling a plane is always okay; we just need to update
-	 * fb tracking in a special way since cleanup_fb() won't
-	 * get called by the plane helpers.
-	 */
-	if (state->fb == NULL && plane->state->fb != NULL) {
-		/*
-		 * 'prepare' is never called when plane is being disabled, so
-		 * we need to handle frontbuffer tracking as a special case
-		 */
-		intel_crtc->atomic.disabled_planes |=
-			(1 << drm_plane_index(plane));
-	}
-
 	if (state->fb && intel_rotation_90_or_270(state->rotation)) {
 		if (!(state->fb->modifier[0] == I915_FORMAT_MOD_Y_TILED ||
 			state->fb->modifier[0] == I915_FORMAT_MOD_Yf_TILED)) {
@@ -198,7 +185,11 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 		}
 	}
 
-	return intel_plane->check_plane(plane, intel_state);
+	ret = intel_plane->check_plane(plane, intel_state);
+	if (ret || !state->state)
+		return ret;
+
+	return intel_plane_atomic_calc_changes(&crtc_state->base, state);
 }
 
 static void intel_plane_atomic_update(struct drm_plane *plane,
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 26d610acb61f..71f6314fb643 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4393,19 +4393,19 @@ int skl_update_scaler_crtc(struct intel_crtc_state *state, int force_detach)
  * skl_update_scaler_plane - Stages update to scaler state for a given plane.
  *
  * @state: crtc's scaler state
- * @intel_plane: affected plane
  * @plane_state: atomic plane state to update
  *
  * Return
  *     0 - scaler_usage updated successfully
  *    error - requested scaling cannot be supported or other error condition
  */
-int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
-			    struct intel_plane *intel_plane,
-			    struct intel_plane_state *plane_state)
+static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
+				   struct intel_plane_state *plane_state)
 {
 
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc);
+	struct intel_plane *intel_plane =
+		to_intel_plane(plane_state->base.plane);
 	struct drm_framebuffer *fb = plane_state->base.fb;
 	int ret;
 
@@ -11665,6 +11665,161 @@ retry:
 	return ret;
 }
 
+
+/**
+ * intel_wm_need_update - Check whether watermarks need updating
+ * @plane: drm plane
+ * @state: new plane state
+ *
+ * Check current plane state versus the new one to determine whether
+ * watermarks need to be recalculated.
+ *
+ * Returns true or false.
+ */
+static bool intel_wm_need_update(struct drm_plane *plane,
+				 struct drm_plane_state *state)
+{
+	/* Update watermarks on tiling changes. */
+	if (!plane->state->fb || !state->fb ||
+	    plane->state->fb->modifier[0] != state->fb->modifier[0] ||
+	    plane->state->rotation != state->rotation)
+		return true;
+
+	if (plane->state->crtc_w != state->crtc_w)
+		return true;
+
+	return false;
+}
+
+int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
+				    struct drm_plane_state *plane_state)
+{
+	struct drm_crtc *crtc = crtc_state->crtc;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+	struct drm_plane *plane = plane_state->plane;
+	struct drm_device *dev = crtc->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	struct intel_plane_state *old_plane_state =
+		to_intel_plane_state(plane->state);
+	int idx = intel_crtc->base.base.id, ret;
+	int i = drm_plane_index(plane);
+	bool mode_changed = needs_modeset(crtc_state);
+	bool was_crtc_enabled = crtc->state->active;
+	bool is_crtc_enabled = crtc_state->active;
+
+	bool turn_off, turn_on, visible, was_visible;
+	struct drm_framebuffer *fb = plane_state->fb;
+
+	if (crtc_state && INTEL_INFO(dev)->gen >= 9 &&
+	    plane->type != DRM_PLANE_TYPE_CURSOR) {
+		ret = skl_update_scaler_plane(
+			to_intel_crtc_state(crtc_state),
+			to_intel_plane_state(plane_state));
+		if (ret)
+			return ret;
+	}
+
+	/*
+	 * Disabling a plane is always okay; we just need to update
+	 * fb tracking in a special way since cleanup_fb() won't
+	 * get called by the plane helpers.
+	 */
+	if (old_plane_state->base.fb && !fb)
+		intel_crtc->atomic.disabled_planes |= 1 << i;
+
+	/* don't run rest during modeset yet */
+	if (!intel_crtc->active || mode_changed)
+		return 0;
+
+	was_visible = old_plane_state->visible;
+	visible = to_intel_plane_state(plane_state)->visible;
+
+	if (!was_crtc_enabled && WARN_ON(was_visible))
+		was_visible = false;
+
+	if (!is_crtc_enabled && WARN_ON(visible))
+		visible = false;
+
+	if (!was_visible && !visible)
+		return 0;
+
+	turn_off = was_visible && (!visible || mode_changed);
+	turn_on = visible && (!was_visible || mode_changed);
+
+	DRM_DEBUG_ATOMIC("[CRTC:%i] has [PLANE:%i] with fb %i\n", idx,
+			 plane->base.id, fb ? fb->base.id : -1);
+
+	DRM_DEBUG_ATOMIC("[PLANE:%i] visible %i -> %i, off %i, on %i, ms %i\n",
+			 plane->base.id, was_visible, visible,
+			 turn_off, turn_on, mode_changed);
+
+	if (intel_wm_need_update(plane, plane_state))
+		intel_crtc->atomic.update_wm = true;
+
+	switch (plane->type) {
+	case DRM_PLANE_TYPE_PRIMARY:
+		if (visible)
+			intel_crtc->atomic.fb_bits |=
+			    INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe);
+
+		intel_crtc->atomic.wait_for_flips = true;
+		intel_crtc->atomic.pre_disable_primary = turn_off;
+		intel_crtc->atomic.post_enable_primary = turn_on;
+
+		if (turn_off)
+			intel_crtc->atomic.disable_fbc = true;
+
+		/*
+		 * FBC does not work on some platforms for rotated
+		 * planes, so disable it when rotation is not 0 and
+		 * update it when rotation is set back to 0.
+		 *
+		 * FIXME: This is redundant with the fbc update done in
+		 * the primary plane enable function except that that
+		 * one is done too late. We eventually need to unify
+		 * this.
+		 */
+
+		if (visible &&
+		    INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev) &&
+		    dev_priv->fbc.crtc == intel_crtc &&
+		    plane_state->rotation != BIT(DRM_ROTATE_0))
+			intel_crtc->atomic.disable_fbc = true;
+
+		/*
+		 * BDW signals flip done immediately if the plane
+		 * is disabled, even if the plane enable is already
+		 * armed to occur at the next vblank :(
+		 */
+		if (turn_on && IS_BROADWELL(dev))
+			intel_crtc->atomic.wait_vblank = true;
+
+		intel_crtc->atomic.update_fbc |= visible || mode_changed;
+		break;
+	case DRM_PLANE_TYPE_CURSOR:
+		if (visible)
+			intel_crtc->atomic.fb_bits |=
+			    INTEL_FRONTBUFFER_CURSOR(intel_crtc->pipe);
+		break;
+	case DRM_PLANE_TYPE_OVERLAY:
+		/*
+		 * 'prepare' is never called when plane is being disabled, so
+		 * we need to handle frontbuffer tracking as a special case
+		 */
+		if (visible)
+			intel_crtc->atomic.fb_bits |=
+			    INTEL_FRONTBUFFER_SPRITE(intel_crtc->pipe);
+
+		if (turn_off && is_crtc_enabled) {
+			intel_crtc->atomic.wait_vblank = true;
+			intel_crtc->atomic.update_sprite_watermarks |=
+				1 << i;
+		}
+		break;
+	}
+	return 0;
+}
+
 static bool encoders_cloneable(const struct intel_encoder *a,
 			       const struct intel_encoder *b)
 {
@@ -13431,28 +13586,6 @@ static void intel_shared_dpll_init(struct drm_device *dev)
 }
 
 /**
- * intel_wm_need_update - Check whether watermarks need updating
- * @plane: drm plane
- * @state: new plane state
- *
- * Check current plane state versus the new one to determine whether
- * watermarks need to be recalculated.
- *
- * Returns true or false.
- */
-bool intel_wm_need_update(struct drm_plane *plane,
-			  struct drm_plane_state *state)
-{
-	/* Update watermarks on tiling changes. */
-	if (!plane->state->fb || !state->fb ||
-	    plane->state->fb->modifier[0] != state->fb->modifier[0] ||
-	    plane->state->rotation != state->rotation)
-		return true;
-
-	return false;
-}
-
-/**
  * intel_prepare_plane_fb - Prepare fb for usage on plane
  * @plane: drm plane to prepare for
  * @fb: framebuffer to prepare for presentation
@@ -13573,7 +13706,6 @@ intel_check_primary_plane(struct drm_plane *plane,
 			  struct intel_plane_state *state)
 {
 	struct drm_device *dev = plane->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct drm_crtc *crtc = state->base.crtc;
 	struct intel_crtc *intel_crtc;
 	struct intel_crtc_state *crtc_state;
@@ -13584,7 +13716,6 @@ intel_check_primary_plane(struct drm_plane *plane,
 	bool can_position = false;
 	int max_scale = DRM_PLANE_HELPER_NO_SCALING;
 	int min_scale = DRM_PLANE_HELPER_NO_SCALING;
-	int ret;
 
 	crtc = crtc ? crtc : plane->crtc;
 	intel_crtc = to_intel_crtc(crtc);
@@ -13600,73 +13731,11 @@ intel_check_primary_plane(struct drm_plane *plane,
 		can_position = true;
 	}
 
-	ret = drm_plane_helper_check_update(plane, crtc, fb,
-					    src, dest, clip,
-					    min_scale,
-					    max_scale,
-					    can_position, true,
-					    &state->visible);
-	if (ret)
-		return ret;
-
-	if (intel_crtc->active) {
-		struct intel_plane_state *old_state =
-			to_intel_plane_state(plane->state);
-
-		intel_crtc->atomic.wait_for_flips = true;
-
-		/*
-		 * FBC does not work on some platforms for rotated
-		 * planes, so disable it when rotation is not 0 and
-		 * update it when rotation is set back to 0.
-		 *
-		 * FIXME: This is redundant with the fbc update done in
-		 * the primary plane enable function except that that
-		 * one is done too late. We eventually need to unify
-		 * this.
-		 */
-		if (state->visible &&
-		    INTEL_INFO(dev)->gen <= 4 && !IS_G4X(dev) &&
-		    dev_priv->fbc.crtc == intel_crtc &&
-		    state->base.rotation != BIT(DRM_ROTATE_0)) {
-			intel_crtc->atomic.disable_fbc = true;
-		}
-
-		if (state->visible && !old_state->visible) {
-			/*
-			 * BDW signals flip done immediately if the plane
-			 * is disabled, even if the plane enable is already
-			 * armed to occur at the next vblank :(
-			 */
-			if (IS_BROADWELL(dev))
-				intel_crtc->atomic.wait_vblank = true;
-
-			if (crtc_state && !needs_modeset(&crtc_state->base))
-				intel_crtc->atomic.post_enable_primary = true;
-		}
-
-		if (!state->visible && old_state->visible &&
-		    crtc_state && !needs_modeset(&crtc_state->base))
-			intel_crtc->atomic.pre_disable_primary = true;
-
-		intel_crtc->atomic.fb_bits |=
-			INTEL_FRONTBUFFER_PRIMARY(intel_crtc->pipe);
-
-		intel_crtc->atomic.update_fbc = true;
-
-		if (intel_wm_need_update(plane, &state->base))
-			intel_crtc->atomic.update_wm = true;
-	}
-
-	if (INTEL_INFO(dev)->gen >= 9) {
-		ret = skl_update_scaler_plane(crtc_state,
-					      to_intel_plane(plane),
-					      state);
-		if (ret)
-			return ret;
-	}
-
-	return 0;
+	return drm_plane_helper_check_update(plane, crtc, fb,
+					     src, dest, clip,
+					     min_scale, max_scale,
+					     can_position, true,
+					     &state->visible);
 }
 
 static void
@@ -13928,10 +13997,9 @@ intel_check_cursor_plane(struct drm_plane *plane,
 	if (ret)
 		return ret;
 
-
 	/* if we want to turn off the cursor ignore width and height */
 	if (!obj)
-		goto finish;
+		return 0;
 
 	/* Check for which cursor types we support */
 	if (!cursor_size_ok(dev, state->base.crtc_w, state->base.crtc_h)) {
@@ -13948,19 +14016,10 @@ intel_check_cursor_plane(struct drm_plane *plane,
 
 	if (fb->modifier[0] != DRM_FORMAT_MOD_NONE) {
 		DRM_DEBUG_KMS("cursor cannot be tiled\n");
-		ret = -EINVAL;
-	}
-
-finish:
-	if (intel_crtc->active) {
-		if (plane->state->crtc_w != state->base.crtc_w)
-			intel_crtc->atomic.update_wm = true;
-
-		intel_crtc->atomic.fb_bits |=
-			INTEL_FRONTBUFFER_CURSOR(intel_crtc->pipe);
+		return -EINVAL;
 	}
 
-	return ret;
+	return 0;
 }
 
 static void
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index b78fa457a780..9f5867bf745e 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1067,6 +1067,8 @@ int intel_plane_atomic_set_property(struct drm_plane *plane,
 				    struct drm_plane_state *state,
 				    struct drm_property *property,
 				    uint64_t val);
+int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
+				    struct drm_plane_state *plane_state);
 
 unsigned int
 intel_tile_height(struct drm_device *dev, uint32_t pixel_format,
@@ -1081,9 +1083,6 @@ intel_rotation_90_or_270(unsigned int rotation)
 void intel_create_rotation_property(struct drm_device *dev,
 					struct intel_plane *plane);
 
-bool intel_wm_need_update(struct drm_plane *plane,
-			  struct drm_plane_state *state);
-
 /* shared dpll functions */
 struct intel_shared_dpll *intel_crtc_to_shared_dpll(struct intel_crtc *crtc);
 void assert_shared_dpll(struct drm_i915_private *dev_priv,
@@ -1147,9 +1146,6 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,
 void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
 void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
 void skl_detach_scalers(struct intel_crtc *intel_crtc);
-int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
-			    struct intel_plane *intel_plane,
-			    struct intel_plane_state *plane_state);
 
 int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state, int force_detach);
 int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index fe95f25f019a..f5921b652b90 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -756,7 +756,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
 	int max_scale, min_scale;
 	bool can_scale;
 	int pixel_size;
-	int ret;
 
 	intel_crtc = intel_crtc ? intel_crtc : to_intel_crtc(plane->crtc);
 	crtc_state = state->base.state ?
@@ -764,7 +763,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
 
 	if (!fb) {
 		state->visible = false;
-		goto finish;
+		return 0;
 	}
 
 	/* Don't modify another pipe's plane */
@@ -917,35 +916,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
 	dst->y1 = crtc_y;
 	dst->y2 = crtc_y + crtc_h;
 
-finish:
-	/*
-	 * If the sprite is completely covering the primary plane,
-	 * we can disable the primary and save power.
-	 */
-	if (intel_crtc->active) {
-		intel_crtc->atomic.fb_bits |=
-			INTEL_FRONTBUFFER_SPRITE(intel_crtc->pipe);
-
-		if (intel_wm_need_update(plane, &state->base))
-			intel_crtc->atomic.update_wm = true;
-
-		if (!state->visible) {
-			/*
-			 * Avoid underruns when disabling the sprite.
-			 * FIXME remove once watermark updates are done properly.
-			 */
-			intel_crtc->atomic.wait_vblank = true;
-			intel_crtc->atomic.update_sprite_watermarks |=
-				(1 << drm_plane_index(plane));
-		}
-	}
-
-	if (INTEL_INFO(dev)->gen >= 9) {
-		ret = skl_update_scaler_plane(crtc_state, intel_plane, state);
-		if (ret)
-			return ret;
-	}
-
 	return 0;
 }
 
-- 
2.1.0

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

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

* [PATCH v3 08/19] drm/i915: clean up plane commit functions
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (6 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 07/19] drm/i915: Split plane updates of crtc->atomic into a helper, v2 Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 09/19] drm/i915: clean up atomic plane check functions, v2 Maarten Lankhorst
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

No point in hiding behind big ifs. This will be true most of the time.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 16 ++++++++--------
 drivers/gpu/drm/i915/intel_sprite.c  | 33 ++++++++++++++-------------------
 2 files changed, 22 insertions(+), 27 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 71f6314fb643..ec4924eecd68 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13756,14 +13756,14 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	crtc->x = src->x1 >> 16;
 	crtc->y = src->y1 >> 16;
 
-	if (intel_crtc->active) {
-		if (state->visible)
-			/* FIXME: kill this fastboot hack */
-			intel_update_pipe_size(intel_crtc);
+	if (!intel_crtc->active)
+		return;
 
-		dev_priv->display.update_primary_plane(crtc, plane->fb,
-						       crtc->x, crtc->y);
-	}
+	if (state->visible)
+		/* FIXME: kill this fastboot hack */
+		intel_update_pipe_size(intel_crtc);
+
+	dev_priv->display.update_primary_plane(crtc, fb, crtc->x, crtc->y);
 }
 
 static void
@@ -14067,8 +14067,8 @@ intel_commit_cursor_plane(struct drm_plane *plane,
 
 	intel_crtc->cursor_addr = addr;
 	intel_crtc->cursor_bo = obj;
-update:
 
+update:
 	if (intel_crtc->active)
 		intel_crtc_update_cursor(crtc, state->visible);
 }
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index f5921b652b90..c909b8b8ce85 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -927,31 +927,26 @@ intel_commit_sprite_plane(struct drm_plane *plane,
 	struct intel_crtc *intel_crtc;
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 	struct drm_framebuffer *fb = state->base.fb;
-	int crtc_x, crtc_y;
-	unsigned int crtc_w, crtc_h;
-	uint32_t src_x, src_y, src_w, src_h;
 
 	crtc = crtc ? crtc : plane->crtc;
 	intel_crtc = to_intel_crtc(crtc);
 
 	plane->fb = fb;
 
-	if (intel_crtc->active) {
-		if (state->visible) {
-			crtc_x = state->dst.x1;
-			crtc_y = state->dst.y1;
-			crtc_w = drm_rect_width(&state->dst);
-			crtc_h = drm_rect_height(&state->dst);
-			src_x = state->src.x1 >> 16;
-			src_y = state->src.y1 >> 16;
-			src_w = drm_rect_width(&state->src) >> 16;
-			src_h = drm_rect_height(&state->src) >> 16;
-			intel_plane->update_plane(plane, crtc, fb,
-						  crtc_x, crtc_y, crtc_w, crtc_h,
-						  src_x, src_y, src_w, src_h);
-		} else {
-			intel_plane->disable_plane(plane, crtc, false);
-		}
+	if (!intel_crtc->active)
+		return;
+
+	if (state->visible) {
+		intel_plane->update_plane(plane, crtc, fb,
+					  state->dst.x1, state->dst.y1,
+					  drm_rect_width(&state->dst),
+					  drm_rect_height(&state->dst),
+					  state->src.x1 >> 16,
+					  state->src.y1 >> 16,
+					  drm_rect_width(&state->src) >> 16,
+					  drm_rect_height(&state->src) >> 16);
+	} else {
+		intel_plane->disable_plane(plane, crtc, false);
 	}
 }
 
-- 
2.1.0

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

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

* [PATCH v3 09/19] drm/i915: clean up atomic plane check functions, v2.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (7 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 08/19] drm/i915: clean up plane commit functions Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-18  1:48   ` Matt Roper
  2015-06-15 10:33 ` [PATCH v3 10/19] drm/i915: remove force argument from disable_plane Maarten Lankhorst
                   ` (10 subsequent siblings)
  19 siblings, 1 reply; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

By passing crtc_state to the check_plane functions a lot of duplicated
code can be removed. There are still some transitional helper calls,
they will be removed later.

Changes since v1:
- Revert state->visible changes.
- Use plane->state->crtc instead of plane->crtc.
- Use drm_atomic_get_existing_crtc_state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic_plane.c | 16 +++++++----
 drivers/gpu/drm/i915/intel_display.c      | 48 ++++++++++---------------------
 drivers/gpu/drm/i915/intel_drv.h          |  1 +
 drivers/gpu/drm/i915/intel_sprite.c       |  9 ++----
 4 files changed, 29 insertions(+), 45 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index aa2128369a0a..91d53768df9d 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -116,7 +116,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 	struct intel_plane_state *intel_state = to_intel_plane_state(state);
 	int ret;
 
-	crtc = crtc ? crtc : plane->crtc;
+	crtc = crtc ? crtc : plane->state->crtc;
 	intel_crtc = to_intel_crtc(crtc);
 
 	/*
@@ -131,10 +131,13 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 	/* FIXME: temporary hack necessary while we still use the plane update
 	 * helper. */
 	if (state->state) {
-		crtc_state =
-			intel_atomic_get_crtc_state(state->state, intel_crtc);
-		if (IS_ERR(crtc_state))
-			return PTR_ERR(crtc_state);
+		struct drm_crtc_state *drm_crtc_state =
+			drm_atomic_get_existing_crtc_state(state->state, crtc);
+
+		if (WARN_ON(!drm_crtc_state))
+			return -EINVAL;
+
+		crtc_state = to_intel_crtc_state(drm_crtc_state);
 	} else {
 		crtc_state = intel_crtc->config;
 	}
@@ -185,7 +188,8 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 		}
 	}
 
-	ret = intel_plane->check_plane(plane, intel_state);
+	intel_state->visible = false;
+	ret = intel_plane->check_plane(plane, crtc_state, intel_state);
 	if (ret || !state->state)
 		return ret;
 
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index ec4924eecd68..61697335bff2 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13703,36 +13703,25 @@ skl_max_scale(struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state
 
 static int
 intel_check_primary_plane(struct drm_plane *plane,
+			  struct intel_crtc_state *crtc_state,
 			  struct intel_plane_state *state)
 {
-	struct drm_device *dev = plane->dev;
 	struct drm_crtc *crtc = state->base.crtc;
-	struct intel_crtc *intel_crtc;
-	struct intel_crtc_state *crtc_state;
 	struct drm_framebuffer *fb = state->base.fb;
-	struct drm_rect *dest = &state->dst;
-	struct drm_rect *src = &state->src;
-	const struct drm_rect *clip = &state->clip;
-	bool can_position = false;
-	int max_scale = DRM_PLANE_HELPER_NO_SCALING;
 	int min_scale = DRM_PLANE_HELPER_NO_SCALING;
+	int max_scale = DRM_PLANE_HELPER_NO_SCALING;
+	bool can_position = false;
 
-	crtc = crtc ? crtc : plane->crtc;
-	intel_crtc = to_intel_crtc(crtc);
-	crtc_state = state->base.state ?
-		intel_atomic_get_crtc_state(state->base.state, intel_crtc) : NULL;
-
-	if (INTEL_INFO(dev)->gen >= 9) {
-		/* use scaler when colorkey is not required */
-		if (to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
-			min_scale = 1;
-			max_scale = skl_max_scale(intel_crtc, crtc_state);
-		}
+	/* use scaler when colorkey is not required */
+	if (INTEL_INFO(plane->dev)->gen >= 9 &&
+	    to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
+		min_scale = 1;
+		max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state);
 		can_position = true;
 	}
 
-	return drm_plane_helper_check_update(plane, crtc, fb,
-					     src, dest, clip,
+	return drm_plane_helper_check_update(plane, crtc, fb, &state->src,
+					     &state->dst, &state->clip,
 					     min_scale, max_scale,
 					     can_position, true,
 					     &state->visible);
@@ -13973,24 +13962,17 @@ void intel_create_rotation_property(struct drm_device *dev, struct intel_plane *
 
 static int
 intel_check_cursor_plane(struct drm_plane *plane,
+			 struct intel_crtc_state *crtc_state,
 			 struct intel_plane_state *state)
 {
-	struct drm_crtc *crtc = state->base.crtc;
-	struct drm_device *dev = plane->dev;
+	struct drm_crtc *crtc = crtc_state->base.crtc;
 	struct drm_framebuffer *fb = state->base.fb;
-	struct drm_rect *dest = &state->dst;
-	struct drm_rect *src = &state->src;
-	const struct drm_rect *clip = &state->clip;
 	struct drm_i915_gem_object *obj = intel_fb_obj(fb);
-	struct intel_crtc *intel_crtc;
 	unsigned stride;
 	int ret;
 
-	crtc = crtc ? crtc : plane->crtc;
-	intel_crtc = to_intel_crtc(crtc);
-
-	ret = drm_plane_helper_check_update(plane, crtc, fb,
-					    src, dest, clip,
+	ret = drm_plane_helper_check_update(plane, crtc, fb, &state->src,
+					    &state->dst, &state->clip,
 					    DRM_PLANE_HELPER_NO_SCALING,
 					    DRM_PLANE_HELPER_NO_SCALING,
 					    true, true, &state->visible);
@@ -14002,7 +13984,7 @@ intel_check_cursor_plane(struct drm_plane *plane,
 		return 0;
 
 	/* Check for which cursor types we support */
-	if (!cursor_size_ok(dev, state->base.crtc_w, state->base.crtc_h)) {
+	if (!cursor_size_ok(plane->dev, state->base.crtc_w, state->base.crtc_h)) {
 		DRM_DEBUG("Cursor dimension %dx%d not supported\n",
 			  state->base.crtc_w, state->base.crtc_h);
 		return -EINVAL;
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 9f5867bf745e..8c0f17e84eee 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -613,6 +613,7 @@ struct intel_plane {
 	void (*disable_plane)(struct drm_plane *plane,
 			      struct drm_crtc *crtc, bool force);
 	int (*check_plane)(struct drm_plane *plane,
+			   struct intel_crtc_state *crtc_state,
 			   struct intel_plane_state *state);
 	void (*commit_plane)(struct drm_plane *plane,
 			     struct intel_plane_state *state);
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index c909b8b8ce85..999a5753dde3 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -739,11 +739,12 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc, bool force)
 
 static int
 intel_check_sprite_plane(struct drm_plane *plane,
+			 struct intel_crtc_state *crtc_state,
 			 struct intel_plane_state *state)
 {
 	struct drm_device *dev = plane->dev;
-	struct intel_crtc *intel_crtc = to_intel_crtc(state->base.crtc);
-	struct intel_crtc_state *crtc_state;
+	struct drm_crtc *crtc = state->base.crtc;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 	struct drm_framebuffer *fb = state->base.fb;
 	int crtc_x, crtc_y;
@@ -757,10 +758,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
 	bool can_scale;
 	int pixel_size;
 
-	intel_crtc = intel_crtc ? intel_crtc : to_intel_crtc(plane->crtc);
-	crtc_state = state->base.state ?
-		intel_atomic_get_crtc_state(state->base.state, intel_crtc) : NULL;
-
 	if (!fb) {
 		state->visible = false;
 		return 0;
-- 
2.1.0

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

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

* [PATCH v3 10/19] drm/i915: remove force argument from disable_plane
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (8 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 09/19] drm/i915: clean up atomic plane check functions, v2 Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 11/19] drm/i915: move detaching scalers to begin_crtc_commit, v2 Maarten Lankhorst
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

The idea was good, but planes can have a fb even though
they're disabled. This makes the force argument useless
and always true, because only the commit function updates
state.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 16 +++-------------
 drivers/gpu/drm/i915/intel_drv.h     |  2 +-
 drivers/gpu/drm/i915/intel_sprite.c  | 10 +++++-----
 3 files changed, 9 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 61697335bff2..a65c1065decf 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4794,7 +4794,7 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc)
 			struct drm_crtc *from = intel_plane->base.crtc;
 
 			intel_plane->disable_plane(&intel_plane->base,
-						   from ?: crtc, true);
+						   from ?: crtc);
 		}
 	}
 
@@ -13757,8 +13757,7 @@ intel_commit_primary_plane(struct drm_plane *plane,
 
 static void
 intel_disable_primary_plane(struct drm_plane *plane,
-			    struct drm_crtc *crtc,
-			    bool force)
+			    struct drm_crtc *crtc)
 {
 	struct drm_device *dev = plane->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -14006,17 +14005,8 @@ intel_check_cursor_plane(struct drm_plane *plane,
 
 static void
 intel_disable_cursor_plane(struct drm_plane *plane,
-			   struct drm_crtc *crtc,
-			   bool force)
+			   struct drm_crtc *crtc)
 {
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
-	if (!force) {
-		plane->fb = NULL;
-		intel_crtc->cursor_bo = NULL;
-		intel_crtc->cursor_addr = 0;
-	}
-
 	intel_crtc_update_cursor(crtc, false);
 }
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 8c0f17e84eee..baf57b3b136f 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -611,7 +611,7 @@ struct intel_plane {
 			     uint32_t x, uint32_t y,
 			     uint32_t src_w, uint32_t src_h);
 	void (*disable_plane)(struct drm_plane *plane,
-			      struct drm_crtc *crtc, bool force);
+			      struct drm_crtc *crtc);
 	int (*check_plane)(struct drm_plane *plane,
 			   struct intel_crtc_state *crtc_state,
 			   struct intel_plane_state *state);
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 999a5753dde3..f7eb3bd0a7c7 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -272,7 +272,7 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 }
 
 static void
-skl_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc, bool force)
+skl_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)
 {
 	struct drm_device *dev = dplane->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -455,7 +455,7 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 }
 
 static void
-vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc, bool force)
+vlv_disable_plane(struct drm_plane *dplane, struct drm_crtc *crtc)
 {
 	struct drm_device *dev = dplane->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -595,7 +595,7 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 }
 
 static void
-ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc, bool force)
+ivb_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)
 {
 	struct drm_device *dev = plane->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -722,7 +722,7 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 }
 
 static void
-ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc, bool force)
+ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc)
 {
 	struct drm_device *dev = plane->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
@@ -943,7 +943,7 @@ intel_commit_sprite_plane(struct drm_plane *plane,
 					  drm_rect_width(&state->src) >> 16,
 					  drm_rect_height(&state->src) >> 16);
 	} else {
-		intel_plane->disable_plane(plane, crtc, false);
+		intel_plane->disable_plane(plane, crtc);
 	}
 }
 
-- 
2.1.0

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

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

* [PATCH v3 11/19] drm/i915: move detaching scalers to begin_crtc_commit, v2.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (9 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 10/19] drm/i915: remove force argument from disable_plane Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 12/19] drm/i915: Move crtc commit updates to separate functions Maarten Lankhorst
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

This is probably intended to be be done during vblank evasion.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic.c  | 3 ---
 drivers/gpu/drm/i915/intel_display.c | 8 ++++----
 drivers/gpu/drm/i915/intel_drv.h     | 1 -
 3 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index d5afc2aa4ac7..c1263be8c98b 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -144,9 +144,6 @@ int intel_atomic_commit(struct drm_device *dev,
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
 		to_intel_crtc(crtc)->config = to_intel_crtc_state(crtc->state);
 
-		if (INTEL_INFO(dev)->gen >= 9)
-			skl_detach_scalers(to_intel_crtc(crtc));
-
 		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
 	}
 
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index a65c1065decf..5e77c2974288 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2915,16 +2915,13 @@ unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
 /*
  * This function detaches (aka. unbinds) unused scalers in hardware
  */
-void skl_detach_scalers(struct intel_crtc *intel_crtc)
+static void skl_detach_scalers(struct intel_crtc *intel_crtc)
 {
 	struct drm_device *dev;
 	struct drm_i915_private *dev_priv;
 	struct intel_crtc_scaler_state *scaler_state;
 	int i;
 
-	if (!intel_crtc || !intel_crtc->config)
-		return;
-
 	dev = intel_crtc->base.dev;
 	dev_priv = dev->dev_private;
 	scaler_state = &intel_crtc->config->scaler_state;
@@ -13819,6 +13816,9 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 		intel_crtc->atomic.evade =
 			intel_pipe_update_start(intel_crtc,
 						&intel_crtc->atomic.start_vbl_count);
+
+	if (!needs_modeset(crtc->state) && INTEL_INFO(dev)->gen >= 9)
+		skl_detach_scalers(intel_crtc);
 }
 
 static void intel_finish_crtc_commit(struct drm_crtc *crtc,
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index baf57b3b136f..81398e279bfb 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -1146,7 +1146,6 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,
 				 struct intel_crtc_state *pipe_config);
 void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
 void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
-void skl_detach_scalers(struct intel_crtc *intel_crtc);
 
 int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state, int force_detach);
 int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
-- 
2.1.0

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

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

* [PATCH v3 12/19] drm/i915: Move crtc commit updates to separate functions.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (10 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 11/19] drm/i915: move detaching scalers to begin_crtc_commit, v2 Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 13/19] drm/i915: Do not run most checks when there's no modeset Maarten Lankhorst
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

To allow them to be used in intel_set_mode.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 127 +++++++++++++++++++----------------
 1 file changed, 69 insertions(+), 58 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 5e77c2974288..6ae9bd0e0283 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4753,6 +4753,72 @@ intel_pre_disable_primary(struct drm_crtc *crtc)
 	hsw_disable_ips(intel_crtc);
 }
 
+static void intel_post_plane_update(struct intel_crtc *crtc)
+{
+	struct intel_crtc_atomic_commit *atomic = &crtc->atomic;
+	struct drm_device *dev = crtc->base.dev;
+	struct drm_plane *plane;
+
+	if (atomic->wait_vblank)
+		intel_wait_for_vblank(dev, crtc->pipe);
+
+	intel_frontbuffer_flip(dev, atomic->fb_bits);
+
+	if (atomic->update_fbc) {
+		mutex_lock(&dev->struct_mutex);
+		intel_fbc_update(dev);
+		mutex_unlock(&dev->struct_mutex);
+	}
+
+	if (atomic->post_enable_primary)
+		intel_post_enable_primary(&crtc->base);
+
+	drm_for_each_plane_mask(plane, dev, atomic->update_sprite_watermarks)
+		intel_update_sprite_watermarks(plane, &crtc->base,
+					       0, 0, 0, false, false);
+
+	memset(atomic, 0, sizeof(*atomic));
+}
+
+static void intel_pre_plane_update(struct intel_crtc *crtc)
+{
+	struct drm_device *dev = crtc->base.dev;
+	struct intel_crtc_atomic_commit *atomic = &crtc->atomic;
+	struct drm_plane *p;
+
+	/* Track fb's for any planes being disabled */
+
+	drm_for_each_plane_mask(p, dev, atomic->disabled_planes) {
+		struct intel_plane *plane = to_intel_plane(p);
+		unsigned fb_bits = 0;
+
+		switch (p->type) {
+		case DRM_PLANE_TYPE_PRIMARY:
+			fb_bits = INTEL_FRONTBUFFER_PRIMARY(plane->pipe);
+			break;
+		case DRM_PLANE_TYPE_CURSOR:
+			fb_bits = INTEL_FRONTBUFFER_CURSOR(plane->pipe);
+			break;
+		case DRM_PLANE_TYPE_OVERLAY:
+			fb_bits = INTEL_FRONTBUFFER_SPRITE(plane->pipe);
+			break;
+		}
+
+		mutex_lock(&dev->struct_mutex);
+		i915_gem_track_fb(intel_fb_obj(plane->base.fb), NULL, fb_bits);
+		mutex_unlock(&dev->struct_mutex);
+	}
+
+	if (atomic->wait_for_flips)
+		intel_crtc_wait_for_pending_flips(&crtc->base);
+
+	if (atomic->disable_fbc)
+		intel_fbc_disable(dev);
+
+	if (atomic->pre_disable_primary)
+		intel_pre_disable_primary(&crtc->base);
+}
+
 static void intel_crtc_enable_planes(struct drm_crtc *crtc)
 {
 	struct drm_device *dev = crtc->dev;
@@ -13768,43 +13834,8 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct drm_crtc_state *crtc_state = intel_crtc->base.state;
-	struct intel_plane *intel_plane;
-	struct drm_plane *p;
-	unsigned fb_bits = 0;
-
-	/* Track fb's for any planes being disabled */
-	list_for_each_entry(p, &dev->mode_config.plane_list, head) {
-		intel_plane = to_intel_plane(p);
-
-		if (intel_crtc->atomic.disabled_planes &
-		    (1 << drm_plane_index(p))) {
-			switch (p->type) {
-			case DRM_PLANE_TYPE_PRIMARY:
-				fb_bits = INTEL_FRONTBUFFER_PRIMARY(intel_plane->pipe);
-				break;
-			case DRM_PLANE_TYPE_CURSOR:
-				fb_bits = INTEL_FRONTBUFFER_CURSOR(intel_plane->pipe);
-				break;
-			case DRM_PLANE_TYPE_OVERLAY:
-				fb_bits = INTEL_FRONTBUFFER_SPRITE(intel_plane->pipe);
-				break;
-			}
-
-			mutex_lock(&dev->struct_mutex);
-			i915_gem_track_fb(intel_fb_obj(p->fb), NULL, fb_bits);
-			mutex_unlock(&dev->struct_mutex);
-		}
-	}
-
-	if (intel_crtc->atomic.wait_for_flips)
-		intel_crtc_wait_for_pending_flips(crtc);
-
-	if (intel_crtc->atomic.disable_fbc)
-		intel_fbc_disable(dev);
 
-	if (intel_crtc->atomic.pre_disable_primary)
-		intel_pre_disable_primary(crtc);
+	intel_pre_plane_update(intel_crtc);
 
 	if (intel_crtc->atomic.update_wm)
 		intel_update_watermarks(crtc);
@@ -13812,7 +13843,7 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 	intel_runtime_pm_get(dev_priv);
 
 	/* Perform vblank evasion around commit operation */
-	if (crtc_state->active && !needs_modeset(crtc_state))
+	if (crtc->state->active && !needs_modeset(crtc->state))
 		intel_crtc->atomic.evade =
 			intel_pipe_update_start(intel_crtc,
 						&intel_crtc->atomic.start_vbl_count);
@@ -13827,7 +13858,6 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc,
 	struct drm_device *dev = crtc->dev;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct drm_plane *p;
 
 	if (intel_crtc->atomic.evade)
 		intel_pipe_update_end(intel_crtc,
@@ -13835,26 +13865,7 @@ static void intel_finish_crtc_commit(struct drm_crtc *crtc,
 
 	intel_runtime_pm_put(dev_priv);
 
-	if (intel_crtc->atomic.wait_vblank && intel_crtc->active)
-		intel_wait_for_vblank(dev, intel_crtc->pipe);
-
-	intel_frontbuffer_flip(dev, intel_crtc->atomic.fb_bits);
-
-	if (intel_crtc->atomic.update_fbc) {
-		mutex_lock(&dev->struct_mutex);
-		intel_fbc_update(dev);
-		mutex_unlock(&dev->struct_mutex);
-	}
-
-	if (intel_crtc->atomic.post_enable_primary)
-		intel_post_enable_primary(crtc);
-
-	drm_for_each_legacy_plane(p, &dev->mode_config.plane_list)
-		if (intel_crtc->atomic.update_sprite_watermarks & drm_plane_index(p))
-			intel_update_sprite_watermarks(p, crtc, 0, 0, 0,
-						       false, false);
-
-	memset(&intel_crtc->atomic, 0, sizeof(intel_crtc->atomic));
+	intel_post_plane_update(intel_crtc);
 }
 
 /**
-- 
2.1.0

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

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

* [PATCH v3 13/19] drm/i915: Do not run most checks when there's no modeset.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (11 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 12/19] drm/i915: Move crtc commit updates to separate functions Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 14/19] drm/i915: Handle disabling planes better, v2 Maarten Lankhorst
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

All the checks in intel_modeset_checks are only useful when a modeset
occurs, because there is nothing to update otherwise.

Same for power/cdclk changes, if there is no modeset they are noops.

Unfortunately intel_modeset_pipe_config still gets called without
modeset, because atomic hw readout isn't done yet.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 33 ++++++++++++++++++++++-----------
 1 file changed, 22 insertions(+), 11 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 6ae9bd0e0283..ae046648c29d 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -13157,18 +13157,18 @@ intel_modeset_compute_config(struct drm_atomic_state *state)
 	struct drm_crtc *crtc;
 	struct drm_crtc_state *crtc_state;
 	int ret, i;
+	bool any_ms = false;
 
 	ret = drm_atomic_helper_check_modeset(state->dev, state);
 	if (ret)
 		return ret;
 
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		if (!crtc_state->enable &&
-		    WARN_ON(crtc_state->active))
-			crtc_state->active = false;
-
-		if (!crtc_state->enable)
+		if (!crtc_state->enable) {
+			if (needs_modeset(crtc_state))
+				any_ms = true;
 			continue;
+		}
 
 		if (!needs_modeset(crtc_state)) {
 			ret = drm_atomic_add_affected_connectors(state, crtc);
@@ -13181,14 +13181,20 @@ intel_modeset_compute_config(struct drm_atomic_state *state)
 		if (ret)
 			return ret;
 
+		if (needs_modeset(crtc_state))
+			any_ms = true;
+
 		intel_dump_pipe_config(to_intel_crtc(crtc),
 				       to_intel_crtc_state(crtc_state),
 				       "[modeset]");
 	}
 
-	ret = intel_modeset_checks(state);
-	if (ret)
-		return ret;
+	if (any_ms) {
+		ret = intel_modeset_checks(state);
+
+		if (ret)
+			return ret;
+	}
 
 	return drm_atomic_helper_check_planes(state->dev, state);
 }
@@ -13201,6 +13207,7 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 	struct drm_crtc_state *crtc_state;
 	int ret = 0;
 	int i;
+	bool any_ms = false;
 
 	ret = drm_atomic_helper_prepare_planes(dev, state);
 	if (ret)
@@ -13209,7 +13216,11 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 	drm_atomic_helper_swap_state(dev, state);
 
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		if (!needs_modeset(crtc->state) || !crtc_state->active)
+		if (!needs_modeset(crtc->state))
+			continue;
+
+		any_ms = true;
+		if (!crtc_state->active)
 			continue;
 
 		intel_crtc_disable_planes(crtc);
@@ -13222,8 +13233,8 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 
 	/* The state has been swaped above, so state actually contains the
 	 * old state now. */
-
-	modeset_update_crtc_power_domains(state);
+	if (any_ms)
+		modeset_update_crtc_power_domains(state);
 
 	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-- 
2.1.0

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

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

* [PATCH v3 14/19] drm/i915: Handle disabling planes better, v2.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (12 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 13/19] drm/i915: Do not run most checks when there's no modeset Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell Maarten Lankhorst
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

Read out the initial state, and add a quirk to force add all planes
to crtc_state->plane_mask during initial commit. This will disable
all planes during the initial modeset.

The initial plane quirk is temporary, and will go away when hardware
readout is fully atomic, and the watermark updates in intel_sprite.c
are removed.

Changes since v1:
- Unset state->visible on !primary planes.
- Do not rely on the plane->crtc pointer in intel_atomic_plane,
  instead assume planes are invisible until modeset.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic.c  |   7 ++
 drivers/gpu/drm/i915/intel_display.c | 120 ++++++++++++++++++++++++++++-------
 drivers/gpu/drm/i915/intel_drv.h     |   1 +
 3 files changed, 106 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index c1263be8c98b..060d98b10f83 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -96,6 +96,13 @@ int intel_atomic_check(struct drm_device *dev,
 		return -EINVAL;
 	}
 
+	if (crtc_state &&
+	    crtc_state->quirks & PIPE_CONFIG_QUIRK_INITIAL_PLANES) {
+		ret = drm_atomic_add_affected_planes(state, &nuclear_crtc->base);
+		if (ret)
+			return ret;
+	}
+
 	ret = drm_atomic_helper_check_planes(dev, state);
 	if (ret)
 		return ret;
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index ae046648c29d..cc4ca4970716 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -109,8 +109,6 @@ static void skl_init_scalers(struct drm_device *dev, struct intel_crtc *intel_cr
 	struct intel_crtc_state *crtc_state);
 static int i9xx_get_refclk(const struct intel_crtc_state *crtc_state,
 			   int num_connectors);
-static void intel_crtc_enable_planes(struct drm_crtc *crtc);
-static void intel_crtc_disable_planes(struct drm_crtc *crtc);
 
 static struct intel_encoder *intel_find_encoder(struct intel_connector *connector, int pipe)
 {
@@ -4840,11 +4838,11 @@ static void intel_crtc_enable_planes(struct drm_crtc *crtc)
 	intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
 }
 
-static void intel_crtc_disable_planes(struct drm_crtc *crtc)
+static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask)
 {
 	struct drm_device *dev = crtc->dev;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	struct intel_plane *intel_plane;
+	struct drm_plane *p;
 	int pipe = intel_crtc->pipe;
 
 	intel_crtc_wait_for_pending_flips(crtc);
@@ -4852,14 +4850,9 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc)
 	intel_pre_disable_primary(crtc);
 
 	intel_crtc_dpms_overlay_disable(intel_crtc);
-	for_each_intel_plane(dev, intel_plane) {
-		if (intel_plane->pipe == pipe) {
-			struct drm_crtc *from = intel_plane->base.crtc;
 
-			intel_plane->disable_plane(&intel_plane->base,
-						   from ?: crtc);
-		}
-	}
+	drm_for_each_plane_mask(p, dev, plane_mask)
+		to_intel_plane(p)->disable_plane(p, crtc);
 
 	/*
 	 * FIXME: Once we grow proper nuclear flip support out of this we need
@@ -6277,7 +6270,7 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
 	if (!intel_crtc->active)
 		return;
 
-	intel_crtc_disable_planes(crtc);
+	intel_crtc_disable_planes(crtc, crtc->state->plane_mask);
 	dev_priv->display.crtc_disable(crtc);
 
 	domains = intel_crtc->enabled_power_domains;
@@ -11873,7 +11866,7 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
 			intel_crtc->atomic.fb_bits |=
 			    INTEL_FRONTBUFFER_SPRITE(intel_crtc->pipe);
 
-		if (turn_off && is_crtc_enabled) {
+		if (turn_off && !mode_changed) {
 			intel_crtc->atomic.wait_vblank = true;
 			intel_crtc->atomic.update_sprite_watermarks |=
 				1 << i;
@@ -11933,6 +11926,34 @@ static bool check_encoder_cloning(struct drm_atomic_state *state,
 	return true;
 }
 
+static void intel_crtc_check_initial_planes(struct drm_crtc *crtc,
+					    struct drm_crtc_state *crtc_state)
+{
+	struct intel_crtc_state *pipe_config =
+		to_intel_crtc_state(crtc_state);
+	struct drm_plane *p;
+	unsigned visible_mask = 0;
+
+	drm_for_each_plane_mask(p, crtc->dev, crtc_state->plane_mask) {
+		struct drm_plane_state *plane_state =
+			drm_atomic_get_existing_plane_state(crtc_state->state, p);
+
+		if (WARN_ON(!plane_state))
+			continue;
+
+		if (!plane_state->fb)
+			crtc_state->plane_mask &=
+				~(1 << drm_plane_index(p));
+		else if (to_intel_plane_state(plane_state)->visible)
+			visible_mask |= 1 << drm_plane_index(p);
+	}
+
+	if (!visible_mask)
+		return;
+
+	pipe_config->quirks &= ~PIPE_CONFIG_QUIRK_INITIAL_PLANES;
+}
+
 static int intel_crtc_atomic_check(struct drm_crtc *crtc,
 				   struct drm_crtc_state *crtc_state)
 {
@@ -11954,6 +11975,10 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
 		"[CRTC:%i] mismatch between state->active(%i) and crtc->active(%i)\n",
 		idx, crtc->state->active, intel_crtc->active);
 
+	/* plane mask is fixed up after all initial planes are calculated */
+	if (pipe_config->quirks & PIPE_CONFIG_QUIRK_INITIAL_PLANES)
+		intel_crtc_check_initial_planes(crtc, crtc_state);
+
 	if (mode_changed && crtc_state->enable &&
 	    dev_priv->display.crtc_compute_clock &&
 	    !WARN_ON(pipe_config->shared_dpll != DPLL_ID_PRIVATE)) {
@@ -13170,6 +13195,20 @@ intel_modeset_compute_config(struct drm_atomic_state *state)
 			continue;
 		}
 
+		if (to_intel_crtc_state(crtc_state)->quirks &
+		    PIPE_CONFIG_QUIRK_INITIAL_PLANES) {
+			ret = drm_atomic_add_affected_planes(state, crtc);
+			if (ret)
+				return ret;
+
+			/*
+			 * We ought to handle i915.fastboot here.
+			 * If no modeset is required and the primary plane has
+			 * a fb, update the members of crtc_state as needed,
+			 * and run the necessary updates during vblank evasion.
+			 */
+		}
+
 		if (!needs_modeset(crtc_state)) {
 			ret = drm_atomic_add_affected_connectors(state, crtc);
 			if (ret)
@@ -13223,7 +13262,7 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 		if (!crtc_state->active)
 			continue;
 
-		intel_crtc_disable_planes(crtc);
+		intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
 		dev_priv->display.crtc_disable(crtc);
 	}
 
@@ -15392,10 +15431,51 @@ static bool primary_get_hw_state(struct intel_crtc *crtc)
 {
 	struct drm_i915_private *dev_priv = crtc->base.dev->dev_private;
 
-	if (!crtc->active)
-		return false;
+	return !!(I915_READ(DSPCNTR(crtc->plane)) & DISPLAY_PLANE_ENABLE);
+}
+
+static void readout_plane_state(struct intel_crtc *crtc,
+				struct intel_crtc_state *crtc_state)
+{
+	struct intel_plane *p;
+	struct drm_plane_state *drm_plane_state;
+	bool active = crtc_state->base.active;
+
+	if (active) {
+		crtc_state->quirks |= PIPE_CONFIG_QUIRK_INITIAL_PLANES;
+
+		/* apply to previous sw state too */
+		to_intel_crtc_state(crtc->base.state)->quirks |=
+			PIPE_CONFIG_QUIRK_INITIAL_PLANES;
+	}
 
-	return I915_READ(DSPCNTR(crtc->plane)) & DISPLAY_PLANE_ENABLE;
+	for_each_intel_plane(crtc->base.dev, p) {
+		bool visible = active;
+
+		if (crtc->pipe != p->pipe)
+			continue;
+
+		drm_plane_state = p->base.state;
+		if (active && p->base.type == DRM_PLANE_TYPE_PRIMARY) {
+			visible = primary_get_hw_state(crtc);
+			to_intel_plane_state(drm_plane_state)->visible = visible;
+		} else {
+			/*
+			 * unknown state, assume it's off to force a transition
+			 * to on when calculating state changes.
+			 */
+			to_intel_plane_state(drm_plane_state)->visible = false;
+		}
+
+		if (visible) {
+			crtc_state->base.plane_mask |=
+				1 << drm_plane_index(&p->base);
+		} else if (crtc_state->base.state) {
+			/* Make this unconditional for atomic hw readout. */
+			crtc_state->base.plane_mask &=
+				~(1 << drm_plane_index(&p->base));
+		}
+	}
 }
 
 static void intel_modeset_readout_hw_state(struct drm_device *dev)
@@ -15408,9 +15488,6 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
 	int i;
 
 	for_each_intel_crtc(dev, crtc) {
-		struct drm_plane *primary = crtc->base.primary;
-		struct intel_plane_state *plane_state;
-
 		memset(crtc->config, 0, sizeof(*crtc->config));
 		crtc->config->base.crtc = &crtc->base;
 
@@ -15424,8 +15501,7 @@ static void intel_modeset_readout_hw_state(struct drm_device *dev)
 		crtc->base.enabled = crtc->active;
 		crtc->base.hwmode = crtc->config->base.adjusted_mode;
 
-		plane_state = to_intel_plane_state(primary->state);
-		plane_state->visible = primary_get_hw_state(crtc);
+		readout_plane_state(crtc, to_intel_crtc_state(crtc->base.state));
 
 		DRM_DEBUG_KMS("[CRTC:%d] hw state readout: %s\n",
 			      crtc->base.base.id,
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 81398e279bfb..93b9542ab8dc 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -338,6 +338,7 @@ struct intel_crtc_state {
 	 */
 #define PIPE_CONFIG_QUIRK_MODE_SYNC_FLAGS	(1<<0) /* unreliable sync mode.flags */
 #define PIPE_CONFIG_QUIRK_INHERITED_MODE	(1<<1) /* mode inherited from firmware */
+#define PIPE_CONFIG_QUIRK_INITIAL_PLANES	(1<<2) /* planes are in unknown state */
 	unsigned long quirks;
 
 	/* Pipe source size (ie. panel fitter input size)
-- 
2.1.0

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

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

* [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (13 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 14/19] drm/i915: Handle disabling planes better, v2 Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-18 14:21   ` Matt Roper
  2015-06-18 15:28   ` Ville Syrjälä
  2015-06-15 10:33 ` [PATCH v3 16/19] drm/i915: Update less state during modeset Maarten Lankhorst
                   ` (4 subsequent siblings)
  19 siblings, 2 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

Now that all planes are added during a modeset we can use the
calculated changes before disabling a plane, and then either commit
or force disable a plane before disabling the crtc.

The code is shared with atomic_begin/flush, except watermark updating
and vblank evasion are not used.

This is needed for proper atomic suspend/resume support.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90868
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 103 ++++++++---------------------------
 drivers/gpu/drm/i915/intel_sprite.c  |   4 +-
 2 files changed, 23 insertions(+), 84 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index cc4ca4970716..beb69281f45c 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -2217,28 +2217,6 @@ static void intel_disable_pipe(struct intel_crtc *crtc)
 		intel_wait_for_pipe_off(crtc);
 }
 
-/**
- * intel_enable_primary_hw_plane - enable the primary plane on a given pipe
- * @plane:  plane to be enabled
- * @crtc: crtc for the plane
- *
- * Enable @plane on @crtc, making sure that the pipe is running first.
- */
-static void intel_enable_primary_hw_plane(struct drm_plane *plane,
-					  struct drm_crtc *crtc)
-{
-	struct drm_device *dev = plane->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-
-	/* If the pipe isn't enabled, we can't pump pixels and may hang */
-	assert_pipe_enabled(dev_priv, intel_crtc->pipe);
-	to_intel_plane_state(plane->state)->visible = true;
-
-	dev_priv->display.update_primary_plane(crtc, plane->fb,
-					       crtc->x, crtc->y);
-}
-
 static bool need_vtd_wa(struct drm_device *dev)
 {
 #ifdef CONFIG_INTEL_IOMMU
@@ -4508,20 +4486,6 @@ static void ironlake_pfit_enable(struct intel_crtc *crtc)
 	}
 }
 
-static void intel_enable_sprite_planes(struct drm_crtc *crtc)
-{
-	struct drm_device *dev = crtc->dev;
-	enum pipe pipe = to_intel_crtc(crtc)->pipe;
-	struct drm_plane *plane;
-	struct intel_plane *intel_plane;
-
-	drm_for_each_legacy_plane(plane, &dev->mode_config.plane_list) {
-		intel_plane = to_intel_plane(plane);
-		if (intel_plane->pipe == pipe)
-			intel_plane_restore(&intel_plane->base);
-	}
-}
-
 void hsw_enable_ips(struct intel_crtc *crtc)
 {
 	struct drm_device *dev = crtc->base.dev;
@@ -4817,27 +4781,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
 		intel_pre_disable_primary(&crtc->base);
 }
 
-static void intel_crtc_enable_planes(struct drm_crtc *crtc)
-{
-	struct drm_device *dev = crtc->dev;
-	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
-	int pipe = intel_crtc->pipe;
-
-	intel_enable_primary_hw_plane(crtc->primary, crtc);
-	intel_enable_sprite_planes(crtc);
-	if (to_intel_plane_state(crtc->cursor->state)->visible)
-		intel_crtc_update_cursor(crtc, true);
-
-	intel_post_enable_primary(crtc);
-
-	/*
-	 * FIXME: Once we grow proper nuclear flip support out of this we need
-	 * to compute the mask of flip planes precisely. For the time being
-	 * consider this a flip to a NULL plane.
-	 */
-	intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
-}
-
 static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask)
 {
 	struct drm_device *dev = crtc->dev;
@@ -4845,10 +4788,6 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask
 	struct drm_plane *p;
 	int pipe = intel_crtc->pipe;
 
-	intel_crtc_wait_for_pending_flips(crtc);
-
-	intel_pre_disable_primary(crtc);
-
 	intel_crtc_dpms_overlay_disable(intel_crtc);
 
 	drm_for_each_plane_mask(p, dev, plane_mask)
@@ -6270,6 +6209,11 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
 	if (!intel_crtc->active)
 		return;
 
+	if (to_intel_plane_state(crtc->primary->state)->visible) {
+		intel_crtc_wait_for_pending_flips(crtc);
+		intel_pre_disable_primary(crtc);
+	}
+
 	intel_crtc_disable_planes(crtc, crtc->state->plane_mask);
 	dev_priv->display.crtc_disable(crtc);
 
@@ -11783,10 +11727,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
 	if (old_plane_state->base.fb && !fb)
 		intel_crtc->atomic.disabled_planes |= 1 << i;
 
-	/* don't run rest during modeset yet */
-	if (!intel_crtc->active || mode_changed)
-		return 0;
-
 	was_visible = old_plane_state->visible;
 	visible = to_intel_plane_state(plane_state)->visible;
 
@@ -13255,15 +13195,18 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 	drm_atomic_helper_swap_state(dev, state);
 
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
+		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
+
 		if (!needs_modeset(crtc->state))
 			continue;
 
 		any_ms = true;
-		if (!crtc_state->active)
-			continue;
+		intel_pre_plane_update(intel_crtc);
 
-		intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
-		dev_priv->display.crtc_disable(crtc);
+		if (crtc_state->active) {
+			intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
+			dev_priv->display.crtc_disable(crtc);
+		}
 	}
 
 	/* Only after disabling all output pipelines that will be changed can we
@@ -13277,15 +13220,12 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 
 	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
-		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
-
-		if (!needs_modeset(crtc->state) || !crtc->state->active)
-			continue;
-
-		update_scanline_offset(to_intel_crtc(crtc));
+		if (needs_modeset(crtc->state) && crtc->state->active) {
+			update_scanline_offset(to_intel_crtc(crtc));
+			dev_priv->display.crtc_enable(crtc);
+		}
 
-		dev_priv->display.crtc_enable(crtc);
-		intel_crtc_enable_planes(crtc);
+		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
 	}
 
 	/* FIXME: add subpixel order */
@@ -13858,7 +13798,7 @@ intel_commit_primary_plane(struct drm_plane *plane,
 	crtc->x = src->x1 >> 16;
 	crtc->y = src->y1 >> 16;
 
-	if (!intel_crtc->active)
+	if (!crtc->state->active)
 		return;
 
 	if (state->visible)
@@ -13885,7 +13825,8 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 
-	intel_pre_plane_update(intel_crtc);
+	if (!needs_modeset(crtc->state))
+		intel_pre_plane_update(intel_crtc);
 
 	if (intel_crtc->atomic.update_wm)
 		intel_update_watermarks(crtc);
@@ -13893,7 +13834,7 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
 	intel_runtime_pm_get(dev_priv);
 
 	/* Perform vblank evasion around commit operation */
-	if (crtc->state->active && !needs_modeset(crtc->state))
+	if (crtc->state->active)
 		intel_crtc->atomic.evade =
 			intel_pipe_update_start(intel_crtc,
 						&intel_crtc->atomic.start_vbl_count);
@@ -14102,7 +14043,7 @@ intel_commit_cursor_plane(struct drm_plane *plane,
 	intel_crtc->cursor_bo = obj;
 
 update:
-	if (intel_crtc->active)
+	if (crtc->state->active)
 		intel_crtc_update_cursor(crtc, state->visible);
 }
 
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index f7eb3bd0a7c7..168f90f346c2 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -921,16 +921,14 @@ intel_commit_sprite_plane(struct drm_plane *plane,
 			  struct intel_plane_state *state)
 {
 	struct drm_crtc *crtc = state->base.crtc;
-	struct intel_crtc *intel_crtc;
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 	struct drm_framebuffer *fb = state->base.fb;
 
 	crtc = crtc ? crtc : plane->crtc;
-	intel_crtc = to_intel_crtc(crtc);
 
 	plane->fb = fb;
 
-	if (!intel_crtc->active)
+	if (!crtc->state->active)
 		return;
 
 	if (state->visible) {
-- 
2.1.0

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

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

* [PATCH v3 16/19] drm/i915: Update less state during modeset.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (14 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-15 10:33 ` [PATCH v3 17/19] drm/i915: Make setting color key atomic Maarten Lankhorst
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

No need to repeatedly call update_watermarks, or update_fbc.
Down to a single call to update_watermarks in .crtc_enable

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_display.c | 66 +++++++++---------------------------
 1 file changed, 16 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index beb69281f45c..5facd0501a34 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -1945,10 +1945,10 @@ static void intel_disable_shared_dpll(struct intel_crtc *crtc)
 
 	/* PCH only available on ILK+ */
 	BUG_ON(INTEL_INFO(dev)->gen < 5);
-	if (WARN_ON(pll == NULL))
-	       return;
+	if (pll == NULL)
+		return;
 
-	if (WARN_ON(pll->config.crtc_mask == 0))
+	if (WARN_ON(!(pll->config.crtc_mask & (1 << drm_crtc_index(&crtc->base)))))
 		return;
 
 	DRM_DEBUG_KMS("disable %s (active %d, on? %d) for crtc %d\n",
@@ -4643,10 +4643,6 @@ intel_post_enable_primary(struct drm_crtc *crtc)
 	 */
 	hsw_enable_ips(intel_crtc);
 
-	mutex_lock(&dev->struct_mutex);
-	intel_fbc_update(dev);
-	mutex_unlock(&dev->struct_mutex);
-
 	/*
 	 * Gen2 reports pipe underruns whenever all planes are disabled.
 	 * So don't enable underrun reporting before at least some planes
@@ -4701,11 +4697,6 @@ intel_pre_disable_primary(struct drm_crtc *crtc)
 	if (HAS_GMCH_DISPLAY(dev))
 		intel_set_memory_cxsr(dev_priv, false);
 
-	mutex_lock(&dev->struct_mutex);
-	if (dev_priv->fbc.crtc == intel_crtc)
-		intel_fbc_disable(dev);
-	mutex_unlock(&dev->struct_mutex);
-
 	/*
 	 * FIXME IPS should be fine as long as one plane is
 	 * enabled, but in practice it seems to have problems
@@ -4745,6 +4736,7 @@ static void intel_post_plane_update(struct intel_crtc *crtc)
 static void intel_pre_plane_update(struct intel_crtc *crtc)
 {
 	struct drm_device *dev = crtc->base.dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	struct intel_crtc_atomic_commit *atomic = &crtc->atomic;
 	struct drm_plane *p;
 
@@ -4774,8 +4766,13 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
 	if (atomic->wait_for_flips)
 		intel_crtc_wait_for_pending_flips(&crtc->base);
 
-	if (atomic->disable_fbc)
-		intel_fbc_disable(dev);
+	if (atomic->disable_fbc &&
+	    dev_priv->fbc.crtc == crtc) {
+		mutex_lock(&dev->struct_mutex);
+		if (dev_priv->fbc.crtc == crtc)
+			intel_fbc_disable(dev);
+		mutex_unlock(&dev->struct_mutex);
+	}
 
 	if (atomic->pre_disable_primary)
 		intel_pre_disable_primary(&crtc->base);
@@ -4992,9 +4989,6 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
 	int pipe = intel_crtc->pipe;
 	u32 reg, temp;
 
-	if (WARN_ON(!intel_crtc->active))
-		return;
-
 	for_each_encoder_on_crtc(dev, crtc, encoder)
 		encoder->disable(encoder);
 
@@ -5033,18 +5027,8 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
 			I915_WRITE(PCH_DPLL_SEL, temp);
 		}
 
-		/* disable PCH DPLL */
-		intel_disable_shared_dpll(intel_crtc);
-
 		ironlake_fdi_pll_disable(intel_crtc);
 	}
-
-	intel_crtc->active = false;
-	intel_update_watermarks(crtc);
-
-	mutex_lock(&dev->struct_mutex);
-	intel_fbc_update(dev);
-	mutex_unlock(&dev->struct_mutex);
 }
 
 static void haswell_crtc_disable(struct drm_crtc *crtc)
@@ -5055,9 +5039,6 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	struct intel_encoder *encoder;
 	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
 
-	if (WARN_ON(!intel_crtc->active))
-		return;
-
 	for_each_encoder_on_crtc(dev, crtc, encoder) {
 		intel_opregion_notify_encoder(encoder, false);
 		encoder->disable(encoder);
@@ -5093,16 +5074,6 @@ static void haswell_crtc_disable(struct drm_crtc *crtc)
 	for_each_encoder_on_crtc(dev, crtc, encoder)
 		if (encoder->post_disable)
 			encoder->post_disable(encoder);
-
-	intel_crtc->active = false;
-	intel_update_watermarks(crtc);
-
-	mutex_lock(&dev->struct_mutex);
-	intel_fbc_update(dev);
-	mutex_unlock(&dev->struct_mutex);
-
-	if (intel_crtc_to_shared_dpll(intel_crtc))
-		intel_disable_shared_dpll(intel_crtc);
 }
 
 static void i9xx_pfit_enable(struct intel_crtc *crtc)
@@ -6154,9 +6125,6 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
 	struct intel_encoder *encoder;
 	int pipe = intel_crtc->pipe;
 
-	if (WARN_ON(!intel_crtc->active))
-		return;
-
 	/*
 	 * On gen2 planes are double buffered but the pipe isn't, so we must
 	 * wait for planes to fully turn off before disabling the pipe.
@@ -6190,13 +6158,6 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
 
 	if (!IS_GEN2(dev))
 		intel_set_cpu_fifo_underrun_reporting(dev_priv, pipe, false);
-
-	intel_crtc->active = false;
-	intel_update_watermarks(crtc);
-
-	mutex_lock(&dev->struct_mutex);
-	intel_fbc_update(dev);
-	mutex_unlock(&dev->struct_mutex);
 }
 
 static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
@@ -11919,6 +11880,9 @@ static int intel_crtc_atomic_check(struct drm_crtc *crtc,
 	if (pipe_config->quirks & PIPE_CONFIG_QUIRK_INITIAL_PLANES)
 		intel_crtc_check_initial_planes(crtc, crtc_state);
 
+	if (mode_changed)
+		intel_crtc->atomic.update_wm = !crtc_state->active;
+
 	if (mode_changed && crtc_state->enable &&
 	    dev_priv->display.crtc_compute_clock &&
 	    !WARN_ON(pipe_config->shared_dpll != DPLL_ID_PRIVATE)) {
@@ -13206,6 +13170,8 @@ static int __intel_set_mode(struct drm_atomic_state *state)
 		if (crtc_state->active) {
 			intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
 			dev_priv->display.crtc_disable(crtc);
+			intel_crtc->active = false;
+			intel_disable_shared_dpll(intel_crtc);
 		}
 	}
 
-- 
2.1.0

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

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

* [PATCH v3 17/19] drm/i915: Make setting color key atomic.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (15 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 16/19] drm/i915: Update less state during modeset Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-18 14:21   ` Matt Roper
  2015-06-15 10:33 ` [PATCH v3 18/19] drm/i915: Remove transitional references from intel_plane_atomic_check Maarten Lankhorst
                   ` (2 subsequent siblings)
  19 siblings, 1 reply; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

By making color key atomic there are no more transitional helpers.
The plane check function will reject the color key when a scaler is
active.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic_plane.c |  1 +
 drivers/gpu/drm/i915/intel_display.c      |  7 ++-
 drivers/gpu/drm/i915/intel_drv.h          |  6 +--
 drivers/gpu/drm/i915/intel_sprite.c       | 85 +++++++++++++++----------------
 4 files changed, 46 insertions(+), 53 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index 91d53768df9d..10a8ecedc942 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -56,6 +56,7 @@ intel_create_plane_state(struct drm_plane *plane)
 
 	state->base.plane = plane;
 	state->base.rotation = BIT(DRM_ROTATE_0);
+	state->ckey.flags = I915_SET_COLORKEY_NONE;
 
 	return state;
 }
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 5facd0501a34..746c73d2ab84 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4401,9 +4401,9 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
 		return ret;
 
 	/* check colorkey */
-	if (WARN_ON(intel_plane->ckey.flags != I915_SET_COLORKEY_NONE)) {
+	if (plane_state->ckey.flags != I915_SET_COLORKEY_NONE) {
 		DRM_DEBUG_KMS("[PLANE:%d] scaling with color key not allowed",
-			intel_plane->base.base.id);
+			      intel_plane->base.base.id);
 		return -EINVAL;
 	}
 
@@ -13733,7 +13733,7 @@ intel_check_primary_plane(struct drm_plane *plane,
 
 	/* use scaler when colorkey is not required */
 	if (INTEL_INFO(plane->dev)->gen >= 9 &&
-	    to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
+	    state->ckey.flags == I915_SET_COLORKEY_NONE) {
 		min_scale = 1;
 		max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state);
 		can_position = true;
@@ -13881,7 +13881,6 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
 	primary->check_plane = intel_check_primary_plane;
 	primary->commit_plane = intel_commit_primary_plane;
 	primary->disable_plane = intel_disable_primary_plane;
-	primary->ckey.flags = I915_SET_COLORKEY_NONE;
 	if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4)
 		primary->plane = !pipe;
 
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 93b9542ab8dc..3a2ac82b0970 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -274,6 +274,8 @@ struct intel_plane_state {
 	 *     update_scaler_plane.
 	 */
 	int scaler_id;
+
+	struct drm_intel_sprite_colorkey ckey;
 };
 
 struct intel_initial_plane_config {
@@ -588,9 +590,6 @@ struct intel_plane {
 	bool can_scale;
 	int max_downscale;
 
-	/* FIXME convert to properties */
-	struct drm_intel_sprite_colorkey ckey;
-
 	/* Since we need to change the watermarks before/after
 	 * enabling/disabling the planes, we need to store the parameters here
 	 * as the other pieces of the struct may not reflect the values we want
@@ -1390,7 +1389,6 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
 
 /* intel_sprite.c */
 int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
-int intel_plane_restore(struct drm_plane *plane);
 int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
 			      struct drm_file *file_priv);
 bool intel_pipe_update_start(struct intel_crtc *crtc,
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 168f90f346c2..21d3f7882c4d 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -182,7 +182,8 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
 	const int plane = intel_plane->plane + 1;
 	u32 plane_ctl, stride_div, stride;
 	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
-	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
+	const struct drm_intel_sprite_colorkey *key =
+		&to_intel_plane_state(drm_plane->state)->ckey;
 	unsigned long surf_addr;
 	u32 tile_height, plane_offset, plane_size;
 	unsigned int rotation;
@@ -344,7 +345,8 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
 	u32 sprctl;
 	unsigned long sprsurf_offset, linear_offset;
 	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
-	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
+	const struct drm_intel_sprite_colorkey *key =
+		&to_intel_plane_state(dplane->state)->ckey;
 
 	sprctl = SP_ENABLE;
 
@@ -487,7 +489,8 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	u32 sprctl, sprscale = 0;
 	unsigned long sprsurf_offset, linear_offset;
 	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
-	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
+	const struct drm_intel_sprite_colorkey *key =
+		&to_intel_plane_state(plane->state)->ckey;
 
 	sprctl = SPRITE_ENABLE;
 
@@ -627,7 +630,8 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
 	unsigned long dvssurf_offset, linear_offset;
 	u32 dvscntr, dvsscale;
 	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
-	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
+	const struct drm_intel_sprite_colorkey *key =
+		&to_intel_plane_state(plane->state)->ckey;
 
 	dvscntr = DVS_ENABLE;
 
@@ -778,7 +782,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
 	/* setup can_scale, min_scale, max_scale */
 	if (INTEL_INFO(dev)->gen >= 9) {
 		/* use scaler when colorkey is not required */
-		if (intel_plane->ckey.flags == I915_SET_COLORKEY_NONE) {
+		if (state->ckey.flags == I915_SET_COLORKEY_NONE) {
 			can_scale = 1;
 			min_scale = 1;
 			max_scale = skl_max_scale(intel_crtc, crtc_state);
@@ -798,7 +802,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
 	 * coordinates and sizes. We probably need some way to decide whether
 	 * more strict checking should be done instead.
 	 */
-
 	drm_rect_rotate(src, fb->width << 16, fb->height << 16,
 			state->base.rotation);
 
@@ -808,7 +811,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
 	vscale = drm_rect_calc_vscale_relaxed(src, dst, min_scale, max_scale);
 	BUG_ON(vscale < 0);
 
-	state->visible =  drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
+	state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
 
 	crtc_x = dst->x1;
 	crtc_y = dst->y1;
@@ -950,7 +953,9 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
 {
 	struct drm_intel_sprite_colorkey *set = data;
 	struct drm_plane *plane;
-	struct intel_plane *intel_plane;
+	struct drm_plane_state *plane_state;
+	struct drm_atomic_state *state;
+	struct drm_modeset_acquire_ctx ctx;
 	int ret = 0;
 
 	/* Make sure we don't try to enable both src & dest simultaneously */
@@ -961,50 +966,41 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
 	    set->flags & I915_SET_COLORKEY_DESTINATION)
 		return -EINVAL;
 
-	drm_modeset_lock_all(dev);
-
 	plane = drm_plane_find(dev, set->plane_id);
-	if (!plane || plane->type != DRM_PLANE_TYPE_OVERLAY) {
-		ret = -ENOENT;
-		goto out_unlock;
-	}
+	if (!plane || plane->type != DRM_PLANE_TYPE_OVERLAY)
+		return -ENOENT;
 
-	intel_plane = to_intel_plane(plane);
+	drm_modeset_acquire_init(&ctx, 0);
 
-	if (INTEL_INFO(dev)->gen >= 9) {
-		/* plane scaling and colorkey are mutually exclusive */
-		if (to_intel_plane_state(plane->state)->scaler_id >= 0) {
-			DRM_ERROR("colorkey not allowed with scaler\n");
-			ret = -EINVAL;
-			goto out_unlock;
-		}
+	state = drm_atomic_state_alloc(plane->dev);
+	if (!state) {
+		ret = -ENOMEM;
+		goto out;
 	}
+	state->acquire_ctx = &ctx;
+
+	while (1) {
+		plane_state = drm_atomic_get_plane_state(state, plane);
+		ret = PTR_ERR_OR_ZERO(plane_state);
+		if (!ret) {
+			to_intel_plane_state(plane_state)->ckey = *set;
+			ret = drm_atomic_commit(state);
+		}
 
-	intel_plane->ckey = *set;
-
-	/*
-	 * The only way this could fail would be due to
-	 * the current plane state being unsupportable already,
-	 * and we dont't consider that an error for the
-	 * colorkey ioctl. So just ignore any error.
-	 */
-	intel_plane_restore(plane);
+		if (ret != -EDEADLK)
+			break;
 
-out_unlock:
-	drm_modeset_unlock_all(dev);
-	return ret;
-}
+		drm_atomic_state_clear(state);
+		drm_modeset_backoff(&ctx);
+	}
 
-int intel_plane_restore(struct drm_plane *plane)
-{
-	if (!plane->crtc || !plane->state->fb)
-		return 0;
+	if (ret)
+		drm_atomic_state_free(state);
 
-	return drm_plane_helper_update(plane, plane->crtc, plane->state->fb,
-				       plane->state->crtc_x, plane->state->crtc_y,
-				       plane->state->crtc_w, plane->state->crtc_h,
-				       plane->state->src_x, plane->state->src_y,
-				       plane->state->src_w, plane->state->src_h);
+out:
+	drm_modeset_drop_locks(&ctx);
+	drm_modeset_acquire_fini(&ctx);
+	return ret;
 }
 
 static const uint32_t ilk_plane_formats[] = {
@@ -1133,7 +1129,6 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
 	intel_plane->plane = plane;
 	intel_plane->check_plane = intel_check_sprite_plane;
 	intel_plane->commit_plane = intel_commit_sprite_plane;
-	intel_plane->ckey.flags = I915_SET_COLORKEY_NONE;
 	possible_crtcs = (1 << pipe);
 	ret = drm_universal_plane_init(dev, &intel_plane->base, possible_crtcs,
 				       &intel_plane_funcs,
-- 
2.1.0

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

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

* [PATCH v3 18/19] drm/i915: Remove transitional references from intel_plane_atomic_check.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (16 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 17/19] drm/i915: Make setting color key atomic Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-18 14:21   ` Matt Roper
  2015-06-15 10:33 ` [PATCH v3 19/19] drm/i915: Make cdclk part of the atomic state Maarten Lankhorst
  2015-06-19 22:29 ` [PATCH v3 00/19] Convert to atomic, part 3 Matt Roper
  19 siblings, 1 reply; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

All transitional plane helpers are gone, party!

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic_plane.c | 19 ++++++-------------
 1 file changed, 6 insertions(+), 13 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
index 10a8ecedc942..f1ab8e4b9c11 100644
--- a/drivers/gpu/drm/i915/intel_atomic_plane.c
+++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
@@ -115,6 +115,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 	struct intel_crtc_state *crtc_state;
 	struct intel_plane *intel_plane = to_intel_plane(plane);
 	struct intel_plane_state *intel_state = to_intel_plane_state(state);
+	struct drm_crtc_state *drm_crtc_state;
 	int ret;
 
 	crtc = crtc ? crtc : plane->state->crtc;
@@ -129,19 +130,11 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 	if (!crtc)
 		return 0;
 
-	/* FIXME: temporary hack necessary while we still use the plane update
-	 * helper. */
-	if (state->state) {
-		struct drm_crtc_state *drm_crtc_state =
-			drm_atomic_get_existing_crtc_state(state->state, crtc);
+	drm_crtc_state = drm_atomic_get_existing_crtc_state(state->state, crtc);
+	if (WARN_ON(!drm_crtc_state))
+		return -EINVAL;
 
-		if (WARN_ON(!drm_crtc_state))
-			return -EINVAL;
-
-		crtc_state = to_intel_crtc_state(drm_crtc_state);
-	} else {
-		crtc_state = intel_crtc->config;
-	}
+	crtc_state = to_intel_crtc_state(drm_crtc_state);
 
 	/*
 	 * The original src/dest coordinates are stored in state->base, but
@@ -191,7 +184,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
 
 	intel_state->visible = false;
 	ret = intel_plane->check_plane(plane, crtc_state, intel_state);
-	if (ret || !state->state)
+	if (ret)
 		return ret;
 
 	return intel_plane_atomic_calc_changes(&crtc_state->base, state);
-- 
2.1.0

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

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

* [PATCH v3 19/19] drm/i915: Make cdclk part of the atomic state.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (17 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 18/19] drm/i915: Remove transitional references from intel_plane_atomic_check Maarten Lankhorst
@ 2015-06-15 10:33 ` Maarten Lankhorst
  2015-06-19 22:29 ` [PATCH v3 00/19] Convert to atomic, part 3 Matt Roper
  19 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-15 10:33 UTC (permalink / raw)
  To: intel-gfx

The skylake scalers depend on the cdclk freq, but that frequency can
change during a modeset. So when a modeset happens calculate the new
cdclk in the atomic state. With the transitional helpers gone the
cached value can be used in the scaler, and committed after all
crtc's are disabled.

Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90874
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
 drivers/gpu/drm/i915/i915_drv.h      |   3 +-
 drivers/gpu/drm/i915/intel_atomic.c  |   2 +
 drivers/gpu/drm/i915/intel_display.c | 274 +++++++++++++++++------------------
 drivers/gpu/drm/i915/intel_drv.h     |   1 +
 4 files changed, 135 insertions(+), 145 deletions(-)

diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index 611fbd86c1cc..0f03d995151b 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -619,7 +619,8 @@ struct drm_i915_display_funcs {
 				 struct drm_crtc *crtc,
 				 uint32_t sprite_width, uint32_t sprite_height,
 				 int pixel_size, bool enable, bool scaled);
-	void (*modeset_global_resources)(struct drm_atomic_state *state);
+	int (*modeset_calc_cdclk)(struct drm_atomic_state *state);
+	void (*modeset_commit_cdclk)(struct drm_atomic_state *state);
 	/* Returns the active state of the crtc, and if the crtc is active,
 	 * fills out the pipe-config with the hw state. */
 	bool (*get_pipe_config)(struct intel_crtc *,
diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 060d98b10f83..0aeced82201e 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -54,6 +54,8 @@ int intel_atomic_check(struct drm_device *dev,
 	int i;
 	bool not_nuclear = false;
 
+	to_intel_atomic_state(state)->cdclk = to_i915(dev)->cdclk_freq;
+
 	/*
 	 * FIXME:  At the moment, we only support "nuclear pageflip" on a
 	 * single CRTC.  Cross-crtc updates will be added later.
diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 746c73d2ab84..39d27d87a0b2 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -5194,8 +5194,13 @@ static void modeset_update_crtc_power_domains(struct drm_atomic_state *state)
 			intel_display_power_get(dev_priv, domain);
 	}
 
-	if (dev_priv->display.modeset_global_resources)
-		dev_priv->display.modeset_global_resources(state);
+	if (dev_priv->display.modeset_commit_cdclk) {
+		unsigned int cdclk = to_intel_atomic_state(state)->cdclk;
+
+		if (cdclk != dev_priv->cdclk_freq &&
+		    !WARN_ON(!state->allow_modeset))
+			dev_priv->display.modeset_commit_cdclk(state);
+	}
 
 	for_each_intel_crtc(dev, crtc) {
 		enum intel_display_power_domain domain;
@@ -5847,11 +5852,7 @@ static int intel_mode_max_pixclk(struct drm_device *dev,
 	int max_pixclk = 0;
 
 	for_each_intel_crtc(dev, intel_crtc) {
-		if (state)
-			crtc_state =
-				intel_atomic_get_crtc_state(state, intel_crtc);
-		else
-			crtc_state = intel_crtc->config;
+		crtc_state = intel_atomic_get_crtc_state(state, intel_crtc);
 		if (IS_ERR(crtc_state))
 			return PTR_ERR(crtc_state);
 
@@ -5865,46 +5866,34 @@ static int intel_mode_max_pixclk(struct drm_device *dev,
 	return max_pixclk;
 }
 
-static int valleyview_modeset_global_pipes(struct drm_atomic_state *state)
+static int valleyview_modeset_calc_cdclk(struct drm_atomic_state *state)
 {
-	struct drm_i915_private *dev_priv = to_i915(state->dev);
-	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
-	int max_pixclk = intel_mode_max_pixclk(state->dev, state);
-	int cdclk, ret = 0;
+	struct drm_device *dev = state->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int max_pixclk = intel_mode_max_pixclk(dev, state);
 
 	if (max_pixclk < 0)
 		return max_pixclk;
 
-	if (IS_VALLEYVIEW(dev_priv))
-		cdclk = valleyview_calc_cdclk(dev_priv, max_pixclk);
-	else
-		cdclk = broxton_calc_cdclk(dev_priv, max_pixclk);
-
-	if (cdclk == dev_priv->cdclk_freq)
-		return 0;
-
-	/* add all active pipes to the state */
-	for_each_crtc(state->dev, crtc) {
-		crtc_state = drm_atomic_get_crtc_state(state, crtc);
-		if (IS_ERR(crtc_state))
-			return PTR_ERR(crtc_state);
+	to_intel_atomic_state(state)->cdclk =
+		valleyview_calc_cdclk(dev_priv, max_pixclk);
 
-		if (!crtc_state->active || needs_modeset(crtc_state))
-			continue;
+	return 0;
+}
 
-		crtc_state->mode_changed = true;
+static int broxton_modeset_calc_cdclk(struct drm_atomic_state *state)
+{
+	struct drm_device *dev = state->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
+	int max_pixclk = intel_mode_max_pixclk(dev, state);
 
-		ret = drm_atomic_add_affected_connectors(state, crtc);
-		if (ret)
-			break;
+	if (max_pixclk < 0)
+		return max_pixclk;
 
-		ret = drm_atomic_add_affected_planes(state, crtc);
-		if (ret)
-			break;
-	}
+	to_intel_atomic_state(state)->cdclk =
+		broxton_calc_cdclk(dev_priv, max_pixclk);
 
-	return ret;
+	return 0;
 }
 
 static void vlv_program_pfi_credits(struct drm_i915_private *dev_priv)
@@ -5943,41 +5932,31 @@ static void vlv_program_pfi_credits(struct drm_i915_private *dev_priv)
 	WARN_ON(I915_READ(GCI_CONTROL) & PFI_CREDIT_RESEND);
 }
 
-static void valleyview_modeset_global_resources(struct drm_atomic_state *old_state)
+static void valleyview_modeset_commit_cdclk(struct drm_atomic_state *old_state)
 {
 	struct drm_device *dev = old_state->dev;
+	unsigned int req_cdclk = to_intel_atomic_state(old_state)->cdclk;
 	struct drm_i915_private *dev_priv = dev->dev_private;
-	int max_pixclk = intel_mode_max_pixclk(dev, NULL);
-	int req_cdclk;
-
-	/* The path in intel_mode_max_pixclk() with a NULL atomic state should
-	 * never fail. */
-	if (WARN_ON(max_pixclk < 0))
-		return;
-
-	req_cdclk = valleyview_calc_cdclk(dev_priv, max_pixclk);
 
-	if (req_cdclk != dev_priv->cdclk_freq) {
-		/*
-		 * FIXME: We can end up here with all power domains off, yet
-		 * with a CDCLK frequency other than the minimum. To account
-		 * for this take the PIPE-A power domain, which covers the HW
-		 * blocks needed for the following programming. This can be
-		 * removed once it's guaranteed that we get here either with
-		 * the minimum CDCLK set, or the required power domains
-		 * enabled.
-		 */
-		intel_display_power_get(dev_priv, POWER_DOMAIN_PIPE_A);
+	/*
+	 * FIXME: We can end up here with all power domains off, yet
+	 * with a CDCLK frequency other than the minimum. To account
+	 * for this take the PIPE-A power domain, which covers the HW
+	 * blocks needed for the following programming. This can be
+	 * removed once it's guaranteed that we get here either with
+	 * the minimum CDCLK set, or the required power domains
+	 * enabled.
+	 */
+	intel_display_power_get(dev_priv, POWER_DOMAIN_PIPE_A);
 
-		if (IS_CHERRYVIEW(dev))
-			cherryview_set_cdclk(dev, req_cdclk);
-		else
-			valleyview_set_cdclk(dev, req_cdclk);
+	if (IS_CHERRYVIEW(dev))
+		cherryview_set_cdclk(dev, req_cdclk);
+	else
+		valleyview_set_cdclk(dev, req_cdclk);
 
-		vlv_program_pfi_credits(dev_priv);
+	vlv_program_pfi_credits(dev_priv);
 
-		intel_display_power_put(dev_priv, POWER_DOMAIN_PIPE_A);
-	}
+	intel_display_power_put(dev_priv, POWER_DOMAIN_PIPE_A);
 }
 
 static void valleyview_crtc_enable(struct drm_crtc *crtc)
@@ -9478,41 +9457,35 @@ void hsw_disable_pc8(struct drm_i915_private *dev_priv)
 	intel_prepare_ddi(dev);
 }
 
-static void broxton_modeset_global_resources(struct drm_atomic_state *old_state)
+static void broxton_modeset_commit_cdclk(struct drm_atomic_state *old_state)
 {
 	struct drm_device *dev = old_state->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	int max_pixclk = intel_mode_max_pixclk(dev, NULL);
-	int req_cdclk;
-
-	/* see the comment in valleyview_modeset_global_resources */
-	if (WARN_ON(max_pixclk < 0))
-		return;
+	unsigned int req_cdclk = to_intel_atomic_state(old_state)->cdclk;
 
-	req_cdclk = broxton_calc_cdclk(dev_priv, max_pixclk);
-
-	if (req_cdclk != dev_priv->cdclk_freq)
-		broxton_set_cdclk(dev, req_cdclk);
+	broxton_set_cdclk(dev, req_cdclk);
 }
 
 /* compute the max rate for new configuration */
-static int ilk_max_pixel_rate(struct drm_i915_private *dev_priv)
+static int ilk_max_pixel_rate(struct drm_atomic_state *state)
 {
-	struct drm_device *dev = dev_priv->dev;
 	struct intel_crtc *intel_crtc;
-	struct drm_crtc *crtc;
+	struct intel_crtc_state *crtc_state;
 	int max_pixel_rate = 0;
-	int pixel_rate;
 
-	for_each_crtc(dev, crtc) {
-		if (!crtc->state->enable)
+	for_each_intel_crtc(state->dev, intel_crtc) {
+		int pixel_rate;
+
+		crtc_state = intel_atomic_get_crtc_state(state, intel_crtc);
+		if (IS_ERR(crtc_state))
+			return PTR_ERR(crtc_state);
+
+		if (!crtc_state->base.enable)
 			continue;
 
-		intel_crtc = to_intel_crtc(crtc);
-		pixel_rate = ilk_pipe_pixel_rate(intel_crtc->config);
+		pixel_rate = ilk_pipe_pixel_rate(crtc_state);
 
 		/* pixel rate mustn't exceed 95% of cdclk with IPS on BDW */
-		if (IS_BROADWELL(dev) && intel_crtc->config->ips_enabled)
+		if (IS_BROADWELL(state->dev) && crtc_state->ips_enabled)
 			pixel_rate = DIV_ROUND_UP(pixel_rate * 100, 95);
 
 		max_pixel_rate = max(max_pixel_rate, pixel_rate);
@@ -9598,20 +9571,21 @@ static void broadwell_set_cdclk(struct drm_device *dev, int cdclk)
 	     cdclk, dev_priv->cdclk_freq);
 }
 
-static int broadwell_calc_cdclk(struct drm_i915_private *dev_priv,
-			      int max_pixel_rate)
+static int broadwell_modeset_calc_cdclk(struct drm_atomic_state *state)
 {
+	struct drm_i915_private *dev_priv = to_i915(state->dev);
+	int max_pixclk = ilk_max_pixel_rate(state);
 	int cdclk;
 
 	/*
 	 * FIXME should also account for plane ratio
 	 * once 64bpp pixel formats are supported.
 	 */
-	if (max_pixel_rate > 540000)
+	if (max_pixclk > 540000)
 		cdclk = 675000;
-	else if (max_pixel_rate > 450000)
+	else if (max_pixclk > 450000)
 		cdclk = 540000;
-	else if (max_pixel_rate > 337500)
+	else if (max_pixclk > 337500)
 		cdclk = 450000;
 	else
 		cdclk = 337500;
@@ -9626,49 +9600,17 @@ static int broadwell_calc_cdclk(struct drm_i915_private *dev_priv,
 		cdclk = dev_priv->max_cdclk_freq;
 	}
 
-	return cdclk;
-}
-
-static int broadwell_modeset_global_pipes(struct drm_atomic_state *state)
-{
-	struct drm_i915_private *dev_priv = to_i915(state->dev);
-	struct drm_crtc *crtc;
-	struct drm_crtc_state *crtc_state;
-	int max_pixclk = ilk_max_pixel_rate(dev_priv);
-	int cdclk, i;
-
-	cdclk = broadwell_calc_cdclk(dev_priv, max_pixclk);
-
-	if (cdclk == dev_priv->cdclk_freq)
-		return 0;
-
-	/* add all active pipes to the state */
-	for_each_crtc(state->dev, crtc) {
-		if (!crtc->state->enable)
-			continue;
-
-		crtc_state = drm_atomic_get_crtc_state(state, crtc);
-		if (IS_ERR(crtc_state))
-			return PTR_ERR(crtc_state);
-	}
-
-	/* disable/enable all currently active pipes while we change cdclk */
-	for_each_crtc_in_state(state, crtc, crtc_state, i)
-		if (crtc_state->enable)
-			crtc_state->mode_changed = true;
+	to_intel_atomic_state(state)->cdclk = cdclk;
 
 	return 0;
 }
 
-static void broadwell_modeset_global_resources(struct drm_atomic_state *state)
+static void broadwell_modeset_commit_cdclk(struct drm_atomic_state *old_state)
 {
-	struct drm_device *dev = state->dev;
-	struct drm_i915_private *dev_priv = dev->dev_private;
-	int max_pixel_rate = ilk_max_pixel_rate(dev_priv);
-	int req_cdclk = broadwell_calc_cdclk(dev_priv, max_pixel_rate);
+	struct drm_device *dev = old_state->dev;
+	unsigned int req_cdclk = to_intel_atomic_state(old_state)->cdclk;
 
-	if (req_cdclk != dev_priv->cdclk_freq)
-		broadwell_set_cdclk(dev, req_cdclk);
+	broadwell_set_cdclk(dev, req_cdclk);
 }
 
 static int haswell_crtc_compute_clock(struct intel_crtc *crtc,
@@ -13044,10 +12986,41 @@ static int haswell_mode_set_planes_workaround(struct drm_atomic_state *state)
 	return 0;
 }
 
+static int intel_modeset_all_pipes(struct drm_atomic_state *state)
+{
+	struct drm_crtc *crtc;
+	struct drm_crtc_state *crtc_state;
+	int ret = 0;
+
+	/* add all active pipes to the state */
+	for_each_crtc(state->dev, crtc) {
+		crtc_state = drm_atomic_get_crtc_state(state, crtc);
+		if (IS_ERR(crtc_state))
+			return PTR_ERR(crtc_state);
+
+		if (!crtc_state->active || needs_modeset(crtc_state))
+			continue;
+
+		crtc_state->mode_changed = true;
+
+		ret = drm_atomic_add_affected_connectors(state, crtc);
+		if (ret)
+			break;
+
+		ret = drm_atomic_add_affected_planes(state, crtc);
+		if (ret)
+			break;
+	}
+
+	return ret;
+}
+
+
 /* Code that should eventually be part of atomic_check() */
 static int intel_modeset_checks(struct drm_atomic_state *state)
 {
 	struct drm_device *dev = state->dev;
+	struct drm_i915_private *dev_priv = dev->dev_private;
 	int ret;
 
 	if (!check_digital_port_conflicts(state)) {
@@ -13062,15 +13035,19 @@ static int intel_modeset_checks(struct drm_atomic_state *state)
 	 * mode set on this crtc.  For other crtcs we need to use the
 	 * adjusted_mode bits in the crtc directly.
 	 */
-	if (IS_VALLEYVIEW(dev) || IS_BROXTON(dev) || IS_BROADWELL(dev)) {
-		if (IS_VALLEYVIEW(dev) || IS_BROXTON(dev))
-			ret = valleyview_modeset_global_pipes(state);
-		else
-			ret = broadwell_modeset_global_pipes(state);
+	if (dev_priv->display.modeset_calc_cdclk) {
+		unsigned int cdclk;
 
-		if (ret)
+		ret = dev_priv->display.modeset_calc_cdclk(state);
+
+		cdclk = to_intel_atomic_state(state)->cdclk;
+		if (!ret && cdclk != dev_priv->cdclk_freq)
+			ret = intel_modeset_all_pipes(state);
+
+		if (ret < 0)
 			return ret;
-	}
+	} else
+		to_intel_atomic_state(state)->cdclk = dev_priv->cdclk_freq;
 
 	intel_modeset_clear_plls(state);
 
@@ -13137,7 +13114,9 @@ intel_modeset_compute_config(struct drm_atomic_state *state)
 
 		if (ret)
 			return ret;
-	}
+	} else
+		to_intel_atomic_state(state)->cdclk =
+			to_i915(state->dev)->cdclk_freq;
 
 	return drm_atomic_helper_check_planes(state->dev, state);
 }
@@ -13704,7 +13683,7 @@ skl_max_scale(struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state
 	dev = intel_crtc->base.dev;
 	dev_priv = dev->dev_private;
 	crtc_clock = crtc_state->base.adjusted_mode.crtc_clock;
-	cdclk = dev_priv->display.get_display_clock_speed(dev);
+	cdclk = to_intel_atomic_state(crtc_state->base.state)->cdclk;
 
 	if (!crtc_clock || !cdclk)
 		return DRM_PLANE_HELPER_NO_SCALING;
@@ -14775,15 +14754,22 @@ static void intel_init_display(struct drm_device *dev)
 		dev_priv->display.fdi_link_train = ivb_manual_fdi_link_train;
 	} else if (IS_HASWELL(dev) || IS_BROADWELL(dev)) {
 		dev_priv->display.fdi_link_train = hsw_fdi_link_train;
-		if (IS_BROADWELL(dev))
-			dev_priv->display.modeset_global_resources =
-				broadwell_modeset_global_resources;
+		if (IS_BROADWELL(dev)) {
+			dev_priv->display.modeset_commit_cdclk =
+				broadwell_modeset_commit_cdclk;
+			dev_priv->display.modeset_calc_cdclk =
+				broadwell_modeset_calc_cdclk;
+		}
 	} else if (IS_VALLEYVIEW(dev)) {
-		dev_priv->display.modeset_global_resources =
-			valleyview_modeset_global_resources;
+		dev_priv->display.modeset_commit_cdclk =
+			valleyview_modeset_commit_cdclk;
+		dev_priv->display.modeset_calc_cdclk =
+			valleyview_modeset_calc_cdclk;
 	} else if (IS_BROXTON(dev)) {
-		dev_priv->display.modeset_global_resources =
-			broxton_modeset_global_resources;
+		dev_priv->display.modeset_commit_cdclk =
+			broxton_modeset_commit_cdclk;
+		dev_priv->display.modeset_calc_cdclk =
+			broxton_modeset_calc_cdclk;
 	}
 
 	switch (INTEL_INFO(dev)->gen) {
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 3a2ac82b0970..e4274617978f 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -244,6 +244,7 @@ typedef struct dpll {
 struct intel_atomic_state {
 	struct drm_atomic_state base;
 
+	unsigned int cdclk;
 	bool dpll_set;
 	struct intel_shared_dpll_config shared_dpll[I915_NUM_PLLS];
 };
-- 
2.1.0

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

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

* Re: [PATCH v3 06/19] drm/i915: Split skl_update_scaler, v3.
  2015-06-15 10:33 ` [PATCH v3 06/19] drm/i915: Split skl_update_scaler, v3 Maarten Lankhorst
@ 2015-06-18  1:48   ` Matt Roper
  2015-06-18  5:42     ` Maarten Lankhorst
  0 siblings, 1 reply; 39+ messages in thread
From: Matt Roper @ 2015-06-18  1:48 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Mon, Jun 15, 2015 at 12:33:43PM +0200, Maarten Lankhorst wrote:
> It's easier to read separate functions for crtc and plane scaler state.
> 
> Changes since v1:
>  - Update documentation.
> Changes since v2:
>  - Get rid of parameters to skl_update_scaler only used for traces.
>    This avoids needing to document the other parameters.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 211 +++++++++++++++++++----------------
>  drivers/gpu/drm/i915/intel_dp.c      |   2 +-
>  drivers/gpu/drm/i915/intel_drv.h     |  12 +-
>  drivers/gpu/drm/i915/intel_sprite.c  |   3 +-
>  4 files changed, 121 insertions(+), 107 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 0f7652a31c95..26d610acb61f 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -4303,62 +4303,16 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
>  	}
>  }
>  
> -/**
> - * skl_update_scaler_users - Stages update to crtc's scaler state
> - * @intel_crtc: crtc
> - * @crtc_state: crtc_state
> - * @plane: plane (NULL indicates crtc is requesting update)
> - * @plane_state: plane's state
> - * @force_detach: request unconditional detachment of scaler
> - *
> - * This function updates scaler state for requested plane or crtc.
> - * To request scaler usage update for a plane, caller shall pass plane pointer.
> - * To request scaler usage update for crtc, caller shall pass plane pointer
> - * as NULL.
> - *
> - * Return
> - *     0 - scaler_usage updated successfully
> - *    error - requested scaling cannot be supported or other error condition
> - */
> -int
> -skl_update_scaler_users(
> -	struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state,
> -	struct intel_plane *intel_plane, struct intel_plane_state *plane_state,
> -	int force_detach)
> +static int
> +skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
> +		  unsigned scaler_idx, int *scaler_id, unsigned int rotation,
                           ^^^^^^^^^^
This parameter isn't actually the scaler index is it (that's what
scaler_id winds up being once assigned here)?  I think this one is the
plane index that we're assigning a scaler for (or the special value of
SKL_CRTC_INDEX if we're assigning for the CRTC instead of a plane).

Maybe 'scaler_target' or 'scaler_user' would be better?


Matt

> +		  int src_w, int src_h, int dst_w, int dst_h)
>  {
> +	struct intel_crtc_scaler_state *scaler_state =
> +		&crtc_state->scaler_state;
> +	struct intel_crtc *intel_crtc =
> +		to_intel_crtc(crtc_state->base.crtc);
>  	int need_scaling;
> -	int idx;
> -	int src_w, src_h, dst_w, dst_h;
> -	int *scaler_id;
> -	struct drm_framebuffer *fb;
> -	struct intel_crtc_scaler_state *scaler_state;
> -	unsigned int rotation;
> -
> -	if (!intel_crtc || !crtc_state)
> -		return 0;
> -
> -	scaler_state = &crtc_state->scaler_state;
> -
> -	idx = intel_plane ? drm_plane_index(&intel_plane->base) : SKL_CRTC_INDEX;
> -	fb = intel_plane ? plane_state->base.fb : NULL;
> -
> -	if (intel_plane) {
> -		src_w = drm_rect_width(&plane_state->src) >> 16;
> -		src_h = drm_rect_height(&plane_state->src) >> 16;
> -		dst_w = drm_rect_width(&plane_state->dst);
> -		dst_h = drm_rect_height(&plane_state->dst);
> -		scaler_id = &plane_state->scaler_id;
> -		rotation = plane_state->base.rotation;
> -	} else {
> -		struct drm_display_mode *adjusted_mode =
> -			&crtc_state->base.adjusted_mode;
> -		src_w = crtc_state->pipe_src_w;
> -		src_h = crtc_state->pipe_src_h;
> -		dst_w = adjusted_mode->hdisplay;
> -		dst_h = adjusted_mode->vdisplay;
> -		scaler_id = &scaler_state->scaler_id;
> -		rotation = DRM_ROTATE_0;
> -	}
>  
>  	need_scaling = intel_rotation_90_or_270(rotation) ?
>  		(src_h != dst_w || src_w != dst_h):
> @@ -4374,17 +4328,14 @@ skl_update_scaler_users(
>  	 * update to free the scaler is done in plane/panel-fit programming.
>  	 * For this purpose crtc/plane_state->scaler_id isn't reset here.
>  	 */
> -	if (force_detach || !need_scaling || (intel_plane &&
> -		(!fb || !plane_state->visible))) {
> +	if (force_detach || !need_scaling) {
>  		if (*scaler_id >= 0) {
> -			scaler_state->scaler_users &= ~(1 << idx);
> +			scaler_state->scaler_users &= ~(1 << scaler_idx);
>  			scaler_state->scalers[*scaler_id].in_use = 0;
>  
> -			DRM_DEBUG_KMS("Staged freeing scaler id %d.%d from %s:%d "
> -				"crtc_state = %p scaler_users = 0x%x\n",
> -				intel_crtc->pipe, *scaler_id, intel_plane ? "PLANE" : "CRTC",
> -				intel_plane ? intel_plane->base.base.id :
> -				intel_crtc->base.base.id, crtc_state,
> +			DRM_DEBUG_KMS("scaler_user index %u.%u: "
> +				"Staged freeing scaler id %d.%d scaler_users = 0x%x\n",
> +				intel_crtc->pipe, scaler_idx, *scaler_id, scaler_idx,
>  				scaler_state->scaler_users);
>  			*scaler_id = -1;
>  		}
> @@ -4397,51 +4348,112 @@ skl_update_scaler_users(
>  
>  		src_w > SKL_MAX_SRC_W || src_h > SKL_MAX_SRC_H ||
>  		dst_w > SKL_MAX_DST_W || dst_h > SKL_MAX_DST_H) {
> -		DRM_DEBUG_KMS("%s:%d scaler_user index %u.%u: src %ux%u dst %ux%u "
> +		DRM_DEBUG_KMS("scaler_user index %u.%u: src %ux%u dst %ux%u "
>  			"size is out of scaler range\n",
> -			intel_plane ? "PLANE" : "CRTC",
> -			intel_plane ? intel_plane->base.base.id : intel_crtc->base.base.id,
> -			intel_crtc->pipe, idx, src_w, src_h, dst_w, dst_h);
> +			intel_crtc->pipe, scaler_idx, src_w, src_h, dst_w, dst_h);
>  		return -EINVAL;
>  	}
>  
> +	/* mark this plane as a scaler user in crtc_state */
> +	scaler_state->scaler_users |= (1 << scaler_idx);
> +	DRM_DEBUG_KMS("scaler_user index %u.%u: "
> +		"staged scaling request for %ux%u->%ux%u scaler_users = 0x%x\n",
> +		intel_crtc->pipe, scaler_idx, src_w, src_h, dst_w, dst_h,
> +		scaler_state->scaler_users);
> +
> +	return 0;
> +}
> +
> +/**
> + * skl_update_scaler_crtc - Stages update to scaler state for a given crtc.
> + *
> + * @state: crtc's scaler state
> + * @force_detach: whether to forcibly disable scaler
> + *
> + * Return
> + *     0 - scaler_usage updated successfully
> + *    error - requested scaling cannot be supported or other error condition
> + */
> +int skl_update_scaler_crtc(struct intel_crtc_state *state, int force_detach)
> +{
> +	struct intel_crtc *intel_crtc = to_intel_crtc(state->base.crtc);
> +	struct drm_display_mode *adjusted_mode =
> +		&state->base.adjusted_mode;
> +
> +	DRM_DEBUG_KMS("Updating scaler for [CRTC:%i] scaler_user index %u.%u\n",
> +		      intel_crtc->base.base.id, intel_crtc->pipe, SKL_CRTC_INDEX);
> +
> +	return skl_update_scaler(state, force_detach, SKL_CRTC_INDEX,
> +		&state->scaler_state.scaler_id, DRM_ROTATE_0,
> +		state->pipe_src_w, state->pipe_src_h,
> +		adjusted_mode->hdisplay, adjusted_mode->hdisplay);
> +}
> +
> +/**
> + * skl_update_scaler_plane - Stages update to scaler state for a given plane.
> + *
> + * @state: crtc's scaler state
> + * @intel_plane: affected plane
> + * @plane_state: atomic plane state to update
> + *
> + * Return
> + *     0 - scaler_usage updated successfully
> + *    error - requested scaling cannot be supported or other error condition
> + */
> +int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
> +			    struct intel_plane *intel_plane,
> +			    struct intel_plane_state *plane_state)
> +{
> +
> +	struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc);
> +	struct drm_framebuffer *fb = plane_state->base.fb;
> +	int ret;
> +
> +	bool force_detach = !fb || !plane_state->visible;
> +
> +	DRM_DEBUG_KMS("Updating scaler for [PLANE:%d] scaler_user index %u.%u\n",
> +		      intel_plane->base.base.id, intel_crtc->pipe,
> +		      drm_plane_index(&intel_plane->base));
> +
> +	ret = skl_update_scaler(crtc_state, force_detach,
> +				drm_plane_index(&intel_plane->base),
> +				&plane_state->scaler_id,
> +				plane_state->base.rotation,
> +				drm_rect_width(&plane_state->src) >> 16,
> +				drm_rect_height(&plane_state->src) >> 16,
> +				drm_rect_width(&plane_state->dst),
> +				drm_rect_height(&plane_state->dst));
> +
> +	if (ret || plane_state->scaler_id < 0)
> +		return ret;
> +
>  	/* check colorkey */
> -	if (WARN_ON(intel_plane &&
> -		intel_plane->ckey.flags != I915_SET_COLORKEY_NONE)) {
> -		DRM_DEBUG_KMS("PLANE:%d scaling %ux%u->%ux%u not allowed with colorkey",
> -			intel_plane->base.base.id, src_w, src_h, dst_w, dst_h);
> +	if (WARN_ON(intel_plane->ckey.flags != I915_SET_COLORKEY_NONE)) {
> +		DRM_DEBUG_KMS("[PLANE:%d] scaling with color key not allowed",
> +			intel_plane->base.base.id);
>  		return -EINVAL;
>  	}
>  
>  	/* Check src format */
> -	if (intel_plane) {
> -		switch (fb->pixel_format) {
> -		case DRM_FORMAT_RGB565:
> -		case DRM_FORMAT_XBGR8888:
> -		case DRM_FORMAT_XRGB8888:
> -		case DRM_FORMAT_ABGR8888:
> -		case DRM_FORMAT_ARGB8888:
> -		case DRM_FORMAT_XRGB2101010:
> -		case DRM_FORMAT_XBGR2101010:
> -		case DRM_FORMAT_YUYV:
> -		case DRM_FORMAT_YVYU:
> -		case DRM_FORMAT_UYVY:
> -		case DRM_FORMAT_VYUY:
> -			break;
> -		default:
> -			DRM_DEBUG_KMS("PLANE:%d FB:%d unsupported scaling format 0x%x\n",
> -				intel_plane->base.base.id, fb->base.id, fb->pixel_format);
> -			return -EINVAL;
> -		}
> +	switch (fb->pixel_format) {
> +	case DRM_FORMAT_RGB565:
> +	case DRM_FORMAT_XBGR8888:
> +	case DRM_FORMAT_XRGB8888:
> +	case DRM_FORMAT_ABGR8888:
> +	case DRM_FORMAT_ARGB8888:
> +	case DRM_FORMAT_XRGB2101010:
> +	case DRM_FORMAT_XBGR2101010:
> +	case DRM_FORMAT_YUYV:
> +	case DRM_FORMAT_YVYU:
> +	case DRM_FORMAT_UYVY:
> +	case DRM_FORMAT_VYUY:
> +		break;
> +	default:
> +		DRM_DEBUG_KMS("[PLANE:%d] FB:%d unsupported scaling format 0x%x\n",
> +			intel_plane->base.base.id, fb->base.id, fb->pixel_format);
> +		return -EINVAL;
>  	}
>  
> -	/* mark this plane as a scaler user in crtc_state */
> -	scaler_state->scaler_users |= (1 << idx);
> -	DRM_DEBUG_KMS("%s:%d staged scaling request for %ux%u->%ux%u "
> -		"crtc_state = %p scaler_users = 0x%x\n",
> -		intel_plane ? "PLANE" : "CRTC",
> -		intel_plane ? intel_plane->base.base.id : intel_crtc->base.base.id,
> -		src_w, src_h, dst_w, dst_h, crtc_state, scaler_state->scaler_users);
>  	return 0;
>  }
>  
> @@ -4456,7 +4468,7 @@ static void skylake_pfit_update(struct intel_crtc *crtc, int enable)
>  	DRM_DEBUG_KMS("for crtc_state = %p\n", crtc->config);
>  
>  	/* To update pfit, first update scaler state */
> -	skl_update_scaler_users(crtc, crtc->config, NULL, NULL, !enable);
> +	skl_update_scaler_crtc(crtc->config, !enable);
>  	intel_atomic_setup_scalers(crtc->base.dev, crtc, crtc->config);
>  	skl_detach_scalers(crtc);
>  	if (!enable)
> @@ -13647,8 +13659,9 @@ intel_check_primary_plane(struct drm_plane *plane,
>  	}
>  
>  	if (INTEL_INFO(dev)->gen >= 9) {
> -		ret = skl_update_scaler_users(intel_crtc, crtc_state,
> -			to_intel_plane(plane), state, 0);
> +		ret = skl_update_scaler_plane(crtc_state,
> +					      to_intel_plane(plane),
> +					      state);
>  		if (ret)
>  			return ret;
>  	}
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index fb3d7f15c04b..f5ce8fdc8bf9 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -1377,7 +1377,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,
>  
>  		if (INTEL_INFO(dev)->gen >= 9) {
>  			int ret;
> -			ret = skl_update_scaler_users(intel_crtc, pipe_config, NULL, NULL, 0);
> +			ret = skl_update_scaler_crtc(pipe_config, 0);
>  			if (ret)
>  				return ret;
>  		}
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 29d6031b19d8..b78fa457a780 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -263,7 +263,7 @@ struct intel_plane_state {
>  	 * plane requiring a scaler:
>  	 *   - During check_plane, its bit is set in
>  	 *     crtc_state->scaler_state.scaler_users by calling helper function
> -	 *     update_scaler_users.
> +	 *     update_scaler_plane.
>  	 *   - scaler_id indicates the scaler it got assigned.
>  	 *
>  	 * plane doesn't require a scaler:
> @@ -271,7 +271,7 @@ struct intel_plane_state {
>  	 *     got disabled.
>  	 *   - During check_plane, corresponding bit is reset in
>  	 *     crtc_state->scaler_state.scaler_users by calling helper function
> -	 *     update_scaler_users.
> +	 *     update_scaler_plane.
>  	 */
>  	int scaler_id;
>  };
> @@ -1147,9 +1147,11 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,
>  void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
>  void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
>  void skl_detach_scalers(struct intel_crtc *intel_crtc);
> -int skl_update_scaler_users(struct intel_crtc *intel_crtc,
> -	struct intel_crtc_state *crtc_state, struct intel_plane *intel_plane,
> -	struct intel_plane_state *plane_state, int force_detach);
> +int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
> +			    struct intel_plane *intel_plane,
> +			    struct intel_plane_state *plane_state);
> +
> +int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state, int force_detach);
>  int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
>  
>  unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index 8193a35388d7..fe95f25f019a 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -941,8 +941,7 @@ finish:
>  	}
>  
>  	if (INTEL_INFO(dev)->gen >= 9) {
> -		ret = skl_update_scaler_users(intel_crtc, crtc_state, intel_plane,
> -			state, 0);
> +		ret = skl_update_scaler_plane(crtc_state, intel_plane, state);
>  		if (ret)
>  			return ret;
>  	}
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 09/19] drm/i915: clean up atomic plane check functions, v2.
  2015-06-15 10:33 ` [PATCH v3 09/19] drm/i915: clean up atomic plane check functions, v2 Maarten Lankhorst
@ 2015-06-18  1:48   ` Matt Roper
  2015-06-22  7:23     ` Maarten Lankhorst
  0 siblings, 1 reply; 39+ messages in thread
From: Matt Roper @ 2015-06-18  1:48 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Mon, Jun 15, 2015 at 12:33:46PM +0200, Maarten Lankhorst wrote:
> By passing crtc_state to the check_plane functions a lot of duplicated
> code can be removed. There are still some transitional helper calls,
> they will be removed later.
> 
> Changes since v1:
> - Revert state->visible changes.
> - Use plane->state->crtc instead of plane->crtc.
> - Use drm_atomic_get_existing_crtc_state.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_atomic_plane.c | 16 +++++++----
>  drivers/gpu/drm/i915/intel_display.c      | 48 ++++++++++---------------------
>  drivers/gpu/drm/i915/intel_drv.h          |  1 +
>  drivers/gpu/drm/i915/intel_sprite.c       |  9 ++----
>  4 files changed, 29 insertions(+), 45 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
> index aa2128369a0a..91d53768df9d 100644
> --- a/drivers/gpu/drm/i915/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
> @@ -116,7 +116,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
>  	struct intel_plane_state *intel_state = to_intel_plane_state(state);
>  	int ret;
>  
> -	crtc = crtc ? crtc : plane->crtc;
> +	crtc = crtc ? crtc : plane->state->crtc;
>  	intel_crtc = to_intel_crtc(crtc);
>  
>  	/*
> @@ -131,10 +131,13 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
>  	/* FIXME: temporary hack necessary while we still use the plane update
>  	 * helper. */
>  	if (state->state) {
> -		crtc_state =
> -			intel_atomic_get_crtc_state(state->state, intel_crtc);
> -		if (IS_ERR(crtc_state))
> -			return PTR_ERR(crtc_state);
> +		struct drm_crtc_state *drm_crtc_state =
> +			drm_atomic_get_existing_crtc_state(state->state, crtc);

Is this change important?  We can't get to this point without the crtc
state being in the atomic transaction can we?  The only case where that
used to happen was if crtc was actually NULL due to a property update of
a disabled plane, but we bail out on !crtc just above this.

Not that this change would cause any problems that I see, I just don't
understand the motivation.

> +
> +		if (WARN_ON(!drm_crtc_state))
> +			return -EINVAL;
> +
> +		crtc_state = to_intel_crtc_state(drm_crtc_state);
>  	} else {
>  		crtc_state = intel_crtc->config;
>  	}
> @@ -185,7 +188,8 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
>  		}
>  	}
>  
> -	ret = intel_plane->check_plane(plane, intel_state);
> +	intel_state->visible = false;
> +	ret = intel_plane->check_plane(plane, crtc_state, intel_state);
>  	if (ret || !state->state)
>  		return ret;
>  
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index ec4924eecd68..61697335bff2 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -13703,36 +13703,25 @@ skl_max_scale(struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state
>  
>  static int
>  intel_check_primary_plane(struct drm_plane *plane,
> +			  struct intel_crtc_state *crtc_state,
>  			  struct intel_plane_state *state)
>  {
> -	struct drm_device *dev = plane->dev;
>  	struct drm_crtc *crtc = state->base.crtc;
> -	struct intel_crtc *intel_crtc;
> -	struct intel_crtc_state *crtc_state;
>  	struct drm_framebuffer *fb = state->base.fb;
> -	struct drm_rect *dest = &state->dst;
> -	struct drm_rect *src = &state->src;
> -	const struct drm_rect *clip = &state->clip;
> -	bool can_position = false;
> -	int max_scale = DRM_PLANE_HELPER_NO_SCALING;
>  	int min_scale = DRM_PLANE_HELPER_NO_SCALING;
> +	int max_scale = DRM_PLANE_HELPER_NO_SCALING;
> +	bool can_position = false;
>  
> -	crtc = crtc ? crtc : plane->crtc;
> -	intel_crtc = to_intel_crtc(crtc);
> -	crtc_state = state->base.state ?
> -		intel_atomic_get_crtc_state(state->base.state, intel_crtc) : NULL;
> -
> -	if (INTEL_INFO(dev)->gen >= 9) {
> -		/* use scaler when colorkey is not required */
> -		if (to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
> -			min_scale = 1;
> -			max_scale = skl_max_scale(intel_crtc, crtc_state);
> -		}
> +	/* use scaler when colorkey is not required */
> +	if (INTEL_INFO(plane->dev)->gen >= 9 &&
> +	    to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
> +		min_scale = 1;
> +		max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state);
>  		can_position = true;
>  	}
>  
> -	return drm_plane_helper_check_update(plane, crtc, fb,
> -					     src, dest, clip,
> +	return drm_plane_helper_check_update(plane, crtc, fb, &state->src,
> +					     &state->dst, &state->clip,
>  					     min_scale, max_scale,
>  					     can_position, true,
>  					     &state->visible);
> @@ -13973,24 +13962,17 @@ void intel_create_rotation_property(struct drm_device *dev, struct intel_plane *
>  
>  static int
>  intel_check_cursor_plane(struct drm_plane *plane,
> +			 struct intel_crtc_state *crtc_state,
>  			 struct intel_plane_state *state)
>  {
> -	struct drm_crtc *crtc = state->base.crtc;
> -	struct drm_device *dev = plane->dev;
> +	struct drm_crtc *crtc = crtc_state->base.crtc;
>  	struct drm_framebuffer *fb = state->base.fb;
> -	struct drm_rect *dest = &state->dst;
> -	struct drm_rect *src = &state->src;
> -	const struct drm_rect *clip = &state->clip;
>  	struct drm_i915_gem_object *obj = intel_fb_obj(fb);
> -	struct intel_crtc *intel_crtc;
>  	unsigned stride;
>  	int ret;
>  
> -	crtc = crtc ? crtc : plane->crtc;
> -	intel_crtc = to_intel_crtc(crtc);
> -
> -	ret = drm_plane_helper_check_update(plane, crtc, fb,
> -					    src, dest, clip,
> +	ret = drm_plane_helper_check_update(plane, crtc, fb, &state->src,
> +					    &state->dst, &state->clip,
>  					    DRM_PLANE_HELPER_NO_SCALING,
>  					    DRM_PLANE_HELPER_NO_SCALING,
>  					    true, true, &state->visible);
> @@ -14002,7 +13984,7 @@ intel_check_cursor_plane(struct drm_plane *plane,
>  		return 0;
>  
>  	/* Check for which cursor types we support */
> -	if (!cursor_size_ok(dev, state->base.crtc_w, state->base.crtc_h)) {
> +	if (!cursor_size_ok(plane->dev, state->base.crtc_w, state->base.crtc_h)) {
>  		DRM_DEBUG("Cursor dimension %dx%d not supported\n",
>  			  state->base.crtc_w, state->base.crtc_h);
>  		return -EINVAL;
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 9f5867bf745e..8c0f17e84eee 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -613,6 +613,7 @@ struct intel_plane {
>  	void (*disable_plane)(struct drm_plane *plane,
>  			      struct drm_crtc *crtc, bool force);
>  	int (*check_plane)(struct drm_plane *plane,
> +			   struct intel_crtc_state *crtc_state,
>  			   struct intel_plane_state *state);
>  	void (*commit_plane)(struct drm_plane *plane,
>  			     struct intel_plane_state *state);
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index c909b8b8ce85..999a5753dde3 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -739,11 +739,12 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc, bool force)
>  
>  static int
>  intel_check_sprite_plane(struct drm_plane *plane,
> +			 struct intel_crtc_state *crtc_state,
>  			 struct intel_plane_state *state)
>  {
>  	struct drm_device *dev = plane->dev;
> -	struct intel_crtc *intel_crtc = to_intel_crtc(state->base.crtc);
> -	struct intel_crtc_state *crtc_state;
> +	struct drm_crtc *crtc = state->base.crtc;
> +	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);

We don't actually use crtc anywhere after this, so I'm not sure if there
was a need to change the assignment of intel_crtc?  Not a big deal
either way.


Matt

>  	struct intel_plane *intel_plane = to_intel_plane(plane);
>  	struct drm_framebuffer *fb = state->base.fb;
>  	int crtc_x, crtc_y;
> @@ -757,10 +758,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
>  	bool can_scale;
>  	int pixel_size;
>  
> -	intel_crtc = intel_crtc ? intel_crtc : to_intel_crtc(plane->crtc);
> -	crtc_state = state->base.state ?
> -		intel_atomic_get_crtc_state(state->base.state, intel_crtc) : NULL;
> -
>  	if (!fb) {
>  		state->visible = false;
>  		return 0;
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 06/19] drm/i915: Split skl_update_scaler, v3.
  2015-06-18  1:48   ` Matt Roper
@ 2015-06-18  5:42     ` Maarten Lankhorst
  2015-06-18  6:51       ` Daniel Vetter
  0 siblings, 1 reply; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-18  5:42 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-gfx

Op 18-06-15 om 03:48 schreef Matt Roper:
> On Mon, Jun 15, 2015 at 12:33:43PM +0200, Maarten Lankhorst wrote:
>> It's easier to read separate functions for crtc and plane scaler state.
>>
>> Changes since v1:
>>  - Update documentation.
>> Changes since v2:
>>  - Get rid of parameters to skl_update_scaler only used for traces.
>>    This avoids needing to document the other parameters.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>>  drivers/gpu/drm/i915/intel_display.c | 211 +++++++++++++++++++----------------
>>  drivers/gpu/drm/i915/intel_dp.c      |   2 +-
>>  drivers/gpu/drm/i915/intel_drv.h     |  12 +-
>>  drivers/gpu/drm/i915/intel_sprite.c  |   3 +-
>>  4 files changed, 121 insertions(+), 107 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index 0f7652a31c95..26d610acb61f 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -4303,62 +4303,16 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
>>  	}
>>  }
>>  
>> -/**
>> - * skl_update_scaler_users - Stages update to crtc's scaler state
>> - * @intel_crtc: crtc
>> - * @crtc_state: crtc_state
>> - * @plane: plane (NULL indicates crtc is requesting update)
>> - * @plane_state: plane's state
>> - * @force_detach: request unconditional detachment of scaler
>> - *
>> - * This function updates scaler state for requested plane or crtc.
>> - * To request scaler usage update for a plane, caller shall pass plane pointer.
>> - * To request scaler usage update for crtc, caller shall pass plane pointer
>> - * as NULL.
>> - *
>> - * Return
>> - *     0 - scaler_usage updated successfully
>> - *    error - requested scaling cannot be supported or other error condition
>> - */
>> -int
>> -skl_update_scaler_users(
>> -	struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state,
>> -	struct intel_plane *intel_plane, struct intel_plane_state *plane_state,
>> -	int force_detach)
>> +static int
>> +skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
>> +		  unsigned scaler_idx, int *scaler_id, unsigned int rotation,
>                            ^^^^^^^^^^
> This parameter isn't actually the scaler index is it (that's what
> scaler_id winds up being once assigned here)?  I think this one is the
> plane index that we're assigning a scaler for (or the special value of
> SKL_CRTC_INDEX if we're assigning for the CRTC instead of a plane).
>
> Maybe 'scaler_target' or 'scaler_user' would be better?
>
Could we call it 'i'?

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

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

* Re: [PATCH v3 06/19] drm/i915: Split skl_update_scaler, v3.
  2015-06-18  5:42     ` Maarten Lankhorst
@ 2015-06-18  6:51       ` Daniel Vetter
  2015-06-22  7:50         ` [PATCH v3.5 06/19] drm/i915: Split skl_update_scaler, v4 Maarten Lankhorst
  0 siblings, 1 reply; 39+ messages in thread
From: Daniel Vetter @ 2015-06-18  6:51 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Thu, Jun 18, 2015 at 07:42:10AM +0200, Maarten Lankhorst wrote:
> Op 18-06-15 om 03:48 schreef Matt Roper:
> > On Mon, Jun 15, 2015 at 12:33:43PM +0200, Maarten Lankhorst wrote:
> >> It's easier to read separate functions for crtc and plane scaler state.
> >>
> >> Changes since v1:
> >>  - Update documentation.
> >> Changes since v2:
> >>  - Get rid of parameters to skl_update_scaler only used for traces.
> >>    This avoids needing to document the other parameters.
> >>
> >> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> >> ---
> >>  drivers/gpu/drm/i915/intel_display.c | 211 +++++++++++++++++++----------------
> >>  drivers/gpu/drm/i915/intel_dp.c      |   2 +-
> >>  drivers/gpu/drm/i915/intel_drv.h     |  12 +-
> >>  drivers/gpu/drm/i915/intel_sprite.c  |   3 +-
> >>  4 files changed, 121 insertions(+), 107 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> >> index 0f7652a31c95..26d610acb61f 100644
> >> --- a/drivers/gpu/drm/i915/intel_display.c
> >> +++ b/drivers/gpu/drm/i915/intel_display.c
> >> @@ -4303,62 +4303,16 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
> >>  	}
> >>  }
> >>  
> >> -/**
> >> - * skl_update_scaler_users - Stages update to crtc's scaler state
> >> - * @intel_crtc: crtc
> >> - * @crtc_state: crtc_state
> >> - * @plane: plane (NULL indicates crtc is requesting update)
> >> - * @plane_state: plane's state
> >> - * @force_detach: request unconditional detachment of scaler
> >> - *
> >> - * This function updates scaler state for requested plane or crtc.
> >> - * To request scaler usage update for a plane, caller shall pass plane pointer.
> >> - * To request scaler usage update for crtc, caller shall pass plane pointer
> >> - * as NULL.
> >> - *
> >> - * Return
> >> - *     0 - scaler_usage updated successfully
> >> - *    error - requested scaling cannot be supported or other error condition
> >> - */
> >> -int
> >> -skl_update_scaler_users(
> >> -	struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state,
> >> -	struct intel_plane *intel_plane, struct intel_plane_state *plane_state,
> >> -	int force_detach)
> >> +static int
> >> +skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
> >> +		  unsigned scaler_idx, int *scaler_id, unsigned int rotation,
> >                            ^^^^^^^^^^
> > This parameter isn't actually the scaler index is it (that's what
> > scaler_id winds up being once assigned here)?  I think this one is the
> > plane index that we're assigning a scaler for (or the special value of
> > SKL_CRTC_INDEX if we're assigning for the CRTC instead of a plane).
> >
> > Maybe 'scaler_target' or 'scaler_user' would be better?
> >
> Could we call it 'i'?

Not for a function argument really ;-)
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell
  2015-06-15 10:33 ` [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell Maarten Lankhorst
@ 2015-06-18 14:21   ` Matt Roper
  2015-06-19  3:57     ` Maarten Lankhorst
  2015-06-18 15:28   ` Ville Syrjälä
  1 sibling, 1 reply; 39+ messages in thread
From: Matt Roper @ 2015-06-18 14:21 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Mon, Jun 15, 2015 at 12:33:52PM +0200, Maarten Lankhorst wrote:
> Now that all planes are added during a modeset we can use the
> calculated changes before disabling a plane, and then either commit
> or force disable a plane before disabling the crtc.
> 
> The code is shared with atomic_begin/flush, except watermark updating
> and vblank evasion are not used.
> 
> This is needed for proper atomic suspend/resume support.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90868
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 103 ++++++++---------------------------
>  drivers/gpu/drm/i915/intel_sprite.c  |   4 +-
>  2 files changed, 23 insertions(+), 84 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index cc4ca4970716..beb69281f45c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -2217,28 +2217,6 @@ static void intel_disable_pipe(struct intel_crtc *crtc)
>  		intel_wait_for_pipe_off(crtc);
>  }
>  
> -/**
> - * intel_enable_primary_hw_plane - enable the primary plane on a given pipe
> - * @plane:  plane to be enabled
> - * @crtc: crtc for the plane
> - *
> - * Enable @plane on @crtc, making sure that the pipe is running first.
> - */
> -static void intel_enable_primary_hw_plane(struct drm_plane *plane,
> -					  struct drm_crtc *crtc)
> -{
> -	struct drm_device *dev = plane->dev;
> -	struct drm_i915_private *dev_priv = dev->dev_private;
> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> -
> -	/* If the pipe isn't enabled, we can't pump pixels and may hang */
> -	assert_pipe_enabled(dev_priv, intel_crtc->pipe);
> -	to_intel_plane_state(plane->state)->visible = true;
> -
> -	dev_priv->display.update_primary_plane(crtc, plane->fb,
> -					       crtc->x, crtc->y);
> -}
> -
>  static bool need_vtd_wa(struct drm_device *dev)
>  {
>  #ifdef CONFIG_INTEL_IOMMU
> @@ -4508,20 +4486,6 @@ static void ironlake_pfit_enable(struct intel_crtc *crtc)
>  	}
>  }
>  
> -static void intel_enable_sprite_planes(struct drm_crtc *crtc)
> -{
> -	struct drm_device *dev = crtc->dev;
> -	enum pipe pipe = to_intel_crtc(crtc)->pipe;
> -	struct drm_plane *plane;
> -	struct intel_plane *intel_plane;
> -
> -	drm_for_each_legacy_plane(plane, &dev->mode_config.plane_list) {
> -		intel_plane = to_intel_plane(plane);
> -		if (intel_plane->pipe == pipe)
> -			intel_plane_restore(&intel_plane->base);
> -	}
> -}
> -
>  void hsw_enable_ips(struct intel_crtc *crtc)
>  {
>  	struct drm_device *dev = crtc->base.dev;
> @@ -4817,27 +4781,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
>  		intel_pre_disable_primary(&crtc->base);
>  }
>  
> -static void intel_crtc_enable_planes(struct drm_crtc *crtc)
> -{
> -	struct drm_device *dev = crtc->dev;
> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> -	int pipe = intel_crtc->pipe;
> -
> -	intel_enable_primary_hw_plane(crtc->primary, crtc);
> -	intel_enable_sprite_planes(crtc);
> -	if (to_intel_plane_state(crtc->cursor->state)->visible)
> -		intel_crtc_update_cursor(crtc, true);
> -
> -	intel_post_enable_primary(crtc);
> -
> -	/*
> -	 * FIXME: Once we grow proper nuclear flip support out of this we need
> -	 * to compute the mask of flip planes precisely. For the time being
> -	 * consider this a flip to a NULL plane.
> -	 */
> -	intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
> -}
> -
>  static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask)
>  {
>  	struct drm_device *dev = crtc->dev;
> @@ -4845,10 +4788,6 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask
>  	struct drm_plane *p;
>  	int pipe = intel_crtc->pipe;
>  
> -	intel_crtc_wait_for_pending_flips(crtc);
> -
> -	intel_pre_disable_primary(crtc);
> -
>  	intel_crtc_dpms_overlay_disable(intel_crtc);
>  
>  	drm_for_each_plane_mask(p, dev, plane_mask)
> @@ -6270,6 +6209,11 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
>  	if (!intel_crtc->active)
>  		return;
>  
> +	if (to_intel_plane_state(crtc->primary->state)->visible) {
> +		intel_crtc_wait_for_pending_flips(crtc);
> +		intel_pre_disable_primary(crtc);
> +	}
> +
>  	intel_crtc_disable_planes(crtc, crtc->state->plane_mask);
>  	dev_priv->display.crtc_disable(crtc);
>  
> @@ -11783,10 +11727,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
>  	if (old_plane_state->base.fb && !fb)
>  		intel_crtc->atomic.disabled_planes |= 1 << i;
>  
> -	/* don't run rest during modeset yet */
> -	if (!intel_crtc->active || mode_changed)
> -		return 0;
> -
>  	was_visible = old_plane_state->visible;
>  	visible = to_intel_plane_state(plane_state)->visible;
>  
> @@ -13255,15 +13195,18 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>  	drm_atomic_helper_swap_state(dev, state);
>  
>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> +
>  		if (!needs_modeset(crtc->state))
>  			continue;
>  
>  		any_ms = true;
> -		if (!crtc_state->active)
> -			continue;
> +		intel_pre_plane_update(intel_crtc);
>  
> -		intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
> -		dev_priv->display.crtc_disable(crtc);
> +		if (crtc_state->active) {
> +			intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
> +			dev_priv->display.crtc_disable(crtc);
> +		}
>  	}
>  
>  	/* Only after disabling all output pipelines that will be changed can we
> @@ -13277,15 +13220,12 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>  
>  	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> -		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
> -
> -		if (!needs_modeset(crtc->state) || !crtc->state->active)
> -			continue;
> -
> -		update_scanline_offset(to_intel_crtc(crtc));
> +		if (needs_modeset(crtc->state) && crtc->state->active) {
> +			update_scanline_offset(to_intel_crtc(crtc));
> +			dev_priv->display.crtc_enable(crtc);
> +		}
>  
> -		dev_priv->display.crtc_enable(crtc);
> -		intel_crtc_enable_planes(crtc);
> +		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
>  	}
>  
>  	/* FIXME: add subpixel order */
> @@ -13858,7 +13798,7 @@ intel_commit_primary_plane(struct drm_plane *plane,
>  	crtc->x = src->x1 >> 16;
>  	crtc->y = src->y1 >> 16;
>  
> -	if (!intel_crtc->active)
> +	if (!crtc->state->active)
>  		return;
>  
>  	if (state->visible)
> @@ -13885,7 +13825,8 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  
> -	intel_pre_plane_update(intel_crtc);
> +	if (!needs_modeset(crtc->state))
> +		intel_pre_plane_update(intel_crtc);

To make sure I'm understanding...we make this change because
__intel_set_mode() has already handled the intel_pre_plane_update() for
the modeset case, so we're only worried about legacy setmode's that
don't result in a full modeset (so we never called this function), or
entry via the atomic ioctl (which doesn't support full modesets yet),
right?  And presumably once we do allow full modesetting via the atomic
ioctl it will also be calling intel_pre_plane_update() before getting to
this point?


Matt

>  
>  	if (intel_crtc->atomic.update_wm)
>  		intel_update_watermarks(crtc);
> @@ -13893,7 +13834,7 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
>  	intel_runtime_pm_get(dev_priv);
>  
>  	/* Perform vblank evasion around commit operation */
> -	if (crtc->state->active && !needs_modeset(crtc->state))
> +	if (crtc->state->active)
>  		intel_crtc->atomic.evade =
>  			intel_pipe_update_start(intel_crtc,
>  						&intel_crtc->atomic.start_vbl_count);
> @@ -14102,7 +14043,7 @@ intel_commit_cursor_plane(struct drm_plane *plane,
>  	intel_crtc->cursor_bo = obj;
>  
>  update:
> -	if (intel_crtc->active)
> +	if (crtc->state->active)
>  		intel_crtc_update_cursor(crtc, state->visible);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index f7eb3bd0a7c7..168f90f346c2 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -921,16 +921,14 @@ intel_commit_sprite_plane(struct drm_plane *plane,
>  			  struct intel_plane_state *state)
>  {
>  	struct drm_crtc *crtc = state->base.crtc;
> -	struct intel_crtc *intel_crtc;
>  	struct intel_plane *intel_plane = to_intel_plane(plane);
>  	struct drm_framebuffer *fb = state->base.fb;
>  
>  	crtc = crtc ? crtc : plane->crtc;
> -	intel_crtc = to_intel_crtc(crtc);
>  
>  	plane->fb = fb;
>  
> -	if (!intel_crtc->active)
> +	if (!crtc->state->active)
>  		return;
>  
>  	if (state->visible) {
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 17/19] drm/i915: Make setting color key atomic.
  2015-06-15 10:33 ` [PATCH v3 17/19] drm/i915: Make setting color key atomic Maarten Lankhorst
@ 2015-06-18 14:21   ` Matt Roper
  2015-06-19  4:03     ` Maarten Lankhorst
  0 siblings, 1 reply; 39+ messages in thread
From: Matt Roper @ 2015-06-18 14:21 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Mon, Jun 15, 2015 at 12:33:54PM +0200, Maarten Lankhorst wrote:
> By making color key atomic there are no more transitional helpers.
> The plane check function will reject the color key when a scaler is
> active.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_atomic_plane.c |  1 +
>  drivers/gpu/drm/i915/intel_display.c      |  7 ++-
>  drivers/gpu/drm/i915/intel_drv.h          |  6 +--
>  drivers/gpu/drm/i915/intel_sprite.c       | 85 +++++++++++++++----------------
>  4 files changed, 46 insertions(+), 53 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
> index 91d53768df9d..10a8ecedc942 100644
> --- a/drivers/gpu/drm/i915/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
> @@ -56,6 +56,7 @@ intel_create_plane_state(struct drm_plane *plane)
>  
>  	state->base.plane = plane;
>  	state->base.rotation = BIT(DRM_ROTATE_0);
> +	state->ckey.flags = I915_SET_COLORKEY_NONE;
>  
>  	return state;
>  }
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 5facd0501a34..746c73d2ab84 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -4401,9 +4401,9 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
>  		return ret;
>  
>  	/* check colorkey */
> -	if (WARN_ON(intel_plane->ckey.flags != I915_SET_COLORKEY_NONE)) {
> +	if (plane_state->ckey.flags != I915_SET_COLORKEY_NONE) {
>  		DRM_DEBUG_KMS("[PLANE:%d] scaling with color key not allowed",
> -			intel_plane->base.base.id);
> +			      intel_plane->base.base.id);
>  		return -EINVAL;
>  	}
>  
> @@ -13733,7 +13733,7 @@ intel_check_primary_plane(struct drm_plane *plane,
>  
>  	/* use scaler when colorkey is not required */
>  	if (INTEL_INFO(plane->dev)->gen >= 9 &&
> -	    to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
> +	    state->ckey.flags == I915_SET_COLORKEY_NONE) {
>  		min_scale = 1;
>  		max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state);
>  		can_position = true;
> @@ -13881,7 +13881,6 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
>  	primary->check_plane = intel_check_primary_plane;
>  	primary->commit_plane = intel_commit_primary_plane;
>  	primary->disable_plane = intel_disable_primary_plane;
> -	primary->ckey.flags = I915_SET_COLORKEY_NONE;
>  	if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4)
>  		primary->plane = !pipe;
>  
> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
> index 93b9542ab8dc..3a2ac82b0970 100644
> --- a/drivers/gpu/drm/i915/intel_drv.h
> +++ b/drivers/gpu/drm/i915/intel_drv.h
> @@ -274,6 +274,8 @@ struct intel_plane_state {
>  	 *     update_scaler_plane.
>  	 */
>  	int scaler_id;
> +
> +	struct drm_intel_sprite_colorkey ckey;
>  };
>  
>  struct intel_initial_plane_config {
> @@ -588,9 +590,6 @@ struct intel_plane {
>  	bool can_scale;
>  	int max_downscale;
>  
> -	/* FIXME convert to properties */
> -	struct drm_intel_sprite_colorkey ckey;
> -
>  	/* Since we need to change the watermarks before/after
>  	 * enabling/disabling the planes, we need to store the parameters here
>  	 * as the other pieces of the struct may not reflect the values we want
> @@ -1390,7 +1389,6 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
>  
>  /* intel_sprite.c */
>  int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
> -int intel_plane_restore(struct drm_plane *plane);
>  int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
>  			      struct drm_file *file_priv);
>  bool intel_pipe_update_start(struct intel_crtc *crtc,
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index 168f90f346c2..21d3f7882c4d 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -182,7 +182,8 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
>  	const int plane = intel_plane->plane + 1;
>  	u32 plane_ctl, stride_div, stride;
>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> -	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
> +	const struct drm_intel_sprite_colorkey *key =
> +		&to_intel_plane_state(drm_plane->state)->ckey;
>  	unsigned long surf_addr;
>  	u32 tile_height, plane_offset, plane_size;
>  	unsigned int rotation;
> @@ -344,7 +345,8 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
>  	u32 sprctl;
>  	unsigned long sprsurf_offset, linear_offset;
>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> -	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
> +	const struct drm_intel_sprite_colorkey *key =
> +		&to_intel_plane_state(dplane->state)->ckey;
>  
>  	sprctl = SP_ENABLE;
>  
> @@ -487,7 +489,8 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
>  	u32 sprctl, sprscale = 0;
>  	unsigned long sprsurf_offset, linear_offset;
>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> -	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
> +	const struct drm_intel_sprite_colorkey *key =
> +		&to_intel_plane_state(plane->state)->ckey;
>  
>  	sprctl = SPRITE_ENABLE;
>  
> @@ -627,7 +630,8 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
>  	unsigned long dvssurf_offset, linear_offset;
>  	u32 dvscntr, dvsscale;
>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
> -	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
> +	const struct drm_intel_sprite_colorkey *key =
> +		&to_intel_plane_state(plane->state)->ckey;
>  
>  	dvscntr = DVS_ENABLE;
>  
> @@ -778,7 +782,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
>  	/* setup can_scale, min_scale, max_scale */
>  	if (INTEL_INFO(dev)->gen >= 9) {
>  		/* use scaler when colorkey is not required */
> -		if (intel_plane->ckey.flags == I915_SET_COLORKEY_NONE) {
> +		if (state->ckey.flags == I915_SET_COLORKEY_NONE) {
>  			can_scale = 1;
>  			min_scale = 1;
>  			max_scale = skl_max_scale(intel_crtc, crtc_state);
> @@ -798,7 +802,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
>  	 * coordinates and sizes. We probably need some way to decide whether
>  	 * more strict checking should be done instead.
>  	 */
> -
>  	drm_rect_rotate(src, fb->width << 16, fb->height << 16,
>  			state->base.rotation);
>  
> @@ -808,7 +811,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
>  	vscale = drm_rect_calc_vscale_relaxed(src, dst, min_scale, max_scale);
>  	BUG_ON(vscale < 0);
>  
> -	state->visible =  drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
> +	state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
>  
>  	crtc_x = dst->x1;
>  	crtc_y = dst->y1;
> @@ -950,7 +953,9 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
>  {
>  	struct drm_intel_sprite_colorkey *set = data;
>  	struct drm_plane *plane;
> -	struct intel_plane *intel_plane;
> +	struct drm_plane_state *plane_state;
> +	struct drm_atomic_state *state;
> +	struct drm_modeset_acquire_ctx ctx;
>  	int ret = 0;

Can we simplify this by just calling
drm_atomic_helper_plane_set_property() and let it handle the atomic
transaction for us?


Matt

>  
>  	/* Make sure we don't try to enable both src & dest simultaneously */
> @@ -961,50 +966,41 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
>  	    set->flags & I915_SET_COLORKEY_DESTINATION)
>  		return -EINVAL;
>  
> -	drm_modeset_lock_all(dev);
> -
>  	plane = drm_plane_find(dev, set->plane_id);
> -	if (!plane || plane->type != DRM_PLANE_TYPE_OVERLAY) {
> -		ret = -ENOENT;
> -		goto out_unlock;
> -	}
> +	if (!plane || plane->type != DRM_PLANE_TYPE_OVERLAY)
> +		return -ENOENT;
>  
> -	intel_plane = to_intel_plane(plane);
> +	drm_modeset_acquire_init(&ctx, 0);
>  
> -	if (INTEL_INFO(dev)->gen >= 9) {
> -		/* plane scaling and colorkey are mutually exclusive */
> -		if (to_intel_plane_state(plane->state)->scaler_id >= 0) {
> -			DRM_ERROR("colorkey not allowed with scaler\n");
> -			ret = -EINVAL;
> -			goto out_unlock;
> -		}
> +	state = drm_atomic_state_alloc(plane->dev);
> +	if (!state) {
> +		ret = -ENOMEM;
> +		goto out;
>  	}
> +	state->acquire_ctx = &ctx;
> +
> +	while (1) {
> +		plane_state = drm_atomic_get_plane_state(state, plane);
> +		ret = PTR_ERR_OR_ZERO(plane_state);
> +		if (!ret) {
> +			to_intel_plane_state(plane_state)->ckey = *set;
> +			ret = drm_atomic_commit(state);
> +		}
>  
> -	intel_plane->ckey = *set;
> -
> -	/*
> -	 * The only way this could fail would be due to
> -	 * the current plane state being unsupportable already,
> -	 * and we dont't consider that an error for the
> -	 * colorkey ioctl. So just ignore any error.
> -	 */
> -	intel_plane_restore(plane);
> +		if (ret != -EDEADLK)
> +			break;
>  
> -out_unlock:
> -	drm_modeset_unlock_all(dev);
> -	return ret;
> -}
> +		drm_atomic_state_clear(state);
> +		drm_modeset_backoff(&ctx);
> +	}
>  
> -int intel_plane_restore(struct drm_plane *plane)
> -{
> -	if (!plane->crtc || !plane->state->fb)
> -		return 0;
> +	if (ret)
> +		drm_atomic_state_free(state);
>  
> -	return drm_plane_helper_update(plane, plane->crtc, plane->state->fb,
> -				       plane->state->crtc_x, plane->state->crtc_y,
> -				       plane->state->crtc_w, plane->state->crtc_h,
> -				       plane->state->src_x, plane->state->src_y,
> -				       plane->state->src_w, plane->state->src_h);
> +out:
> +	drm_modeset_drop_locks(&ctx);
> +	drm_modeset_acquire_fini(&ctx);
> +	return ret;
>  }
>  
>  static const uint32_t ilk_plane_formats[] = {
> @@ -1133,7 +1129,6 @@ intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane)
>  	intel_plane->plane = plane;
>  	intel_plane->check_plane = intel_check_sprite_plane;
>  	intel_plane->commit_plane = intel_commit_sprite_plane;
> -	intel_plane->ckey.flags = I915_SET_COLORKEY_NONE;
>  	possible_crtcs = (1 << pipe);
>  	ret = drm_universal_plane_init(dev, &intel_plane->base, possible_crtcs,
>  				       &intel_plane_funcs,
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 18/19] drm/i915: Remove transitional references from intel_plane_atomic_check.
  2015-06-15 10:33 ` [PATCH v3 18/19] drm/i915: Remove transitional references from intel_plane_atomic_check Maarten Lankhorst
@ 2015-06-18 14:21   ` Matt Roper
  2015-06-19  4:05     ` Maarten Lankhorst
  0 siblings, 1 reply; 39+ messages in thread
From: Matt Roper @ 2015-06-18 14:21 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Mon, Jun 15, 2015 at 12:33:55PM +0200, Maarten Lankhorst wrote:
> All transitional plane helpers are gone, party!
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>

There's also a reference in skylake_update_primary_plane() that I assume
can be removed?


Matt


> ---
>  drivers/gpu/drm/i915/intel_atomic_plane.c | 19 ++++++-------------
>  1 file changed, 6 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
> index 10a8ecedc942..f1ab8e4b9c11 100644
> --- a/drivers/gpu/drm/i915/intel_atomic_plane.c
> +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
> @@ -115,6 +115,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
>  	struct intel_crtc_state *crtc_state;
>  	struct intel_plane *intel_plane = to_intel_plane(plane);
>  	struct intel_plane_state *intel_state = to_intel_plane_state(state);
> +	struct drm_crtc_state *drm_crtc_state;
>  	int ret;
>  
>  	crtc = crtc ? crtc : plane->state->crtc;
> @@ -129,19 +130,11 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
>  	if (!crtc)
>  		return 0;
>  
> -	/* FIXME: temporary hack necessary while we still use the plane update
> -	 * helper. */
> -	if (state->state) {
> -		struct drm_crtc_state *drm_crtc_state =
> -			drm_atomic_get_existing_crtc_state(state->state, crtc);
> +	drm_crtc_state = drm_atomic_get_existing_crtc_state(state->state, crtc);
> +	if (WARN_ON(!drm_crtc_state))
> +		return -EINVAL;
>  
> -		if (WARN_ON(!drm_crtc_state))
> -			return -EINVAL;
> -
> -		crtc_state = to_intel_crtc_state(drm_crtc_state);
> -	} else {
> -		crtc_state = intel_crtc->config;
> -	}
> +	crtc_state = to_intel_crtc_state(drm_crtc_state);
>  
>  	/*
>  	 * The original src/dest coordinates are stored in state->base, but
> @@ -191,7 +184,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
>  
>  	intel_state->visible = false;
>  	ret = intel_plane->check_plane(plane, crtc_state, intel_state);
> -	if (ret || !state->state)
> +	if (ret)
>  		return ret;
>  
>  	return intel_plane_atomic_calc_changes(&crtc_state->base, state);
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell
  2015-06-15 10:33 ` [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell Maarten Lankhorst
  2015-06-18 14:21   ` Matt Roper
@ 2015-06-18 15:28   ` Ville Syrjälä
  2015-06-19  4:01     ` Maarten Lankhorst
  1 sibling, 1 reply; 39+ messages in thread
From: Ville Syrjälä @ 2015-06-18 15:28 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Mon, Jun 15, 2015 at 12:33:52PM +0200, Maarten Lankhorst wrote:
> Now that all planes are added during a modeset we can use the
> calculated changes before disabling a plane, and then either commit
> or force disable a plane before disabling the crtc.
> 
> The code is shared with atomic_begin/flush, except watermark updating
> and vblank evasion are not used.
> 
> This is needed for proper atomic suspend/resume support.
> 
> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90868
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/intel_display.c | 103 ++++++++---------------------------
>  drivers/gpu/drm/i915/intel_sprite.c  |   4 +-
>  2 files changed, 23 insertions(+), 84 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index cc4ca4970716..beb69281f45c 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -2217,28 +2217,6 @@ static void intel_disable_pipe(struct intel_crtc *crtc)
>  		intel_wait_for_pipe_off(crtc);
>  }
>  
> -/**
> - * intel_enable_primary_hw_plane - enable the primary plane on a given pipe
> - * @plane:  plane to be enabled
> - * @crtc: crtc for the plane
> - *
> - * Enable @plane on @crtc, making sure that the pipe is running first.
> - */
> -static void intel_enable_primary_hw_plane(struct drm_plane *plane,
> -					  struct drm_crtc *crtc)
> -{
> -	struct drm_device *dev = plane->dev;
> -	struct drm_i915_private *dev_priv = dev->dev_private;
> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> -
> -	/* If the pipe isn't enabled, we can't pump pixels and may hang */
> -	assert_pipe_enabled(dev_priv, intel_crtc->pipe);
> -	to_intel_plane_state(plane->state)->visible = true;
> -
> -	dev_priv->display.update_primary_plane(crtc, plane->fb,
> -					       crtc->x, crtc->y);
> -}
> -
>  static bool need_vtd_wa(struct drm_device *dev)
>  {
>  #ifdef CONFIG_INTEL_IOMMU
> @@ -4508,20 +4486,6 @@ static void ironlake_pfit_enable(struct intel_crtc *crtc)
>  	}
>  }
>  
> -static void intel_enable_sprite_planes(struct drm_crtc *crtc)
> -{
> -	struct drm_device *dev = crtc->dev;
> -	enum pipe pipe = to_intel_crtc(crtc)->pipe;
> -	struct drm_plane *plane;
> -	struct intel_plane *intel_plane;
> -
> -	drm_for_each_legacy_plane(plane, &dev->mode_config.plane_list) {
> -		intel_plane = to_intel_plane(plane);
> -		if (intel_plane->pipe == pipe)
> -			intel_plane_restore(&intel_plane->base);
> -	}
> -}
> -
>  void hsw_enable_ips(struct intel_crtc *crtc)
>  {
>  	struct drm_device *dev = crtc->base.dev;
> @@ -4817,27 +4781,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
>  		intel_pre_disable_primary(&crtc->base);
>  }
>  
> -static void intel_crtc_enable_planes(struct drm_crtc *crtc)
> -{
> -	struct drm_device *dev = crtc->dev;
> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> -	int pipe = intel_crtc->pipe;
> -
> -	intel_enable_primary_hw_plane(crtc->primary, crtc);
> -	intel_enable_sprite_planes(crtc);
> -	if (to_intel_plane_state(crtc->cursor->state)->visible)
> -		intel_crtc_update_cursor(crtc, true);
> -
> -	intel_post_enable_primary(crtc);
> -
> -	/*
> -	 * FIXME: Once we grow proper nuclear flip support out of this we need
> -	 * to compute the mask of flip planes precisely. For the time being
> -	 * consider this a flip to a NULL plane.
> -	 */
> -	intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
> -}
> -
>  static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask)
>  {
>  	struct drm_device *dev = crtc->dev;
> @@ -4845,10 +4788,6 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask
>  	struct drm_plane *p;
>  	int pipe = intel_crtc->pipe;
>  
> -	intel_crtc_wait_for_pending_flips(crtc);
> -
> -	intel_pre_disable_primary(crtc);
> -
>  	intel_crtc_dpms_overlay_disable(intel_crtc);
>  
>  	drm_for_each_plane_mask(p, dev, plane_mask)
> @@ -6270,6 +6209,11 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
>  	if (!intel_crtc->active)
>  		return;
>  
> +	if (to_intel_plane_state(crtc->primary->state)->visible) {
> +		intel_crtc_wait_for_pending_flips(crtc);
> +		intel_pre_disable_primary(crtc);
> +	}
> +
>  	intel_crtc_disable_planes(crtc, crtc->state->plane_mask);
>  	dev_priv->display.crtc_disable(crtc);
>  
> @@ -11783,10 +11727,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
>  	if (old_plane_state->base.fb && !fb)
>  		intel_crtc->atomic.disabled_planes |= 1 << i;
>  
> -	/* don't run rest during modeset yet */
> -	if (!intel_crtc->active || mode_changed)
> -		return 0;
> -
>  	was_visible = old_plane_state->visible;
>  	visible = to_intel_plane_state(plane_state)->visible;
>  
> @@ -13255,15 +13195,18 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>  	drm_atomic_helper_swap_state(dev, state);
>  
>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> +		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> +
>  		if (!needs_modeset(crtc->state))
>  			continue;
>  
>  		any_ms = true;
> -		if (!crtc_state->active)
> -			continue;
> +		intel_pre_plane_update(intel_crtc);
>  
> -		intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
> -		dev_priv->display.crtc_disable(crtc);
> +		if (crtc_state->active) {
> +			intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
> +			dev_priv->display.crtc_disable(crtc);
> +		}
>  	}
>  
>  	/* Only after disabling all output pipelines that will be changed can we
> @@ -13277,15 +13220,12 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>  
>  	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> -		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
> -
> -		if (!needs_modeset(crtc->state) || !crtc->state->active)
> -			continue;
> -
> -		update_scanline_offset(to_intel_crtc(crtc));
> +		if (needs_modeset(crtc->state) && crtc->state->active) {
> +			update_scanline_offset(to_intel_crtc(crtc));
> +			dev_priv->display.crtc_enable(crtc);
> +		}
>  
> -		dev_priv->display.crtc_enable(crtc);
> -		intel_crtc_enable_planes(crtc);
> +		drm_atomic_helper_commit_planes_on_crtc(crtc_state);

Why are we still commiting planes on a disabled pipes?

The way I envisioned the modeset path looking is something like this:

1. atomically disable all planes for pipes getting disabled
2. disable all pipes that need disabling
3. enable all pipes that need enabling
4. atomically update all planes that require it on now active pipes

>  	}
>  
>  	/* FIXME: add subpixel order */
> @@ -13858,7 +13798,7 @@ intel_commit_primary_plane(struct drm_plane *plane,
>  	crtc->x = src->x1 >> 16;
>  	crtc->y = src->y1 >> 16;
>  
> -	if (!intel_crtc->active)
> +	if (!crtc->state->active)
>  		return;
>  
>  	if (state->visible)
> @@ -13885,7 +13825,8 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
>  	struct drm_i915_private *dev_priv = dev->dev_private;
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  
> -	intel_pre_plane_update(intel_crtc);
> +	if (!needs_modeset(crtc->state))
> +		intel_pre_plane_update(intel_crtc);
>  
>  	if (intel_crtc->atomic.update_wm)
>  		intel_update_watermarks(crtc);
> @@ -13893,7 +13834,7 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
>  	intel_runtime_pm_get(dev_priv);
>  
>  	/* Perform vblank evasion around commit operation */
> -	if (crtc->state->active && !needs_modeset(crtc->state))
> +	if (crtc->state->active)
>  		intel_crtc->atomic.evade =
>  			intel_pipe_update_start(intel_crtc,
>  						&intel_crtc->atomic.start_vbl_count);
> @@ -14102,7 +14043,7 @@ intel_commit_cursor_plane(struct drm_plane *plane,
>  	intel_crtc->cursor_bo = obj;
>  
>  update:
> -	if (intel_crtc->active)
> +	if (crtc->state->active)
>  		intel_crtc_update_cursor(crtc, state->visible);
>  }
>  
> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
> index f7eb3bd0a7c7..168f90f346c2 100644
> --- a/drivers/gpu/drm/i915/intel_sprite.c
> +++ b/drivers/gpu/drm/i915/intel_sprite.c
> @@ -921,16 +921,14 @@ intel_commit_sprite_plane(struct drm_plane *plane,
>  			  struct intel_plane_state *state)
>  {
>  	struct drm_crtc *crtc = state->base.crtc;
> -	struct intel_crtc *intel_crtc;
>  	struct intel_plane *intel_plane = to_intel_plane(plane);
>  	struct drm_framebuffer *fb = state->base.fb;
>  
>  	crtc = crtc ? crtc : plane->crtc;
> -	intel_crtc = to_intel_crtc(crtc);
>  
>  	plane->fb = fb;
>  
> -	if (!intel_crtc->active)
> +	if (!crtc->state->active)
>  		return;
>  
>  	if (state->visible) {
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell
  2015-06-18 14:21   ` Matt Roper
@ 2015-06-19  3:57     ` Maarten Lankhorst
  0 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-19  3:57 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-gfx

Op 18-06-15 om 16:21 schreef Matt Roper:
> On Mon, Jun 15, 2015 at 12:33:52PM +0200, Maarten Lankhorst wrote:
>> Now that all planes are added during a modeset we can use the
>> calculated changes before disabling a plane, and then either commit
>> or force disable a plane before disabling the crtc.
>>
>> The code is shared with atomic_begin/flush, except watermark updating
>> and vblank evasion are not used.
>>
>> This is needed for proper atomic suspend/resume support.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90868
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>>  drivers/gpu/drm/i915/intel_display.c | 103 ++++++++---------------------------
>>  drivers/gpu/drm/i915/intel_sprite.c  |   4 +-
>>  2 files changed, 23 insertions(+), 84 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index cc4ca4970716..beb69281f45c 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -2217,28 +2217,6 @@ static void intel_disable_pipe(struct intel_crtc *crtc)
>>  		intel_wait_for_pipe_off(crtc);
>>  }
>>  
>> -/**
>> - * intel_enable_primary_hw_plane - enable the primary plane on a given pipe
>> - * @plane:  plane to be enabled
>> - * @crtc: crtc for the plane
>> - *
>> - * Enable @plane on @crtc, making sure that the pipe is running first.
>> - */
>> -static void intel_enable_primary_hw_plane(struct drm_plane *plane,
>> -					  struct drm_crtc *crtc)
>> -{
>> -	struct drm_device *dev = plane->dev;
>> -	struct drm_i915_private *dev_priv = dev->dev_private;
>> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>> -
>> -	/* If the pipe isn't enabled, we can't pump pixels and may hang */
>> -	assert_pipe_enabled(dev_priv, intel_crtc->pipe);
>> -	to_intel_plane_state(plane->state)->visible = true;
>> -
>> -	dev_priv->display.update_primary_plane(crtc, plane->fb,
>> -					       crtc->x, crtc->y);
>> -}
>> -
>>  static bool need_vtd_wa(struct drm_device *dev)
>>  {
>>  #ifdef CONFIG_INTEL_IOMMU
>> @@ -4508,20 +4486,6 @@ static void ironlake_pfit_enable(struct intel_crtc *crtc)
>>  	}
>>  }
>>  
>> -static void intel_enable_sprite_planes(struct drm_crtc *crtc)
>> -{
>> -	struct drm_device *dev = crtc->dev;
>> -	enum pipe pipe = to_intel_crtc(crtc)->pipe;
>> -	struct drm_plane *plane;
>> -	struct intel_plane *intel_plane;
>> -
>> -	drm_for_each_legacy_plane(plane, &dev->mode_config.plane_list) {
>> -		intel_plane = to_intel_plane(plane);
>> -		if (intel_plane->pipe == pipe)
>> -			intel_plane_restore(&intel_plane->base);
>> -	}
>> -}
>> -
>>  void hsw_enable_ips(struct intel_crtc *crtc)
>>  {
>>  	struct drm_device *dev = crtc->base.dev;
>> @@ -4817,27 +4781,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
>>  		intel_pre_disable_primary(&crtc->base);
>>  }
>>  
>> -static void intel_crtc_enable_planes(struct drm_crtc *crtc)
>> -{
>> -	struct drm_device *dev = crtc->dev;
>> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>> -	int pipe = intel_crtc->pipe;
>> -
>> -	intel_enable_primary_hw_plane(crtc->primary, crtc);
>> -	intel_enable_sprite_planes(crtc);
>> -	if (to_intel_plane_state(crtc->cursor->state)->visible)
>> -		intel_crtc_update_cursor(crtc, true);
>> -
>> -	intel_post_enable_primary(crtc);
>> -
>> -	/*
>> -	 * FIXME: Once we grow proper nuclear flip support out of this we need
>> -	 * to compute the mask of flip planes precisely. For the time being
>> -	 * consider this a flip to a NULL plane.
>> -	 */
>> -	intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
>> -}
>> -
>>  static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask)
>>  {
>>  	struct drm_device *dev = crtc->dev;
>> @@ -4845,10 +4788,6 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask
>>  	struct drm_plane *p;
>>  	int pipe = intel_crtc->pipe;
>>  
>> -	intel_crtc_wait_for_pending_flips(crtc);
>> -
>> -	intel_pre_disable_primary(crtc);
>> -
>>  	intel_crtc_dpms_overlay_disable(intel_crtc);
>>  
>>  	drm_for_each_plane_mask(p, dev, plane_mask)
>> @@ -6270,6 +6209,11 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
>>  	if (!intel_crtc->active)
>>  		return;
>>  
>> +	if (to_intel_plane_state(crtc->primary->state)->visible) {
>> +		intel_crtc_wait_for_pending_flips(crtc);
>> +		intel_pre_disable_primary(crtc);
>> +	}
>> +
>>  	intel_crtc_disable_planes(crtc, crtc->state->plane_mask);
>>  	dev_priv->display.crtc_disable(crtc);
>>  
>> @@ -11783,10 +11727,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
>>  	if (old_plane_state->base.fb && !fb)
>>  		intel_crtc->atomic.disabled_planes |= 1 << i;
>>  
>> -	/* don't run rest during modeset yet */
>> -	if (!intel_crtc->active || mode_changed)
>> -		return 0;
>> -
>>  	was_visible = old_plane_state->visible;
>>  	visible = to_intel_plane_state(plane_state)->visible;
>>  
>> @@ -13255,15 +13195,18 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>>  	drm_atomic_helper_swap_state(dev, state);
>>  
>>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
>> +		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>> +
>>  		if (!needs_modeset(crtc->state))
>>  			continue;
>>  
>>  		any_ms = true;
>> -		if (!crtc_state->active)
>> -			continue;
>> +		intel_pre_plane_update(intel_crtc);
>>  
>> -		intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
>> -		dev_priv->display.crtc_disable(crtc);
>> +		if (crtc_state->active) {
>> +			intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
>> +			dev_priv->display.crtc_disable(crtc);
>> +		}
>>  	}
>>  
>>  	/* Only after disabling all output pipelines that will be changed can we
>> @@ -13277,15 +13220,12 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>>  
>>  	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
>>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
>> -		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
>> -
>> -		if (!needs_modeset(crtc->state) || !crtc->state->active)
>> -			continue;
>> -
>> -		update_scanline_offset(to_intel_crtc(crtc));
>> +		if (needs_modeset(crtc->state) && crtc->state->active) {
>> +			update_scanline_offset(to_intel_crtc(crtc));
>> +			dev_priv->display.crtc_enable(crtc);
>> +		}
>>  
>> -		dev_priv->display.crtc_enable(crtc);
>> -		intel_crtc_enable_planes(crtc);
>> +		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
>>  	}
>>  
>>  	/* FIXME: add subpixel order */
>> @@ -13858,7 +13798,7 @@ intel_commit_primary_plane(struct drm_plane *plane,
>>  	crtc->x = src->x1 >> 16;
>>  	crtc->y = src->y1 >> 16;
>>  
>> -	if (!intel_crtc->active)
>> +	if (!crtc->state->active)
>>  		return;
>>  
>>  	if (state->visible)
>> @@ -13885,7 +13825,8 @@ static void intel_begin_crtc_commit(struct drm_crtc *crtc,
>>  	struct drm_i915_private *dev_priv = dev->dev_private;
>>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>>  
>> -	intel_pre_plane_update(intel_crtc);
>> +	if (!needs_modeset(crtc->state))
>> +		intel_pre_plane_update(intel_crtc);
> To make sure I'm understanding...we make this change because
> __intel_set_mode() has already handled the intel_pre_plane_update() for
> the modeset case, so we're only worried about legacy setmode's that
> don't result in a full modeset (so we never called this function), or
> entry via the atomic ioctl (which doesn't support full modesets yet),
> right?  And presumably once we do allow full modesetting via the atomic
> ioctl it will also be calling intel_pre_plane_update() before getting to
> this point?
>
Correct, pre_plane_update does all the scafffolding for disabling planes.

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

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

* Re: [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell
  2015-06-18 15:28   ` Ville Syrjälä
@ 2015-06-19  4:01     ` Maarten Lankhorst
  2015-06-22  9:49       ` Ville Syrjälä
  0 siblings, 1 reply; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-19  4:01 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

Op 18-06-15 om 17:28 schreef Ville Syrjälä:
> On Mon, Jun 15, 2015 at 12:33:52PM +0200, Maarten Lankhorst wrote:
>> Now that all planes are added during a modeset we can use the
>> calculated changes before disabling a plane, and then either commit
>> or force disable a plane before disabling the crtc.
>>
>> The code is shared with atomic_begin/flush, except watermark updating
>> and vblank evasion are not used.
>>
>> This is needed for proper atomic suspend/resume support.
>>
>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90868
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>>  drivers/gpu/drm/i915/intel_display.c | 103 ++++++++---------------------------
>>  drivers/gpu/drm/i915/intel_sprite.c  |   4 +-
>>  2 files changed, 23 insertions(+), 84 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index cc4ca4970716..beb69281f45c 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -2217,28 +2217,6 @@ static void intel_disable_pipe(struct intel_crtc *crtc)
>>  		intel_wait_for_pipe_off(crtc);
>>  }
>>  
>> -/**
>> - * intel_enable_primary_hw_plane - enable the primary plane on a given pipe
>> - * @plane:  plane to be enabled
>> - * @crtc: crtc for the plane
>> - *
>> - * Enable @plane on @crtc, making sure that the pipe is running first.
>> - */
>> -static void intel_enable_primary_hw_plane(struct drm_plane *plane,
>> -					  struct drm_crtc *crtc)
>> -{
>> -	struct drm_device *dev = plane->dev;
>> -	struct drm_i915_private *dev_priv = dev->dev_private;
>> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>> -
>> -	/* If the pipe isn't enabled, we can't pump pixels and may hang */
>> -	assert_pipe_enabled(dev_priv, intel_crtc->pipe);
>> -	to_intel_plane_state(plane->state)->visible = true;
>> -
>> -	dev_priv->display.update_primary_plane(crtc, plane->fb,
>> -					       crtc->x, crtc->y);
>> -}
>> -
>>  static bool need_vtd_wa(struct drm_device *dev)
>>  {
>>  #ifdef CONFIG_INTEL_IOMMU
>> @@ -4508,20 +4486,6 @@ static void ironlake_pfit_enable(struct intel_crtc *crtc)
>>  	}
>>  }
>>  
>> -static void intel_enable_sprite_planes(struct drm_crtc *crtc)
>> -{
>> -	struct drm_device *dev = crtc->dev;
>> -	enum pipe pipe = to_intel_crtc(crtc)->pipe;
>> -	struct drm_plane *plane;
>> -	struct intel_plane *intel_plane;
>> -
>> -	drm_for_each_legacy_plane(plane, &dev->mode_config.plane_list) {
>> -		intel_plane = to_intel_plane(plane);
>> -		if (intel_plane->pipe == pipe)
>> -			intel_plane_restore(&intel_plane->base);
>> -	}
>> -}
>> -
>>  void hsw_enable_ips(struct intel_crtc *crtc)
>>  {
>>  	struct drm_device *dev = crtc->base.dev;
>> @@ -4817,27 +4781,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
>>  		intel_pre_disable_primary(&crtc->base);
>>  }
>>  
>> -static void intel_crtc_enable_planes(struct drm_crtc *crtc)
>> -{
>> -	struct drm_device *dev = crtc->dev;
>> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>> -	int pipe = intel_crtc->pipe;
>> -
>> -	intel_enable_primary_hw_plane(crtc->primary, crtc);
>> -	intel_enable_sprite_planes(crtc);
>> -	if (to_intel_plane_state(crtc->cursor->state)->visible)
>> -		intel_crtc_update_cursor(crtc, true);
>> -
>> -	intel_post_enable_primary(crtc);
>> -
>> -	/*
>> -	 * FIXME: Once we grow proper nuclear flip support out of this we need
>> -	 * to compute the mask of flip planes precisely. For the time being
>> -	 * consider this a flip to a NULL plane.
>> -	 */
>> -	intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
>> -}
>> -
>>  static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask)
>>  {
>>  	struct drm_device *dev = crtc->dev;
>> @@ -4845,10 +4788,6 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask
>>  	struct drm_plane *p;
>>  	int pipe = intel_crtc->pipe;
>>  
>> -	intel_crtc_wait_for_pending_flips(crtc);
>> -
>> -	intel_pre_disable_primary(crtc);
>> -
>>  	intel_crtc_dpms_overlay_disable(intel_crtc);
>>  
>>  	drm_for_each_plane_mask(p, dev, plane_mask)
>> @@ -6270,6 +6209,11 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
>>  	if (!intel_crtc->active)
>>  		return;
>>  
>> +	if (to_intel_plane_state(crtc->primary->state)->visible) {
>> +		intel_crtc_wait_for_pending_flips(crtc);
>> +		intel_pre_disable_primary(crtc);
>> +	}
>> +
>>  	intel_crtc_disable_planes(crtc, crtc->state->plane_mask);
>>  	dev_priv->display.crtc_disable(crtc);
>>  
>> @@ -11783,10 +11727,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
>>  	if (old_plane_state->base.fb && !fb)
>>  		intel_crtc->atomic.disabled_planes |= 1 << i;
>>  
>> -	/* don't run rest during modeset yet */
>> -	if (!intel_crtc->active || mode_changed)
>> -		return 0;
>> -
>>  	was_visible = old_plane_state->visible;
>>  	visible = to_intel_plane_state(plane_state)->visible;
>>  
>> @@ -13255,15 +13195,18 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>>  	drm_atomic_helper_swap_state(dev, state);
>>  
>>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
>> +		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>> +
>>  		if (!needs_modeset(crtc->state))
>>  			continue;
>>  
>>  		any_ms = true;
>> -		if (!crtc_state->active)
>> -			continue;
>> +		intel_pre_plane_update(intel_crtc);
>>  
>> -		intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
>> -		dev_priv->display.crtc_disable(crtc);
>> +		if (crtc_state->active) {
>> +			intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
>> +			dev_priv->display.crtc_disable(crtc);
>> +		}
>>  	}
>>  
>>  	/* Only after disabling all output pipelines that will be changed can we
>> @@ -13277,15 +13220,12 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>>  
>>  	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
>>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
>> -		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
>> -
>> -		if (!needs_modeset(crtc->state) || !crtc->state->active)
>> -			continue;
>> -
>> -		update_scanline_offset(to_intel_crtc(crtc));
>> +		if (needs_modeset(crtc->state) && crtc->state->active) {
>> +			update_scanline_offset(to_intel_crtc(crtc));
>> +			dev_priv->display.crtc_enable(crtc);
>> +		}
>>  
>> -		dev_priv->display.crtc_enable(crtc);
>> -		intel_crtc_enable_planes(crtc);
>> +		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
> Why are we still commiting planes on a disabled pipes?
>
> The way I envisioned the modeset path looking is something like this:
>
> 1. atomically disable all planes for pipes getting disabled
> 2. disable all pipes that need disabling
> 3. enable all pipes that need enabling
> 4. atomically update all planes that require it on now active pipes
>
>
I looked for other ways to do this, but they were ugly. Only updating sw state in commit_planes for disabled crtc's made things a lot cleaner without worrying about special cases.

plane_disable doesn't update sw state, so it performs 1. The commit function is still called because update plane->fb
needs to be updated, even for disabled crtc's. Conditionally calling plane_commit caused more issues than it solved.

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

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

* Re: [PATCH v3 17/19] drm/i915: Make setting color key atomic.
  2015-06-18 14:21   ` Matt Roper
@ 2015-06-19  4:03     ` Maarten Lankhorst
  0 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-19  4:03 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-gfx

Op 18-06-15 om 16:21 schreef Matt Roper:
> On Mon, Jun 15, 2015 at 12:33:54PM +0200, Maarten Lankhorst wrote:
>> By making color key atomic there are no more transitional helpers.
>> The plane check function will reject the color key when a scaler is
>> active.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>>  drivers/gpu/drm/i915/intel_atomic_plane.c |  1 +
>>  drivers/gpu/drm/i915/intel_display.c      |  7 ++-
>>  drivers/gpu/drm/i915/intel_drv.h          |  6 +--
>>  drivers/gpu/drm/i915/intel_sprite.c       | 85 +++++++++++++++----------------
>>  4 files changed, 46 insertions(+), 53 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
>> index 91d53768df9d..10a8ecedc942 100644
>> --- a/drivers/gpu/drm/i915/intel_atomic_plane.c
>> +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
>> @@ -56,6 +56,7 @@ intel_create_plane_state(struct drm_plane *plane)
>>  
>>  	state->base.plane = plane;
>>  	state->base.rotation = BIT(DRM_ROTATE_0);
>> +	state->ckey.flags = I915_SET_COLORKEY_NONE;
>>  
>>  	return state;
>>  }
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index 5facd0501a34..746c73d2ab84 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -4401,9 +4401,9 @@ static int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
>>  		return ret;
>>  
>>  	/* check colorkey */
>> -	if (WARN_ON(intel_plane->ckey.flags != I915_SET_COLORKEY_NONE)) {
>> +	if (plane_state->ckey.flags != I915_SET_COLORKEY_NONE) {
>>  		DRM_DEBUG_KMS("[PLANE:%d] scaling with color key not allowed",
>> -			intel_plane->base.base.id);
>> +			      intel_plane->base.base.id);
>>  		return -EINVAL;
>>  	}
>>  
>> @@ -13733,7 +13733,7 @@ intel_check_primary_plane(struct drm_plane *plane,
>>  
>>  	/* use scaler when colorkey is not required */
>>  	if (INTEL_INFO(plane->dev)->gen >= 9 &&
>> -	    to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
>> +	    state->ckey.flags == I915_SET_COLORKEY_NONE) {
>>  		min_scale = 1;
>>  		max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state);
>>  		can_position = true;
>> @@ -13881,7 +13881,6 @@ static struct drm_plane *intel_primary_plane_create(struct drm_device *dev,
>>  	primary->check_plane = intel_check_primary_plane;
>>  	primary->commit_plane = intel_commit_primary_plane;
>>  	primary->disable_plane = intel_disable_primary_plane;
>> -	primary->ckey.flags = I915_SET_COLORKEY_NONE;
>>  	if (HAS_FBC(dev) && INTEL_INFO(dev)->gen < 4)
>>  		primary->plane = !pipe;
>>  
>> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
>> index 93b9542ab8dc..3a2ac82b0970 100644
>> --- a/drivers/gpu/drm/i915/intel_drv.h
>> +++ b/drivers/gpu/drm/i915/intel_drv.h
>> @@ -274,6 +274,8 @@ struct intel_plane_state {
>>  	 *     update_scaler_plane.
>>  	 */
>>  	int scaler_id;
>> +
>> +	struct drm_intel_sprite_colorkey ckey;
>>  };
>>  
>>  struct intel_initial_plane_config {
>> @@ -588,9 +590,6 @@ struct intel_plane {
>>  	bool can_scale;
>>  	int max_downscale;
>>  
>> -	/* FIXME convert to properties */
>> -	struct drm_intel_sprite_colorkey ckey;
>> -
>>  	/* Since we need to change the watermarks before/after
>>  	 * enabling/disabling the planes, we need to store the parameters here
>>  	 * as the other pieces of the struct may not reflect the values we want
>> @@ -1390,7 +1389,6 @@ bool intel_sdvo_init(struct drm_device *dev, uint32_t sdvo_reg, bool is_sdvob);
>>  
>>  /* intel_sprite.c */
>>  int intel_plane_init(struct drm_device *dev, enum pipe pipe, int plane);
>> -int intel_plane_restore(struct drm_plane *plane);
>>  int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
>>  			      struct drm_file *file_priv);
>>  bool intel_pipe_update_start(struct intel_crtc *crtc,
>> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
>> index 168f90f346c2..21d3f7882c4d 100644
>> --- a/drivers/gpu/drm/i915/intel_sprite.c
>> +++ b/drivers/gpu/drm/i915/intel_sprite.c
>> @@ -182,7 +182,8 @@ skl_update_plane(struct drm_plane *drm_plane, struct drm_crtc *crtc,
>>  	const int plane = intel_plane->plane + 1;
>>  	u32 plane_ctl, stride_div, stride;
>>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
>> -	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
>> +	const struct drm_intel_sprite_colorkey *key =
>> +		&to_intel_plane_state(drm_plane->state)->ckey;
>>  	unsigned long surf_addr;
>>  	u32 tile_height, plane_offset, plane_size;
>>  	unsigned int rotation;
>> @@ -344,7 +345,8 @@ vlv_update_plane(struct drm_plane *dplane, struct drm_crtc *crtc,
>>  	u32 sprctl;
>>  	unsigned long sprsurf_offset, linear_offset;
>>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
>> -	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
>> +	const struct drm_intel_sprite_colorkey *key =
>> +		&to_intel_plane_state(dplane->state)->ckey;
>>  
>>  	sprctl = SP_ENABLE;
>>  
>> @@ -487,7 +489,8 @@ ivb_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
>>  	u32 sprctl, sprscale = 0;
>>  	unsigned long sprsurf_offset, linear_offset;
>>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
>> -	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
>> +	const struct drm_intel_sprite_colorkey *key =
>> +		&to_intel_plane_state(plane->state)->ckey;
>>  
>>  	sprctl = SPRITE_ENABLE;
>>  
>> @@ -627,7 +630,8 @@ ilk_update_plane(struct drm_plane *plane, struct drm_crtc *crtc,
>>  	unsigned long dvssurf_offset, linear_offset;
>>  	u32 dvscntr, dvsscale;
>>  	int pixel_size = drm_format_plane_cpp(fb->pixel_format, 0);
>> -	const struct drm_intel_sprite_colorkey *key = &intel_plane->ckey;
>> +	const struct drm_intel_sprite_colorkey *key =
>> +		&to_intel_plane_state(plane->state)->ckey;
>>  
>>  	dvscntr = DVS_ENABLE;
>>  
>> @@ -778,7 +782,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
>>  	/* setup can_scale, min_scale, max_scale */
>>  	if (INTEL_INFO(dev)->gen >= 9) {
>>  		/* use scaler when colorkey is not required */
>> -		if (intel_plane->ckey.flags == I915_SET_COLORKEY_NONE) {
>> +		if (state->ckey.flags == I915_SET_COLORKEY_NONE) {
>>  			can_scale = 1;
>>  			min_scale = 1;
>>  			max_scale = skl_max_scale(intel_crtc, crtc_state);
>> @@ -798,7 +802,6 @@ intel_check_sprite_plane(struct drm_plane *plane,
>>  	 * coordinates and sizes. We probably need some way to decide whether
>>  	 * more strict checking should be done instead.
>>  	 */
>> -
>>  	drm_rect_rotate(src, fb->width << 16, fb->height << 16,
>>  			state->base.rotation);
>>  
>> @@ -808,7 +811,7 @@ intel_check_sprite_plane(struct drm_plane *plane,
>>  	vscale = drm_rect_calc_vscale_relaxed(src, dst, min_scale, max_scale);
>>  	BUG_ON(vscale < 0);
>>  
>> -	state->visible =  drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
>> +	state->visible = drm_rect_clip_scaled(src, dst, clip, hscale, vscale);
>>  
>>  	crtc_x = dst->x1;
>>  	crtc_y = dst->y1;
>> @@ -950,7 +953,9 @@ int intel_sprite_set_colorkey(struct drm_device *dev, void *data,
>>  {
>>  	struct drm_intel_sprite_colorkey *set = data;
>>  	struct drm_plane *plane;
>> -	struct intel_plane *intel_plane;
>> +	struct drm_plane_state *plane_state;
>> +	struct drm_atomic_state *state;
>> +	struct drm_modeset_acquire_ctx ctx;
>>  	int ret = 0;
> Can we simplify this by just calling
> drm_atomic_helper_plane_set_property() and let it handle the atomic
> transaction for us?
>
set_property requires drm_modeset_lock_all, and doing so requires making a specification for the
atomic color key property here. I don't know how what it would look like, so creating an atomic
property is left as a TODO.

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

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

* Re: [PATCH v3 18/19] drm/i915: Remove transitional references from intel_plane_atomic_check.
  2015-06-18 14:21   ` Matt Roper
@ 2015-06-19  4:05     ` Maarten Lankhorst
  0 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-19  4:05 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-gfx

Op 18-06-15 om 16:21 schreef Matt Roper:
> On Mon, Jun 15, 2015 at 12:33:55PM +0200, Maarten Lankhorst wrote:
>> All transitional plane helpers are gone, party!
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> There's also a reference in skylake_update_primary_plane() that I assume
> can be removed?
>
Sure, I left it in because people will complain about unrelated changes otherwise. :P
It should be a separate patch though..

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

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

* Re: [PATCH v3 00/19] Convert to atomic, part 3.
  2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
                   ` (18 preceding siblings ...)
  2015-06-15 10:33 ` [PATCH v3 19/19] drm/i915: Make cdclk part of the atomic state Maarten Lankhorst
@ 2015-06-19 22:29 ` Matt Roper
  2015-06-22 12:31   ` Daniel Vetter
  19 siblings, 1 reply; 39+ messages in thread
From: Matt Roper @ 2015-06-19 22:29 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Mon, Jun 15, 2015 at 12:33:37PM +0200, Maarten Lankhorst wrote:
> Requisites:
> - "[PATCH] drm/atomic: pass old crtc state to atomic_begin/flush."
> 
> This patch series converts plane updates and cdclk updates to atomic,
> but still doesn't touch the hw readout code, which was regressing a lot.
> 
> The fixes in this series are needed to support proper hw readout, and can
> be applied on top of topic/atomic-conversion.
> 
> In particular, this fixes the following bugs:
> - https://bugs.freedesktop.org/show_bug.cgi?id=90874
>   Needs atomic CDCLK as part of state, before any plane checks,
>   or scalers will not work correctly.
> - https://bugs.freedesktop.org/show_bug.cgi?id=90868
>   It shows a problem with plane visibility on resume.
>   This is fixed by calcing plane states correctly across modeset.
>   There's also a problem with DPLL 0 failing to lock, I hope that's
>   fixed by cdclk changes, but it might have been a bug in the reverted
>   atomic hw readout patch too.

I've spent the last week looking over these and I don't see any major
functional problems so I think these are probably ready for merging.  A
couple patches got into areas of the code I'm not super familiar with,
but I've also done quite a bit of testing of this series (on IVB) and
haven't run into issues, so that increases my confidence.

I think there was one incorrectly identified function parameter I called
out on one of the early scaler patches, but with a sensible parameter
rename there, you can consider these

Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Tested-by(IVB): Matt Roper <matthew.d.roper@intel.com>


Matt

> 
> Maarten Lankhorst (19):
>   drm/i915: Use crtc state in intel_modeset_pipe_config
>   drm/i915: Clean up intel_atomic_setup_scalers slightly.
>   drm/i915: Add a simple atomic crtc check function, v2.
>   drm/i915: Move scaler setup to check crtc function, v2.
>   drm/i915: Assign a new pll from the crtc check function, v2.
>   drm/i915: Split skl_update_scaler, v3.
>   drm/i915: Split plane updates of crtc->atomic into a helper, v2.
>   drm/i915: clean up plane commit functions
>   drm/i915: clean up atomic plane check functions, v2.
>   drm/i915: remove force argument from disable_plane
>   drm/i915: move detaching scalers to begin_crtc_commit, v2.
>   drm/i915: Move crtc commit updates to separate functions.
>   drm/i915: Do not run most checks when there's no modeset.
>   drm/i915: Handle disabling planes better, v2.
>   drm/i915: atomic plane updates in a nutshell
>   drm/i915: Update less state during modeset.
>   drm/i915: Make setting color key atomic.
>   drm/i915: Remove transitional references from
>     intel_plane_atomic_check.
>   drm/i915: Make cdclk part of the atomic state.
> 
>  drivers/gpu/drm/i915/i915_drv.h           |    3 +-
>  drivers/gpu/drm/i915/intel_atomic.c       |   47 +-
>  drivers/gpu/drm/i915/intel_atomic_plane.c |   41 +-
>  drivers/gpu/drm/i915/intel_display.c      | 1480 +++++++++++++++--------------
>  drivers/gpu/drm/i915/intel_dp.c           |    2 +-
>  drivers/gpu/drm/i915/intel_drv.h          |   27 +-
>  drivers/gpu/drm/i915/intel_sprite.c       |  170 ++--
>  7 files changed, 874 insertions(+), 896 deletions(-)
> 
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Matt Roper
Graphics Software Engineer
IoTG Platform Enabling & Development
Intel Corporation
(916) 356-2795
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 09/19] drm/i915: clean up atomic plane check functions, v2.
  2015-06-18  1:48   ` Matt Roper
@ 2015-06-22  7:23     ` Maarten Lankhorst
  0 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-22  7:23 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-gfx

Op 18-06-15 om 03:48 schreef Matt Roper:
> On Mon, Jun 15, 2015 at 12:33:46PM +0200, Maarten Lankhorst wrote:
>> By passing crtc_state to the check_plane functions a lot of duplicated
>> code can be removed. There are still some transitional helper calls,
>> they will be removed later.
>>
>> Changes since v1:
>> - Revert state->visible changes.
>> - Use plane->state->crtc instead of plane->crtc.
>> - Use drm_atomic_get_existing_crtc_state.
>>
>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>> ---
>>  drivers/gpu/drm/i915/intel_atomic_plane.c | 16 +++++++----
>>  drivers/gpu/drm/i915/intel_display.c      | 48 ++++++++++---------------------
>>  drivers/gpu/drm/i915/intel_drv.h          |  1 +
>>  drivers/gpu/drm/i915/intel_sprite.c       |  9 ++----
>>  4 files changed, 29 insertions(+), 45 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/i915/intel_atomic_plane.c b/drivers/gpu/drm/i915/intel_atomic_plane.c
>> index aa2128369a0a..91d53768df9d 100644
>> --- a/drivers/gpu/drm/i915/intel_atomic_plane.c
>> +++ b/drivers/gpu/drm/i915/intel_atomic_plane.c
>> @@ -116,7 +116,7 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
>>  	struct intel_plane_state *intel_state = to_intel_plane_state(state);
>>  	int ret;
>>  
>> -	crtc = crtc ? crtc : plane->crtc;
>> +	crtc = crtc ? crtc : plane->state->crtc;
>>  	intel_crtc = to_intel_crtc(crtc);
>>  
>>  	/*
>> @@ -131,10 +131,13 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
>>  	/* FIXME: temporary hack necessary while we still use the plane update
>>  	 * helper. */
>>  	if (state->state) {
>> -		crtc_state =
>> -			intel_atomic_get_crtc_state(state->state, intel_crtc);
>> -		if (IS_ERR(crtc_state))
>> -			return PTR_ERR(crtc_state);
>> +		struct drm_crtc_state *drm_crtc_state =
>> +			drm_atomic_get_existing_crtc_state(state->state, crtc);
> Is this change important?  We can't get to this point without the crtc
> state being in the atomic transaction can we?  The only case where that
> used to happen was if crtc was actually NULL due to a property update of
> a disabled plane, but we bail out on !crtc just above this.
>
> Not that this change would cause any problems that I see, I just don't
> understand the motivation.
It's just paranoia. There were some cases in which we didn't add the crtc state correctly, which was a bug.
This mostly happened without the other hunk that checks plane->state->crtc, but since we really don't want
to deal with errors by allocating crtc state here, I felt adding a WARN_ON was more appropriate.
>> +
>> +		if (WARN_ON(!drm_crtc_state))
>> +			return -EINVAL;
>> +
>> +		crtc_state = to_intel_crtc_state(drm_crtc_state);
>>  	} else {
>>  		crtc_state = intel_crtc->config;
>>  	}
>> @@ -185,7 +188,8 @@ static int intel_plane_atomic_check(struct drm_plane *plane,
>>  		}
>>  	}
>>  
>> -	ret = intel_plane->check_plane(plane, intel_state);
>> +	intel_state->visible = false;
>> +	ret = intel_plane->check_plane(plane, crtc_state, intel_state);
>>  	if (ret || !state->state)
>>  		return ret;
>>  
>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>> index ec4924eecd68..61697335bff2 100644
>> --- a/drivers/gpu/drm/i915/intel_display.c
>> +++ b/drivers/gpu/drm/i915/intel_display.c
>> @@ -13703,36 +13703,25 @@ skl_max_scale(struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state
>>  
>>  static int
>>  intel_check_primary_plane(struct drm_plane *plane,
>> +			  struct intel_crtc_state *crtc_state,
>>  			  struct intel_plane_state *state)
>>  {
>> -	struct drm_device *dev = plane->dev;
>>  	struct drm_crtc *crtc = state->base.crtc;
>> -	struct intel_crtc *intel_crtc;
>> -	struct intel_crtc_state *crtc_state;
>>  	struct drm_framebuffer *fb = state->base.fb;
>> -	struct drm_rect *dest = &state->dst;
>> -	struct drm_rect *src = &state->src;
>> -	const struct drm_rect *clip = &state->clip;
>> -	bool can_position = false;
>> -	int max_scale = DRM_PLANE_HELPER_NO_SCALING;
>>  	int min_scale = DRM_PLANE_HELPER_NO_SCALING;
>> +	int max_scale = DRM_PLANE_HELPER_NO_SCALING;
>> +	bool can_position = false;
>>  
>> -	crtc = crtc ? crtc : plane->crtc;
>> -	intel_crtc = to_intel_crtc(crtc);
>> -	crtc_state = state->base.state ?
>> -		intel_atomic_get_crtc_state(state->base.state, intel_crtc) : NULL;
>> -
>> -	if (INTEL_INFO(dev)->gen >= 9) {
>> -		/* use scaler when colorkey is not required */
>> -		if (to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
>> -			min_scale = 1;
>> -			max_scale = skl_max_scale(intel_crtc, crtc_state);
>> -		}
>> +	/* use scaler when colorkey is not required */
>> +	if (INTEL_INFO(plane->dev)->gen >= 9 &&
>> +	    to_intel_plane(plane)->ckey.flags == I915_SET_COLORKEY_NONE) {
>> +		min_scale = 1;
>> +		max_scale = skl_max_scale(to_intel_crtc(crtc), crtc_state);
>>  		can_position = true;
>>  	}
>>  
>> -	return drm_plane_helper_check_update(plane, crtc, fb,
>> -					     src, dest, clip,
>> +	return drm_plane_helper_check_update(plane, crtc, fb, &state->src,
>> +					     &state->dst, &state->clip,
>>  					     min_scale, max_scale,
>>  					     can_position, true,
>>  					     &state->visible);
>> @@ -13973,24 +13962,17 @@ void intel_create_rotation_property(struct drm_device *dev, struct intel_plane *
>>  
>>  static int
>>  intel_check_cursor_plane(struct drm_plane *plane,
>> +			 struct intel_crtc_state *crtc_state,
>>  			 struct intel_plane_state *state)
>>  {
>> -	struct drm_crtc *crtc = state->base.crtc;
>> -	struct drm_device *dev = plane->dev;
>> +	struct drm_crtc *crtc = crtc_state->base.crtc;
>>  	struct drm_framebuffer *fb = state->base.fb;
>> -	struct drm_rect *dest = &state->dst;
>> -	struct drm_rect *src = &state->src;
>> -	const struct drm_rect *clip = &state->clip;
>>  	struct drm_i915_gem_object *obj = intel_fb_obj(fb);
>> -	struct intel_crtc *intel_crtc;
>>  	unsigned stride;
>>  	int ret;
>>  
>> -	crtc = crtc ? crtc : plane->crtc;
>> -	intel_crtc = to_intel_crtc(crtc);
>> -
>> -	ret = drm_plane_helper_check_update(plane, crtc, fb,
>> -					    src, dest, clip,
>> +	ret = drm_plane_helper_check_update(plane, crtc, fb, &state->src,
>> +					    &state->dst, &state->clip,
>>  					    DRM_PLANE_HELPER_NO_SCALING,
>>  					    DRM_PLANE_HELPER_NO_SCALING,
>>  					    true, true, &state->visible);
>> @@ -14002,7 +13984,7 @@ intel_check_cursor_plane(struct drm_plane *plane,
>>  		return 0;
>>  
>>  	/* Check for which cursor types we support */
>> -	if (!cursor_size_ok(dev, state->base.crtc_w, state->base.crtc_h)) {
>> +	if (!cursor_size_ok(plane->dev, state->base.crtc_w, state->base.crtc_h)) {
>>  		DRM_DEBUG("Cursor dimension %dx%d not supported\n",
>>  			  state->base.crtc_w, state->base.crtc_h);
>>  		return -EINVAL;
>> diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
>> index 9f5867bf745e..8c0f17e84eee 100644
>> --- a/drivers/gpu/drm/i915/intel_drv.h
>> +++ b/drivers/gpu/drm/i915/intel_drv.h
>> @@ -613,6 +613,7 @@ struct intel_plane {
>>  	void (*disable_plane)(struct drm_plane *plane,
>>  			      struct drm_crtc *crtc, bool force);
>>  	int (*check_plane)(struct drm_plane *plane,
>> +			   struct intel_crtc_state *crtc_state,
>>  			   struct intel_plane_state *state);
>>  	void (*commit_plane)(struct drm_plane *plane,
>>  			     struct intel_plane_state *state);
>> diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
>> index c909b8b8ce85..999a5753dde3 100644
>> --- a/drivers/gpu/drm/i915/intel_sprite.c
>> +++ b/drivers/gpu/drm/i915/intel_sprite.c
>> @@ -739,11 +739,12 @@ ilk_disable_plane(struct drm_plane *plane, struct drm_crtc *crtc, bool force)
>>  
>>  static int
>>  intel_check_sprite_plane(struct drm_plane *plane,
>> +			 struct intel_crtc_state *crtc_state,
>>  			 struct intel_plane_state *state)
>>  {
>>  	struct drm_device *dev = plane->dev;
>> -	struct intel_crtc *intel_crtc = to_intel_crtc(state->base.crtc);
>> -	struct intel_crtc_state *crtc_state;
>> +	struct drm_crtc *crtc = state->base.crtc;
>> +	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> We don't actually use crtc anywhere after this, so I'm not sure if there
> was a need to change the assignment of intel_crtc?  Not a big deal
> either way.
>
Can't remember why I did this, but it's not worth sending a new patch for. :)

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

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

* [PATCH v3.5 06/19] drm/i915: Split skl_update_scaler, v4.
  2015-06-18  6:51       ` Daniel Vetter
@ 2015-06-22  7:50         ` Maarten Lankhorst
  0 siblings, 0 replies; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-22  7:50 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: intel-gfx

commit 2c310b9d2859863826c3688c88218d607d5dd19a
Author: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Date:   Mon May 18 12:28:52 2015 +0200

drm/i915: Split skl_update_scaler, v4.

It's easier to read separate functions for crtc and plane scaler state.

Changes since v1:
 - Update documentation.
Changes since v2:
 - Get rid of parameters to skl_update_scaler only used for traces.
   This avoids needing to document the other parameters.
Changes since v3:
 - Rename scaler_idx to scaler_user.

Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Tested-by(IVB): Matt Roper <matthew.d.roper@intel.com>

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 36f2924b9a68..7e008a1b105b 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -4313,62 +4313,16 @@ static void cpt_verify_modeset(struct drm_device *dev, int pipe)
 	}
 }
 
-/**
- * skl_update_scaler_users - Stages update to crtc's scaler state
- * @intel_crtc: crtc
- * @crtc_state: crtc_state
- * @plane: plane (NULL indicates crtc is requesting update)
- * @plane_state: plane's state
- * @force_detach: request unconditional detachment of scaler
- *
- * This function updates scaler state for requested plane or crtc.
- * To request scaler usage update for a plane, caller shall pass plane pointer.
- * To request scaler usage update for crtc, caller shall pass plane pointer
- * as NULL.
- *
- * Return
- *     0 - scaler_usage updated successfully
- *    error - requested scaling cannot be supported or other error condition
- */
-int
-skl_update_scaler_users(
-	struct intel_crtc *intel_crtc, struct intel_crtc_state *crtc_state,
-	struct intel_plane *intel_plane, struct intel_plane_state *plane_state,
-	int force_detach)
+static int
+skl_update_scaler(struct intel_crtc_state *crtc_state, bool force_detach,
+		  unsigned scaler_user, int *scaler_id, unsigned int rotation,
+		  int src_w, int src_h, int dst_w, int dst_h)
 {
+	struct intel_crtc_scaler_state *scaler_state =
+		&crtc_state->scaler_state;
+	struct intel_crtc *intel_crtc =
+		to_intel_crtc(crtc_state->base.crtc);
 	int need_scaling;
-	int idx;
-	int src_w, src_h, dst_w, dst_h;
-	int *scaler_id;
-	struct drm_framebuffer *fb;
-	struct intel_crtc_scaler_state *scaler_state;
-	unsigned int rotation;
-
-	if (!intel_crtc || !crtc_state)
-		return 0;
-
-	scaler_state = &crtc_state->scaler_state;
-
-	idx = intel_plane ? drm_plane_index(&intel_plane->base) : SKL_CRTC_INDEX;
-	fb = intel_plane ? plane_state->base.fb : NULL;
-
-	if (intel_plane) {
-		src_w = drm_rect_width(&plane_state->src) >> 16;
-		src_h = drm_rect_height(&plane_state->src) >> 16;
-		dst_w = drm_rect_width(&plane_state->dst);
-		dst_h = drm_rect_height(&plane_state->dst);
-		scaler_id = &plane_state->scaler_id;
-		rotation = plane_state->base.rotation;
-	} else {
-		struct drm_display_mode *adjusted_mode =
-			&crtc_state->base.adjusted_mode;
-		src_w = crtc_state->pipe_src_w;
-		src_h = crtc_state->pipe_src_h;
-		dst_w = adjusted_mode->hdisplay;
-		dst_h = adjusted_mode->vdisplay;
-		scaler_id = &scaler_state->scaler_id;
-		rotation = DRM_ROTATE_0;
-	}
 
 	need_scaling = intel_rotation_90_or_270(rotation) ?
 		(src_h != dst_w || src_w != dst_h):
@@ -4384,17 +4338,14 @@ skl_update_scaler_users(
 	 * update to free the scaler is done in plane/panel-fit programming.
 	 * For this purpose crtc/plane_state->scaler_id isn't reset here.
 	 */
-	if (force_detach || !need_scaling || (intel_plane &&
-		(!fb || !plane_state->visible))) {
+	if (force_detach || !need_scaling) {
 		if (*scaler_id >= 0) {
-			scaler_state->scaler_users &= ~(1 << idx);
+			scaler_state->scaler_users &= ~(1 << scaler_user);
 			scaler_state->scalers[*scaler_id].in_use = 0;
 
-			DRM_DEBUG_KMS("Staged freeing scaler id %d.%d from %s:%d "
-				"crtc_state = %p scaler_users = 0x%x\n",
-				intel_crtc->pipe, *scaler_id, intel_plane ? "PLANE" : "CRTC",
-				intel_plane ? intel_plane->base.base.id :
-				intel_crtc->base.base.id, crtc_state,
+			DRM_DEBUG_KMS("scaler_user index %u.%u: "
+				"Staged freeing scaler id %d scaler_users = 0x%x\n",
+				intel_crtc->pipe, scaler_user, *scaler_id,
 				scaler_state->scaler_users);
 			*scaler_id = -1;
 		}
@@ -4407,51 +4358,112 @@ skl_update_scaler_users(
 
 		src_w > SKL_MAX_SRC_W || src_h > SKL_MAX_SRC_H ||
 		dst_w > SKL_MAX_DST_W || dst_h > SKL_MAX_DST_H) {
-		DRM_DEBUG_KMS("%s:%d scaler_user index %u.%u: src %ux%u dst %ux%u "
+		DRM_DEBUG_KMS("scaler_user index %u.%u: src %ux%u dst %ux%u "
 			"size is out of scaler range\n",
-			intel_plane ? "PLANE" : "CRTC",
-			intel_plane ? intel_plane->base.base.id : intel_crtc->base.base.id,
-			intel_crtc->pipe, idx, src_w, src_h, dst_w, dst_h);
+			intel_crtc->pipe, scaler_user, src_w, src_h, dst_w, dst_h);
 		return -EINVAL;
 	}
 
+	/* mark this plane as a scaler user in crtc_state */
+	scaler_state->scaler_users |= (1 << scaler_user);
+	DRM_DEBUG_KMS("scaler_user index %u.%u: "
+		"staged scaling request for %ux%u->%ux%u scaler_users = 0x%x\n",
+		intel_crtc->pipe, scaler_user, src_w, src_h, dst_w, dst_h,
+		scaler_state->scaler_users);
+
+	return 0;
+}
+
+/**
+ * skl_update_scaler_crtc - Stages update to scaler state for a given crtc.
+ *
+ * @state: crtc's scaler state
+ * @force_detach: whether to forcibly disable scaler
+ *
+ * Return
+ *     0 - scaler_usage updated successfully
+ *    error - requested scaling cannot be supported or other error condition
+ */
+int skl_update_scaler_crtc(struct intel_crtc_state *state, int force_detach)
+{
+	struct intel_crtc *intel_crtc = to_intel_crtc(state->base.crtc);
+	struct drm_display_mode *adjusted_mode =
+		&state->base.adjusted_mode;
+
+	DRM_DEBUG_KMS("Updating scaler for [CRTC:%i] scaler_user index %u.%u\n",
+		      intel_crtc->base.base.id, intel_crtc->pipe, SKL_CRTC_INDEX);
+
+	return skl_update_scaler(state, force_detach, SKL_CRTC_INDEX,
+		&state->scaler_state.scaler_id, DRM_ROTATE_0,
+		state->pipe_src_w, state->pipe_src_h,
+		adjusted_mode->hdisplay, adjusted_mode->hdisplay);
+}
+
+/**
+ * skl_update_scaler_plane - Stages update to scaler state for a given plane.
+ *
+ * @state: crtc's scaler state
+ * @intel_plane: affected plane
+ * @plane_state: atomic plane state to update
+ *
+ * Return
+ *     0 - scaler_usage updated successfully
+ *    error - requested scaling cannot be supported or other error condition
+ */
+int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
+			    struct intel_plane *intel_plane,
+			    struct intel_plane_state *plane_state)
+{
+
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc_state->base.crtc);
+	struct drm_framebuffer *fb = plane_state->base.fb;
+	int ret;
+
+	bool force_detach = !fb || !plane_state->visible;
+
+	DRM_DEBUG_KMS("Updating scaler for [PLANE:%d] scaler_user index %u.%u\n",
+		      intel_plane->base.base.id, intel_crtc->pipe,
+		      drm_plane_index(&intel_plane->base));
+
+	ret = skl_update_scaler(crtc_state, force_detach,
+				drm_plane_index(&intel_plane->base),
+				&plane_state->scaler_id,
+				plane_state->base.rotation,
+				drm_rect_width(&plane_state->src) >> 16,
+				drm_rect_height(&plane_state->src) >> 16,
+				drm_rect_width(&plane_state->dst),
+				drm_rect_height(&plane_state->dst));
+
+	if (ret || plane_state->scaler_id < 0)
+		return ret;
+
 	/* check colorkey */
-	if (WARN_ON(intel_plane &&
-		intel_plane->ckey.flags != I915_SET_COLORKEY_NONE)) {
-		DRM_DEBUG_KMS("PLANE:%d scaling %ux%u->%ux%u not allowed with colorkey",
-			intel_plane->base.base.id, src_w, src_h, dst_w, dst_h);
+	if (WARN_ON(intel_plane->ckey.flags != I915_SET_COLORKEY_NONE)) {
+		DRM_DEBUG_KMS("[PLANE:%d] scaling with color key not allowed",
+			intel_plane->base.base.id);
 		return -EINVAL;
 	}
 
 	/* Check src format */
-	if (intel_plane) {
-		switch (fb->pixel_format) {
-		case DRM_FORMAT_RGB565:
-		case DRM_FORMAT_XBGR8888:
-		case DRM_FORMAT_XRGB8888:
-		case DRM_FORMAT_ABGR8888:
-		case DRM_FORMAT_ARGB8888:
-		case DRM_FORMAT_XRGB2101010:
-		case DRM_FORMAT_XBGR2101010:
-		case DRM_FORMAT_YUYV:
-		case DRM_FORMAT_YVYU:
-		case DRM_FORMAT_UYVY:
-		case DRM_FORMAT_VYUY:
-			break;
-		default:
-			DRM_DEBUG_KMS("PLANE:%d FB:%d unsupported scaling format 0x%x\n",
-				intel_plane->base.base.id, fb->base.id, fb->pixel_format);
-			return -EINVAL;
-		}
+	switch (fb->pixel_format) {
+	case DRM_FORMAT_RGB565:
+	case DRM_FORMAT_XBGR8888:
+	case DRM_FORMAT_XRGB8888:
+	case DRM_FORMAT_ABGR8888:
+	case DRM_FORMAT_ARGB8888:
+	case DRM_FORMAT_XRGB2101010:
+	case DRM_FORMAT_XBGR2101010:
+	case DRM_FORMAT_YUYV:
+	case DRM_FORMAT_YVYU:
+	case DRM_FORMAT_UYVY:
+	case DRM_FORMAT_VYUY:
+		break;
+	default:
+		DRM_DEBUG_KMS("[PLANE:%d] FB:%d unsupported scaling format 0x%x\n",
+			intel_plane->base.base.id, fb->base.id, fb->pixel_format);
+		return -EINVAL;
 	}
 
-	/* mark this plane as a scaler user in crtc_state */
-	scaler_state->scaler_users |= (1 << idx);
-	DRM_DEBUG_KMS("%s:%d staged scaling request for %ux%u->%ux%u "
-		"crtc_state = %p scaler_users = 0x%x\n",
-		intel_plane ? "PLANE" : "CRTC",
-		intel_plane ? intel_plane->base.base.id : intel_crtc->base.base.id,
-		src_w, src_h, dst_w, dst_h, crtc_state, scaler_state->scaler_users);
 	return 0;
 }
 
@@ -4466,7 +4478,7 @@ static void skylake_pfit_update(struct intel_crtc *crtc, int enable)
 	DRM_DEBUG_KMS("for crtc_state = %p\n", crtc->config);
 
 	/* To update pfit, first update scaler state */
-	skl_update_scaler_users(crtc, crtc->config, NULL, NULL, !enable);
+	skl_update_scaler_crtc(crtc->config, !enable);
 	intel_atomic_setup_scalers(crtc->base.dev, crtc, crtc->config);
 	skl_detach_scalers(crtc);
 	if (!enable)
@@ -13659,8 +13671,9 @@ intel_check_primary_plane(struct drm_plane *plane,
 	}
 
 	if (INTEL_INFO(dev)->gen >= 9) {
-		ret = skl_update_scaler_users(intel_crtc, crtc_state,
-			to_intel_plane(plane), state, 0);
+		ret = skl_update_scaler_plane(crtc_state,
+					      to_intel_plane(plane),
+					      state);
 		if (ret)
 			return ret;
 	}
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index f52eef138247..6141a702ba36 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -1377,7 +1377,7 @@ intel_dp_compute_config(struct intel_encoder *encoder,
 
 		if (INTEL_INFO(dev)->gen >= 9) {
 			int ret;
-			ret = skl_update_scaler_users(intel_crtc, pipe_config, NULL, NULL, 0);
+			ret = skl_update_scaler_crtc(pipe_config, 0);
 			if (ret)
 				return ret;
 		}
diff --git a/drivers/gpu/drm/i915/intel_drv.h b/drivers/gpu/drm/i915/intel_drv.h
index 02b18a173472..2436af9d2678 100644
--- a/drivers/gpu/drm/i915/intel_drv.h
+++ b/drivers/gpu/drm/i915/intel_drv.h
@@ -263,7 +263,7 @@ struct intel_plane_state {
 	 * plane requiring a scaler:
 	 *   - During check_plane, its bit is set in
 	 *     crtc_state->scaler_state.scaler_users by calling helper function
-	 *     update_scaler_users.
+	 *     update_scaler_plane.
 	 *   - scaler_id indicates the scaler it got assigned.
 	 *
 	 * plane doesn't require a scaler:
@@ -271,7 +271,7 @@ struct intel_plane_state {
 	 *     got disabled.
 	 *   - During check_plane, corresponding bit is reset in
 	 *     crtc_state->scaler_state.scaler_users by calling helper function
-	 *     update_scaler_users.
+	 *     update_scaler_plane.
 	 */
 	int scaler_id;
 };
@@ -1148,9 +1148,11 @@ void intel_mode_from_pipe_config(struct drm_display_mode *mode,
 void intel_crtc_wait_for_pending_flips(struct drm_crtc *crtc);
 void intel_modeset_preclose(struct drm_device *dev, struct drm_file *file);
 void skl_detach_scalers(struct intel_crtc *intel_crtc);
-int skl_update_scaler_users(struct intel_crtc *intel_crtc,
-	struct intel_crtc_state *crtc_state, struct intel_plane *intel_plane,
-	struct intel_plane_state *plane_state, int force_detach);
+int skl_update_scaler_plane(struct intel_crtc_state *crtc_state,
+			    struct intel_plane *intel_plane,
+			    struct intel_plane_state *plane_state);
+
+int skl_update_scaler_crtc(struct intel_crtc_state *crtc_state, int force_detach);
 int skl_max_scale(struct intel_crtc *crtc, struct intel_crtc_state *crtc_state);
 
 unsigned long intel_plane_obj_offset(struct intel_plane *intel_plane,
diff --git a/drivers/gpu/drm/i915/intel_sprite.c b/drivers/gpu/drm/i915/intel_sprite.c
index 0434cbe1634b..f57268bde9aa 100644
--- a/drivers/gpu/drm/i915/intel_sprite.c
+++ b/drivers/gpu/drm/i915/intel_sprite.c
@@ -944,8 +944,7 @@ finish:
 	}
 
 	if (INTEL_INFO(dev)->gen >= 9) {
-		ret = skl_update_scaler_users(intel_crtc, crtc_state, intel_plane,
-			state, 0);
+		ret = skl_update_scaler_plane(crtc_state, intel_plane, state);
 		if (ret)
 			return ret;
 	}

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

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

* Re: [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell
  2015-06-19  4:01     ` Maarten Lankhorst
@ 2015-06-22  9:49       ` Ville Syrjälä
  2015-06-22 10:08         ` Maarten Lankhorst
  0 siblings, 1 reply; 39+ messages in thread
From: Ville Syrjälä @ 2015-06-22  9:49 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Fri, Jun 19, 2015 at 06:01:07AM +0200, Maarten Lankhorst wrote:
> Op 18-06-15 om 17:28 schreef Ville Syrjälä:
> > On Mon, Jun 15, 2015 at 12:33:52PM +0200, Maarten Lankhorst wrote:
> >> Now that all planes are added during a modeset we can use the
> >> calculated changes before disabling a plane, and then either commit
> >> or force disable a plane before disabling the crtc.
> >>
> >> The code is shared with atomic_begin/flush, except watermark updating
> >> and vblank evasion are not used.
> >>
> >> This is needed for proper atomic suspend/resume support.
> >>
> >> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90868
> >> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> >> ---
> >>  drivers/gpu/drm/i915/intel_display.c | 103 ++++++++---------------------------
> >>  drivers/gpu/drm/i915/intel_sprite.c  |   4 +-
> >>  2 files changed, 23 insertions(+), 84 deletions(-)
> >>
> >> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> >> index cc4ca4970716..beb69281f45c 100644
> >> --- a/drivers/gpu/drm/i915/intel_display.c
> >> +++ b/drivers/gpu/drm/i915/intel_display.c
> >> @@ -2217,28 +2217,6 @@ static void intel_disable_pipe(struct intel_crtc *crtc)
> >>  		intel_wait_for_pipe_off(crtc);
> >>  }
> >>  
> >> -/**
> >> - * intel_enable_primary_hw_plane - enable the primary plane on a given pipe
> >> - * @plane:  plane to be enabled
> >> - * @crtc: crtc for the plane
> >> - *
> >> - * Enable @plane on @crtc, making sure that the pipe is running first.
> >> - */
> >> -static void intel_enable_primary_hw_plane(struct drm_plane *plane,
> >> -					  struct drm_crtc *crtc)
> >> -{
> >> -	struct drm_device *dev = plane->dev;
> >> -	struct drm_i915_private *dev_priv = dev->dev_private;
> >> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> >> -
> >> -	/* If the pipe isn't enabled, we can't pump pixels and may hang */
> >> -	assert_pipe_enabled(dev_priv, intel_crtc->pipe);
> >> -	to_intel_plane_state(plane->state)->visible = true;
> >> -
> >> -	dev_priv->display.update_primary_plane(crtc, plane->fb,
> >> -					       crtc->x, crtc->y);
> >> -}
> >> -
> >>  static bool need_vtd_wa(struct drm_device *dev)
> >>  {
> >>  #ifdef CONFIG_INTEL_IOMMU
> >> @@ -4508,20 +4486,6 @@ static void ironlake_pfit_enable(struct intel_crtc *crtc)
> >>  	}
> >>  }
> >>  
> >> -static void intel_enable_sprite_planes(struct drm_crtc *crtc)
> >> -{
> >> -	struct drm_device *dev = crtc->dev;
> >> -	enum pipe pipe = to_intel_crtc(crtc)->pipe;
> >> -	struct drm_plane *plane;
> >> -	struct intel_plane *intel_plane;
> >> -
> >> -	drm_for_each_legacy_plane(plane, &dev->mode_config.plane_list) {
> >> -		intel_plane = to_intel_plane(plane);
> >> -		if (intel_plane->pipe == pipe)
> >> -			intel_plane_restore(&intel_plane->base);
> >> -	}
> >> -}
> >> -
> >>  void hsw_enable_ips(struct intel_crtc *crtc)
> >>  {
> >>  	struct drm_device *dev = crtc->base.dev;
> >> @@ -4817,27 +4781,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
> >>  		intel_pre_disable_primary(&crtc->base);
> >>  }
> >>  
> >> -static void intel_crtc_enable_planes(struct drm_crtc *crtc)
> >> -{
> >> -	struct drm_device *dev = crtc->dev;
> >> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> >> -	int pipe = intel_crtc->pipe;
> >> -
> >> -	intel_enable_primary_hw_plane(crtc->primary, crtc);
> >> -	intel_enable_sprite_planes(crtc);
> >> -	if (to_intel_plane_state(crtc->cursor->state)->visible)
> >> -		intel_crtc_update_cursor(crtc, true);
> >> -
> >> -	intel_post_enable_primary(crtc);
> >> -
> >> -	/*
> >> -	 * FIXME: Once we grow proper nuclear flip support out of this we need
> >> -	 * to compute the mask of flip planes precisely. For the time being
> >> -	 * consider this a flip to a NULL plane.
> >> -	 */
> >> -	intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
> >> -}
> >> -
> >>  static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask)
> >>  {
> >>  	struct drm_device *dev = crtc->dev;
> >> @@ -4845,10 +4788,6 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask
> >>  	struct drm_plane *p;
> >>  	int pipe = intel_crtc->pipe;
> >>  
> >> -	intel_crtc_wait_for_pending_flips(crtc);
> >> -
> >> -	intel_pre_disable_primary(crtc);
> >> -
> >>  	intel_crtc_dpms_overlay_disable(intel_crtc);
> >>  
> >>  	drm_for_each_plane_mask(p, dev, plane_mask)
> >> @@ -6270,6 +6209,11 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
> >>  	if (!intel_crtc->active)
> >>  		return;
> >>  
> >> +	if (to_intel_plane_state(crtc->primary->state)->visible) {
> >> +		intel_crtc_wait_for_pending_flips(crtc);
> >> +		intel_pre_disable_primary(crtc);
> >> +	}
> >> +
> >>  	intel_crtc_disable_planes(crtc, crtc->state->plane_mask);
> >>  	dev_priv->display.crtc_disable(crtc);
> >>  
> >> @@ -11783,10 +11727,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
> >>  	if (old_plane_state->base.fb && !fb)
> >>  		intel_crtc->atomic.disabled_planes |= 1 << i;
> >>  
> >> -	/* don't run rest during modeset yet */
> >> -	if (!intel_crtc->active || mode_changed)
> >> -		return 0;
> >> -
> >>  	was_visible = old_plane_state->visible;
> >>  	visible = to_intel_plane_state(plane_state)->visible;
> >>  
> >> @@ -13255,15 +13195,18 @@ static int __intel_set_mode(struct drm_atomic_state *state)
> >>  	drm_atomic_helper_swap_state(dev, state);
> >>  
> >>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> >> +		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> >> +
> >>  		if (!needs_modeset(crtc->state))
> >>  			continue;
> >>  
> >>  		any_ms = true;
> >> -		if (!crtc_state->active)
> >> -			continue;
> >> +		intel_pre_plane_update(intel_crtc);
> >>  
> >> -		intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
> >> -		dev_priv->display.crtc_disable(crtc);
> >> +		if (crtc_state->active) {
> >> +			intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
> >> +			dev_priv->display.crtc_disable(crtc);
> >> +		}
> >>  	}
> >>  
> >>  	/* Only after disabling all output pipelines that will be changed can we
> >> @@ -13277,15 +13220,12 @@ static int __intel_set_mode(struct drm_atomic_state *state)
> >>  
> >>  	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
> >>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
> >> -		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
> >> -
> >> -		if (!needs_modeset(crtc->state) || !crtc->state->active)
> >> -			continue;
> >> -
> >> -		update_scanline_offset(to_intel_crtc(crtc));
> >> +		if (needs_modeset(crtc->state) && crtc->state->active) {
> >> +			update_scanline_offset(to_intel_crtc(crtc));
> >> +			dev_priv->display.crtc_enable(crtc);
> >> +		}
> >>  
> >> -		dev_priv->display.crtc_enable(crtc);
> >> -		intel_crtc_enable_planes(crtc);
> >> +		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
> > Why are we still commiting planes on a disabled pipes?
> >
> > The way I envisioned the modeset path looking is something like this:
> >
> > 1. atomically disable all planes for pipes getting disabled
> > 2. disable all pipes that need disabling
> > 3. enable all pipes that need enabling
> > 4. atomically update all planes that require it on now active pipes
> >
> >
> I looked for other ways to do this, but they were ugly. Only updating sw state in commit_planes for disabled crtc's made things a lot cleaner without worrying about special cases.

The commit hooks shouldn't update any sw state.

As for special cases, the current code has one special case after another,
and it's giving me a headache every time I look at it.

> 
> plane_disable doesn't update sw state, so it performs 1. The commit function is still called because update plane->fb
> needs to be updated, even for disabled crtc's. Conditionally calling plane_commit caused more issues than it solved.

plane->fb should be clearly moved out of the commit hooks to where the
rest of the state gets swapped (assuming we can't just get rid of it).

-- 
Ville Syrjälä
Intel OTC
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell
  2015-06-22  9:49       ` Ville Syrjälä
@ 2015-06-22 10:08         ` Maarten Lankhorst
  2015-06-22 12:33           ` Daniel Vetter
  0 siblings, 1 reply; 39+ messages in thread
From: Maarten Lankhorst @ 2015-06-22 10:08 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

Hey,

Op 22-06-15 om 11:49 schreef Ville Syrjälä:
> On Fri, Jun 19, 2015 at 06:01:07AM +0200, Maarten Lankhorst wrote:
>> Op 18-06-15 om 17:28 schreef Ville Syrjälä:
>>> On Mon, Jun 15, 2015 at 12:33:52PM +0200, Maarten Lankhorst wrote:
>>>> Now that all planes are added during a modeset we can use the
>>>> calculated changes before disabling a plane, and then either commit
>>>> or force disable a plane before disabling the crtc.
>>>>
>>>> The code is shared with atomic_begin/flush, except watermark updating
>>>> and vblank evasion are not used.
>>>>
>>>> This is needed for proper atomic suspend/resume support.
>>>>
>>>> Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=90868
>>>> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
>>>> ---
>>>>  drivers/gpu/drm/i915/intel_display.c | 103 ++++++++---------------------------
>>>>  drivers/gpu/drm/i915/intel_sprite.c  |   4 +-
>>>>  2 files changed, 23 insertions(+), 84 deletions(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
>>>> index cc4ca4970716..beb69281f45c 100644
>>>> --- a/drivers/gpu/drm/i915/intel_display.c
>>>> +++ b/drivers/gpu/drm/i915/intel_display.c
>>>> @@ -2217,28 +2217,6 @@ static void intel_disable_pipe(struct intel_crtc *crtc)
>>>>  		intel_wait_for_pipe_off(crtc);
>>>>  }
>>>>  
>>>> -/**
>>>> - * intel_enable_primary_hw_plane - enable the primary plane on a given pipe
>>>> - * @plane:  plane to be enabled
>>>> - * @crtc: crtc for the plane
>>>> - *
>>>> - * Enable @plane on @crtc, making sure that the pipe is running first.
>>>> - */
>>>> -static void intel_enable_primary_hw_plane(struct drm_plane *plane,
>>>> -					  struct drm_crtc *crtc)
>>>> -{
>>>> -	struct drm_device *dev = plane->dev;
>>>> -	struct drm_i915_private *dev_priv = dev->dev_private;
>>>> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>>>> -
>>>> -	/* If the pipe isn't enabled, we can't pump pixels and may hang */
>>>> -	assert_pipe_enabled(dev_priv, intel_crtc->pipe);
>>>> -	to_intel_plane_state(plane->state)->visible = true;
>>>> -
>>>> -	dev_priv->display.update_primary_plane(crtc, plane->fb,
>>>> -					       crtc->x, crtc->y);
>>>> -}
>>>> -
>>>>  static bool need_vtd_wa(struct drm_device *dev)
>>>>  {
>>>>  #ifdef CONFIG_INTEL_IOMMU
>>>> @@ -4508,20 +4486,6 @@ static void ironlake_pfit_enable(struct intel_crtc *crtc)
>>>>  	}
>>>>  }
>>>>  
>>>> -static void intel_enable_sprite_planes(struct drm_crtc *crtc)
>>>> -{
>>>> -	struct drm_device *dev = crtc->dev;
>>>> -	enum pipe pipe = to_intel_crtc(crtc)->pipe;
>>>> -	struct drm_plane *plane;
>>>> -	struct intel_plane *intel_plane;
>>>> -
>>>> -	drm_for_each_legacy_plane(plane, &dev->mode_config.plane_list) {
>>>> -		intel_plane = to_intel_plane(plane);
>>>> -		if (intel_plane->pipe == pipe)
>>>> -			intel_plane_restore(&intel_plane->base);
>>>> -	}
>>>> -}
>>>> -
>>>>  void hsw_enable_ips(struct intel_crtc *crtc)
>>>>  {
>>>>  	struct drm_device *dev = crtc->base.dev;
>>>> @@ -4817,27 +4781,6 @@ static void intel_pre_plane_update(struct intel_crtc *crtc)
>>>>  		intel_pre_disable_primary(&crtc->base);
>>>>  }
>>>>  
>>>> -static void intel_crtc_enable_planes(struct drm_crtc *crtc)
>>>> -{
>>>> -	struct drm_device *dev = crtc->dev;
>>>> -	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>>>> -	int pipe = intel_crtc->pipe;
>>>> -
>>>> -	intel_enable_primary_hw_plane(crtc->primary, crtc);
>>>> -	intel_enable_sprite_planes(crtc);
>>>> -	if (to_intel_plane_state(crtc->cursor->state)->visible)
>>>> -		intel_crtc_update_cursor(crtc, true);
>>>> -
>>>> -	intel_post_enable_primary(crtc);
>>>> -
>>>> -	/*
>>>> -	 * FIXME: Once we grow proper nuclear flip support out of this we need
>>>> -	 * to compute the mask of flip planes precisely. For the time being
>>>> -	 * consider this a flip to a NULL plane.
>>>> -	 */
>>>> -	intel_frontbuffer_flip(dev, INTEL_FRONTBUFFER_ALL_MASK(pipe));
>>>> -}
>>>> -
>>>>  static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask)
>>>>  {
>>>>  	struct drm_device *dev = crtc->dev;
>>>> @@ -4845,10 +4788,6 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask
>>>>  	struct drm_plane *p;
>>>>  	int pipe = intel_crtc->pipe;
>>>>  
>>>> -	intel_crtc_wait_for_pending_flips(crtc);
>>>> -
>>>> -	intel_pre_disable_primary(crtc);
>>>> -
>>>>  	intel_crtc_dpms_overlay_disable(intel_crtc);
>>>>  
>>>>  	drm_for_each_plane_mask(p, dev, plane_mask)
>>>> @@ -6270,6 +6209,11 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
>>>>  	if (!intel_crtc->active)
>>>>  		return;
>>>>  
>>>> +	if (to_intel_plane_state(crtc->primary->state)->visible) {
>>>> +		intel_crtc_wait_for_pending_flips(crtc);
>>>> +		intel_pre_disable_primary(crtc);
>>>> +	}
>>>> +
>>>>  	intel_crtc_disable_planes(crtc, crtc->state->plane_mask);
>>>>  	dev_priv->display.crtc_disable(crtc);
>>>>  
>>>> @@ -11783,10 +11727,6 @@ int intel_plane_atomic_calc_changes(struct drm_crtc_state *crtc_state,
>>>>  	if (old_plane_state->base.fb && !fb)
>>>>  		intel_crtc->atomic.disabled_planes |= 1 << i;
>>>>  
>>>> -	/* don't run rest during modeset yet */
>>>> -	if (!intel_crtc->active || mode_changed)
>>>> -		return 0;
>>>> -
>>>>  	was_visible = old_plane_state->visible;
>>>>  	visible = to_intel_plane_state(plane_state)->visible;
>>>>  
>>>> @@ -13255,15 +13195,18 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>>>>  	drm_atomic_helper_swap_state(dev, state);
>>>>  
>>>>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
>>>> +		struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>>>> +
>>>>  		if (!needs_modeset(crtc->state))
>>>>  			continue;
>>>>  
>>>>  		any_ms = true;
>>>> -		if (!crtc_state->active)
>>>> -			continue;
>>>> +		intel_pre_plane_update(intel_crtc);
>>>>  
>>>> -		intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
>>>> -		dev_priv->display.crtc_disable(crtc);
>>>> +		if (crtc_state->active) {
>>>> +			intel_crtc_disable_planes(crtc, crtc_state->plane_mask);
>>>> +			dev_priv->display.crtc_disable(crtc);
>>>> +		}
>>>>  	}
>>>>  
>>>>  	/* Only after disabling all output pipelines that will be changed can we
>>>> @@ -13277,15 +13220,12 @@ static int __intel_set_mode(struct drm_atomic_state *state)
>>>>  
>>>>  	/* Now enable the clocks, plane, pipe, and connectors that we set up. */
>>>>  	for_each_crtc_in_state(state, crtc, crtc_state, i) {
>>>> -		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
>>>> -
>>>> -		if (!needs_modeset(crtc->state) || !crtc->state->active)
>>>> -			continue;
>>>> -
>>>> -		update_scanline_offset(to_intel_crtc(crtc));
>>>> +		if (needs_modeset(crtc->state) && crtc->state->active) {
>>>> +			update_scanline_offset(to_intel_crtc(crtc));
>>>> +			dev_priv->display.crtc_enable(crtc);
>>>> +		}
>>>>  
>>>> -		dev_priv->display.crtc_enable(crtc);
>>>> -		intel_crtc_enable_planes(crtc);
>>>> +		drm_atomic_helper_commit_planes_on_crtc(crtc_state);
>>> Why are we still commiting planes on a disabled pipes?
>>>
>>> The way I envisioned the modeset path looking is something like this:
>>>
>>> 1. atomically disable all planes for pipes getting disabled
>>> 2. disable all pipes that need disabling
>>> 3. enable all pipes that need enabling
>>> 4. atomically update all planes that require it on now active pipes
>>>
>>>
>> I looked for other ways to do this, but they were ugly. Only updating sw state in commit_planes for disabled crtc's made things a lot cleaner without worrying about special cases.
> The commit hooks shouldn't update any sw state.
>
> As for special cases, the current code has one special case after another,
> and it's giving me a headache every time I look at it.
Yes, but this will simplify with a unified atomic commit path.
>> plane_disable doesn't update sw state, so it performs 1. The commit function is still called because update plane->fb
>> needs to be updated, even for disabled crtc's. Conditionally calling plane_commit caused more issues than it solved.
> plane->fb should be clearly moved out of the commit hooks to where the
> rest of the state gets swapped (assuming we can't just get rid of it
I completely agree, but this becomes a lot easier when all transitional helpers are gone.

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

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

* Re: [PATCH v3 00/19] Convert to atomic, part 3.
  2015-06-19 22:29 ` [PATCH v3 00/19] Convert to atomic, part 3 Matt Roper
@ 2015-06-22 12:31   ` Daniel Vetter
  0 siblings, 0 replies; 39+ messages in thread
From: Daniel Vetter @ 2015-06-22 12:31 UTC (permalink / raw)
  To: Matt Roper; +Cc: intel-gfx

On Fri, Jun 19, 2015 at 03:29:37PM -0700, Matt Roper wrote:
> On Mon, Jun 15, 2015 at 12:33:37PM +0200, Maarten Lankhorst wrote:
> > Requisites:
> > - "[PATCH] drm/atomic: pass old crtc state to atomic_begin/flush."
> > 
> > This patch series converts plane updates and cdclk updates to atomic,
> > but still doesn't touch the hw readout code, which was regressing a lot.
> > 
> > The fixes in this series are needed to support proper hw readout, and can
> > be applied on top of topic/atomic-conversion.
> > 
> > In particular, this fixes the following bugs:
> > - https://bugs.freedesktop.org/show_bug.cgi?id=90874
> >   Needs atomic CDCLK as part of state, before any plane checks,
> >   or scalers will not work correctly.
> > - https://bugs.freedesktop.org/show_bug.cgi?id=90868
> >   It shows a problem with plane visibility on resume.
> >   This is fixed by calcing plane states correctly across modeset.
> >   There's also a problem with DPLL 0 failing to lock, I hope that's
> >   fixed by cdclk changes, but it might have been a bug in the reverted
> >   atomic hw readout patch too.
> 
> I've spent the last week looking over these and I don't see any major
> functional problems so I think these are probably ready for merging.  A
> couple patches got into areas of the code I'm not super familiar with,
> but I've also done quite a bit of testing of this series (on IVB) and
> haven't run into issues, so that increases my confidence.
> 
> I think there was one incorrectly identified function parameter I called
> out on one of the early scaler patches, but with a sensible parameter
> rename there, you can consider these
> 
> Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
> Tested-by(IVB): Matt Roper <matthew.d.roper@intel.com>

All merged to dinq, thanks for patches&review.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

* Re: [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell
  2015-06-22 10:08         ` Maarten Lankhorst
@ 2015-06-22 12:33           ` Daniel Vetter
  0 siblings, 0 replies; 39+ messages in thread
From: Daniel Vetter @ 2015-06-22 12:33 UTC (permalink / raw)
  To: Maarten Lankhorst; +Cc: intel-gfx

On Mon, Jun 22, 2015 at 12:08:36PM +0200, Maarten Lankhorst wrote:
> >>> Why are we still commiting planes on a disabled pipes?
> >>>
> >>> The way I envisioned the modeset path looking is something like this:
> >>>
> >>> 1. atomically disable all planes for pipes getting disabled
> >>> 2. disable all pipes that need disabling
> >>> 3. enable all pipes that need enabling
> >>> 4. atomically update all planes that require it on now active pipes
> >>>
> >>>
> >> I looked for other ways to do this, but they were ugly. Only updating sw state in commit_planes for disabled crtc's made things a lot cleaner without worrying about special cases.
> > The commit hooks shouldn't update any sw state.

I looked at that a bit and the plane disabling (i.e. step 2 above) doesn't
touch state objects. plane->fb is still a bit a sorry state since
apparently page_flip won't update this properly. There's even a TODO about
this in drm_atomic_helper_page_flip, I guess I should finally address this
one asap.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

end of thread, other threads:[~2015-06-22 12:31 UTC | newest]

Thread overview: 39+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-15 10:33 [PATCH v3 00/19] Convert to atomic, part 3 Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 01/19] drm/i915: Use crtc state in intel_modeset_pipe_config Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 02/19] drm/i915: Clean up intel_atomic_setup_scalers slightly Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 03/19] drm/i915: Add a simple atomic crtc check function, v2 Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 04/19] drm/i915: Move scaler setup to check crtc " Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 05/19] drm/i915: Assign a new pll from the crtc check " Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 06/19] drm/i915: Split skl_update_scaler, v3 Maarten Lankhorst
2015-06-18  1:48   ` Matt Roper
2015-06-18  5:42     ` Maarten Lankhorst
2015-06-18  6:51       ` Daniel Vetter
2015-06-22  7:50         ` [PATCH v3.5 06/19] drm/i915: Split skl_update_scaler, v4 Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 07/19] drm/i915: Split plane updates of crtc->atomic into a helper, v2 Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 08/19] drm/i915: clean up plane commit functions Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 09/19] drm/i915: clean up atomic plane check functions, v2 Maarten Lankhorst
2015-06-18  1:48   ` Matt Roper
2015-06-22  7:23     ` Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 10/19] drm/i915: remove force argument from disable_plane Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 11/19] drm/i915: move detaching scalers to begin_crtc_commit, v2 Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 12/19] drm/i915: Move crtc commit updates to separate functions Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 13/19] drm/i915: Do not run most checks when there's no modeset Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 14/19] drm/i915: Handle disabling planes better, v2 Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 15/19] drm/i915: atomic plane updates in a nutshell Maarten Lankhorst
2015-06-18 14:21   ` Matt Roper
2015-06-19  3:57     ` Maarten Lankhorst
2015-06-18 15:28   ` Ville Syrjälä
2015-06-19  4:01     ` Maarten Lankhorst
2015-06-22  9:49       ` Ville Syrjälä
2015-06-22 10:08         ` Maarten Lankhorst
2015-06-22 12:33           ` Daniel Vetter
2015-06-15 10:33 ` [PATCH v3 16/19] drm/i915: Update less state during modeset Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 17/19] drm/i915: Make setting color key atomic Maarten Lankhorst
2015-06-18 14:21   ` Matt Roper
2015-06-19  4:03     ` Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 18/19] drm/i915: Remove transitional references from intel_plane_atomic_check Maarten Lankhorst
2015-06-18 14:21   ` Matt Roper
2015-06-19  4:05     ` Maarten Lankhorst
2015-06-15 10:33 ` [PATCH v3 19/19] drm/i915: Make cdclk part of the atomic state Maarten Lankhorst
2015-06-19 22:29 ` [PATCH v3 00/19] Convert to atomic, part 3 Matt Roper
2015-06-22 12:31   ` Daniel Vetter

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.