[PATCH v4 17/17] drm: bridge: dw_hdmi: Merge top and bottom half IRQ handlers

Jonas Karlman
2026-05-04T19:12:45Z

The bottom half IRQ handler only modify delay of or queue a delayed work
used for HPD handling. The mod_delayed_work() called is documented as
being safe to call from any context including IRQ handler.

Merge top and bottom half IRQ handlers to simplify IRQ handling now that
HPD event is handled using a delayed work.

Signed-off-by: Jonas Karlman <jonas@kwiboo.se>
---
v4: New patch
---
drivers/gpu/drm/bridge/synopsys/dw-hdmi.c | 32 +++++++----------------
1 file changed, 10 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
index c0ed067154c7..a42c45ff0ade 100644
--- a/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
+++ b/drivers/gpu/drm/bridge/synopsys/dw-hdmi.c
@@ -2971,24 +2971,12 @@ static irqreturn_t dw_hdmi_hardirq(int irq, void *dev_id)
if (hdmi->i2c)
ret = dw_hdmi_i2c_irq(hdmi);

- intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0);
+ intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0) & HDMI_IH_PHY_STAT0_HPD;
if (intr_stat) {
- hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0);
- return IRQ_WAKE_THREAD;
- }
-
- return ret;
-}
-
-static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)
-{
- struct dw_hdmi *hdmi = dev_id;
- u8 intr_stat;
-
- intr_stat = hdmi_readb(hdmi, HDMI_IH_PHY_STAT0);
- if (intr_stat & HDMI_IH_PHY_STAT0_HPD) {
enum drm_connector_status status;

+ hdmi_writeb(hdmi, ~0, HDMI_IH_MUTE_PHY_STAT0);
+
/* Set HPD interrupt polarity based on current HPD status. */
status = dw_hdmi_phy_read_hpd(hdmi, hdmi->phy.data);
hdmi_modb(hdmi, status == connector_status_connected ?
@@ -3000,12 +2988,13 @@ static irqreturn_t dw_hdmi_irq(int irq, void *dev_id)

mod_delayed_work(system_percpu_wq, &hdmi->hpd_work,
msecs_to_jiffies(HOTPLUG_DEBOUNCE_MS));
- }

- hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0);
- hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0);
+ hdmi_writeb(hdmi, intr_stat, HDMI_IH_PHY_STAT0);
+ hdmi_writeb(hdmi, ~HDMI_IH_PHY_STAT0_HPD, HDMI_IH_MUTE_PHY_STAT0);
+ ret = IRQ_HANDLED;
+ }

- return IRQ_HANDLED;
+ return ret;
}

static void dw_hdmi_hpd_work(struct work_struct *work)
@@ -3305,9 +3294,8 @@ struct dw_hdmi *dw_hdmi_probe(struct platform_device *pdev,
INIT_DELAYED_WORK(&hdmi->hpd_work, dw_hdmi_hpd_work);
disable_delayed_work(&hdmi->hpd_work);

- ret = devm_request_threaded_irq(dev, irq, dw_hdmi_hardirq,
- dw_hdmi_irq, IRQF_SHARED,
- dev_name(dev), hdmi);
+ ret = devm_request_irq(dev, irq, dw_hdmi_hardirq, IRQF_SHARED,
+ dev_name(dev), hdmi);
if (ret)
goto err_res;

--
2.54.0