All of lore.kernel.org
 help / color / mirror / Atom feed
From: Javier Martinez Canillas <javierm@redhat.com>
To: maxime@cerno.tech, Daniel Vetter <daniel.vetter@intel.com>,
	David Airlie <airlied@linux.ie>,
	Maarten Lankhorst <maarten.lankhorst@linux.intel.com>,
	Thomas Zimmermann <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org,
	Dave Stevenson <dave.stevenson@raspberrypi.com>,
	Dom Cobley <dom@raspberrypi.com>,
	Tim Gover <tim.gover@raspberrypi.com>,
	Phil Elwell <phil@raspberrypi.com>
Subject: Re: [PATCH 1/2] drm/vc4: hdmi: Take our lock to reset the link
Date: Thu, 27 Oct 2022 17:13:04 +0200	[thread overview]
Message-ID: <bf04d1da-f9cb-9aa8-4c99-cef00177a41a@redhat.com> (raw)
In-Reply-To: <20221024093634.118190-1-maxime@cerno.tech>

Hello Maxime,

On 10/24/22 11:36, maxime@cerno.tech wrote:
> We access some fields protected by our internal mutex in
> vc4_hdmi_reset_link() (saved_adjusted_mode, output_bpc, output_format)
> and are calling functions that need to have that lock taken
> (vc4_hdmi_supports_scrambling()).
> 
> However, the current code doesn't lock that mutex. Let's make sure it
> does.
> 
> Fixes: 6bed2ea3cb38 ("drm/vc4: hdmi: Reset link on hotplug")
> Signed-off-by: Maxime Ripard <maxime@cerno.tech>
> ---

Reviewed-by: Javier Martinez Canillas <javierm@redhat.com>

Just a trivial nit below:

>  drivers/gpu/drm/vc4/vc4_hdmi.c | 21 +++++++++++++++++----
>  1 file changed, 17 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c
> index 596e311d6e58..9e549fa07467 100644
> --- a/drivers/gpu/drm/vc4/vc4_hdmi.c
> +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c
> @@ -349,27 +349,40 @@ static int vc4_hdmi_reset_link(struct drm_connector *connector,
>  	if (!crtc_state->active)
>  		return 0;
>  
> -	if (!vc4_hdmi_supports_scrambling(encoder))
> +	mutex_lock(&vc4_hdmi->mutex);
> +
> +	if (!vc4_hdmi_supports_scrambling(encoder)) {
> +		mutex_unlock(&vc4_hdmi->mutex);
>  		return 0;
> +	}
>  
>  	scrambling_needed = vc4_hdmi_mode_needs_scrambling(&vc4_hdmi->saved_adjusted_mode,
>  							   vc4_hdmi->output_bpc,
>  							   vc4_hdmi->output_format);
> -	if (!scrambling_needed)
> +	if (!scrambling_needed) {
> +		mutex_unlock(&vc4_hdmi->mutex);
>  		return 0;
> +	}
>  
>  	if (conn_state->commit &&
> -	    !try_wait_for_completion(&conn_state->commit->hw_done))
> +	    !try_wait_for_completion(&conn_state->commit->hw_done)) {
> +		mutex_unlock(&vc4_hdmi->mutex);
>  		return 0;
> +	}

I think the convention is to have a ret_unlock label followed by the
mutex_unlock() and ret 0, to avoid duplicating this. You could have
that label after the return reset_pipe(crtc, ctx).

But it's OK if you prefer to land this version too.

-- 
Best regards,

Javier Martinez Canillas
Core Platforms
Red Hat


  parent reply	other threads:[~2022-10-27 15:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-10-24  9:36 [PATCH 1/2] drm/vc4: hdmi: Take our lock to reset the link maxime
2022-10-24  9:36 ` [PATCH 2/2] drm/vc4: hdmi: Fix outdated function name in comment maxime
2022-10-27 15:34   ` Javier Martinez Canillas
2022-10-27 15:13 ` Javier Martinez Canillas [this message]
2022-10-28 11:12 ` [PATCH 1/2] drm/vc4: hdmi: Take our lock to reset the link Maxime Ripard

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=bf04d1da-f9cb-9aa8-4c99-cef00177a41a@redhat.com \
    --to=javierm@redhat.com \
    --cc=airlied@linux.ie \
    --cc=daniel.vetter@intel.com \
    --cc=dave.stevenson@raspberrypi.com \
    --cc=dom@raspberrypi.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=maarten.lankhorst@linux.intel.com \
    --cc=maxime@cerno.tech \
    --cc=phil@raspberrypi.com \
    --cc=tim.gover@raspberrypi.com \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.