public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
From: Daniel Vetter <daniel@ffwll.ch>
To: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH 02/15] drm/i915: Pass atomic state to crtc enable/disable functions
Date: Thu, 18 Aug 2016 15:19:37 +0200	[thread overview]
Message-ID: <20160818131937.GE6232@phenom.ffwll.local> (raw)
In-Reply-To: <1470755054-32699-3-git-send-email-maarten.lankhorst@linux.intel.com>

On Tue, Aug 09, 2016 at 05:04:01PM +0200, Maarten Lankhorst wrote:
> This is required for supporting nonblocking modesets. Iterating over
> the connector list will no longer be allowed when we don't hold
> connection_mutex, so we have to use the atomic state.
> 
> Fix disable_noatomic by populating the minimal state required to
> disable a connector.
> 
> Signed-off-by: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
> ---
>  drivers/gpu/drm/i915/i915_drv.h      |  6 ++--
>  drivers/gpu/drm/i915/intel_display.c | 56 ++++++++++++++++++++++++------------
>  2 files changed, 42 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index c36d17659ebe..6030d0edcf8f 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -628,8 +628,10 @@ struct drm_i915_display_funcs {
>  					 struct intel_initial_plane_config *);
>  	int (*crtc_compute_clock)(struct intel_crtc *crtc,
>  				  struct intel_crtc_state *crtc_state);
> -	void (*crtc_enable)(struct drm_crtc *crtc);
> -	void (*crtc_disable)(struct drm_crtc *crtc);
> +	void (*crtc_enable)(struct intel_crtc_state *pipe_config,
> +			    struct drm_atomic_state *old_state);
> +	void (*crtc_disable)(struct intel_crtc_state *old_crtc_state,
> +			     struct drm_atomic_state *old_state);
>  	void (*audio_codec_enable)(struct drm_connector *connector,
>  				   struct intel_encoder *encoder,
>  				   const struct drm_display_mode *adjusted_mode);
> diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
> index 9cbf5431c1e3..ae555b4240c6 100644
> --- a/drivers/gpu/drm/i915/intel_display.c
> +++ b/drivers/gpu/drm/i915/intel_display.c
> @@ -4694,15 +4694,15 @@ static void intel_crtc_disable_planes(struct drm_crtc *crtc, unsigned plane_mask
>  	intel_frontbuffer_flip(to_i915(dev), INTEL_FRONTBUFFER_ALL_MASK(pipe));
>  }
>  
> -static void ironlake_crtc_enable(struct drm_crtc *crtc)
> +static void ironlake_crtc_enable(struct intel_crtc_state *pipe_config,
> +				 struct drm_atomic_state *old_state)
>  {
> +	struct drm_crtc *crtc = pipe_config->base.crtc;
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  	struct intel_encoder *encoder;
>  	int pipe = intel_crtc->pipe;
> -	struct intel_crtc_state *pipe_config =
> -		to_intel_crtc_state(crtc->state);
>  
>  	if (WARN_ON(intel_crtc->active))
>  		return;
> @@ -4791,16 +4791,16 @@ static bool hsw_crtc_supports_ips(struct intel_crtc *crtc)
>  	return HAS_IPS(crtc->base.dev) && crtc->pipe == PIPE_A;
>  }
>  
> -static void haswell_crtc_enable(struct drm_crtc *crtc)
> +static void haswell_crtc_enable(struct intel_crtc_state *pipe_config,
> +				struct drm_atomic_state *old_state)
>  {
> +	struct drm_crtc *crtc = pipe_config->base.crtc;
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  	struct intel_encoder *encoder;
>  	int pipe = intel_crtc->pipe, hsw_workaround_pipe;
>  	enum transcoder cpu_transcoder = intel_crtc->config->cpu_transcoder;
> -	struct intel_crtc_state *pipe_config =
> -		to_intel_crtc_state(crtc->state);
>  
>  	if (WARN_ON(intel_crtc->active))
>  		return;
> @@ -4930,8 +4930,10 @@ static void ironlake_pfit_disable(struct intel_crtc *crtc, bool force)
>  	}
>  }
>  
> -static void ironlake_crtc_disable(struct drm_crtc *crtc)
> +static void ironlake_crtc_disable(struct intel_crtc_state *old_crtc_state,
> +				  struct drm_atomic_state *old_state)
>  {
> +	struct drm_crtc *crtc = old_crtc_state->base.crtc;
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> @@ -4993,8 +4995,10 @@ static void ironlake_crtc_disable(struct drm_crtc *crtc)
>  	intel_set_pch_fifo_underrun_reporting(dev_priv, pipe, true);
>  }
>  
> -static void haswell_crtc_disable(struct drm_crtc *crtc)
> +static void haswell_crtc_disable(struct intel_crtc_state *old_crtc_state,
> +				 struct drm_atomic_state *old_state)
>  {
> +	struct drm_crtc *crtc = old_crtc_state->base.crtc;
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> @@ -6098,14 +6102,14 @@ static void valleyview_modeset_commit_cdclk(struct drm_atomic_state *old_state)
>  	intel_display_power_put(dev_priv, POWER_DOMAIN_PIPE_A);
>  }
>  
> -static void valleyview_crtc_enable(struct drm_crtc *crtc)
> +static void valleyview_crtc_enable(struct intel_crtc_state *pipe_config,
> +				   struct drm_atomic_state *old_state)
>  {
> +	struct drm_crtc *crtc = pipe_config->base.crtc;
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  	struct intel_encoder *encoder;
> -	struct intel_crtc_state *pipe_config =
> -		to_intel_crtc_state(crtc->state);
>  	int pipe = intel_crtc->pipe;
>  
>  	if (WARN_ON(intel_crtc->active))
> @@ -6169,14 +6173,14 @@ static void i9xx_set_pll_dividers(struct intel_crtc *crtc)
>  	I915_WRITE(FP1(crtc->pipe), crtc->config->dpll_hw_state.fp1);
>  }
>  
> -static void i9xx_crtc_enable(struct drm_crtc *crtc)
> +static void i9xx_crtc_enable(struct intel_crtc_state *pipe_config,
> +			     struct drm_atomic_state *old_state)
>  {
> +	struct drm_crtc *crtc = pipe_config->base.crtc;
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
>  	struct intel_encoder *encoder;
> -	struct intel_crtc_state *pipe_config =
> -		to_intel_crtc_state(crtc->state);
>  	enum pipe pipe = intel_crtc->pipe;
>  
>  	if (WARN_ON(intel_crtc->active))
> @@ -6232,8 +6236,10 @@ static void i9xx_pfit_disable(struct intel_crtc *crtc)
>  	I915_WRITE(PFIT_CONTROL, 0);
>  }
>  
> -static void i9xx_crtc_disable(struct drm_crtc *crtc)
> +static void i9xx_crtc_disable(struct intel_crtc_state *old_crtc_state,
> +			      struct drm_atomic_state *old_state)
>  {
> +	struct drm_crtc *crtc = old_crtc_state->base.crtc;
>  	struct drm_device *dev = crtc->dev;
>  	struct drm_i915_private *dev_priv = to_i915(dev);
>  	struct intel_crtc *intel_crtc = to_intel_crtc(crtc);
> @@ -6285,6 +6291,9 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
>  	struct drm_i915_private *dev_priv = to_i915(crtc->dev);
>  	enum intel_display_power_domain domain;
>  	unsigned long domains;
> +	struct drm_atomic_state *state;
> +	struct intel_crtc_state *crtc_state;
> +	int ret;
>  
>  	if (!intel_crtc->active)
>  		return;
> @@ -6298,7 +6307,18 @@ static void intel_crtc_disable_noatomic(struct drm_crtc *crtc)
>  		to_intel_plane_state(crtc->primary->state)->visible = false;
>  	}
>  
> -	dev_priv->display.crtc_disable(crtc);
> +	state = drm_atomic_state_alloc(crtc->dev);
> +	state->acquire_ctx = crtc->dev->mode_config.acquire_ctx;

Ugh, really not nice to not pass the acquire_ctx explicitly around here.
Anyway, this is

Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch>

> +
> +	/* Everything's already locked, -EDEADLK can't happen. */
> +	crtc_state = intel_atomic_get_crtc_state(state, intel_crtc);
> +	ret = drm_atomic_add_affected_connectors(state, crtc);
> +
> +	WARN_ON(IS_ERR(crtc_state) || ret);
> +
> +	dev_priv->display.crtc_disable(crtc_state, state);
> +
> +	drm_atomic_state_free(state);
>  
>  	DRM_DEBUG_KMS("[CRTC:%d:%s] hw state adjusted, was enabled, now disabled\n",
>  		      crtc->base.id, crtc->name);
> @@ -13669,7 +13689,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
>  
>  		if (old_crtc_state->active) {
>  			intel_crtc_disable_planes(crtc, old_crtc_state->plane_mask);
> -			dev_priv->display.crtc_disable(crtc);
> +			dev_priv->display.crtc_disable(to_intel_crtc_state(old_crtc_state), state);
>  			intel_crtc->active = false;
>  			intel_fbc_disable(intel_crtc);
>  			intel_disable_shared_dpll(intel_crtc);
> @@ -13710,7 +13730,7 @@ static void intel_atomic_commit_tail(struct drm_atomic_state *state)
>  
>  		if (modeset && crtc->state->active) {
>  			update_scanline_offset(to_intel_crtc(crtc));
> -			dev_priv->display.crtc_enable(crtc);
> +			dev_priv->display.crtc_enable(pipe_config, state);
>  		}
>  
>  		/* Complete events for now disable pipes here. */
> -- 
> 2.7.4
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  reply	other threads:[~2016-08-18 13:19 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-09 15:03 [PATCH 00/15] drm/i915: Use connector atomic state in encoders Maarten Lankhorst
2016-08-09 15:04 ` [PATCH 01/15] drm/i915: handle DP_MST correctly in bxt_get_dpll Maarten Lankhorst
2016-08-18 13:17   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 02/15] drm/i915: Pass atomic state to crtc enable/disable functions Maarten Lankhorst
2016-08-18 13:19   ` Daniel Vetter [this message]
2016-08-09 15:04 ` [PATCH 03/15] drm/i915: Remove unused mode_set hook from encoder Maarten Lankhorst
2016-08-18 13:20   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 04/15] drm/i915: Walk over encoders in crtc enable/disable using atomic state Maarten Lankhorst
2016-08-22 14:28   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 05/15] drm/i915: Pass crtc_state and connector_state to encoder functions Maarten Lankhorst
2016-08-18 13:30   ` Daniel Vetter
2016-08-22  8:06     ` Maarten Lankhorst
2016-08-22 14:32       ` Daniel Vetter
2016-08-23  8:18         ` Maarten Lankhorst
2016-08-23  8:33           ` Daniel Vetter
2016-08-23 11:48         ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 06/15] drm/i915: Make encoder->compute_config take the connector state Maarten Lankhorst
2016-08-18 13:31   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 07/15] drm/i915: Remove unused loop from intel_dp_mst_compute_config Maarten Lankhorst
2016-08-18 13:34   ` Daniel Vetter
2016-08-22 12:43     ` Maarten Lankhorst
2016-08-22 14:33       ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 08/15] drm/i915: Convert intel_crt to use atomic state Maarten Lankhorst
2016-08-18 13:35   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 09/15] drm/i915: Convert intel_dvo " Maarten Lankhorst
2016-08-18 13:36   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 10/15] drm/i915: Convert intel_dsi " Maarten Lankhorst
2016-08-18 13:43   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 11/15] drm/i915: Convert intel_sdvo " Maarten Lankhorst
2016-08-18 13:44   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 12/15] drm/i915: Convert intel_lvds " Maarten Lankhorst
2016-08-18 13:47   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 13/15] drm/i915: Convert intel_dp_mst " Maarten Lankhorst
2016-08-18 13:54   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 14/15] drm/i915: Convert intel_dp " Maarten Lankhorst
2016-08-18 14:01   ` Daniel Vetter
2016-08-09 15:04 ` [PATCH 15/15] drm/i915: Use more atomic state in intel_color.c Maarten Lankhorst
2016-08-18 14:02   ` Daniel Vetter
2016-08-09 15:55 ` ✗ Ro.CI.BAT: failure for drm/i915: Use connector atomic state in encoders Patchwork
2016-08-10  7:53 ` Patchwork
2016-08-18 14:04 ` [PATCH 00/15] " Daniel Vetter
2016-08-22  8:12   ` Maarten Lankhorst
  -- strict thread matches above, loose matches on Subject: below --
2016-07-07 11:55 [PATCH 01/15] drm/i915: handle DP_MST correctly in bxt_get_dpll Maarten Lankhorst
2016-07-07 11:55 ` [PATCH 02/15] drm/i915: Pass atomic state to crtc enable/disable functions Maarten Lankhorst

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=20160818131937.GE6232@phenom.ffwll.local \
    --to=daniel@ffwll.ch \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    /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