All of lore.kernel.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel.vetter@ffwll.ch>
To: DRI Development <dri-devel@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@intel.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Subject: [PATCH 09/38] drm: Consolidate connector arrays in drm_atomic_state
Date: Thu,  2 Jun 2016 00:06:32 +0200	[thread overview]
Message-ID: <1464818821-5736-10-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1464818821-5736-1-git-send-email-daniel.vetter@ffwll.ch>

It's kinda pointless to have 2 separate mallocs for these. And when we
add more per-connector state in the future it's even more pointless.

Right now there's no such thing planned, but both Gustavo's per-crtc
fence patches, and some nonblocking commit helpers I'm playing around
with will add more per-crtc stuff. It makes sense to also consolidate
connectors, just for consistency.

In the future we can use this to store a pointer to the preceeding
state, making an atomic update entirely free-standing. This will be
needed to be able to queue them up with a depth > 1.

Cc: Gustavo Padovan <gustavo@padovan.org>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
 drivers/gpu/drm/drm_atomic.c        | 27 +++++++++------------------
 drivers/gpu/drm/drm_atomic_helper.c |  2 +-
 include/drm/drm_atomic.h            | 10 +++++-----
 include/drm/drm_crtc.h              | 11 +++++++----
 4 files changed, 22 insertions(+), 28 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index c204ef32df16..8ca0ae21287f 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -44,7 +44,6 @@
 void drm_atomic_state_default_release(struct drm_atomic_state *state)
 {
 	kfree(state->connectors);
-	kfree(state->connector_states);
 	kfree(state->crtcs);
 	kfree(state->crtc_states);
 	kfree(state->planes);
@@ -139,15 +138,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
 	DRM_DEBUG_ATOMIC("Clearing atomic state %p\n", state);
 
 	for (i = 0; i < state->num_connector; i++) {
-		struct drm_connector *connector = state->connectors[i];
+		struct drm_connector *connector = state->connectors[i].ptr;
 
 		if (!connector)
 			continue;
 
 		connector->funcs->atomic_destroy_state(connector,
-						       state->connector_states[i]);
-		state->connectors[i] = NULL;
-		state->connector_states[i] = NULL;
+						       state->connectors[i].state);
+		state->connectors[i].ptr = NULL;
+		state->connectors[i].state = NULL;
 		drm_connector_unreference(connector);
 	}
 
@@ -897,8 +896,7 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
 	index = drm_connector_index(connector);
 
 	if (index >= state->num_connector) {
-		struct drm_connector **c;
-		struct drm_connector_state **cs;
+		struct __drm_connnectors_state *c;
 		int alloc = max(index + 1, config->num_connector);
 
 		c = krealloc(state->connectors, alloc * sizeof(*state->connectors), GFP_KERNEL);
@@ -909,26 +907,19 @@ drm_atomic_get_connector_state(struct drm_atomic_state *state,
 		memset(&state->connectors[state->num_connector], 0,
 		       sizeof(*state->connectors) * (alloc - state->num_connector));
 
-		cs = krealloc(state->connector_states, alloc * sizeof(*state->connector_states), GFP_KERNEL);
-		if (!cs)
-			return ERR_PTR(-ENOMEM);
-
-		state->connector_states = cs;
-		memset(&state->connector_states[state->num_connector], 0,
-		       sizeof(*state->connector_states) * (alloc - state->num_connector));
 		state->num_connector = alloc;
 	}
 
-	if (state->connector_states[index])
-		return state->connector_states[index];
+	if (state->connectors[index].state)
+		return state->connectors[index].state;
 
 	connector_state = connector->funcs->atomic_duplicate_state(connector);
 	if (!connector_state)
 		return ERR_PTR(-ENOMEM);
 
 	drm_connector_reference(connector);
-	state->connector_states[index] = connector_state;
-	state->connectors[index] = connector;
+	state->connectors[index].state = connector_state;
+	state->connectors[index].ptr = connector;
 	connector_state->state = state;
 
 	DRM_DEBUG_ATOMIC("Added [CONNECTOR:%d] %p state to %p\n",
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 872dbc844d69..70504cbb3a9a 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1570,7 +1570,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
 
 	for_each_connector_in_state(state, connector, conn_state, i) {
 		connector->state->state = state;
-		swap(state->connector_states[i], connector->state);
+		swap(state->connectors[i].state, connector->state);
 		connector->state->state = NULL;
 	}
 
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 4e97186293be..37478adb6a16 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -106,7 +106,7 @@ drm_atomic_get_existing_connector_state(struct drm_atomic_state *state,
 	if (index >= state->num_connector)
 		return NULL;
 
-	return state->connector_states[index];
+	return state->connectors[index].state;
 }
 
 /**
@@ -175,11 +175,11 @@ int __must_check drm_atomic_check_only(struct drm_atomic_state *state);
 int __must_check drm_atomic_commit(struct drm_atomic_state *state);
 int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
 
-#define for_each_connector_in_state(state, connector, connector_state, __i) \
+#define for_each_connector_in_state(__state, connector, connector_state, __i) \
 	for ((__i) = 0;							\
-	     (__i) < (state)->num_connector &&				\
-	     ((connector) = (state)->connectors[__i],			\
-	     (connector_state) = (state)->connector_states[__i], 1); 	\
+	     (__i) < (__state)->num_connector &&				\
+	     ((connector) = (__state)->connectors[__i].ptr,			\
+	     (connector_state) = (__state)->connectors[__i].state, 1); 	\
 	     (__i)++)							\
 		for_each_if (connector)
 
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index 5bffb5c86ea8..d4c46bfe4142 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1694,6 +1694,11 @@ struct drm_bridge {
 	void *driver_private;
 };
 
+struct __drm_connnectors_state {
+	struct drm_connector *ptr;
+	struct drm_connector_state *state;
+};
+
 /**
  * struct drm_atomic_state - the global state object for atomic updates
  * @dev: parent DRM device
@@ -1705,8 +1710,7 @@ struct drm_bridge {
  * @crtcs: pointer to array of CRTC pointers
  * @crtc_states: pointer to array of CRTC states pointers
  * @num_connector: size of the @connectors and @connector_states arrays
- * @connectors: pointer to array of connector pointers
- * @connector_states: pointer to array of connector states pointers
+ * @connectors: pointer to array of structures with per-connector data
  * @acquire_ctx: acquire context for this atomic modeset state update
  */
 struct drm_atomic_state {
@@ -1719,8 +1723,7 @@ struct drm_atomic_state {
 	struct drm_crtc **crtcs;
 	struct drm_crtc_state **crtc_states;
 	int num_connector;
-	struct drm_connector **connectors;
-	struct drm_connector_state **connector_states;
+	struct __drm_connnectors_state *connectors;
 
 	struct drm_modeset_acquire_ctx *acquire_ctx;
 };
-- 
2.8.1

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

  parent reply	other threads:[~2016-06-01 22:06 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-01 22:06 [PATCH 00/38] nonblocking atomic commits for everyone! Daniel Vetter
2016-06-01 22:06 ` [PATCH 01/38] drm/atomic-helper: use for_each_*_in_state more Daniel Vetter
2016-06-02 11:26   ` Maarten Lankhorst
2016-06-01 22:06 ` [PATCH 02/38] drm/i915: Use drm_atomic_get_existing_plane_state Daniel Vetter
2016-06-02 11:25   ` Maarten Lankhorst
2016-06-02 13:40     ` Daniel Vetter
2016-06-01 22:06 ` [PATCH 03/38] drm/msm: Use for_each_*_in_state Daniel Vetter
2016-06-02 13:13   ` Maarten Lankhorst
2016-06-01 22:06 ` [PATCH 04/38] drm/rcar-du: " Daniel Vetter
2016-06-02 13:14   ` Maarten Lankhorst
2016-06-02 13:48     ` Daniel Vetter
2016-06-02 21:08   ` Laurent Pinchart
2016-06-01 22:06 ` [PATCH 05/38] drm/vc4: Use for_each_plane_in_state Daniel Vetter
2016-06-02 13:15   ` Maarten Lankhorst
2016-06-01 22:06 ` [PATCH 06/38] drm/omap: " Daniel Vetter
2016-06-02 13:23   ` Maarten Lankhorst
2016-06-02 13:50     ` Daniel Vetter
2016-06-02 21:08   ` Laurent Pinchart
2016-06-01 22:06 ` [PATCH 07/38] drm/exynos: Use for_each_crtc_in_state Daniel Vetter
2016-06-02 13:23   ` Maarten Lankhorst
2016-06-01 22:06 ` [PATCH 08/38] drm/atomic: Add __drm_atomic_get_current_plane_state Daniel Vetter
2016-06-02 13:41   ` Maarten Lankhorst
2016-06-02 14:21   ` [PATCH] " Daniel Vetter
2016-06-02 14:43     ` Maarten Lankhorst
2016-06-02 14:59       ` Daniel Vetter
2016-06-02 14:47     ` Eric Engestrom
2016-06-01 22:06 ` Daniel Vetter [this message]
2016-06-01 22:06 ` [PATCH 10/38] drm: Consolidate plane arrays in drm_atomic_state Daniel Vetter
2016-06-01 22:06 ` [PATCH 11/38] drm: Consolidate crtc " Daniel Vetter
2016-06-02 14:42   ` Maarten Lankhorst
2016-06-02 15:20     ` Daniel Vetter
2016-06-01 22:06 ` [PATCH 12/38] drm/fence: add fence to drm_pending_event Daniel Vetter
2016-06-02 18:49   ` Sean Paul
2016-06-02 20:15     ` Daniel Vetter
2016-06-01 22:06 ` [PATCH 13/38] drm/atomic-helper: Massage swap_state signature somewhat Daniel Vetter
2016-06-01 22:06 ` [PATCH 14/38] drm/arc: Nuke event_list Daniel Vetter
2016-06-01 22:06   ` Daniel Vetter
2016-06-01 22:06 ` [PATCH 15/38] drm/arc: Actually bother with handling atomic events Daniel Vetter
2016-06-01 22:06   ` Daniel Vetter
2016-06-01 22:06 ` [PATCH 16/38] drm/hdlcd: Clean up crtc hooks Daniel Vetter
2016-06-02 13:33   ` Daniel Vetter
2016-06-01 22:06 ` [PATCH 17/38] drm/hdlcd: Fix up crtc_state->event handling Daniel Vetter
2016-06-01 22:06 ` [PATCH 18/38] drm/fsl-du: Implement some semblance of vblank event handling Daniel Vetter
2016-06-03 17:43   ` Stefan Agner
2016-06-01 22:06 ` [PATCH 19/38] drm/hisilicon: " Daniel Vetter
2016-06-17  2:09   ` Xinliang Liu
2016-06-17  7:23     ` Daniel Vetter
2016-06-17  8:38       ` Xinliang Liu
2016-06-17 12:24         ` Daniel Vetter
2016-06-21  1:32           ` Xinliang Liu
2016-06-21  7:19             ` Daniel Vetter
2016-06-22  2:50               ` Xinliang Liu
2016-06-01 22:06 ` [PATCH 20/38] drm/sun4i: " Daniel Vetter
2016-06-01 22:06 ` [PATCH 21/38] drm/atomic: kerneldoc for drm_atomic_crtc_needs_modeset Daniel Vetter
2016-06-01 22:06 ` [PATCH 22/38] drm/atomic-helper: nonblocking commit support Daniel Vetter
2016-06-02  9:56   ` [PATCH 1/2] drm/atomic: Add struct drm_crtc_commit to track async updates Daniel Vetter
2016-06-02  9:56     ` [PATCH 2/2] drm/atomic-helper: nonblocking commit support Daniel Vetter
2016-06-01 22:06 ` [PATCH 23/38] drm/hdlcd: Use helper support for nonblocking commits Daniel Vetter
2016-06-01 22:06 ` [PATCH 24/38] drm/arc: Implement nonblocking commit correctly Daniel Vetter
2016-06-01 22:06   ` Daniel Vetter
2016-06-01 22:06 ` [PATCH 25/38] drm/i915: Signal drm events for atomic Daniel Vetter
2016-06-01 22:06 ` [PATCH 26/38] drm/i915: Roll out the helper nonblock tracking Daniel Vetter
2016-06-01 22:06 ` [PATCH 27/38] drm/i915: nonblocking commit Daniel Vetter
2016-06-01 22:06 ` [PATCH 28/38] drm/i915: Use atomic commits for legacy page_flips Daniel Vetter
2016-06-01 22:06 ` [PATCH 29/38] drm/i915: Move fb_bits updating later in atomic_commit Daniel Vetter
2016-06-01 22:06 ` [PATCH 30/38] drm/rockchip: Disarm vop->is_enabled Daniel Vetter
2016-06-01 22:06 ` [PATCH 31/38] drm/rockchip: Fix crtc_state->event signalling Daniel Vetter
2016-06-01 22:06 ` [PATCH 32/38] drm/rockchip: convert to helper nonblocking atomic commit Daniel Vetter
2016-06-01 22:06 ` [PATCH 33/38] drm/rockchip: Nuke pending event handling in preclose Daniel Vetter
2016-06-01 22:06 ` [PATCH 34/38] drm/virtio: Don't reinvent a flipping wheel Daniel Vetter
2016-06-01 22:06 ` [PATCH 35/38] drm: Replace fb_helper->atomic with mode_config->atomic_commit Daniel Vetter
2016-06-01 22:06 ` [PATCH 36/38] drm: Resurrect atomic rmfb code Daniel Vetter
2016-06-01 22:07 ` [PATCH 37/38] drm/sti: Don't call drm_helper_disable_unused_functions Daniel Vetter
2016-06-17 10:04   ` Benjamin Gaignard
2016-06-17 12:27     ` Daniel Vetter
2016-06-01 22:07 ` [PATCH 38/38] drm/crtc-helper: disable_unused_functions really isn't for atomic Daniel Vetter
2016-06-02 13:10 ` ✗ Ro.CI.BAT: failure for nonblocking atomic commits for everyone! Patchwork

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=1464818821-5736-10-git-send-email-daniel.vetter@ffwll.ch \
    --to=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@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.