drm/atomic-helper: Reject attempts at re-stealing encoders
Subsystems (2)
PATCH 1/1 drm/atomic-helper: Reject attempts at re-stealing encoders
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 <[email protected]>
Cc Maarten Lankhorst <[email protected]>
Signed-off-by Daniel Vetter <[email protected]>
--- drivers/gpu/drm/drm_atomic_helper.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
drivers/gpu/drm/drm_atomic_helper.c +28 -0
@@ -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);
Signature · 6 lines
2.5.1 _______________________________________________ dri-devel mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/dri-devel
Quoted 7 lines · 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 <[email protected]>Cc Maarten Lankhorst <[email protected]>Signed-off-by Daniel Vetter <[email protected]>
And also pulled into drm-misc, it prevents fireworks on i915 with Maarten's latest atomic work.
-Daniel
Quoted 53 lines
--- drivers/gpu/drm/drm_atomic_helper.c | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)drivers/gpu/drm/drm_atomic_helper.c +28
-0@@ -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);Signature · 1 line
2.5.1
Signature · 7 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch _______________________________________________ Intel-gfx mailing list [email protected] http://lists.freedesktop.org/mailman/listinfo/intel-gfx