public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Intel Graphics Development <intel-gfx@lists.freedesktop.org>
Cc: Daniel Vetter <daniel.vetter@ffwll.ch>,
	DRI Development <dri-devel@lists.freedesktop.org>,
	Daniel Vetter <daniel.vetter@intel.com>
Subject: Re: [PATCH] drm/atomic-helper: Reject attempts at re-stealing encoders
Date: Thu, 3 Dec 2015 10:50:57 +0100	[thread overview]
Message-ID: <20151203095057.GP10243@phenom.ffwll.local> (raw)
In-Reply-To: <1449136154-11588-1-git-send-email-daniel.vetter@ffwll.ch>

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

      reply	other threads:[~2015-12-03  9:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 message]

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=20151203095057.GP10243@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel.vetter@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