All of lore.kernel.org
 help / color / mirror / Atom feed
From: ville.syrjala@linux.intel.com
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH 71/81] drm/i915: Eliminate swap_old_new() hack in the atomic code
Date: Wed, 12 Dec 2012 18:16:38 +0200	[thread overview]
Message-ID: <1355329008-31459-72-git-send-email-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <1355329008-31459-1-git-send-email-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Use the new_crtc and new_encoder pointes inside the intel_encoder and
intel_connector structures instead of swapping the crtc and encoder
pointers in the drm base structures around the disable calls.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/i915/intel_atomic.c |  115 ++++++++++++++--------------------
 1 files changed, 47 insertions(+), 68 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_atomic.c b/drivers/gpu/drm/i915/intel_atomic.c
index 3717e89..3f093d6 100644
--- a/drivers/gpu/drm/i915/intel_atomic.c
+++ b/drivers/gpu/drm/i915/intel_atomic.c
@@ -115,43 +115,57 @@ struct intel_atomic_state {
 	struct drm_encoder *saved_encoders;
 };
 
-static void update_connectors_bitmask(struct drm_crtc *crtc,
+static void update_connectors_bitmask(struct intel_crtc *intel_crtc,
 				      unsigned long *connectors_bitmask)
 {
-	struct drm_device *dev = crtc->dev;
-	struct drm_connector *connector;
+	struct drm_device *dev = intel_crtc->base.dev;
+	struct intel_connector *intel_connector;
 	unsigned int i = 0;
 
 	*connectors_bitmask = 0;
 
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
-		if (connector->encoder && connector->encoder->crtc == crtc)
+	list_for_each_entry(intel_connector, &dev->mode_config.connector_list, base.head) {
+		if (intel_connector->new_encoder &&
+		    intel_connector->new_encoder->new_crtc == intel_crtc)
 			__set_bit(i, connectors_bitmask);
 
 		i++;
 	}
 }
 
-static void update_encoders_bitmask(struct drm_crtc *crtc,
+static void update_encoders_bitmask(struct intel_crtc *intel_crtc,
 				    unsigned long *encoders_bitmask)
 {
-	struct drm_device *dev = crtc->dev;
-	struct drm_encoder *encoder;
+	struct drm_device *dev = intel_crtc->base.dev;
+	struct intel_encoder *intel_encoder;
 	unsigned int i = 0;
 
 	*encoders_bitmask = 0;
 
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
-		if (encoder->crtc == crtc)
+	list_for_each_entry(intel_encoder, &dev->mode_config.encoder_list, base.head) {
+		if (intel_encoder->new_crtc == intel_crtc)
 			__set_bit(i, encoders_bitmask);
 
 		i++;
 	}
 }
 
+static bool intel_encoder_in_use(struct intel_encoder *intel_encoder)
+{
+	struct drm_device *dev = intel_encoder->base.dev;
+	struct intel_connector *intel_connector;
+
+	list_for_each_entry(intel_connector, &dev->mode_config.connector_list, base.head)
+		if (intel_connector->new_encoder == intel_encoder)
+			return true;
+
+	return false;
+}
+
 static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, int count_ids)
 {
 	struct drm_crtc *crtc = s->crtc;
+	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
 	struct drm_device *dev = crtc->dev;
 	struct drm_connector *connectors[count_ids];
 	struct drm_connector *connector;
@@ -184,6 +198,9 @@ static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, i
 	}
 
 	list_for_each_entry(connector, &dev->mode_config.connector_list, head) {
+		struct intel_connector *intel_connector = to_intel_connector(connector);
+		struct intel_encoder *intel_encoder;
+
 		for (i = 0; i < count_ids; i++) {
 			if (connector == connectors[i])
 				break;
@@ -192,25 +209,28 @@ static int process_connectors(struct intel_crtc_state *s, const uint32_t *ids, i
 		/* this connector isn't in the set */
 		if (i == count_ids) {
 			/* remove the link to the encoder if this crtc was set to drive it */
-			if (connector->encoder && connector->encoder->crtc == crtc)
-				connector->encoder = NULL;
+			if (intel_connector->new_encoder &&
+			    intel_connector->new_encoder->new_crtc == intel_crtc)
+				intel_connector->new_encoder = NULL;
 			continue;
 		}
 
-		encoder = intel_best_encoder(connector);
+		intel_encoder = to_intel_encoder(intel_best_encoder(connector));
 
-		connector->encoder = encoder;
-		encoder->crtc = crtc;
+		intel_connector->new_encoder = intel_encoder;
+		intel_encoder->new_crtc = intel_crtc;
 	}
 
 	/* prune dangling encoder->crtc links pointing to this crtc  */
 	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
-		if (encoder->crtc == crtc && !drm_helper_encoder_in_use(encoder))
-			encoder->crtc = NULL;
+		struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
+
+		if (intel_encoder->new_crtc == intel_crtc && !intel_encoder_in_use(intel_encoder))
+			intel_encoder->new_crtc = NULL;
 	}
 
-	update_connectors_bitmask(s->crtc, &s->connectors_bitmask);
-	update_encoders_bitmask(s->crtc, &s->encoders_bitmask);
+	update_connectors_bitmask(intel_crtc, &s->connectors_bitmask);
+	update_encoders_bitmask(intel_crtc, &s->encoders_bitmask);
 
 	return 0;
 }
@@ -232,19 +252,6 @@ static size_t intel_atomic_state_size(const struct drm_device *dev)
 		num_plane * sizeof state->saved_planes[0];
 }
 
-
-static void populate_old(struct drm_device *dev)
-{
-	struct drm_encoder *encoder;
-	struct drm_connector *connector;
-
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
-		encoder->old_crtc = encoder->crtc;
-
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head)
-		connector->old_encoder = connector->encoder;
-}
-
 static void *intel_atomic_begin(struct drm_device *dev, struct drm_file *file,
 				uint32_t flags, uint64_t user_data)
 {
@@ -275,8 +282,6 @@ static void *intel_atomic_begin(struct drm_device *dev, struct drm_file *file,
 	state->saved_crtcs = (struct intel_crtc *)(state->saved_encoders + num_encoder);
 	state->saved_planes = (struct drm_plane *)(state->saved_crtcs + num_crtc);
 
-	populate_old(dev);
-
 	i = 0;
 	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) {
 		struct intel_crtc_state *s = &state->crtc[i++];
@@ -297,8 +302,8 @@ static void *intel_atomic_begin(struct drm_device *dev, struct drm_file *file,
 		s->old.x = crtc->x;
 		s->old.y = crtc->y;
 
-		update_connectors_bitmask(crtc, &s->connectors_bitmask);
-		update_encoders_bitmask(crtc, &s->encoders_bitmask);
+		update_connectors_bitmask(intel_crtc, &s->connectors_bitmask);
+		update_encoders_bitmask(intel_crtc, &s->encoders_bitmask);
 
 		s->old.connectors_bitmask = s->connectors_bitmask;
 		s->old.encoders_bitmask = s->encoders_bitmask;
@@ -1045,39 +1050,11 @@ static void queue_remaining_events(struct drm_device *dev, struct intel_atomic_s
 	}
 }
 
-static void swap_old_new(struct drm_device *dev,
-			 struct intel_atomic_state *s)
-{
-	struct drm_encoder *encoder;
-	struct drm_connector *connector;
-	int i;
-
-	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head)
-		swap(encoder->crtc, encoder->old_crtc);
-
-	list_for_each_entry(connector, &dev->mode_config.connector_list, head)
-		swap(connector->encoder, connector->old_encoder);
-
-	for (i = 0; i < dev->mode_config.num_crtc; i++) {
-		struct intel_crtc_state *st = &s->crtc[i];
-		struct drm_crtc *crtc = st->crtc;
-
-		swap(crtc->enabled, st->old.enabled);
-	}
-}
-
 static int apply_config(struct drm_device *dev,
 			struct intel_atomic_state *s)
 {
 	int i, ret;
 
-	/*
-	 * FIXME
-`	 * Hackish way to make crtc_disable() see the current
-	 * state (actually just some select pieces of it).
-	 */
-	swap_old_new(dev, s);
-
 	for (i = 0; i < dev->mode_config.num_crtc; i++) {
 		struct intel_crtc_state *st = &s->crtc[i];
 
@@ -1097,8 +1074,7 @@ static int apply_config(struct drm_device *dev,
 		crtc_prepare(st, st->crtc);
 	}
 
-	/* Undo the hack above. */
-	swap_old_new(dev, s);
+	intel_modeset_commit_output_state(dev);
 
 	for (i = 0; i < dev->mode_config.num_crtc; i++) {
 		struct intel_crtc_state *st = &s->crtc[i];
@@ -1204,6 +1180,9 @@ static void restore_state(struct drm_device *dev,
 	list_for_each_entry(plane, &dev->mode_config.plane_list, head)
 		*plane = s->saved_planes[i++];
 
+	/* must restore the new_crtc and new_encoder pointers as well */
+	intel_modeset_update_staged_output_state(dev);
+
 	/* FIXME props etc. */
 
 	/* was the hardware state clobbered? */
@@ -1318,8 +1297,9 @@ static int check_crtc(struct intel_crtc_state *s)
 
 	list_for_each_entry(encoder, &dev->mode_config.encoder_list, head) {
 		const struct drm_encoder_helper_funcs *encoder_funcs = encoder->helper_private;
+		struct intel_encoder *intel_encoder = to_intel_encoder(encoder);
 
-		if (encoder->crtc != crtc)
+		if (intel_encoder->new_crtc != intel_crtc)
 			continue;
 
 		if (!encoder_funcs->mode_fixup(encoder, &crtc->mode, &crtc->hwmode))
@@ -1693,7 +1673,6 @@ static int intel_atomic_commit(struct drm_device *dev, void *state)
 
 	update_props(dev, s);
 
-	intel_modeset_update_staged_output_state(dev);
 
 	return 0;
 }
-- 
1.7.8.6

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2012-12-12 16:16 UTC|newest]

Thread overview: 85+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-12 16:15 [PATCH 00/81] drm/i915: Atomic mode setting / page flip, yet again ville.syrjala
2012-12-12 16:15 ` [PATCH 01/81] drm: Add struct drm_region and assorted utility functions ville.syrjala
2012-12-12 16:15 ` [PATCH 02/81] drm: Add drm_calc_{hscale, vscale}() " ville.syrjala
2012-12-12 16:15 ` [PATCH 03/81] drm: Keep a copy of last plane coordinates ville.syrjala
2012-12-12 16:15 ` [PATCH 04/81] drm: Add restore_fbdev_mode() hook to drm_fb_helper ville.syrjala
2012-12-12 16:15 ` [PATCH 05/81] drm: Export drm_property_create_blob() and drm_property_destroy_blob() ville.syrjala
2012-12-12 16:15 ` [PATCH 06/81] drm: Allow signed values for range properties ville.syrjala
2012-12-12 16:15 ` [PATCH 07/81] drm: Allow drm_mode_object_find() to look up an object of any type ville.syrjala
2012-12-12 16:15 ` [PATCH 08/81] drm: Export drm_encoder_crtc_ok ville.syrjala
2012-12-12 16:15 ` [PATCH 09/81] drm: Export drm_crtc_prepare_encoders() ville.syrjala
2012-12-12 16:15 ` [PATCH 10/81] drm: Refactor object property check code ville.syrjala
2012-12-12 16:15 ` [PATCH 11/81] drm: Export mode<->umode conversion functions ville.syrjala
2012-12-12 16:15 ` [PATCH 12/81] drm: Make blobs resizeable ville.syrjala
2012-12-12 16:15 ` [PATCH 13/81] drm: Add drm_flip helper ville.syrjala
2012-12-12 16:15 ` [PATCH 14/81] drm: Add mode_blob and connector_ids_blob to drm_crtc ville.syrjala
2012-12-12 16:15 ` [PATCH 15/81] drm: Add the atomic modeset ioctl ville.syrjala
2012-12-12 16:15 ` [PATCH 16/81] drm/i915: Use drm_format_plane_cpp() rather than bits_per_pixel/8 ville.syrjala
2012-12-12 16:15 ` [PATCH 17/81] drm/i915: Implement proper clipping for video sprites ville.syrjala
2012-12-12 16:15 ` [PATCH 18/81] drm/i915: Implement restore_fbdev_mode hook ville.syrjala
2012-12-12 16:15 ` [PATCH 19/81] drm/i915: Split clipping and checking from update_plane hook ville.syrjala
2012-12-12 16:15 ` [PATCH 20/81] drm/i915: Factor out i9xx_compute_clocks() like ironlake_compute_clocks() ville.syrjala
2012-12-12 16:15 ` [PATCH 21/81] drm/i915: Consitify adjusted_mode parameter ville.syrjala
2012-12-12 16:15 ` [PATCH 22/81] drm/i915: Add intel_check_clock() ville.syrjala
2012-12-12 16:15 ` [PATCH 23/81] drm/i915: store cursor_handle in struct intel_crtc ville.syrjala
2012-12-12 16:15 ` [PATCH 24/81] drm/i915: split cursor setting code into prepare/commit/unref parts ville.syrjala
2012-12-12 16:15 ` [PATCH 25/81] drm/i915: unstatic cursor functions for use with atomic modesetting ville.syrjala
2012-12-12 16:15 ` [PATCH 26/81] drm/i915: Unstatic intel_finish_fb() ville.syrjala
2012-12-12 16:15 ` [PATCH 27/81] drm/i915: Pull intel_pipe_set_base() out of the crtc_mode_set() functions ville.syrjala
2012-12-12 16:15 ` [PATCH 28/81] drm/i915: Unstatic intel_crtc_update_sarea() ville.syrjala
2012-12-12 16:15 ` [PATCH 29/81] drm/i915: Unstatic intel_crtc_update_sarea_pos() ville.syrjala
2012-12-12 16:15 ` [PATCH 30/81] drm/i915: Constify mode argument to intel_modeset_adjusted_mode() ville.syrjala
2012-12-12 16:15 ` [PATCH 31/81] drm/i915: Unstatic intel_crtc_mode_fixup() ville.syrjala
2012-12-12 16:15 ` [PATCH 32/81] drm/i915: Introduce intel_plane_regs ville.syrjala
2012-12-12 16:16 ` [PATCH 33/81] drm/i915: Split primary plane update_plane() into calc+commit phases ville.syrjala
2012-12-12 16:16 ` [PATCH 34/81] drm/i915: Split sprite " ville.syrjala
2012-12-12 16:16 ` [PATCH 35/81] drm/i915: Implement atomic modesetting ville.syrjala
2012-12-12 16:16 ` [PATCH 36/81] drm/i915: Add support for atomic modesetting completion events ville.syrjala
2012-12-12 16:16 ` [PATCH 37/81] drm/i915: Add atomic page flip support ville.syrjala
2012-12-12 16:16 ` [PATCH 38/81] drm/i915: Unstatic intel_enable_primary() and intel_disable_primary() ville.syrjala
2012-12-12 16:16 ` [PATCH 39/81] drm/i915: Respect primary_disabled in crtc_enable() ville.syrjala
2012-12-12 16:16 ` [PATCH 40/81] drm/i915: Enable/disable primary plane in calc_plane() ville.syrjala
2012-12-12 16:16 ` [PATCH 41/81] drm/i915: Add primary plane disable logic to atomic mode setting code ville.syrjala
2012-12-12 16:16 ` [PATCH 42/81] drm: Add missing EXPORT_SYMBOL()s for drm_flip ville.syrjala
2012-12-12 16:16 ` [PATCH 43/81] drm/i915: Clear flip helpers for sprites too ville.syrjala
2012-12-12 16:16 ` [PATCH 44/81] drm/i915: Refactor property handling in atomic code ville.syrjala
2012-12-12 16:16 ` [PATCH 45/81] drm/i915: Move standard properties under mode_config ville.syrjala
2012-12-12 16:16 ` [PATCH 46/81] drm_crtc_helper: Update standard crtc properties after modeset ville.syrjala
2012-12-12 16:16 ` [PATCH 47/81] drm: Update standard plane properties after update_plane/disable_plane ville.syrjala
2012-12-12 16:16 ` [PATCH 48/81] drm/i915: Update CRTC properties after modeset ville.syrjala
2012-12-12 16:16 ` [PATCH 49/81] drm: Move standard crtc/plane prop handling to drm_crtc.c ville.syrjala
2012-12-12 16:16 ` [PATCH 50/81] drm/i915: Use intel_best_encoder() directly ville.syrjala
2012-12-12 16:16 ` [PATCH 51/81] drm/i915: Unstatic intel_modeset_update_staged_output_state() ville.syrjala
2012-12-12 16:16 ` [PATCH 52/81] drm/i915: Update new_crtc and new_encoder fields after atomic modeset ville.syrjala
2012-12-12 16:16 ` [PATCH 53/81] drm/i915: Update connector DPMS state after an " ville.syrjala
2012-12-12 16:16 ` [PATCH 54/81] drm/i915: Kill the pending_flip counter manipulations ville.syrjala
2012-12-12 16:16 ` [PATCH 55/81] drm/i915: Don't mark cursor as pinned, when we don't have a cursor bo ville.syrjala
2012-12-12 16:16 ` [PATCH 56/81] drm/i915: Fix sprite_scaling_enabled for multiple sprites ville.syrjala
2012-12-12 16:16 ` [PATCH 57/81] drm/i915: Fix hiding the cursor with atomic ioctl ville.syrjala
2012-12-12 16:16 ` [PATCH 58/81] drm/i915: Fix plane src rectangle dirty check ville.syrjala
2012-12-12 16:16 ` [PATCH 59/81] drm/i915: Send atomic completion events even if nothing changed ville.syrjala
2012-12-12 16:16 ` [PATCH 60/81] drm/i915: Unpin old fbs only when appropriate ville.syrjala
2012-12-12 16:16 ` [PATCH 61/81] drm/i915: Remove stale prototypes form atomic code ville.syrjala
2012-12-12 16:16 ` [PATCH 62/81] drm/i915: Unstatic i915_gem_check_olr() ville.syrjala
2012-12-12 16:16 ` [PATCH 63/81] drm/i915: Refactor atomic flip code ville.syrjala
2012-12-12 16:16 ` [PATCH 64/81] drm/i915: Implement a non-blocking GPU synchronization mechanism for atomic page flips ville.syrjala
2012-12-12 16:16 ` [PATCH 65/81] drm/i915: Release all atomic flips when GPU hangs ville.syrjala
2012-12-12 16:16 ` [PATCH 66/81] drm/i915: Make a copy of the calculated plane regs ville.syrjala
2012-12-12 16:16 ` [PATCH 67/81] drm/i915: Clear pending flips in haswell_crtc_disable() ville.syrjala
2012-12-12 16:16 ` [PATCH 68/81] drm/i915: Drop all flips waiting for the GPU when the CRTC is about to be disabled ville.syrjala
2012-12-12 16:16 ` [PATCH 69/81] drm/i915: Refactor flip preaparation ville.syrjala
2012-12-12 16:16 ` [PATCH 70/81] drm/i915: Unstatic intel_modeset_commit_output_state() ville.syrjala
2012-12-12 16:16 ` ville.syrjala [this message]
2012-12-12 16:16 ` [PATCH 72/81] drm: Drop old_crtc and old_encoder pointers ville.syrjala
2012-12-12 16:16 ` [PATCH 73/81] drm/i915: Use new_crtc when checking if CRTC is in use ville.syrjala
2012-12-12 16:16 ` [PATCH 74/81] drm/i915: Add some TODO items to the atomic code ville.syrjala
2012-12-12 16:16 ` [PATCH 75/81] drm/i915: Drop some stale FIXMEs from " ville.syrjala
2012-12-12 16:16 ` [PATCH 76/81] drm/i915: Add pin count trace point ville.syrjala
2012-12-12 16:16 ` [PATCH 77/81] drm/i915: Add trace points for flip queue length ville.syrjala
2012-12-12 16:16 ` [PATCH 78/81] HACK: drm/i915: Make non-blocking GPU synchronization optional ville.syrjala
2012-12-12 16:16 ` [PATCH 79/81] drm/i915: Add some timing debugs to atomic flips ville.syrjala
2012-12-12 16:16 ` [PATCH 80/81] drm/i915: Add post flush DSL readout for surflive debug ville.syrjala
2012-12-12 16:16 ` [PATCH 81/81] drm/i915: Add trace point for atomic flip vblank evade ville.syrjala
2012-12-13 14:17 ` [PATCH 00/81] drm/i915: Atomic mode setting / page flip, yet again Daniel Vetter
2012-12-13 14:33   ` Ville Syrjälä
2012-12-14 16:28 ` Ville Syrjälä

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=1355329008-31459-72-git-send-email-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --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 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.