From: Dave Airlie <airlied@gmail.com>
To: dri-devel@lists.freedesktop.org, intel-gfx@lists.freedesktop.org
Subject: [PATCH 4/5] drm/atomic: use connector references
Date: Wed, 27 Apr 2016 12:03:28 +1000 [thread overview]
Message-ID: <1461722609-32474-4-git-send-email-airlied@gmail.com> (raw)
In-Reply-To: <1461722609-32474-1-git-send-email-airlied@gmail.com>
From: Dave Airlie <airlied@redhat.com>
Take a reference when setting a crtc on a connecter,
also take one when duplicating if a crtc is set,
and drop one on destroy if a crtc is set.
Signed-off-by: Dave Airlie <airlied@redhat.com>
---
drivers/gpu/drm/drm_atomic.c | 11 ++++++++++-
drivers/gpu/drm/drm_atomic_helper.c | 4 ++++
2 files changed, 14 insertions(+), 1 deletion(-)
diff --git a/drivers/gpu/drm/drm_atomic.c b/drivers/gpu/drm/drm_atomic.c
index 9d5e3c8..d899dac 100644
--- a/drivers/gpu/drm/drm_atomic.c
+++ b/drivers/gpu/drm/drm_atomic.c
@@ -1159,7 +1159,7 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
struct drm_crtc *crtc)
{
struct drm_crtc_state *crtc_state;
-
+ bool had_crtc = conn_state->crtc ? true : false;
if (conn_state->crtc && conn_state->crtc != crtc) {
crtc_state = drm_atomic_get_existing_crtc_state(conn_state->state,
conn_state->crtc);
@@ -1179,6 +1179,15 @@ drm_atomic_set_crtc_for_connector(struct drm_connector_state *conn_state,
conn_state->crtc = crtc;
+ /* If we had no crtc then got one, add a reference,
+ * if we had a crtc and are going to none, drop a reference,
+ * otherwise just keep the reference we have.
+ */
+ if (!had_crtc && crtc)
+ drm_connector_reference(conn_state->connector);
+ else if (!crtc && had_crtc)
+ drm_connector_unreference(conn_state->connector);
+
if (crtc)
DRM_DEBUG_ATOMIC("Link connector state %p to [CRTC:%d:%s]\n",
conn_state, crtc->base.id, crtc->name);
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index d25abce..a29deac 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -2762,6 +2762,8 @@ __drm_atomic_helper_connector_duplicate_state(struct drm_connector *connector,
struct drm_connector_state *state)
{
memcpy(state, connector->state, sizeof(*state));
+ if (state->crtc)
+ drm_connector_reference(connector);
}
EXPORT_SYMBOL(__drm_atomic_helper_connector_duplicate_state);
@@ -2889,6 +2891,8 @@ __drm_atomic_helper_connector_destroy_state(struct drm_connector *connector,
* state will automatically do the right thing if code is ever added
* to this function.
*/
+ if (state->crtc)
+ drm_connector_unreference(connector);
}
EXPORT_SYMBOL(__drm_atomic_helper_connector_destroy_state);
--
2.5.5
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-04-27 2:03 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-04-27 2:03 [PATCH 1/5] drm/modes: add connector reference counting. (v2) Dave Airlie
2016-04-27 2:03 ` [PATCH 2/5] drm/fb_helper: add connector reference counting Dave Airlie
2016-04-27 7:33 ` [Intel-gfx] " Daniel Vetter
2016-04-27 2:03 ` [PATCH 3/5] drm/crtc: take references to connectors used in a modeset Dave Airlie
2016-04-27 7:07 ` Daniel Stone
2016-04-27 7:34 ` [Intel-gfx] " Daniel Vetter
2016-04-27 7:48 ` Daniel Vetter
2016-04-27 2:03 ` Dave Airlie [this message]
2016-04-27 7:13 ` [PATCH 4/5] drm/atomic: use connector references Daniel Stone
2016-04-27 7:47 ` [Intel-gfx] " Daniel Vetter
2016-04-27 7:22 ` Daniel Stone
2016-04-27 2:03 ` [PATCH 5/5] drm/i915/mst: use reference counted connectors. (v2) Dave Airlie
2016-04-27 7:52 ` Daniel Vetter
2016-04-27 7:28 ` [Intel-gfx] [PATCH 1/5] drm/modes: add connector reference counting. (v2) 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=1461722609-32474-4-git-send-email-airlied@gmail.com \
--to=airlied@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox