Linux on ARM based TI OMAP SoCs
 help / color / mirror / Atom feed
* [PATCH] drm/bridge: tda998x: Fix CEC calibration with lazy IRQ disable
@ 2026-11-20 15:00 Nhat Tran
  2026-11-23  7:52 ` Hans Verkuil
  0 siblings, 1 reply; 2+ messages in thread
From: Nhat Tran @ 2026-11-20 15:00 UTC (permalink / raw)
  To: Russell King, Andrzej Hajda, Neil Armstrong, Robert Foss
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Hans Verkuil, Linus Walleij, dri-devel, linux-gpio, linux-omap,
	linux-kernel, Nhat Tran, stable

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>
---
 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);
 }
 
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] drm/bridge: tda998x: Fix CEC calibration with lazy IRQ disable
  2026-11-20 15:00 [PATCH] drm/bridge: tda998x: Fix CEC calibration with lazy IRQ disable Nhat Tran
@ 2026-11-23  7:52 ` Hans Verkuil
  0 siblings, 0 replies; 2+ messages in thread
From: Hans Verkuil @ 2026-11-23  7:52 UTC (permalink / raw)
  To: Nhat Tran, Russell King, Andrzej Hajda, Neil Armstrong,
	Robert Foss
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Hans Verkuil, Linus Walleij, dri-devel, linux-gpio, linux-omap,
	linux-kernel, stable

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);
>  }
>  


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-11-23  7:52 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-20 15:00 [PATCH] drm/bridge: tda998x: Fix CEC calibration with lazy IRQ disable Nhat Tran
2026-11-23  7:52 ` Hans Verkuil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox