From: Daniel Stone <daniels@collabora.com>
To: dri-devel@lists.freedesktop.org
Subject: [RFC PATCH 32/37] drm: atomic_helper: Reference, not duplicate, modes
Date: Thu, 19 Mar 2015 04:33:31 +0000 [thread overview]
Message-ID: <1426739616-10635-32-git-send-email-daniels@collabora.com> (raw)
In-Reply-To: <1426739616-10635-1-git-send-email-daniels@collabora.com>
Take a reference to existing modes, rather than duplicating them to
create new ones.
Signed-off-by: Daniel Stone <daniels@collabora.com>
---
drivers/gpu/drm/drm_atomic_helper.c | 49 ++++++++++++++++++-------------------
1 file changed, 24 insertions(+), 25 deletions(-)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index bc7b629..f5ee83c 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -260,7 +260,12 @@ mode_fixup(struct drm_atomic_state *state)
if (!crtc_state || !crtc_state->mode_changed)
continue;
- drm_mode_copy(&crtc_state->adjusted_mode, crtc_state->mode);
+ if (crtc_state->mode)
+ drm_mode_copy(&crtc_state->adjusted_mode,
+ crtc_state->mode);
+ else
+ memset(&crtc_state->adjusted_mode, 0,
+ sizeof(crtc_state->adjusted_mode));
}
for (i = 0; i < state->num_connector; i++) {
@@ -699,14 +704,12 @@ set_routing_links(struct drm_device *dev, struct drm_atomic_state *old_state)
if (!crtc)
continue;
- if (crtc->state->mode) {
- if (crtc->mode)
- drm_mode_destroy(dev, crtc->mode);
- crtc->mode = drm_mode_duplicate(dev, crtc->state->mode);
- } else if (crtc->mode) {
+ if (crtc->mode)
drm_mode_destroy(dev, crtc->mode);
- crtc->mode = NULL;
- }
+ crtc->mode = crtc->state->mode;
+ if (crtc->mode)
+ drm_mode_reference(crtc->mode);
+
crtc->enabled = crtc->state->enable;
crtc->x = crtc->primary->state->src_x >> 16;
crtc->y = crtc->primary->state->src_y >> 16;
@@ -731,8 +734,9 @@ crtc_set_mode(struct drm_device *dev, struct drm_atomic_state *old_state)
funcs = crtc->helper_private;
if (crtc->state->enable && funcs->mode_set_nofb) {
- DRM_DEBUG_ATOMIC("modeset on [CRTC:%d]\n",
- crtc->base.id);
+ DRM_DEBUG_ATOMIC("modeset on [CRTC:%d] [MODE:%d]\n",
+ crtc->base.id,
+ crtc->state->mode ? crtc->state->mode->base.id : 0);
funcs->mode_set_nofb(crtc);
}
@@ -1652,7 +1656,9 @@ retry:
crtc_state->active = true;
if (crtc_state->mode)
drm_mode_destroy(crtc->dev, crtc_state->mode);
- crtc_state->mode = drm_mode_duplicate(crtc->dev, set->mode);
+ crtc_state->mode = set->mode;
+ if (crtc_state->mode)
+ drm_mode_reference(crtc_state->mode);
ret = drm_atomic_set_crtc_for_plane(primary_state, crtc);
if (ret != 0)
@@ -1660,12 +1666,12 @@ retry:
drm_atomic_set_fb_for_plane(primary_state, set->fb);
primary_state->crtc_x = 0;
primary_state->crtc_y = 0;
- primary_state->crtc_h = set->mode->vdisplay;
- primary_state->crtc_w = set->mode->hdisplay;
+ primary_state->crtc_h = set->mode ? set->mode->vdisplay : 0;
+ primary_state->crtc_w = set->mode ? set->mode->hdisplay : 0;
primary_state->src_x = set->x << 16;
primary_state->src_y = set->y << 16;
- primary_state->src_h = set->mode->vdisplay << 16;
- primary_state->src_w = set->mode->hdisplay << 16;
+ primary_state->src_h = set->mode ? set->mode->vdisplay << 16 : 0;
+ primary_state->src_w = set->mode ? set->mode->hdisplay << 16 : 0;
commit:
ret = update_output_state(state, set);
@@ -2105,15 +2111,8 @@ drm_atomic_helper_crtc_duplicate_state(struct drm_crtc *crtc)
state->planes_changed = false;
state->event = NULL;
- if (crtc->state->mode) {
- state->mode =
- drm_mode_duplicate(crtc->dev,
- crtc->state->mode);
- if (!state->mode) {
- kfree(state);
- state = NULL;
- }
- }
+ if (state->mode)
+ drm_mode_reference(state->mode);
return state;
}
@@ -2130,7 +2129,7 @@ EXPORT_SYMBOL(drm_atomic_helper_crtc_duplicate_state);
void drm_atomic_helper_crtc_destroy_state(struct drm_crtc *crtc,
struct drm_crtc_state *state)
{
- kfree(state->mode);
+ drm_mode_destroy(crtc->dev, state->mode);
kfree(state);
}
EXPORT_SYMBOL(drm_atomic_helper_crtc_destroy_state);
--
2.3.2
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2015-03-19 4:34 UTC|newest]
Thread overview: 48+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-03-19 4:32 [RFC PATCH 00/37] Modesetting for atomic modesetting Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 01/37] drm: mode: Fix typo in kerneldoc Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 02/37] drm: fb_helper: Simplify exit condition Daniel Stone
2015-03-20 15:57 ` Daniel Vetter
2015-03-19 4:33 ` [RFC PATCH 03/37] drm: mode: Allow NULL modes for equality check Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 04/37] drm: crtc_helper: Update hwmode before mode_set call Daniel Stone
2015-03-20 16:05 ` Daniel Vetter
2015-03-19 4:33 ` [RFC PATCH 05/37] drm: Exynos: Remove mode validation inside mode_fixup Daniel Stone
2015-03-20 15:59 ` Daniel Vetter
2015-03-19 4:33 ` [RFC PATCH 06/37] drm: Exynos: Use hwmode for adjusted_mode Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 07/37] drm: sti: Use crtc->hwmode for adjusted mode Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 08/37] drm: ast: Split register set from get_vbios_mode_info Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 09/37] drm: ast: Split mode adjustment " Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 10/37] drm: armada: Use crtc->hwmode for adjusted mode Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 11/37] drm: bridge: Constify mode parameters Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 12/37] drm: encoder-slave: " Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 13/37] drm: connector-helper: Constify mode_valid parameter Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 14/37] drm: connector-helper: Constify mode_set parameters Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 15/37] drm: crtc-helper: " Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 16/37] drm: fb_helper: Constify modeset mode member Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 17/37] DRM: Atomic: Use pointer for mode in CRTC state Daniel Stone
2015-03-20 16:16 ` Daniel Vetter
2015-03-19 4:33 ` [RFC PATCH 18/37] DRM: CRTC: Use pointer for display mode Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 19/37] DRM: Constify crtc->mode pointer Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 20/37] DRM: mode: Rename and combine drm_crtc_convert_umode Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 21/37] DRM: mode: Un-staticise drm_mode_new_from_umode Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 22/37] DRM: mode: Un-staticise drm_crtc_convert_to_umode Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 23/37] drm: mode: Cache userspace mode representation Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 24/37] drm: mode: Use cached usermode representation Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 25/37] drm: mode: Allow userspace to fetch mode as blob Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 26/37] drm: atomic: Expose CRTC active property Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 27/37] drm: atomic: Allow setting " Daniel Stone
2015-03-20 16:21 ` Daniel Vetter
2015-03-19 4:33 ` [RFC PATCH 28/37] drm: mode: Add kref to modes Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 29/37] drm: mode: Add drm_mode_reference Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 30/37] drm: fb_helper: Reference, not duplicate, modes Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 31/37] drm: crtc_helper: " Daniel Stone
2015-03-19 4:33 ` Daniel Stone [this message]
2015-03-19 4:33 ` [RFC PATCH 33/37] drm: i915/tegra: atomic: " Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 34/37] drm: atomic: Add MODE_ID property Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 35/37] drm: property: Allow non-global blob properties Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 36/37] drm: mode: Add user object-creation ioctl Daniel Stone
2015-03-19 4:33 ` [RFC PATCH 37/37] Tegra: SOR: Don't always assume a valid mode Daniel Stone
2015-03-23 8:20 ` [RFC PATCH 00/37] Modesetting for atomic modesetting Daniel Vetter
2015-03-23 16:58 ` Daniel Stone
2015-03-24 8:55 ` Daniel Vetter
2015-03-24 22:49 ` Daniel Stone
2015-03-25 8:37 ` 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=1426739616-10635-32-git-send-email-daniels@collabora.com \
--to=daniels@collabora.com \
--cc=dri-devel@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