From: Russell King - ARM Linux admin <linux@armlinux.org.uk>
To: Dariusz Marcinkiewicz <darekm@google.com>
Cc: dri-devel@lists.freedesktop.org, linux-media@vger.kernel.org,
hverkuil-cisco@xs4all.nl, David Airlie <airlied@linux.ie>,
Daniel Vetter <daniel@ffwll.ch>,
open list <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v6 4/8] drm: tda998x: use cec_notifier_conn_(un)register
Date: Tue, 13 Aug 2019 12:20:14 +0100 [thread overview]
Message-ID: <20190813112014.GE13294@shell.armlinux.org.uk> (raw)
In-Reply-To: <20190813110300.83025-5-darekm@google.com>
On Tue, Aug 13, 2019 at 01:02:36PM +0200, Dariusz Marcinkiewicz wrote:
> Use the new cec_notifier_conn_(un)register() functions to
> (un)register the notifier for the HDMI connector, and fill
> in the cec_connector_info.
>
> Changes since v2:
> - cec_notifier_phys_addr_invalidate where appropriate,
> - don't check for NULL notifier before calling
> cec_notifier_conn_unregister.
> Changes since v1:
> Add memory barrier to make sure that the notifier
> becomes visible to the irq thread once it is
> fully constructed.
>
> Signed-off-by: Dariusz Marcinkiewicz <darekm@google.com>
> Tested-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
> ---
> drivers/gpu/drm/i2c/tda998x_drv.c | 33 +++++++++++++++++++++----------
> 1 file changed, 23 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/i2c/tda998x_drv.c b/drivers/gpu/drm/i2c/tda998x_drv.c
> index 61e042918a7fc..19a63ee1b3f53 100644
> --- a/drivers/gpu/drm/i2c/tda998x_drv.c
> +++ b/drivers/gpu/drm/i2c/tda998x_drv.c
> @@ -804,9 +804,14 @@ static irqreturn_t tda998x_irq_thread(int irq, void *data)
> if (lvl & CEC_RXSHPDLEV_HPD) {
> tda998x_edid_delay_start(priv);
> } else {
> + struct cec_notifier *notify;
> +
> schedule_work(&priv->detect_work);
> - cec_notifier_set_phys_addr(priv->cec_notify,
> - CEC_PHYS_ADDR_INVALID);
> +
> + notify = READ_ONCE(priv->cec_notify);
> + if (notify)
> + cec_notifier_phys_addr_invalidate(
> + notify);
> }
>
> handled = true;
> @@ -1331,6 +1336,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;
> @@ -1347,6 +1354,19 @@ 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;
> + /*
> + * Make sure that tda998x_irq_thread does see the notifier
> + * when it fully constructed.
> + */
> + smp_wmb();
> + priv->cec_notify = notifier;
To nitpick, this comment and the following code do not go together.
I think what you actually mean is:
* Make sure that tda998x_irq_thread sees the notifier
* only after it is fully constructed.
> +
> drm_connector_attach_encoder(&priv->connector,
> priv->bridge.encoder);
>
> @@ -1790,8 +1810,7 @@ static void tda998x_destroy(struct device *dev)
>
> i2c_unregister_device(priv->cec);
>
> - if (priv->cec_notify)
> - cec_notifier_put(priv->cec_notify);
> + cec_notifier_conn_unregister(priv->cec_notify);
This also doesn't make sense: tda998x_destroy() is the opposite of
tda998x_create(). However, tda998x_connector_destroy() is the
opposite of tda998x_connector_create().
By moving the CEC creation code into tda998x_connector_create(), you
are creating the possibility for the following sequence to mess up
CEC and leak:
tda998x_create()
tda998x_connector_create()
tda998x_connector_destroy()
tda998x_connector_create()
tda998x_connector_destroy()
tda998x_destroy()
Anything you create in tda998x_connector_create() must be cleaned up
by tda998x_connector_destroy().
> }
>
> static int tda998x_create(struct device *dev)
> @@ -1916,12 +1935,6 @@ static int tda998x_create(struct device *dev)
> cec_write(priv, REG_CEC_RXSHPDINTENA, CEC_RXSHPDLEV_HPD);
> }
>
> - priv->cec_notify = cec_notifier_get(dev);
> - if (!priv->cec_notify) {
> - ret = -ENOMEM;
> - goto fail;
> - }
> -
> priv->cec_glue.parent = dev;
> priv->cec_glue.data = priv;
> priv->cec_glue.init = tda998x_cec_hook_init;
> --
> 2.23.0.rc1.153.gdeed80330f-goog
>
>
--
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
next prev parent reply other threads:[~2019-08-13 11:20 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-08-13 11:02 [PATCH v6 0/8] drm: cec: convert DRM drivers to the new notifier API Dariusz Marcinkiewicz
2019-08-13 11:02 ` [PATCH v6 1/8] drm/i915/intel_hdmi: use cec_notifier_conn_(un)register Dariusz Marcinkiewicz
2019-08-13 11:02 ` [PATCH v6 2/8] dw-hdmi-cec: use cec_notifier_cec_adap_(un)register Dariusz Marcinkiewicz
2019-08-13 11:02 ` [PATCH v6 3/8] tda9950: " Dariusz Marcinkiewicz
2019-08-13 11:32 ` Russell King - ARM Linux admin
2019-08-13 11:44 ` Hans Verkuil
2019-08-13 11:02 ` [PATCH v6 4/8] drm: tda998x: use cec_notifier_conn_(un)register Dariusz Marcinkiewicz
2019-08-13 11:20 ` Russell King - ARM Linux admin [this message]
2019-08-14 10:52 ` Dariusz Marcinkiewicz
2019-08-13 11:02 ` [PATCH v6 5/8] drm: sti: " Dariusz Marcinkiewicz
2019-08-13 11:02 ` [PATCH v6 6/8] drm: tegra: " Dariusz Marcinkiewicz
2019-08-13 11:02 ` [PATCH v6 7/8] drm: dw-hdmi: " Dariusz Marcinkiewicz
2019-08-13 11:37 ` Hans Verkuil
2019-08-14 10:49 ` Dariusz Marcinkiewicz
2019-08-13 11:02 ` [PATCH v6 8/8] drm: exynos: exynos_hdmi: " Dariusz Marcinkiewicz
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=20190813112014.GE13294@shell.armlinux.org.uk \
--to=linux@armlinux.org.uk \
--cc=airlied@linux.ie \
--cc=daniel@ffwll.ch \
--cc=darekm@google.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hverkuil-cisco@xs4all.nl \
--cc=linux-kernel@vger.kernel.org \
--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).