diff mbox series

[v2,18/24] drm/msm: dpu: Remove crtc_lock from setup_mixers

Message ID 20181116184238.170034-19-sean@poorly.run (mailing list archive)
State Not Applicable, archived
Headers show
Series drm/msm: Various dpu locking and legacy cleanups | expand

Commit Message

Sean Paul Nov. 16, 2018, 6:42 p.m. UTC
From: Sean Paul <seanpaul@chromium.org>

I think the intention here was to protect the enc->crtc access, but
that's insufficient to avoid enc->crtc changing. Fortunately we're
already holding the modeset lock when this is called (from
atomic_check), so remove the crtc_lock and add a modeset lock check.

While we're at it, use the encoder mask from crtc state instead of
legacy pointer.

Changes in v2:
- None

Signed-off-by: Sean Paul <seanpaul@chromium.org>
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

Comments

Jeykumar Sankaran Nov. 19, 2018, 8:09 p.m. UTC | #1
On 2018-11-16 10:42, Sean Paul wrote:
> From: Sean Paul <seanpaul@chromium.org>
> 
> I think the intention here was to protect the enc->crtc access, but
> that's insufficient to avoid enc->crtc changing. Fortunately we're
> already holding the modeset lock when this is called (from
> atomic_check), so remove the crtc_lock and add a modeset lock check.
> 
> While we're at it, use the encoder mask from crtc state instead of
> legacy pointer.
> 
> Changes in v2:
> - None
> 
> Signed-off-by: Sean Paul <seanpaul@chromium.org>

Reviewed-by: Jeykumar Sankaran <jsanka@codeaurora.org>

> ---
>  drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
> 
> diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> index c49aaf412b6e..141ed1b0e90a 100644
> --- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> +++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
> @@ -474,19 +474,13 @@ static void _dpu_crtc_setup_mixer_for_encoder(
> 
>  static void _dpu_crtc_setup_mixers(struct drm_crtc *crtc)
>  {
> -	struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
>  	struct drm_encoder *enc;
> 
> -	mutex_lock(&dpu_crtc->crtc_lock);
> -	/* Check for mixers on all encoders attached to this crtc */
> -	list_for_each_entry(enc, &crtc->dev->mode_config.encoder_list,
> head) {
> -		if (enc->crtc != crtc)
> -			continue;
> +	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
> 
> +	/* Check for mixers on all encoders attached to this crtc */
> +	drm_for_each_encoder_mask(enc, crtc->dev,
> crtc->state->encoder_mask)
>  		_dpu_crtc_setup_mixer_for_encoder(crtc, enc);
> -	}
> -
> -	mutex_unlock(&dpu_crtc->crtc_lock);
>  }
> 
>  static void _dpu_crtc_setup_lm_bounds(struct drm_crtc *crtc,
diff mbox series

Patch

diff --git a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
index c49aaf412b6e..141ed1b0e90a 100644
--- a/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
+++ b/drivers/gpu/drm/msm/disp/dpu1/dpu_crtc.c
@@ -474,19 +474,13 @@  static void _dpu_crtc_setup_mixer_for_encoder(
 
 static void _dpu_crtc_setup_mixers(struct drm_crtc *crtc)
 {
-	struct dpu_crtc *dpu_crtc = to_dpu_crtc(crtc);
 	struct drm_encoder *enc;
 
-	mutex_lock(&dpu_crtc->crtc_lock);
-	/* Check for mixers on all encoders attached to this crtc */
-	list_for_each_entry(enc, &crtc->dev->mode_config.encoder_list, head) {
-		if (enc->crtc != crtc)
-			continue;
+	WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
 
+	/* Check for mixers on all encoders attached to this crtc */
+	drm_for_each_encoder_mask(enc, crtc->dev, crtc->state->encoder_mask)
 		_dpu_crtc_setup_mixer_for_encoder(crtc, enc);
-	}
-
-	mutex_unlock(&dpu_crtc->crtc_lock);
 }
 
 static void _dpu_crtc_setup_lm_bounds(struct drm_crtc *crtc,