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 11/38] drm: Consolidate crtc arrays in drm_atomic_state
Date: Thu,  2 Jun 2016 00:06:34 +0200	[thread overview]
Message-ID: <1464818821-5736-12-git-send-email-daniel.vetter@ffwll.ch> (raw)
In-Reply-To: <1464818821-5736-1-git-send-email-daniel.vetter@ffwll.ch>

It's silly to have 2 mallocs when we could tie these two together.

Also, Gustavo adds another one in his per-crtc out-fence patches. And
I want to add more stuff here for nonblocking commit helpers.

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        | 17 ++++++-----------
 drivers/gpu/drm/drm_atomic_helper.c |  2 +-
 include/drm/drm_atomic.h            | 10 +++++-----
 include/drm/drm_crtc.h              |  8 ++++++--
 4 files changed, 18 insertions(+), 19 deletions(-)

diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index dce4627aa1c6..5093d81f60f7 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -45,7 +45,6 @@ void drm_atomic_state_default_release(struct drm_atomic_state *state)
 {
 	kfree(state->connectors);
 	kfree(state->crtcs);
-	kfree(state->crtc_states);
 	kfree(state->planes);
 }
 EXPORT_SYMBOL(drm_atomic_state_default_release);
@@ -70,10 +69,6 @@ drm_atomic_state_init(struct drm_device *dev, struct drm_atomic_state *state)
 			       sizeof(*state->crtcs), GFP_KERNEL);
 	if (!state->crtcs)
 		goto fail;
-	state->crtc_states = kcalloc(dev->mode_config.num_crtc,
-				     sizeof(*state->crtc_states), GFP_KERNEL);
-	if (!state->crtc_states)
-		goto fail;
 	state->planes = kcalloc(dev->mode_config.num_total_plane,
 				sizeof(*state->planes), GFP_KERNEL);
 	if (!state->planes)
@@ -146,15 +141,15 @@ void drm_atomic_state_default_clear(struct drm_atomic_state *state)
 	}
 
 	for (i = 0; i < config->num_crtc; i++) {
-		struct drm_crtc *crtc = state->crtcs[i];
+		struct drm_crtc *crtc = state->crtcs[i].ptr;
 
 		if (!crtc)
 			continue;
 
 		crtc->funcs->atomic_destroy_state(crtc,
-						  state->crtc_states[i]);
-		state->crtcs[i] = NULL;
-		state->crtc_states[i] = NULL;
+						  state->crtcs[i].state);
+		state->crtcs[i].ptr = NULL;
+		state->crtcs[i].state = NULL;
 	}
 
 	for (i = 0; i < config->num_total_plane; i++) {
@@ -264,8 +259,8 @@ drm_atomic_get_crtc_state(struct drm_atomic_state *state,
 	if (!crtc_state)
 		return ERR_PTR(-ENOMEM);
 
-	state->crtc_states[index] = crtc_state;
-	state->crtcs[index] = crtc;
+	state->crtcs[index].state = crtc_state;
+	state->crtcs[index].ptr = crtc;
 	crtc_state->state = state;
 
 	DRM_DEBUG_ATOMIC("Added [CRTC:%d:%s] %p state to %p\n",
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 451b86ecd253..b2d276d97d32 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -1576,7 +1576,7 @@ void drm_atomic_helper_swap_state(struct drm_device *dev,
 
 	for_each_crtc_in_state(state, crtc, crtc_state, i) {
 		crtc->state->state = state;
-		swap(state->crtc_states[i], crtc->state);
+		swap(state->crtcs[i].state, crtc->state);
 		crtc->state->state = NULL;
 	}
 
diff --git a/include/drm/drm_atomic.h b/include/drm/drm_atomic.h
index 8e616d39353b..d9504dfcd1cc 100644
--- a/include/drm/drm_atomic.h
+++ b/include/drm/drm_atomic.h
@@ -71,7 +71,7 @@ static inline struct drm_crtc_state *
 drm_atomic_get_existing_crtc_state(struct drm_atomic_state *state,
 				   struct drm_crtc *crtc)
 {
-	return state->crtc_states[drm_crtc_index(crtc)];
+	return state->crtcs[drm_crtc_index(crtc)].state;
 }
 
 /**
@@ -183,11 +183,11 @@ int __must_check drm_atomic_nonblocking_commit(struct drm_atomic_state *state);
 	     (__i)++)							\
 		for_each_if (connector)
 
-#define for_each_crtc_in_state(state, crtc, crtc_state, __i)	\
+#define for_each_crtc_in_state(__state, crtc, crtc_state, __i)	\
 	for ((__i) = 0;						\
-	     (__i) < (state)->dev->mode_config.num_crtc &&	\
-	     ((crtc) = (state)->crtcs[__i],			\
-	     (crtc_state) = (state)->crtc_states[__i], 1);	\
+	     (__i) < (__state)->dev->mode_config.num_crtc &&	\
+	     ((crtc) = (__state)->crtcs[__i].ptr,			\
+	     (crtc_state) = (__state)->crtcs[__i].state, 1);	\
 	     (__i)++)						\
 		for_each_if (crtc_state)
 
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h
index c7c2b3fa7179..d5d5e343531e 100644
--- a/include/drm/drm_crtc.h
+++ b/include/drm/drm_crtc.h
@@ -1699,6 +1699,11 @@ struct __drm_planes_state {
 	struct drm_plane_state *state;
 };
 
+struct __drm_crtcs_state {
+	struct drm_crtc *ptr;
+	struct drm_crtc_state *state;
+};
+
 struct __drm_connnectors_state {
 	struct drm_connector *ptr;
 	struct drm_connector_state *state;
@@ -1723,8 +1728,7 @@ struct drm_atomic_state {
 	bool legacy_cursor_update : 1;
 	bool legacy_set_config : 1;
 	struct __drm_planes_state *planes;
-	struct drm_crtc **crtcs;
-	struct drm_crtc_state **crtc_states;
+	struct __drm_crtcs_state *crtcs;
 	int num_connector;
 	struct __drm_connnectors_state *connectors;
 
-- 
2.8.1

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

  parent reply	other threads:[~2016-06-01 22:07 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 ` [PATCH 09/38] drm: Consolidate connector arrays in drm_atomic_state Daniel Vetter
2016-06-01 22:06 ` [PATCH 10/38] drm: Consolidate plane " Daniel Vetter
2016-06-01 22:06 ` Daniel Vetter [this message]
2016-06-02 14:42   ` [PATCH 11/38] drm: Consolidate crtc " 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-12-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.