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: [email protected]
> Signed-off-by: Nhat Tran <[email protected]>

Acked-by: Hans Verkuil <[email protected]>

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

Reply via email to