intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
Subject: [PATCH 69/81] drm/i915: push commit_output_state past the crtc/encoder preparing
Date: Wed, 11 Jul 2012 16:28:52 +0200	[thread overview]
Message-ID: <1342016944-23395-70-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1342016944-23395-1-git-send-email-daniel.vetter@ffwll.ch>

With this change we can (finally!) rip out a few of the temporary hacks
and clean up a few other things:
- Kill intel_crtc_prepare_encoders, now unused.
- Kill the hacks in the crtc_disable/enable functions to always call the
  encoder callbacks, we now always call the crtc functions with the right
  encoder -> crtc links.
- Also push down the crtc->enable, encoder and connector dpms state
  updates. Unfortunately we can't add a WARN in the crtc_disable
  callbacks to ensure that the crtc is always still enabled when
  disabling an output pipe - the crtc sanitizer of the hw readout path
  can hit this when it needs to disable an active pipe without any
  enabled outputs.
- Only call crtc->disable if the pipe is already enabled - again avoids
  running afoul of the new WARN.

v2: Copy&paste our own version of crtc_in_use, too.

v3: We need to update the dpms an encoder->connectors_active states,
too.

v4: I've forgotten to kill the unconditional encoder->disable calls in
the crtc_disable functions.

Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
---
 drivers/gpu/drm/i915/intel_display.c |   88 +++++++++++++++++++---------------
 1 files changed, 50 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 2815dc9..45db3e7 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -3190,10 +3190,8 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
 
 	WARN_ON(!crtc->enabled);
 
-	/* XXX: For compatability with the crtc helper code, call the encoder's
-	 * enable function unconditionally for now. */
 	if (intel_crtc->active)
-		goto encoders;
+		return;
 
 	intel_crtc->active = true;
 	intel_update_watermarks(dev);
@@ -3241,7 +3239,6 @@ static void ironlake_crtc_enable(struct drm_crtc *crtc)
 
 	intel_crtc_update_cursor(crtc, true);
 
-encoders:
 	for_each_encoder_on_crtc(dev, crtc, encoder)
 		encoder->enable(encoder);
 
@@ -3259,14 +3256,13 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
 	int plane = intel_crtc->plane;
 	u32 reg, temp;
 
-	/* XXX: For compatability with the crtc helper code, call the encoder's
-	 * disable function unconditionally for now. */
-	for_each_encoder_on_crtc(dev, crtc, encoder)
-		encoder->disable(encoder);
 
 	if (!intel_crtc->active)
 		return;
 
+	for_each_encoder_on_crtc(dev, crtc, encoder)
+		encoder->disable(encoder);
+
 	intel_crtc_wait_for_pending_flips(crtc);
 	drm_vblank_off(dev, pipe);
 	intel_crtc_update_cursor(crtc, false);
@@ -3387,10 +3383,8 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)
 
 	WARN_ON(!crtc->enabled);
 
-	/* XXX: For compatability with the crtc helper code, call the encoder's
-	 * enable function unconditionally for now. */
 	if (intel_crtc->active)
-		goto encoders;
+		return;
 
 	intel_crtc->active = true;
 	intel_update_watermarks(dev);
@@ -3406,7 +3400,6 @@ static void i9xx_crtc_enable(struct drm_crtc *crtc)
 	intel_crtc_dpms_overlay(intel_crtc, true);
 	intel_crtc_update_cursor(crtc, true);
 
-encoders:
 	for_each_encoder_on_crtc(dev, crtc, encoder)
 		encoder->enable(encoder);
 }
@@ -3420,14 +3413,13 @@ static void i9xx_crtc_disable(struct drm_crtc *crtc)
 	int pipe = intel_crtc->pipe;
 	int plane = intel_crtc->plane;
 
-	/* XXX: For compatability with the crtc helper code, call the encoder's
-	 * disable function unconditionally for now. */
-	for_each_encoder_on_crtc(dev, crtc, encoder)
-		encoder->disable(encoder);
 
 	if (!intel_crtc->active)
 		return;
 
+	for_each_encoder_on_crtc(dev, crtc, encoder)
+		encoder->disable(encoder);
+
 	/* Give the overlay scaler a chance to disable if it's on this pipe */
 	intel_crtc_wait_for_pending_flips(crtc);
 	drm_vblank_off(dev, pipe);
@@ -6631,18 +6623,6 @@ static bool intel_encoder_crtc_ok(struct drm_encoder *encoder,
 	return false;
 }
 
-static void
-intel_crtc_prepare_encoders(struct drm_device *dev)
-{
-	struct intel_encoder *encoder;
-
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, base.head) {
-		/* Disable unused encoders */
-		if (encoder->base.crtc == NULL)
-			encoder->disable(encoder);
-	}
-}
-
 /**
  * intel_modeset_update_staged_output_state
  *
@@ -6815,6 +6795,18 @@ intel_modeset_affected_pipes(struct drm_crtc *crtc, unsigned *modeset_pipes,
 	*prepare_pipes &= ~(*disable_pipes);
 }
 
+static bool intel_crtc_in_use(struct drm_crtc *crtc)
+{
+	struct drm_encoder *encoder;
+	struct drm_device *dev = crtc->dev;
+
+	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
+		if (encoder->crtc == crtc)
+			return true;
+
+	return false;
+}
+
 #define for_each_intel_crtc_masked(dev, mask, intel_crtc) \
 	list_for_each_entry((intel_crtc), \
 			    &(dev)->mode_config.crtc_list, \
@@ -6832,6 +6824,7 @@ bool intel_crtc_set_mode(struct drm_crtc *crtc,
 	struct drm_encoder_helper_funcs *encoder_funcs;
 	struct drm_encoder *encoder;
 	struct intel_crtc *intel_crtc;
+	struct drm_connector *connector;
 	unsigned disable_pipes, prepare_pipes, modeset_pipes;
 	bool ret = true;
 
@@ -6844,12 +6837,6 @@ bool intel_crtc_set_mode(struct drm_crtc *crtc,
 	for_each_intel_crtc_masked(dev, disable_pipes, intel_crtc)
 		intel_crtc_disable(&intel_crtc->base);
 
-	intel_modeset_commit_output_state(dev);
-
-	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
-			    base.head)
-		intel_crtc->base.enabled = drm_helper_crtc_in_use(crtc);
-
 	saved_hwmode = crtc->hwmode;
 	saved_mode = crtc->mode;
 
@@ -6864,12 +6851,12 @@ bool intel_crtc_set_mode(struct drm_crtc *crtc,
 		if (IS_ERR(adjusted_mode)) {
 			return false;
 		}
-
-		intel_crtc_prepare_encoders(dev);
 	}
 
-	for_each_intel_crtc_masked(dev, prepare_pipes, intel_crtc)
-		dev_priv->display.crtc_disable(&intel_crtc->base);
+	for_each_intel_crtc_masked(dev, prepare_pipes, intel_crtc) {
+		if (intel_crtc->base.enabled)
+			dev_priv->display.crtc_disable(&intel_crtc->base);
+	}
 
 	if (modeset_pipes) {
 		crtc->mode = *mode;
@@ -6877,6 +6864,31 @@ bool intel_crtc_set_mode(struct drm_crtc *crtc,
 		crtc->y = y;
 	}
 
+	/* Only after disabling all output pipelines that will be changed can we
+	 * update the the output configuration. */
+	intel_modeset_commit_output_state(dev);
+
+	/* Update computed state. */
+	list_for_each_entry(intel_crtc, &dev->mode_config.crtc_list,
+			    base.head) {
+		intel_crtc->base.enabled = intel_crtc_in_use(&intel_crtc->base);
+	}
+
+	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+		if (!connector->encoder || !connector->encoder->crtc)
+			continue;
+
+		intel_crtc = to_intel_crtc(connector->encoder->crtc);
+
+		if (prepare_pipes & (1 << intel_crtc->pipe))
+			connector->dpms = DRM_MODE_DPMS_ON;
+
+		to_intel_encoder(connector->encoder)->connectors_active = true;
+
+		printk("adjusting dpms for connector %i to %i\n", connector->base.id,
+		       connector->dpms);
+	}
+
 	/* Set up the DPLL and any encoders state that needs to adjust or depend
 	 * on the DPLL.
 	 */
-- 
1.7.7.6

  parent reply	other threads:[~2012-07-11 15:36 UTC|newest]

Thread overview: 107+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-11 14:27 [PATCH 00/81] modeset rework Daniel Vetter
2012-07-11 14:27 ` [PATCH 01/81] drm/i915: add crtc->enable/disable vfuncs insted of dpms Daniel Vetter
2012-07-11 14:27 ` [PATCH 02/81] drm/i915: rip out crtc prepare/commit indirection Daniel Vetter
2012-07-12 14:44   ` Daniel Vetter
2012-07-11 14:27 ` [PATCH 03/81] drm/i915: add direct encoder disable/enable infrastructure Daniel Vetter
2012-07-11 14:27 ` [PATCH 04/81] drm/i915: add missing gen2 pipe A quirk entries Daniel Vetter
2012-07-11 14:27 ` [PATCH 05/81] drm/i915: rip out the overlay pipe A workaround Daniel Vetter
2012-07-11 14:27 ` [PATCH 06/81] drm/i915: prepare load-detect pipe code for dpms changes Daniel Vetter
2012-07-11 14:27 ` [PATCH 07/81] drm/i915/hdmi: convert to encoder->disable/enable Daniel Vetter
2012-07-11 14:27 ` [PATCH 08/81] drm/i915/tv: convert to encoder enable/disable Daniel Vetter
2012-07-11 14:27 ` [PATCH 09/81] drm/i915/lvds: ditch ->prepare special case Daniel Vetter
2012-07-22 14:52   ` Daniel Vetter
2012-07-22 16:32     ` Takashi Iwai
2012-07-22 19:20       ` Daniel Vetter
2012-07-11 14:27 ` [PATCH 10/81] drm/i915/lvds: convert to encoder disable/enable Daniel Vetter
2012-07-11 14:27 ` [PATCH 11/81] drm/i915/dp: " Daniel Vetter
2012-07-11 14:27 ` [PATCH 12/81] drm/i915: create VLV_DSIPLAY_BASE #define Daniel Vetter
2012-07-20 12:07   ` Daniel Vetter
2012-07-11 14:27 ` [PATCH 13/81] drm/i915: group ADPA #defines together Daniel Vetter
2012-07-12 13:06   ` Paulo Zanoni
2012-07-11 14:27 ` [PATCH 14/81] drm/i915: add inte_crt->adpa_reg Daniel Vetter
2012-07-20 11:56   ` Chris Wilson
2012-07-20 12:09   ` Daniel Vetter
2012-07-11 14:27 ` [PATCH 15/81] drm/i915/crt: convert to encoder disable/enable Daniel Vetter
2012-07-11 14:27 ` [PATCH 16/81] drm/i915/sdvo: " Daniel Vetter
2012-07-11 14:28 ` [PATCH 17/81] drm/i915: simplify dvo dpms interface Daniel Vetter
2012-07-11 14:28 ` [PATCH 18/81] drm/i915/dvo: convert to encoder disable/enable Daniel Vetter
2012-07-11 14:28 ` [PATCH 19/81] drm/i915: simplify possible_clones computation Daniel Vetter
2012-07-12 18:10   ` Paulo Zanoni
2012-07-12 18:47     ` Daniel Vetter
2012-07-12 18:08       ` [PATCH] " Daniel Vetter
2012-07-12 19:48         ` Paulo Zanoni
2012-07-11 14:28 ` [PATCH 20/81] drm/i915: add port parameter to intel_hdmi_init Daniel Vetter
2012-07-12 18:19   ` [PATCH] " Daniel Vetter
2012-07-12 19:49     ` Paulo Zanoni
2012-07-17  8:43       ` Daniel Vetter
2012-07-11 14:28 ` [PATCH 21/81] drm/i915: convert dpms functions of dvo/sdvo/crt Daniel Vetter
2012-07-11 14:28 ` [PATCH 22/81] drm/i915: rip out encoder->disable/enable checks Daniel Vetter
2012-07-11 14:28 ` [PATCH 23/81] drm/i915: clean up encoder_prepare/commit Daniel Vetter
2012-07-11 14:28 ` [PATCH 24/81] drm/fb helper: don't call drm_crtc_helper_set_config Daniel Vetter
2012-07-18 15:49   ` Daniel Vetter
2012-07-18 15:50     ` Daniel Vetter
2012-07-20  1:17       ` Dave Airlie
2012-07-11 14:28 ` [PATCH 25/81] drm: remove the list_head from drm_mode_set Daniel Vetter
2012-07-20  1:23   ` Dave Airlie
2012-07-11 14:28 ` [PATCH 26/81] drm/i915: copy&paste drm_crtc_helper_set_config Daniel Vetter
2012-07-11 14:28 ` [PATCH 27/81] drm/i915: call set_base directly Daniel Vetter
2012-07-11 14:28 ` [PATCH 28/81] drm/i915: inline intel_best_encoder Daniel Vetter
2012-07-11 14:28 ` [PATCH 29/81] drm/i915: copy&paste drm_crtc_helper_set_mode Daniel Vetter
2012-07-11 14:28 ` [PATCH 30/81] drm/i915: simplify intel_crtc_prepare_encoders Daniel Vetter
2012-07-11 14:28 ` [PATCH 31/81] drm/i915: rip out encoder->prepare/commit Daniel Vetter
2012-07-11 14:28 ` [PATCH 32/81] drm/i915: call crtc functions directly Daniel Vetter
2012-07-11 14:28 ` [PATCH 33/81] drm/i915: WARN when trying to enabled an unused crtc Daniel Vetter
2012-07-11 14:28 ` [PATCH 34/81] drm/i915: Add interfaces to read out encoder/connector hw state Daniel Vetter
2012-07-11 14:28 ` [PATCH 35/81] drm/i915/dp: implement get_hw_state Daniel Vetter
2012-07-11 14:28 ` [PATCH 36/81] drm/i915/hdmi: " Daniel Vetter
2012-07-11 14:28 ` [PATCH 37/81] drm/i915/tv: " Daniel Vetter
2012-07-11 14:28 ` [PATCH 38/81] drm/i915/lvds: " Daniel Vetter
2012-07-11 14:28 ` [PATCH 39/81] drm/i915/crt: " Daniel Vetter
2012-07-11 14:28 ` [PATCH 40/81] drm/i915/sdvo: " Daniel Vetter
2012-07-11 14:28 ` [PATCH 41/81] drm/i915/dvo: " Daniel Vetter
2012-07-11 14:28 ` [PATCH 42/81] drm/i915: read out the modeset hw state at load and resume time Daniel Vetter
2012-07-11 14:28 ` [PATCH 43/81] drm/i915: check connector hw/sw state Daniel Vetter
2012-07-11 14:28 ` [PATCH 44/81] drm/i915: rip out intel_crtc->dpms_mode Daniel Vetter
2012-07-11 14:28 ` [PATCH 45/81] drm/i915: rip out intel_dp->dpms_mode Daniel Vetter
2012-07-26 18:06   ` Paulo Zanoni
2012-07-11 14:28 ` [PATCH 46/81] drm/i915: ensure the force pipe A quirk is actually followed Daniel Vetter
2012-07-11 14:28 ` [PATCH 47/81] drm/i915: introduce struct intel_set_config Daniel Vetter
2012-07-11 14:28 ` [PATCH 48/81] drm/i915: extract modeset config save/restore code Daniel Vetter
2012-07-11 14:28 ` [PATCH 49/81] drm/i915: extract intel_set_config_compute_mode_changes Daniel Vetter
2012-07-11 14:28 ` [PATCH 50/81] drm/i915: extract intel_set_config_update_output_state Daniel Vetter
2012-07-11 14:28 ` [PATCH 51/81] drm/i915: implement crtc helper semantics relied upon by the fb helper Daniel Vetter
2012-07-11 14:28 ` [PATCH 52/81] drm/i915: don't update the fb base if there is no fb Daniel Vetter
2012-07-11 14:28 ` [PATCH 53/81] drm/i915: convert pointless error checks in set_config to BUGs Daniel Vetter
2012-07-11 14:28 ` [PATCH 54/81] drm/i915: don't save all the encoder/crtc state in set_config Daniel Vetter
2012-07-11 14:28 ` [PATCH 55/81] drm/i915: stage modeset output changes Daniel Vetter
2012-07-11 14:28 ` [PATCH 56/81] drm/i915: push crtc->fb update into pipe_set_base Daniel Vetter
2012-07-11 14:28 ` [PATCH 57/81] drm/i915: remove crtc disabling special case Daniel Vetter
2012-07-11 14:28 ` [PATCH 58/81] drm/i915: move output commit and crtc disabling into set_mode Daniel Vetter
2012-07-11 14:28 ` [PATCH 59/81] drm/i915: extract adjusted mode computation Daniel Vetter
2012-07-11 14:28 ` [PATCH 60/81] drm/i915: use staged outuput config in tv->mode_fixup Daniel Vetter
2012-07-11 14:28 ` [PATCH 61/81] drm/i915: use staged outuput config in lvds->mode_fixup Daniel Vetter
2012-07-11 14:28 ` [PATCH 62/81] drm/i915: compute masks of crtcs affected in set_mode Daniel Vetter
2012-07-11 14:28 ` [PATCH 63/81] drm/i915: implement new set_mode code flow Daniel Vetter
2012-07-11 14:28 ` [PATCH 64/81] drm/i915: push commit_output_state past crtc disabling Daniel Vetter
2012-07-11 14:28 ` [PATCH 65/81] drm/i915: s/intel_encoder_disable/intel_encoder_noop Daniel Vetter
2012-07-11 14:28 ` [PATCH 66/81] drm/i915: kill a few unused things in dev_priv Daniel Vetter
2012-07-11 14:28 ` [PATCH 67/81] drm/i915: WARN if the pipe won't turn off Daniel Vetter
2012-07-11 14:28 ` [PATCH 68/81] drm/i915: switch the load detect code to the staged modeset config Daniel Vetter
2012-07-11 14:28 ` Daniel Vetter [this message]
2012-07-11 16:02   ` [PATCH] drm/i915: push commit_output_state past the crtc/encoder preparing Daniel Vetter
2012-07-11 14:28 ` [PATCH 70/81] drm/i915: disable all crtcs at suspend time Daniel Vetter
2012-07-11 14:28 ` [PATCH 71/81] drm/i915: add tons of modeset state checks Daniel Vetter
2012-07-11 17:46   ` [PATCH] " Daniel Vetter
2012-07-11 14:28 ` [PATCH 72/81] drm/i915: extract ironlake_fdi_pll_disable Daniel Vetter
2012-07-11 14:28 ` [PATCH 73/81] drm/i915: rip out intel_disable_pch_ports Daniel Vetter
2012-07-11 14:28 ` [PATCH 74/81] drm/i915: don't disable fdi links harder in ilk_crtc_enable Daniel Vetter
2012-07-11 14:28 ` [PATCH 75/81] drm/i915: don't call dpms funcs after set_mode Daniel Vetter
2012-07-11 14:28 ` [PATCH 76/81] drm/i915: update dpms property in set_mode Daniel Vetter
2012-07-11 14:29 ` [PATCH 77/81] drm/i915: add encoder->pre_enable/post_disable Daniel Vetter
2012-07-11 14:29 ` [PATCH 78/81] drm/i915: clean up the cpu edp pll special case Daniel Vetter
2012-07-11 14:29 ` [PATCH 79/81] drm/i915: robustify edp_pll_on/off Daniel Vetter
2012-07-11 17:47   ` [PATCH] " Daniel Vetter
2012-07-11 14:29 ` [PATCH 80/81] drm/i915: rip out dp port enabling cludges^Wchecks Daniel Vetter
2012-07-11 14:38 ` [PATCH 81/81] drm/i915: disable the cpu edp port after the cpu pipe Daniel Vetter
2012-07-15 13:13 ` [PATCH 00/81] modeset rework Chris Wilson
2012-07-15 14:57   ` Daniel Vetter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1342016944-23395-70-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).