Analogix DP controllers support two sets of interrupts for hotplug
detection: HOTPLUG_CHG, and the pair PLUG / HPD_LOST.  The current
driver logic relies on PLUG/HPD_LOST only, and
analogix_dp_get_irq_type() returns on the first matched interrupt
flag, so the hardirq handler unconditionally mutes all HPD
interrupts, including HOTPLUG_CHG and INT_HPD.

To prepare fine-grained interrupt handling, convert the return type
from enum dp_irq_type to a u32 bitmask, accumulate all pending
interrupt flags instead of returning early, add detection for
DP_IRQ_TYPE_IRQ_HPD, and use zero instead of the DP_IRQ_TYPE_UNKNOWN
sentinel to indicate no pending interrupts.

Tested-by: Heiko Stuebner <[email protected]>
Signed-off-by: Damon Ding <[email protected]>

---

Changes in v4:
- Add Tested-by tag.

Changes in v5:
- Simplify the commit msg.
---
 .../gpu/drm/bridge/analogix/analogix_dp_core.c |  8 ++++----
 .../gpu/drm/bridge/analogix/analogix_dp_core.h |  4 ++--
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c  | 18 ++++++++++--------
 3 files changed, 16 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 35b273a803a0..a3871f28b835 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -704,10 +704,10 @@ static irqreturn_t analogix_dp_hardirq(int irq, void *arg)
 {
        struct analogix_dp_device *dp = arg;
        irqreturn_t ret = IRQ_NONE;
-       enum dp_irq_type irq_type;
+       u32 irq_type;
 
        irq_type = analogix_dp_get_irq_type(dp);
-       if (irq_type != DP_IRQ_TYPE_UNKNOWN) {
+       if (irq_type) {
                analogix_dp_mute_hpd_interrupt(dp);
                ret = IRQ_WAKE_THREAD;
        }
@@ -718,7 +718,7 @@ static irqreturn_t analogix_dp_hardirq(int irq, void *arg)
 static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
 {
        struct analogix_dp_device *dp = arg;
-       enum dp_irq_type irq_type;
+       u32 irq_type;
 
        irq_type = analogix_dp_get_irq_type(dp);
        if (irq_type & DP_IRQ_TYPE_HP_CABLE_IN ||
@@ -728,7 +728,7 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void 
*arg)
                        drm_helper_hpd_irq_event(dp->drm_dev);
        }
 
-       if (irq_type != DP_IRQ_TYPE_UNKNOWN) {
+       if (irq_type) {
                analogix_dp_clear_hotplug_interrupts(dp);
                analogix_dp_unmute_hpd_interrupt(dp);
        }
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
index 64aaba67e669..dc189f0b7a19 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
@@ -120,7 +120,7 @@ enum dp_irq_type {
        DP_IRQ_TYPE_HP_CABLE_IN  = BIT(0),
        DP_IRQ_TYPE_HP_CABLE_OUT = BIT(1),
        DP_IRQ_TYPE_HP_CHANGE    = BIT(2),
-       DP_IRQ_TYPE_UNKNOWN      = BIT(3),
+       DP_IRQ_TYPE_IRQ_HPD      = BIT(3),
 };
 
 struct video_info {
@@ -196,7 +196,7 @@ void analogix_dp_set_analog_power_down(struct 
analogix_dp_device *dp,
 int analogix_dp_init_analog_func(struct analogix_dp_device *dp);
 void analogix_dp_init_hpd(struct analogix_dp_device *dp);
 void analogix_dp_force_hpd(struct analogix_dp_device *dp);
-enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp);
+u32 analogix_dp_get_irq_type(struct analogix_dp_device *dp);
 void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp);
 void analogix_dp_reset_aux(struct analogix_dp_device *dp);
 void analogix_dp_init_aux(struct analogix_dp_device *dp);
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c 
b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
index c1344a3f013a..49c1961e4326 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
@@ -412,8 +412,9 @@ void analogix_dp_force_hpd(struct analogix_dp_device *dp)
        writel(reg, dp->reg_base + ANALOGIX_DP_SYS_CTL_3);
 }
 
-enum dp_irq_type analogix_dp_get_irq_type(struct analogix_dp_device *dp)
+u32 analogix_dp_get_irq_type(struct analogix_dp_device *dp)
 {
+       u32 irq_type = 0;
        u32 reg;
 
        if (dp->hpd_gpiod) {
@@ -425,17 +426,18 @@ enum dp_irq_type analogix_dp_get_irq_type(struct 
analogix_dp_device *dp)
        } else {
                /* Parse hotplug interrupt status register */
                reg = readl(dp->reg_base + ANALOGIX_DP_COMMON_INT_STA_4);
-
                if (reg & PLUG)
-                       return DP_IRQ_TYPE_HP_CABLE_IN;
-
+                       irq_type |= DP_IRQ_TYPE_HP_CABLE_IN;
                if (reg & HPD_LOST)
-                       return DP_IRQ_TYPE_HP_CABLE_OUT;
-
+                       irq_type |= DP_IRQ_TYPE_HP_CABLE_OUT;
                if (reg & HOTPLUG_CHG)
-                       return DP_IRQ_TYPE_HP_CHANGE;
+                       irq_type |= DP_IRQ_TYPE_HP_CHANGE;
+
+               reg = readl(dp->reg_base + ANALOGIX_DP_INT_STA);
+               if (reg & INT_HPD)
+                       irq_type |= DP_IRQ_TYPE_IRQ_HPD;
 
-               return DP_IRQ_TYPE_UNKNOWN;
+               return irq_type;
        }
 }
 
-- 
2.34.1

Reply via email to