linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Cc: linux-media@vger.kernel.org,
	Dariusz Marcinkiewicz <darekm@google.com>,
	dri-devel@lists.freedesktop.org, Daniel Vetter <daniel@ffwll.ch>,
	Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Subject: Re: [PATCHv8 2/2] drm: tda998x: set the connector info
Date: Wed, 16 Oct 2019 17:22:32 +0100	[thread overview]
Message-ID: <20191016162232.GY25745@shell.armlinux.org.uk> (raw)
In-Reply-To: <20191016133916.21475-3-hverkuil-cisco@xs4all.nl>

On Wed, Oct 16, 2019 at 03:39:16PM +0200, Hans Verkuil wrote:
> From: Dariusz Marcinkiewicz <darekm@google.com>
> 
> Fill in the cec_connector_info when calling cec_notifier_conn_register().
> 
> Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
> Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
>  drivers/gpu/drm/i2c/tda998x_drv.c | 31 ++++++++++++++++++-------------
>  1 file changed, 18 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
> index 8262b44b776e..b0620842fa3a 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -1337,6 +1337,8 @@ static int tda998x_connector_init(struct tda998x_priv *priv,
>  				  struct drm_device *drm)
>  {
>  	struct drm_connector *connector = &priv->connector;
> +	struct cec_connector_info conn_info;
> +	struct cec_notifier *notifier;
>  	int ret;
>  
>  	connector->interlace_allowed = 1;
> @@ -1353,6 +1355,17 @@ static int tda998x_connector_init(struct tda998x_priv *priv,
>  	if (ret)
>  		return ret;
>  
> +	cec_fill_conn_info_from_drm(&conn_info, connector);
> +
> +	notifier = cec_notifier_conn_register(priv->cec_glue.parent,
> +					      NULL, &conn_info);
> +	if (!notifier)
> +		return -ENOMEM;
> +
> +	mutex_lock(&priv->cec_notify_mutex);
> +	priv->cec_notify = notifier;
> +	mutex_unlock(&priv->cec_notify_mutex);

As per my previous comments, this is a single-copy atomic operation.
Either priv->cec_notify is set or it isn't; there is no intermediate
value.  It can't be set to a value until cec_notifier_conn_register()
has completed.  So the lock doesn't help.

> +
>  	drm_connector_attach_encoder(&priv->connector,
>  				     priv->bridge.encoder);
>  
> @@ -1372,6 +1385,11 @@ static void tda998x_bridge_detach(struct drm_bridge *bridge)
>  {
>  	struct tda998x_priv *priv = bridge_to_tda998x_priv(bridge);
>  
> +	mutex_lock(&priv->cec_notify_mutex);
> +	cec_notifier_conn_unregister(priv->cec_notify);
> +	priv->cec_notify = NULL;
> +	mutex_unlock(&priv->cec_notify_mutex);

This is the only case where the lock makes sense - to ensure that any
of the cec_notifier_set_phys_addr*() functions aren't called
concurrently with it.  However, there's no locking around the instance
in tda998x_connector_get_modes(), so have you ensured that that
function can't be called concurrently?

Thanks.

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 12.1Mbps down 622kbps up
According to speedtest.net: 11.9Mbps down 500kbps up

  reply	other threads:[~2019-10-16 16:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-16 13:39 [PATCHv8 0/2] drm: tda998x: use cec_notifier_conn_(un)register Hans Verkuil
2019-10-16 13:39 ` [PATCHv8 1/2] " Hans Verkuil
2019-10-16 16:14   ` Russell King - ARM Linux admin
2019-10-17  7:03     ` Hans Verkuil
2019-10-17  7:29       ` Hans Verkuil
2019-10-17  9:27     ` Dariusz Marcinkiewicz
2019-10-16 13:39 ` [PATCHv8 2/2] drm: tda998x: set the connector info Hans Verkuil
2019-10-16 16:22   ` Russell King - ARM Linux admin [this message]
2019-10-17  9:26     ` Dariusz Marcinkiewicz
2019-10-17  9:44       ` Russell King - ARM Linux admin

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=20191016162232.GY25745@shell.armlinux.org.uk \
    --to=linux@armlinux.org.uk \
    --cc=daniel@ffwll.ch \
    --cc=darekm@google.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=laurent.pinchart@ideasonboard.com \
    --cc=linux-media@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;
as well as URLs for NNTP newsgroup(s).