From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [PATCH v2.1 3/6] drm/atomic: Always call steal_encoder, v2.
Date: Tue, 1 Mar 2016 14:52:05 +0100 [thread overview]
Message-ID: <56D59E85.2060205@linux.intel.com> (raw)
In-Reply-To: <1456303053-28806-4-git-send-email-maarten.lankhorst@linux.intel.com>
There's no need to have a separate function to get the crtc
which is stolen, this can already be found when actually
stealing the encoder.
drm_for_each_connector already checks for connection_mutex, so
use that macro now.
Changes since v1:
- Do not check for NULL crtc in connector_state,
this may happen when a crtc is disabled and its encoder stolen.
- Because of this, use connector->state->crtc instead of conn_state->crtc.
Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
---
Oops, this patch had a WARN_ON(!conn_state->crtc); in v1,
this broke DP MST which had a legitimate reason to do so.
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index 3d1f97a832fc..72ca85b32260 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -106,25 +106,6 @@ check_pending_encoder_assignment(struct drm_atomic_state *state,
return true;
}
-static struct drm_crtc *
-get_current_crtc_for_encoder(struct drm_device *dev,
- struct drm_encoder *encoder)
-{
- struct drm_mode_config *config = &dev->mode_config;
- struct drm_connector *connector;
-
- WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
-
- drm_for_each_connector(connector, dev) {
- if (connector->state->best_encoder != encoder)
- continue;
-
- return connector->state->crtc;
- }
-
- return NULL;
-}
-
static void
set_best_encoder(struct drm_atomic_state *state,
struct drm_connector_state *conn_state,
@@ -168,38 +149,18 @@ set_best_encoder(struct drm_atomic_state *state,
static int
steal_encoder(struct drm_atomic_state *state,
- struct drm_encoder *encoder,
- struct drm_crtc *encoder_crtc)
+ struct drm_encoder *encoder)
{
- struct drm_mode_config *config = &state->dev->mode_config;
struct drm_crtc_state *crtc_state;
struct drm_connector *connector;
struct drm_connector_state *connector_state;
- /*
- * We can only steal an encoder coming from a connector, which means we
- * must already hold the connection_mutex.
- */
- WARN_ON(!drm_modeset_is_locked(&config->connection_mutex));
-
- DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], stealing it\n",
- encoder->base.id, encoder->name,
- encoder_crtc->base.id, encoder_crtc->name);
+ drm_for_each_connector(connector, state->dev) {
+ struct drm_crtc *encoder_crtc;
- crtc_state = drm_atomic_get_crtc_state(state, encoder_crtc);
- if (IS_ERR(crtc_state))
- return PTR_ERR(crtc_state);
-
- crtc_state->connectors_changed = true;
-
- list_for_each_entry(connector, &config->connector_list, head) {
if (connector->state->best_encoder != encoder)
continue;
- DRM_DEBUG_ATOMIC("Stealing encoder from [CONNECTOR:%d:%s]\n",
- connector->base.id,
- connector->name);
-
connector_state = drm_atomic_get_connector_state(state,
connector);
if (IS_ERR(connector_state))
@@ -208,7 +169,18 @@ steal_encoder(struct drm_atomic_state *state,
if (connector_state->best_encoder != encoder)
continue;
+ encoder_crtc = connector->state->crtc;
+
+ DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] in use on [CRTC:%d:%s], stealing it\n",
+ encoder->base.id, encoder->name,
+ encoder_crtc->base.id, encoder_crtc->name);
+
set_best_encoder(state, connector_state, NULL);
+
+ crtc_state = drm_atomic_get_existing_crtc_state(state, encoder_crtc);
+ crtc_state->connectors_changed = true;
+
+ return 0;
}
return 0;
@@ -221,7 +193,6 @@ update_connector_routing(struct drm_atomic_state *state,
{
const struct drm_connector_helper_funcs *funcs;
struct drm_encoder *new_encoder;
- struct drm_crtc *encoder_crtc;
struct drm_crtc_state *crtc_state;
int idx, ret;
@@ -299,17 +270,12 @@ update_connector_routing(struct drm_atomic_state *state,
return -EINVAL;
}
- encoder_crtc = get_current_crtc_for_encoder(state->dev,
- new_encoder);
-
- if (encoder_crtc) {
- ret = steal_encoder(state, new_encoder, encoder_crtc);
- if (ret) {
- DRM_DEBUG_ATOMIC("Encoder stealing failed for [CONNECTOR:%d:%s]\n",
- connector->base.id,
- connector->name);
- return ret;
- }
+ ret = steal_encoder(state, new_encoder);
+ if (ret) {
+ DRM_DEBUG_ATOMIC("Encoder stealing failed for [CONNECTOR:%d:%s]\n",
+ connector->base.id,
+ connector->name);
+ return ret;
}
if (WARN_ON(!connector_state->crtc))
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx
next prev parent reply other threads:[~2016-03-01 13:52 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-02-24 8:37 [PATCH v2 0/6] drm/atomic: Fix encoder stealing, v2 Maarten Lankhorst
2016-02-24 8:37 ` [PATCH v2 1/6] drm/atomic: Clean up update_output_state Maarten Lankhorst
2016-03-01 15:16 ` Ville Syrjälä
2016-02-24 8:37 ` [PATCH v2 2/6] drm/atomic: Pass connector and state to update_connector_routing Maarten Lankhorst
2016-03-01 15:19 ` Ville Syrjälä
2016-03-04 16:18 ` [Intel-gfx] " Daniel Vetter
2016-02-24 8:37 ` [PATCH v2 3/6] drm/atomic: Always call steal_encoder Maarten Lankhorst
2016-03-01 13:52 ` Maarten Lankhorst [this message]
2016-03-04 16:20 ` [PATCH v2.1 3/6] drm/atomic: Always call steal_encoder, v2 Daniel Vetter
2016-02-24 8:37 ` [PATCH v2 4/6] drm/atomic: Handle encoder stealing from set_config better Maarten Lankhorst
2016-03-04 16:20 ` Daniel Vetter
2016-02-24 8:37 ` [PATCH v2 5/6] drm/atomic: Handle encoder assignment conflicts in a separate check Maarten Lankhorst
2016-02-25 9:34 ` [PATCH v2.1 5/6] drm/atomic: Handle encoder assignment conflicts in a separate check, v2 Maarten Lankhorst
2016-03-01 17:21 ` [PATCH v2 5/6] drm/atomic: Handle encoder assignment conflicts in a separate check Ville Syrjälä
2016-03-01 17:45 ` [Intel-gfx] " Maarten Lankhorst
2016-03-01 17:58 ` Ville Syrjälä
2016-03-02 13:38 ` [PATCH v2.1 5/6] drm/atomic: Handle encoder assignment conflicts in a separate check, v3 Maarten Lankhorst
2016-02-24 8:37 ` [PATCH v2 6/6] drm/atomic: Clean up steal_encoder Maarten Lankhorst
2016-03-02 17:32 ` Ville Syrjälä
2016-03-02 17:36 ` 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=56D59E85.2060205@linux.intel.com \
--to=maarten.lankhorst@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox