public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
To: dri-devel@lists.freedesktop.org
Cc: Daniel Vetter <daniel@ffwll.ch>,
	Archit Taneja <architt@codeaurora.org>,
	Jose Abreu <Jose.Abreu@synopsys.com>,
	Daniel Vetter <daniel.vetter@ffwll.ch>,
	Alexey Brodkin <Alexey.Brodkin@synopsys.com>,
	linux-kernel@vger.kernel.org,
	Carlos Palminha <CARLOS.PALMINHA@synopsys.com>
Subject: Re: [PATCH v2 7/8] drm: Use mode_valid() in atomic modeset
Date: Fri, 12 May 2017 12:53:56 +0300	[thread overview]
Message-ID: <2428951.QzsFL2NRhO@avalon> (raw)
In-Reply-To: <20170510175556.wxdrgjzdxosdnbx2@phenom.ffwll.local>

Hi Daniel,

On Wednesday 10 May 2017 19:55:56 Daniel Vetter wrote:
> On Wed, May 10, 2017 at 09:38:00PM +0530, Archit Taneja wrote:
> > On 5/9/2017 10:30 PM, Jose Abreu wrote:
> > > This patches makes use of the new mode_valid() callbacks introduced
> > > previously to validate the full video pipeline when modesetting.
> > > 
> > > This calls the connector->mode_valid(), encoder->mode_valid(),
> > > bridge->mode_valid() and crtc->mode_valid() so that we can
> > > make sure that the mode will be accepted in every components.
> > > 
> > > Signed-off-by: Jose Abreu <joabreu@synopsys.com>
> > > Cc: Carlos Palminha <palminha@synopsys.com>
> > > Cc: Alexey Brodkin <abrodkin@synopsys.com>
> > > Cc: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > Cc: Daniel Vetter <daniel.vetter@ffwll.ch>
> > > Cc: Dave Airlie <airlied@linux.ie>
> > > Cc: Andrzej Hajda <a.hajda@samsung.com>
> > > Cc: Archit Taneja <architt@codeaurora.org>
> > > ---
> > > 
> > > Changes v1->v2:
> > > 	- Removed call to connector->mode_valid (Ville, Daniel)
> > > 	- Change function name (Ville)
> > > 	- Use for_each_new_connector_in_state (Ville)
> > > 	- Do not validate if connector and mode didn't change (Ville)
> > > 	- Use new helpers to call mode_valid
> > > 	
> > >   drivers/gpu/drm/drm_atomic_helper.c | 75 +++++++++++++++++++++++++++--
> > >   1 file changed, 72 insertions(+), 3 deletions(-)
> > > 
> > > diff --git a/drivers/gpu/drm/drm_atomic_helper.c
> > > b/drivers/gpu/drm/drm_atomic_helper.c index 8be9719..19d0ea1 100644
> > > --- a/drivers/gpu/drm/drm_atomic_helper.c
> > > +++ b/drivers/gpu/drm/drm_atomic_helper.c
> > > @@ -452,6 +452,69 @@ static int handle_conflicting_encoders(struct
> > > drm_atomic_state *state,
> > >   	return 0;
> > >   }
> > > 
> > > +static enum drm_mode_status mode_valid_path(struct drm_connector
> > > *connector,
> > > +					    struct drm_encoder *encoder,
> > > +					    struct drm_crtc *crtc,
> > > +					    struct drm_display_mode *mode)
> > > +{
> > > +	enum drm_mode_status ret;
> > > +
> > > +	ret = drm_encoder_mode_valid(encoder, mode);
> > > +	if (ret != MODE_OK) {
> > > +		DRM_DEBUG_ATOMIC("[ENCODER:%d:%s] mode_valid() failed\n",
> > > +				encoder->base.id, encoder->name);
> > > +		return ret;
> > > +	}
> > > +
> > > +	ret = drm_bridge_mode_valid(encoder->bridge, mode);
> > > +	if (ret != MODE_OK) {
> > > +		DRM_DEBUG_ATOMIC("[BRIDGE] mode_valid() failed\n");
> > > +		return ret;
> > > +	}
> > > +
> > > +	ret = drm_crtc_mode_valid(crtc, mode);
> > > +	if (ret != MODE_OK) {
> > > +		DRM_DEBUG_ATOMIC("[CRTC:%d:%s] mode_valid() failed\n",
> > > +				crtc->base.id, crtc->name);
> > > +		return ret;
> > > +	}
> > > +
> > > +	return ret;
> > > +}
> > > +
> > > +static int
> > > +mode_valid(struct drm_atomic_state *state)
> > > +{
> > > +	struct drm_connector_state *conn_state;
> > > +	struct drm_connector *connector;
> > > +	int i;
> > > +
> > > +	for_each_new_connector_in_state(state, connector, conn_state, i) {
> > > +		struct drm_encoder *encoder = conn_state->best_encoder;
> > > +		struct drm_crtc *crtc = conn_state->crtc;
> > > +		struct drm_crtc_state *crtc_state;
> > > +		enum drm_mode_status mode_status;
> > > +		struct drm_display_mode *mode;
> > > +
> > > +		if (!crtc || !encoder)
> > > +			continue;
> > > +
> > > +		crtc_state = drm_atomic_get_new_crtc_state(state, crtc);
> > > +		if (!crtc_state)
> > > +			continue;
> > > +		if (!crtc_state->mode_changed && !crtc_state
> > > ->connectors_changed)
> > > +			continue;
> > > +
> > > +		mode = &crtc_state->mode;
> > > +
> > > +		mode_status = mode_valid_path(connector, encoder, crtc, mode);
> > > +		if (mode_status != MODE_OK)
> > > +			return -EINVAL;
> > > +	}
> > > +
> > > +	return 0;
> > > +}
> > > +
> > >   /**
> > >    * drm_atomic_helper_check_modeset - validate state object for modeset
> > >    changes * @dev: DRM device
> > > @@ -466,13 +529,15 @@ static int handle_conflicting_encoders(struct
> > > drm_atomic_state *state,
> > >   * 2. &drm_connector_helper_funcs.atomic_check to validate the
> > >   connector state.
> > >   * 3. If it's determined a modeset is needed then all connectors on the
> > >   affected crtc
> > >   *    crtc are added and &drm_connector_helper_funcs.atomic_check is
> > >   run on them.
> > > - * 4. &drm_bridge_funcs.mode_fixup is called on all encoder bridges.
> > > - * 5. &drm_encoder_helper_funcs.atomic_check is called to validate any
> > > encoder state.
> > > + * 4. &drm_encoder_helper_funcs.mode_valid,
> > > &drm_bridge_funcs.mode_valid and
> > > + *    &drm_crtc_helper_funcs.mode_valid are called on the affected
> > > components.
> > > + * 5. &drm_bridge_funcs.mode_fixup is called on all encoder bridges.
> > > + * 6. &drm_encoder_helper_funcs.atomic_check is called to validate any
> > > encoder state.
> > >   *    This function is only called when the encoder will be part of a
> > >   configured crtc,
> > >   *    it must not be used for implementing connector property
> > >   validation.
> > >   *    If this function is NULL,
> > >   &drm_atomic_encoder_helper_funcs.mode_fixup is called
> > >   *    instead.
> > > - * 6. &drm_crtc_helper_funcs.mode_fixup is called last, to fix up the
> > > mode with crtc constraints.
> > > + * 7. &drm_crtc_helper_funcs.mode_fixup is called last, to fix up the
> > > mode with crtc constraints.
> > >    *
> > >    * &drm_crtc_state.mode_changed is set when the input mode is changed.
> > >    * &drm_crtc_state.connectors_changed is set when a connector is added
> > >    or
> > > 
> > > @@ -617,6 +682,10 @@ static int handle_conflicting_encoders(struct
> > > drm_atomic_state *state,
> > >   			return ret;
> > >   	}
> > > 
> > > +	ret = mode_valid(state);
> > > +	if (ret)
> > > +		return ret;
> > > +
> > 
> > Since we've ensured that the modes won't fail, can mode_fixup() and
> > the mode_fixup() ops for crtc/bridge/encoders be assured to not fail
> > too? This is assuming that all drivers have moved to using the new
> > mode_valid() ops correctly.
> 
> The entire point of re-checking is that userspace can create its own modes
> and submit them to the kernel, bypassing the current
> connector->mode_valid() check. I think almost all drivers get this wrong
> unfortunately :(

How about documenting the expected driver behaviour in details ? I won't 
volunteer as I have to confess it's not clear to me what we expect from 
drivers.

-- 
Regards,

Laurent Pinchart

  reply	other threads:[~2017-05-12  9:53 UTC|newest]

Thread overview: 39+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-09 17:00 [PATCH v2 0/8] Introduce new mode validation callbacks Jose Abreu
2017-05-09 17:00 ` [PATCH v2 1/8] drm: Add crtc/encoder/bridge->mode_valid() callbacks Jose Abreu
2017-05-10  8:03   ` Daniel Vetter
2017-05-10  9:05     ` Jose Abreu
2017-05-12  8:24     ` Laurent Pinchart
2017-05-15  6:46       ` Daniel Vetter
2017-05-09 17:00 ` [PATCH v2 2/8] drm: Add drm_crtc_mode_valid() Jose Abreu
2017-05-10  7:59   ` Daniel Vetter
2017-05-10  8:57     ` Jose Abreu
2017-05-10 15:12       ` Daniel Vetter
2017-05-09 17:00 ` [PATCH v2 3/8] drm: Add drm_encoder_mode_valid() Jose Abreu
2017-05-09 17:00 ` [PATCH v2 4/8] drm: Add drm_connector_mode_valid() Jose Abreu
2017-05-09 17:00 ` [PATCH v2 5/8] drm: Use new mode_valid() helpers in connector probe helper Jose Abreu
2017-05-10  8:01   ` Daniel Vetter
2017-05-10  8:59     ` Jose Abreu
2017-05-12  9:35   ` Laurent Pinchart
2017-05-12 16:06     ` Jose Abreu
2017-05-14 11:04       ` Laurent Pinchart
2017-05-15  6:47         ` Daniel Vetter
2017-05-15  7:05           ` Laurent Pinchart
2017-05-16  5:11             ` Jose Abreu
2017-05-09 17:00 ` [PATCH v2 6/8] drm: Introduce drm_bridge_mode_valid() Jose Abreu
2017-05-10 13:41   ` Ville Syrjälä
2017-05-10 14:01     ` Jose Abreu
2017-05-10 14:07       ` Jose Abreu
2017-05-10 15:14     ` Daniel Vetter
2017-05-12  9:38       ` Laurent Pinchart
2017-05-12 10:50         ` Archit Taneja
2017-05-12 11:01           ` Laurent Pinchart
2017-05-15  4:18             ` Archit Taneja
2017-05-15  6:49             ` Daniel Vetter
2017-05-09 17:00 ` [PATCH v2 7/8] drm: Use mode_valid() in atomic modeset Jose Abreu
2017-05-10 16:08   ` Archit Taneja
2017-05-10 17:55     ` Daniel Vetter
2017-05-12  9:53       ` Laurent Pinchart [this message]
2017-05-15  6:50         ` Daniel Vetter
2017-05-09 17:00 ` [PATCH v2 8/8] drm: arc: Use crtc->mode_valid() callback Jose Abreu
2017-05-12  9:57   ` Laurent Pinchart
2017-05-15  1:40     ` Jose Abreu

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=2428951.QzsFL2NRhO@avalon \
    --to=laurent.pinchart@ideasonboard.com \
    --cc=Alexey.Brodkin@synopsys.com \
    --cc=CARLOS.PALMINHA@synopsys.com \
    --cc=Jose.Abreu@synopsys.com \
    --cc=architt@codeaurora.org \
    --cc=daniel.vetter@ffwll.ch \
    --cc=daniel@ffwll.ch \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-kernel@vger.kernel.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