[Intel-gfx] [RFC PATCH 6/7] drm/i915: Always reset in intel_crtc_restore_mode

Daniel Vetter daniel at ffwll.ch
Mon Jun 22 08:25:11 PDT 2015


On Fri, Jun 19, 2015 at 10:02:29AM +0200, Maarten Lankhorst wrote:
> And get rid of things that are no longer true. This function is only
> used for forcing a modeset when encoder properties are changed.
> 
> All the existing state is fine in this case, only setting mode_changed
> will force a full recalculation here, and take all the state needed.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst at linux.intel.com>

Just to make sure we're aligned here on future work: When we start
converting over connector props we simply need to push the ->mode_changed
(or well perhaps better crtc_state->connector_changed) update if there's
anything to do into the connector's atomic_set_prop callback.

But I guess for a lot of state it's actually better to not do that, and
rely upon intel_pipe_config_compare to figure things out for us. That
means we must run pretty much all the modeset compute_config code
unconditionally, but I think that has a clear advantage of reducing
duplicated state comparisons.

I don't expect we'll ever get rid of this one since of Old Crap
encoders/connectores (dvo, sdvo, tv, ...) we'll likely never convert the
props to atomic properly.
-Daniel

> ---
>  drivers/gpu/drm/i915/intel_display.c | 62 +++++++++++-------------------------
>  1 file changed, 18 insertions(+), 44 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 942d25e7490a..796d08c4606e 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -13174,66 +13174,40 @@ void intel_crtc_restore_mode(struct drm_crtc *crtc)
>  {
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_atomic_state *state;
> -	struct intel_crtc *intel_crtc;
> -	struct intel_encoder *encoder;
> -	struct intel_connector *connector;
> -	struct drm_connector_state *connector_state;
> -	struct intel_crtc_state *crtc_state;
> +	struct drm_crtc_state *crtc_state;
>  	int ret;
>  
>  	state = drm_atomic_state_alloc(dev);
>  	if (!state) {
> -		DRM_DEBUG_KMS("[CRTC:%d] mode restore failed, out of memory",
> +		DRM_DEBUG_KMS("[CRTC:%d] crtc restore failed, out of memory",
>  			      crtc->base.id);
>  		return;
>  	}
>  
> -	state->acquire_ctx = dev->mode_config.acquire_ctx;
> -
> -	/* The force restore path in the HW readout code relies on the staged
> -	 * config still keeping the user requested config while the actual
> -	 * state has been overwritten by the configuration read from HW. We
> -	 * need to copy the staged config to the atomic state, otherwise the
> -	 * mode set will just reapply the state the HW is already in. */
> -	for_each_intel_encoder(dev, encoder) {
> -		if (encoder->base.crtc != crtc)
> -			continue;
> +	state->acquire_ctx = drm_modeset_legacy_acquire_ctx(crtc);
>  
> -		for_each_intel_connector(dev, connector) {
> -			if (connector->base.state->best_encoder != &encoder->base)
> -				continue;
> -
> -			connector_state = drm_atomic_get_connector_state(state, &connector->base);
> -			if (IS_ERR(connector_state)) {
> -				DRM_DEBUG_KMS("Failed to add [CONNECTOR:%d:%s] to state: %ld\n",
> -					      connector->base.base.id,
> -					      connector->base.name,
> -					      PTR_ERR(connector_state));
> -				continue;
> -			}
> +retry:
> +	crtc_state = drm_atomic_get_crtc_state(state, crtc);
> +	ret = PTR_ERR_OR_ZERO(crtc_state);
> +	if (!ret) {
> +		if (!crtc_state->active)
> +			goto out;
>  
> -			connector_state->crtc = crtc;
> -		}
> +		crtc_state->mode_changed = true;
> +		ret = intel_modeset_compute_config(state);
>  	}
>  
> -	for_each_intel_crtc(dev, intel_crtc) {
> -		crtc_state = intel_atomic_get_crtc_state(state, intel_crtc);
> -		if (IS_ERR(crtc_state)) {
> -			DRM_DEBUG_KMS("Failed to add [CRTC:%d] to state: %ld\n",
> -				      intel_crtc->base.base.id,
> -				      PTR_ERR(crtc_state));
> -			continue;
> -		}
> +	if (!ret)
> +		ret = intel_set_mode_checked(state);
>  
> -		if (&intel_crtc->base == crtc)
> -			drm_mode_copy(&crtc_state->base.mode, &crtc->mode);
> +	if (ret == -EDEADLK) {
> +		drm_atomic_state_clear(state);
> +		drm_modeset_backoff(state->acquire_ctx);
> +		goto retry;
>  	}
>  
> -	intel_modeset_setup_plane_state(state, crtc, &crtc->mode,
> -					crtc->primary->fb, crtc->x, crtc->y);
> -
> -	ret = intel_set_mode(state);
>  	if (ret)
> +out:
>  		drm_atomic_state_free(state);
>  }
>  
> -- 
> 2.1.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch


More information about the Intel-gfx mailing list