* [PATCH] drm/atomic-helper: Reject attempts at re-stealing encoders
@ 2015-12-03 9:49 Daniel Vetter
2015-12-03 9:50 ` Daniel Vetter
0 siblings, 1 reply; 2+ messages in thread
From: Daniel Vetter @ 2015-12-03 9:49 UTC (permalink / raw)
To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter
This can happen when we run out of encoders for a multi-crtc modeset,
or also when userspace is silly and tries to clone multiple connectors
that need the same encoder on the same crtc.
Reported-and-Tested-and-Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
---
drivers/gpu/drm/drm_atomic_helper.c | 28 ++++++++++++++++++++++++++++
1 file changed, 28 insertions(+)
diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
index d6d80b30f751..aff616dc6caf 100644
--- a/drivers/gpu/drm/drm_atomic_helper.c
+++ b/drivers/gpu/drm/drm_atomic_helper.c
@@ -86,6 +86,27 @@ drm_atomic_helper_plane_changed(struct drm_atomic_state *state,
}
}
+static bool
+check_pending_encoder_assignment(struct drm_atomic_state *state,
+ struct drm_encoder *new_encoder,
+ struct drm_connector *new_connector)
+{
+ struct drm_connector *connector;
+ struct drm_connector_state *conn_state;
+ int i;
+
+ for_each_connector_in_state(state, connector, conn_state, i) {
+ if (conn_state->best_encoder != new_encoder)
+ continue;
+
+ /* encoder already assigned and we're trying to re-steal it! */
+ if (connector->state->best_encoder != conn_state->best_encoder)
+ return false;
+ }
+
+ return true;
+}
+
static struct drm_crtc *
get_current_crtc_for_encoder(struct drm_device *dev,
struct drm_encoder *encoder)
@@ -235,6 +256,13 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx)
return 0;
}
+ if (!check_pending_encoder_assignment(state, new_encoder, connector)) {
+ DRM_DEBUG_ATOMIC("Encoder for [CONNECTOR:%d:%s] already assigned\n",
+ connector->base.id,
+ connector->name);
+ return -EINVAL;
+ }
+
encoder_crtc = get_current_crtc_for_encoder(state->dev,
new_encoder);
--
2.5.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/dri-devel
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] drm/atomic-helper: Reject attempts at re-stealing encoders
2015-12-03 9:49 [PATCH] drm/atomic-helper: Reject attempts at re-stealing encoders Daniel Vetter
@ 2015-12-03 9:50 ` Daniel Vetter
0 siblings, 0 replies; 2+ messages in thread
From: Daniel Vetter @ 2015-12-03 9:50 UTC (permalink / raw)
To: Intel Graphics Development; +Cc: Daniel Vetter, DRI Development, Daniel Vetter
On Thu, Dec 03, 2015 at 10:49:14AM +0100, Daniel Vetter wrote:
> This can happen when we run out of encoders for a multi-crtc modeset,
> or also when userspace is silly and tries to clone multiple connectors
> that need the same encoder on the same crtc.
>
> Reported-and-Tested-and-Reviewed-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Cc: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com>
And also pulled into drm-misc, it prevents fireworks on i915 with
Maarten's latest atomic work.
-Daniel
> ---
> drivers/gpu/drm/drm_atomic_helper.c | 28 ++++++++++++++++++++++++++++
> 1 file changed, 28 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_atomic_helper.c b/drivers/gpu/drm/drm_atomic_helper.c
> index d6d80b30f751..aff616dc6caf 100644
> --- a/drivers/gpu/drm/drm_atomic_helper.c
> +++ b/drivers/gpu/drm/drm_atomic_helper.c
> @@ -86,6 +86,27 @@ drm_atomic_helper_plane_changed(struct drm_atomic_state *state,
> }
> }
>
> +static bool
> +check_pending_encoder_assignment(struct drm_atomic_state *state,
> + struct drm_encoder *new_encoder,
> + struct drm_connector *new_connector)
> +{
> + struct drm_connector *connector;
> + struct drm_connector_state *conn_state;
> + int i;
> +
> + for_each_connector_in_state(state, connector, conn_state, i) {
> + if (conn_state->best_encoder != new_encoder)
> + continue;
> +
> + /* encoder already assigned and we're trying to re-steal it! */
> + if (connector->state->best_encoder != conn_state->best_encoder)
> + return false;
> + }
> +
> + return true;
> +}
> +
> static struct drm_crtc *
> get_current_crtc_for_encoder(struct drm_device *dev,
> struct drm_encoder *encoder)
> @@ -235,6 +256,13 @@ update_connector_routing(struct drm_atomic_state *state, int conn_idx)
> return 0;
> }
>
> + if (!check_pending_encoder_assignment(state, new_encoder, connector)) {
> + DRM_DEBUG_ATOMIC("Encoder for [CONNECTOR:%d:%s] already assigned\n",
> + connector->base.id,
> + connector->name);
> + return -EINVAL;
> + }
> +
> encoder_crtc = get_current_crtc_for_encoder(state->dev,
> new_encoder);
>
> --
> 2.5.1
>
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-12-03 9:51 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-03 9:49 [PATCH] drm/atomic-helper: Reject attempts at re-stealing encoders Daniel Vetter
2015-12-03 9:50 ` Daniel Vetter
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox