drm/bridge: tda998x: Fix CEC calibration with lazy IRQ disable
Subsystems (6)
PATCH 1/1 drm/bridge: tda998x: Fix CEC calibration with lazy IRQ disable
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.
--- drivers/gpu/drm/bridge/tda998x_drv.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/tda998x_drv.c +12 -2
@@ -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); }
Signature · 1 line
2.25.1