From: Hans Verkuil <hverkuil+cisco@kernel.org>
To: Nhat Tran <nhat.tranminhk2@gmail.com>,
Russell King <linux@armlinux.org.uk>,
Andrzej Hajda <andrzej.hajda@intel.com>,
Neil Armstrong <neil.armstrong@linaro.org>,
Robert Foss <rfoss@kernel.org>
Cc: Laurent Pinchart <Laurent.pinchart@ideasonboard.com>,
Jonas Karlman <jonas@kwiboo.se>,
Jernej Skrabec <jernej.skrabec@gmail.com>,
Luca Ceresoli <luca.ceresoli@bootlin.com>,
Hans Verkuil <hverkuil@kernel.org>,
Linus Walleij <linusw@kernel.org>,
dri-devel@lists.freedesktop.org, linux-gpio@vger.kernel.org,
linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org
Subject: Re: [PATCH] drm/bridge: tda998x: Fix CEC calibration with lazy IRQ disable
Date: Mon, 23 Nov 2026 08:52:22 +0100 [thread overview]
Message-ID: <24b7d337-341b-4bd6-82bd-97347095be2d@kernel.org> (raw)
In-Reply-To: <20261120150004.64033-1-nhat.tranminhk2@gmail.com>
On 20/11/2026 16:00, Nhat Tran wrote:
> The CEC oscillator calibration pulses the TDA998x interrupt line low for
> 10ms through the "nxp,calib" GPIO. Before driving the line,
> tda998x_cec_calibration() calls disable_irq() so that gpiolib allows the
> GPIO, which is also used as an interrupt, to be switched to an output.
>
> gpiolib only allows that once the interrupt is actually disabled at the
> GPIO controller. Since commit a8173820f441 ("gpio: gpiolib: Allow GPIO
> IRQs to lazy disable"), disable_irq() is lazy on GPIO controllers that
> do not implement .irq_disable, such as gpio-omap: the line is not masked
> and gpiolib still considers the interrupt enabled. The direction change
> is refused and the calibration pulse is never generated. On a
> BeagleBone Black this happens on every boot:
>
> tda998x 0-0070: found TDA19988
> gpio-537 (nxp,calib): gpiod_direction_output_nonotify: tried to set a GPIO tied to an IRQ as output
> tda9950 0-0034: TDA9950 CEC interface, hardware version 3.3
>
> Set IRQ_DISABLE_UNLAZY for the duration of the calibration so that
> disable_irq() masks the line immediately, and clear it again once the
> interrupt has been re-enabled.
>
> Tested on a BeagleBone Black without an HDMI sink connected: the error
> is gone, the GPIO is back to an input used as an interrupt afterwards,
> no spurious interrupts are raised, and rebinding tda9950 repeatedly
> reruns the calibration cleanly. CEC communication with a sink was not
> tested.
>
> Fixes: a8173820f441 ("gpio: gpiolib: Allow GPIO IRQs to lazy disable")
> Cc: stable@vger.kernel.org
> Signed-off-by: Nhat Tran <nhat.tranminhk2@gmail.com>
Acked-by: Hans Verkuil <hverkuil+cisco@kernel.org>
Regards,
Hans
> ---
> drivers/gpu/drm/bridge/tda998x_drv.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/bridge/tda998x_drv.c b/drivers/gpu/drm/bridge/tda998x_drv.c
> index 0b966c9844e7..0815ce283f49 100644
> --- a/drivers/gpu/drm/bridge/tda998x_drv.c
> +++ b/drivers/gpu/drm/bridge/tda998x_drv.c
> @@ -495,8 +495,16 @@ static void tda998x_cec_calibration(struct tda998x_priv *priv)
> struct gpio_desc *calib = priv->calib;
>
> mutex_lock(&priv->edid_mutex);
> - if (priv->hdmi->irq > 0)
> + if (priv->hdmi->irq > 0) {
> + /*
> + * The pulse is driven on the IRQ line itself, and gpiolib
> + * refuses to drive a GPIO whose interrupt is still enabled.
> + * Make disable_irq() mask the line right away instead of
> + * lazily, so that the GPIO can be switched to an output.
> + */
> + irq_set_status_flags(priv->hdmi->irq, IRQ_DISABLE_UNLAZY);
> disable_irq(priv->hdmi->irq);
> + }
> gpiod_direction_output(calib, 1);
> tda998x_cec_set_calibration(priv, true);
>
> @@ -508,8 +516,10 @@ static void tda998x_cec_calibration(struct tda998x_priv *priv)
>
> tda998x_cec_set_calibration(priv, false);
> gpiod_direction_input(calib);
> - if (priv->hdmi->irq > 0)
> + if (priv->hdmi->irq > 0) {
> enable_irq(priv->hdmi->irq);
> + irq_clear_status_flags(priv->hdmi->irq, IRQ_DISABLE_UNLAZY);
> + }
> mutex_unlock(&priv->edid_mutex);
> }
>
prev parent reply other threads:[~2026-11-23 7:52 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-20 15:00 Nhat Tran
2026-11-23 7:52 ` Hans Verkuil [this message]
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=24b7d337-341b-4bd6-82bd-97347095be2d@kernel.org \
--to=hverkuil+cisco@kernel.org \
--cc=Laurent.pinchart@ideasonboard.com \
--cc=andrzej.hajda@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=hverkuil@kernel.org \
--cc=jernej.skrabec@gmail.com \
--cc=jonas@kwiboo.se \
--cc=linusw@kernel.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=luca.ceresoli@bootlin.com \
--cc=neil.armstrong@linaro.org \
--cc=nhat.tranminhk2@gmail.com \
--cc=rfoss@kernel.org \
--cc=stable@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
all inboxes | Powered by JetHome®