mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP
@ 2026-11-25 11:21 Damon Ding
  2026-11-25 11:21 ` [PATCH v7 01/20] drm/bridge: Select VIDEOMODE_HELPERS for DRM_OF_DISPLAY_MODE_BRIDGE Damon Ding
                   ` (19 more replies)
  0 siblings, 20 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

This series improves the HPD (Hotplug Detect) interrupt handling in
the Analogix DP driver to enable reliable native HPD pin detection on
Rockchip platforms, and introduces platform-specific HPD detection
schemes with fine-grained interrupt control.

On Rockchip platforms, the Analogix DP native HPD pin IRQ requires the
DP controller to remain powered, clocked and initialized to generate
plug/unplug interrupts. The previous driver enabled/disabled IRQ during
bridge enable/disable, which left no HPD detection when the display
pipeline was inactive. Additionally, the interrupt mute/unmute/clear
routines operated on all HPD interrupt bits unconditionally, lacking
the granularity needed for per-event control.

The series reorganizes IRQ and pm_runtime management into bind/unbind,
adds IRQF_ONESHOT to eliminate read-modify-write races on interrupt
mask registers between hardirq and threaded handlers, converts the
interrupt type detection to a bitmask-based scheme for fine-grained
mute/unmute/clear operations, and configures Rockchip platforms to use
the HOTPLUG_CHG interrupt with a 2ms HPD deglitch setting for better
stability.

Furthermore, the next bridge is now resolved into bridge->next_bridge
instead of the platform data field, the forced connected-status logic
is restricted to panel endpoints based on the bridge chain, and HPD
events from downstream bridges (e.g. display-connector with hpd-gpios)
are handled through the .hpd_notify callback. The DRM_BRIDGE_OP_HPD
capability and the hotplug IRQ are only enabled for the platforms
which actually support hotplug detection, and the fixed panels are
excluded from the hotplug reporting.

Tested on RK3576 with both native HPD pin and GPIO HPD configurations.

Case 1: No display-connector mode (native HPD pin):

  &edp {
      status = "okay";
      pinctrl-names = "default";
      pinctrl-0 = <&edp_txm0_pins>;
  };

Case 2: No display-connector mode (HPD GPIO):

  &edp {
      status = "okay";
      pinctrl-names = "default";
      pinctrl-0 = <&edp0_hpd>;
      hpd-gpios = <&gpio4 RK_PC1 GPIO_ACTIVE_HIGH>;
  };

  &pinctrl {
      edp {
          edp0_hpd: edp0-hpd {
              rockchip,pins = <4 RK_PC1 0 &pcfg_pull_none>;
          };
      };
  };

Case 3: Display-connector mode (native HPD pin, the &edp node as in case 1):

  dp-con {
      compatible = "dp-connector";
      label = "DP OUT";
      type = "full-size";

      port {
          dp_con_in: endpoint {
              remote-endpoint = <&edp_out_conn>;
          };
      };
  };

Case 4: Display-connector mode (HPD GPIO on the eDP node, the &edp node
as in case 2):

  dp-con {
      compatible = "dp-connector";
      label = "DP OUT";
      type = "full-size";

      port {
          dp_con_in: endpoint {
              remote-endpoint = <&edp_out_conn>;
          };
      };
  };

Case 5: Display-connector mode (HPD GPIO on the connector):

  dp-con {
      compatible = "dp-connector";
      label = "DP OUT";
      type = "full-size";
      pinctrl-0 = <&edp0_hpd>;
      pinctrl-names = "default";
      hpd-gpios = <&gpio4 RK_PC1 GPIO_ACTIVE_HIGH>;

      port {
          dp_con_in: endpoint {
              remote-endpoint = <&edp_out_conn>;
          };
      };
  };

All five configurations detect cable plug/unplug events correctly.

Damon Ding (20):
  drm/bridge: Select VIDEOMODE_HELPERS for DRM_OF_DISPLAY_MODE_BRIDGE
  drm/bridge: analogix_dp: Drop the redundant
    pm_runtime_mark_last_busy() calls
  drm/bridge: analogix_dp: Use bridge->next_bridge instead of plat_data
    field
  drm/bridge: analogix_dp: Restrict forced connected status to panel
    endpoints
  drm/bridge: analogix_dp: Take a runtime PM reference in bridge detect
  drm/bridge: analogix_dp: Return bitmask from
    analogix_dp_get_irq_type()
  drm/bridge: analogix_dp: Check all negative return values for
    &analogix_dp_device.irq
  drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling
  drm/bridge: analogix_dp: Extend clear_hotplug_interrupts to accept IRQ
    bitmask
  drm/bridge: analogix_dp: Extend mute/unmute HPD interrupts to accept
    irq bitmask
  drm/bridge: analogix_dp: Simplify analogix_dp_config_interrupt()
  drm/bridge: analogix_dp: Use platform-specific HPD detection scheme
  drm/bridge: analogix_dp: Skip native HPD interrupt ops for GPIO HPD
  drm/rockchip: analogix_dp: Unbind bridge when connector init fails
  drm/exynos: exynos_dp: Unbind bridge when connector init fails
  drm/bridge: analogix_dp: Move IRQ enable/disable to bind/unbind
  drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin
    detection
  drm/bridge: analogix_dp: Declare DRM_BRIDGE_OP_HPD for hotplug
    reporting
  drm/bridge: analogix_dp: Handle HPD notification from downstream
    bridge
  MAINTAINERS: Add entry for Analogix DP controller bridge

 MAINTAINERS                                   |  11 +
 drivers/gpu/drm/bridge/Kconfig                |   1 +
 drivers/gpu/drm/bridge/analogix/Kconfig       |   1 +
 .../drm/bridge/analogix/analogix_dp_core.c    | 277 ++++++++++++++----
 .../drm/bridge/analogix/analogix_dp_core.h    |  16 +-
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 167 +++++++----
 drivers/gpu/drm/exynos/Kconfig                |   1 -
 drivers/gpu/drm/exynos/exynos_dp.c            |  16 +-
 .../gpu/drm/rockchip/analogix_dp-rockchip.c   |   1 +
 include/drm/bridge/analogix_dp.h              |   1 -
 10 files changed, 352 insertions(+), 140 deletions(-)

---

Changes in v2:
- Split IRQ enable/disable logic, handle native HPD pin and
  GPIO/force-HPD modes separately to avoid unbalanced enable_irq()
  calls. (Sashiko)
- Add separate patch for IRQF_ONESHOT to resolve interrupt mask issues
  triggered by interrupt preemption. (Sashiko)
- Update commit messages to align with newly added IRQF_ONESHOT related
  commit.
- Move ANALOGIX_DP_HPD_DEGLITCH_L/ANALOGIX_DP_HPD_DEGLITCH_H configs to
  analogix_dp_reset().
- Add new patch to restrict the forced connected-status shortcut to
  panel endpoints only, allowing DP connector bridges to rely on HPD
  detection. (Reported by Heiko Stuebner)
- Add new patch to handle HPD notification from downstream bridges
  (e.g., display-connector with hpd-gpios).

Changes in v3:
- Reorder the series: convert the IRQ handling to a bitmask and add
  IRQF_ONESHOT before moving IRQ enable/disable to bind/unbind.
- Add new patch to check all negative return values for
  &analogix_dp_device.irq and propagate the actual error code. (Sashiko)
- Rename macro HPD_IRQ to HPD_IRQ_ALL to avoid confusion with the
  DP specification IRQ_HPD, extract the irq_type-to-register bit
  mapping into a shared helper, and drop the unused
  COMMON_INT_4_HPD_IRQ macro.
- Simplify commit messages across the series.
- Add new patch to use bridge->next_bridge instead of the plat_data
  field, resolving the next bridge in
  analogix_dp_aux_done_probing(). (Suggested by Heiko Stuebner)
- Report panel endpoints as always connected from
  analogix_dp_get_plug_in_status() via force_connected_mode, computed
  from the bridge chain at attach time.
- Determine the hpd notify mode from DRM_BRIDGE_OP_HPD on downstream
  bridges that lack DRM_BRIDGE_OP_DETECT.
- Add a MAINTAINERS entry for the Analogix DP controller bridge.

Changes in v4:
- Add Tested-by tag from Heiko.
- Rebase onto latest tree, picking up the two related patch series [0][1].

[0] https://lore.kernel.org/all/20260915-drm-bridge-drm_panel-cleanup-v4-0-30401d9406f3@bootlin.com/
[1] https://lore.kernel.org/all/20260916-drm-bridge-every-panel-v3-0-83afb4f1a707@bootlin.com/

Changes in v5:
- Add four new patches:
  - Select VIDEOMODE_HELPERS for DRM_OF_DISPLAY_MODE_BRIDGE to fix
    the undefined references for non-Exynos users.
  - Unbind the bridge when drm_bridge_connector_init() fails on the
    Rockchip and Exynos platforms.
  - Declare DRM_BRIDGE_OP_HPD on the Analogix DP bridge and report
    the hotplug events via drm_bridge_hpd_notify().
- Move the next_bridge resolving patch and the forced connected
  status restriction to the front of the series.
- Use a pure threaded IRQ handler and hold runtime PM references in
  the IRQ thread and the detect paths. (Sashiko)
- Limit the runtime PM holding to the RK3576/RK3588 platforms and
  exclude the boards with a fixed panel. (Sashiko)
- Fix the display timings leak in analogix_dp_aux_done_probing().
  (Sashiko)
- Change the type of &analogix_dp_device.irq to int to fix the dead
  dp->irq < 0 check. (Sashiko)
- Rebase onto the latest drm-misc-next.

Changes in v6:
- Skip the runtime PM reference in the IRQ thread for the GPIO HPD
  mode, since it only reads the GPIO level. (Sashiko)
- Enable the hotplug IRQ only for the platforms which support hotplug
  detection (the GPIO HPD mode, or the native HPD mode on RK3576 and
  RK3588). (Sashiko)
- Exclude the force-connected and force-HPD modes from the hotplug
  detection support check. (Sashiko)
- Declare DRM_BRIDGE_OP_HPD only for the platforms which support
  hotplug detection, since the drm core stops polling the connector
  once DRM_BRIDGE_OP_HPD is declared. (Sashiko)
- Return the cached connection status instead of connector->status
  from analogix_dp_bridge_detect(), as connector->status may still be
  unknown before the first HPD notification or stale after the sysfs
  state forcing. (Sashiko)
- Add Tested-by tags from Heiko and Marek.

Changes in v7:
- Add a patch to drop the redundant pm_runtime_mark_last_busy()
  calls, as pm_runtime_put_autosuspend() updates the last busy stamp
  since commit b3db492e8335.
- Move the runtime PM reference handling in
  analogix_dp_bridge_detect() to a separate patch, and add the Fixes
  and Reported-by tags for it.
- Derive analogix_dp_require_pm_for_hpd_irq() from
  analogix_dp_supports_hpd(), so that the runtime PM reference is
  explicitly a subset of the platforms which support hotplug
  detection.
- Track the hotplug IRQ enable state for an idempotent enable/disable,
  and gate the IRQ around the runtime PM transitions only for the
  platforms which hold the runtime PM reference, so that the GPIO HPD
  mode keeps detecting the plug events while the display is off.
  (Sashiko)
- Set the bridge ops after the chain is attached, as the
  DRM_BRIDGE_OP_HPD declaration previously preceded the
  force_connected_mode initialization, leaving the hotplug detection
  broken on fixed panels with a wired HPD GPIO. (Sashiko)
- Probe the sink over the AUX channel in the hpd notify mode instead
  of relying on the notified status, and skip the HPD polling and the
  AUX probe where they are not needed. (Sashiko)
- Exclude the hpd notify mode from analogix_dp_supports_hpd(), so
  that neither DRM_BRIDGE_OP_HPD is declared nor the hotplug IRQ is
  enabled for the muted native interrupts. (Sashiko)
- Drop the Tested-by tags of the patches whose design changed
  significantly in this version.
- Add Fixes tags to the two unbind fixes.
- Rebase onto the latest drm-misc-next.

-- 
2.34.1

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

* [PATCH v7 01/20] drm/bridge: Select VIDEOMODE_HELPERS for DRM_OF_DISPLAY_MODE_BRIDGE
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 02/20] drm/bridge: analogix_dp: Drop the redundant pm_runtime_mark_last_busy() calls Damon Ding
                   ` (18 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

The of-display-mode-bridge driver calls of_get_drm_display_mode(),
which is provided when VIDEOMODE_HELPERS is selected.  So far the
dependency has been satisfied by the users selecting
VIDEOMODE_HELPERS themselves (e.g. the Exynos and i.MX DRM drivers),
which breaks as soon as a user does not, resulting in undefined
references to of_get_drm_display_mode() at link time.

Select VIDEOMODE_HELPERS from DRM_OF_DISPLAY_MODE_BRIDGE, so that the
dependency is always satisfied.

Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
---
 drivers/gpu/drm/bridge/Kconfig | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/bridge/Kconfig b/drivers/gpu/drm/bridge/Kconfig
index c7da6b02d7b6..f717523014e8 100644
--- a/drivers/gpu/drm/bridge/Kconfig
+++ b/drivers/gpu/drm/bridge/Kconfig
@@ -266,6 +266,7 @@ config DRM_NXP_PTN3460
 config DRM_OF_DISPLAY_MODE_BRIDGE
 	tristate
 	depends on DRM_BRIDGE && OF
+	select VIDEOMODE_HELPERS
 	help
 	  This is a DRM bridge implementation that uses of_get_drm_display_mode
 	  to acquire display mode.
-- 
2.34.1


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

* [PATCH v7 02/20] drm/bridge: analogix_dp: Drop the redundant pm_runtime_mark_last_busy() calls
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
  2026-11-25 11:21 ` [PATCH v7 01/20] drm/bridge: Select VIDEOMODE_HELPERS for DRM_OF_DISPLAY_MODE_BRIDGE Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 03/20] drm/bridge: analogix_dp: Use bridge->next_bridge instead of plat_data field Damon Ding
                   ` (17 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

Since commit b3db492e8335 ("PM: runtime: Mark last busy stamp in
pm_runtime_put_autosuspend()"), pm_runtime_put_autosuspend() updates
the last busy timestamp itself, so the explicit
pm_runtime_mark_last_busy() calls right before it are no longer needed.

Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v7:
- Add this patch to drop the redundant pm_runtime_mark_last_busy()
  calls, as pm_runtime_put_autosuspend() updates the last busy stamp
  since commit b3db492e8335.
---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 8bb4c48aa3b4..50da43d64034 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1369,7 +1369,6 @@ static ssize_t analogix_dpaux_transfer(struct drm_dp_aux *aux,
 
 	ret = analogix_dp_transfer(dp, msg);
 out:
-	pm_runtime_mark_last_busy(dp->dev);
 	pm_runtime_put_autosuspend(dp->dev);
 
 	return ret;
@@ -1389,7 +1388,6 @@ static int analogix_dpaux_wait_hpd_asserted(struct drm_dp_aux *aux, unsigned lon
 	ret = readx_poll_timeout(analogix_dp_get_plug_in_status, dp, val, !val,
 				 wait_us / 100, wait_us);
 
-	pm_runtime_mark_last_busy(dp->dev);
 	pm_runtime_put_autosuspend(dp->dev);
 
 	return ret;
-- 
2.34.1


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

* [PATCH v7 03/20] drm/bridge: analogix_dp: Use bridge->next_bridge instead of plat_data field
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
  2026-11-25 11:21 ` [PATCH v7 01/20] drm/bridge: Select VIDEOMODE_HELPERS for DRM_OF_DISPLAY_MODE_BRIDGE Damon Ding
  2026-11-25 11:21 ` [PATCH v7 02/20] drm/bridge: analogix_dp: Drop the redundant pm_runtime_mark_last_busy() calls Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 04/20] drm/bridge: analogix_dp: Restrict forced connected status to panel endpoints Damon Ding
                   ` (16 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

The DRM bridge core provides a standard next_bridge field in struct
drm_bridge for chaining downstream bridges. Use dp->bridge.next_bridge
consistently inside the analogix_dp driver and drop the separate
dp->plat_data->next_bridge field.

The next bridge is now resolved in analogix_dp_aux_done_probing(): a
display mode bridge is created for the legacy display-timings on the
Exynos platforms, while the remote endpoint bridge (panel or bridge)
is looked up via of_drm_get_bridge_by_endpoint() otherwise. The
obtained references are transferred to bridge->next_bridge, which the
bridge core automatically puts at bridge destroy time.

Also select DRM_OF_DISPLAY_MODE_BRIDGE for DRM_ANALOGIX_DP and drop
the now redundant select from the Exynos Kconfig, as the core now
creates the display mode bridge itself.

Suggested-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/all/5609825.iZASKD2KPV@diego/
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v4:
- Add Tested-by tag.

Changes in v5:
- Move this patch to the front of the patch series, as the
  following patches rely on the dp->bridge.next_bridge field it
  introduces.
- Select DRM_OF_DISPLAY_MODE_BRIDGE for DRM_ANALOGIX_DP and drop the
  redundant select from the Exynos Kconfig, to fix the undefined
  reference build error. (kernel test robot)
- Check the presence of the display-timings node with
  of_get_child_by_name() instead of of_get_display_timings(), to
  avoid leaking the allocated display timings. (Sashiko)

Changes in v6:
- Add Tested-by tag.
---
 drivers/gpu/drm/bridge/analogix/Kconfig       |  1 +
 .../drm/bridge/analogix/analogix_dp_core.c    | 50 +++++++++++--------
 drivers/gpu/drm/exynos/Kconfig                |  1 -
 drivers/gpu/drm/exynos/exynos_dp.c            | 15 +-----
 include/drm/bridge/analogix_dp.h              |  1 -
 5 files changed, 30 insertions(+), 38 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/Kconfig b/drivers/gpu/drm/bridge/analogix/Kconfig
index 5672d83cb4a1..293d7b443163 100644
--- a/drivers/gpu/drm/bridge/analogix/Kconfig
+++ b/drivers/gpu/drm/bridge/analogix/Kconfig
@@ -33,6 +33,7 @@ config DRM_ANALOGIX_DP
 	depends on DRM
 	depends on OF
 	select DRM_DISPLAY_DP_AUX_BUS
+	select DRM_OF_DISPLAY_MODE_BRIDGE
 
 config DRM_ANALOGIX_ANX7625
 	tristate "Analogix Anx7625 MIPI to DP interface support"
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 50da43d64034..af7fc5afb8ec 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -21,6 +21,7 @@
 #include <linux/platform_device.h>
 
 #include <drm/bridge/analogix_dp.h>
+#include <drm/bridge/of-display-mode-bridge.h>
 #include <drm/display/drm_dp_aux_bus.h>
 #include <drm/drm_atomic.h>
 #include <drm/drm_atomic_helper.h>
@@ -32,6 +33,8 @@
 #include <drm/drm_print.h>
 #include <drm/drm_probe_helper.h>
 
+#include <video/of_display_timing.h>
+
 #include "analogix_dp_core.h"
 #include "analogix_dp_reg.h"
 
@@ -902,7 +905,7 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
 	struct analogix_dp_device *dp = to_dp(bridge);
 	enum drm_connector_status status = connector_status_disconnected;
 
-	if (dp->plat_data->next_bridge)
+	if (dp->bridge.next_bridge)
 		return connector_status_connected;
 
 	if (!analogix_dp_detect_hpd(dp))
@@ -923,8 +926,8 @@ static int analogix_dp_bridge_attach(struct drm_bridge *bridge,
 		return -EINVAL;
 	}
 
-	if (dp->plat_data->next_bridge) {
-		ret = drm_bridge_attach(dp->encoder, dp->plat_data->next_bridge, bridge,
+	if (dp->bridge.next_bridge) {
+		ret = drm_bridge_attach(dp->encoder, dp->bridge.next_bridge, bridge,
 					DRM_BRIDGE_ATTACH_NO_CONNECTOR);
 		if (ret) {
 			dev_err(dp->dev, "failed to attach following panel or bridge (%d)\n", ret);
@@ -1636,37 +1639,40 @@ struct drm_dp_aux *analogix_dp_get_aux(struct analogix_dp_device *dp)
 }
 EXPORT_SYMBOL_GPL(analogix_dp_get_aux);
 
-static void analogix_dp_put_bridge(void *data)
-{
-	drm_bridge_put(data);
-}
-
 static int analogix_dp_aux_done_probing(struct drm_dp_aux *aux)
 {
 	struct analogix_dp_device *dp = to_dp(aux);
 	struct analogix_dp_plat_data *plat_data = dp->plat_data;
+	struct drm_bridge *bridge = &dp->bridge, *next_bridge;
+	struct device_node *timings_np;
 	int port = plat_data->dev_type == EXYNOS_DP ? 0 : 1;
-	int ret;
+
+	if (plat_data->dev_type == EXYNOS_DP) {
+		timings_np = of_get_child_by_name(dp->dev->of_node, "display-timings");
+		of_node_put(timings_np);
+		if (timings_np) {
+			next_bridge = devm_drm_of_display_mode_bridge(dp->dev,
+								      dp->dev->of_node,
+								      DRM_MODE_CONNECTOR_eDP);
+			if (IS_ERR(next_bridge))
+				return PTR_ERR(next_bridge);
+			bridge->next_bridge = drm_bridge_get(next_bridge);
+
+			return component_add(dp->dev, plat_data->ops);
+		}
+	}
 
 	/*
 	 * If of_drm_get_bridge_by_endpoint() returns -ENODEV, there may be no
 	 * valid panel or bridge nodes. The driver should go on for the
 	 * driver-free bridge or the DP mode applications.
 	 */
-	plat_data->next_bridge = of_drm_get_bridge_by_endpoint(dp->dev->of_node,
-							       port, 0);
-	if (IS_ERR(plat_data->next_bridge)) {
-		if (PTR_ERR(plat_data->next_bridge) == -ENODEV)
-			plat_data->next_bridge = NULL;
+	bridge->next_bridge = of_drm_get_bridge_by_endpoint(dp->dev->of_node, port, 0);
+	if (IS_ERR(bridge->next_bridge)) {
+		if (PTR_ERR(bridge->next_bridge) == -ENODEV)
+			bridge->next_bridge = NULL;
 		else
-			return PTR_ERR(plat_data->next_bridge);
-	}
-
-	if (plat_data->next_bridge) {
-		ret = devm_add_action_or_reset(dp->dev, analogix_dp_put_bridge,
-					       plat_data->next_bridge);
-		if (ret)
-			return ret;
+			return PTR_ERR(bridge->next_bridge);
 	}
 
 	return component_add(dp->dev, plat_data->ops);
diff --git a/drivers/gpu/drm/exynos/Kconfig b/drivers/gpu/drm/exynos/Kconfig
index a59131ae122c..d63db6c36eb3 100644
--- a/drivers/gpu/drm/exynos/Kconfig
+++ b/drivers/gpu/drm/exynos/Kconfig
@@ -74,7 +74,6 @@ config DRM_EXYNOS_DP
 	select DRM_BRIDGE_CONNECTOR
 	select DRM_DISPLAY_DP_HELPER
 	default DRM_EXYNOS
-	select DRM_OF_DISPLAY_MODE_BRIDGE
 	select DRM_PANEL
 	help
 	  This enables support for DP device.
diff --git a/drivers/gpu/drm/exynos/exynos_dp.c b/drivers/gpu/drm/exynos/exynos_dp.c
index 4db7400c8a23..572e261e09da 100644
--- a/drivers/gpu/drm/exynos/exynos_dp.c
+++ b/drivers/gpu/drm/exynos/exynos_dp.c
@@ -14,12 +14,10 @@
 #include <linux/of_graph.h>
 #include <linux/platform_device.h>
 #include <linux/pm_runtime.h>
-#include <video/of_display_timing.h>
 #include <video/of_videomode.h>
 #include <video/videomode.h>
 
 #include <drm/bridge/analogix_dp.h>
-#include <drm/bridge/of-display-mode-bridge.h>
 #include <drm/drm_atomic_helper.h>
 #include <drm/drm_bridge.h>
 #include <drm/drm_bridge_connector.h>
@@ -160,14 +158,6 @@ static int exynos_dp_probe(struct platform_device *pdev)
 	 */
 	platform_set_drvdata(pdev, dp);
 
-	if (of_get_display_timings(dev->of_node)) {
-		dp->plat_data.next_bridge = devm_drm_of_display_mode_bridge(dp->dev,
-									dp->dev->of_node,
-									DRM_MODE_CONNECTOR_eDP);
-		if (IS_ERR(dp->plat_data.next_bridge))
-			return PTR_ERR(dp->plat_data.next_bridge);
-	}
-
 	/* The remote port can be either a panel or a bridge */
 	dp->plat_data.dev_type = EXYNOS_DP;
 	dp->plat_data.power_on = exynos_dp_poweron;
@@ -178,10 +168,7 @@ static int exynos_dp_probe(struct platform_device *pdev)
 	if (IS_ERR(dp->adp))
 		return PTR_ERR(dp->adp);
 
-	if (dp->plat_data.next_bridge)
-		return component_add(&pdev->dev, &exynos_dp_ops);
-	else
-		return analogix_dp_finish_probe(dp->adp);
+	return analogix_dp_finish_probe(dp->adp);
 }
 
 static void exynos_dp_remove(struct platform_device *pdev)
diff --git a/include/drm/bridge/analogix_dp.h b/include/drm/bridge/analogix_dp.h
index e05ff4bd689c..7b5615ae0dc1 100644
--- a/include/drm/bridge/analogix_dp.h
+++ b/include/drm/bridge/analogix_dp.h
@@ -37,7 +37,6 @@ static inline bool analogix_dp_is_rockchip(enum analogix_dp_devtype type)
 
 struct analogix_dp_plat_data {
 	enum analogix_dp_devtype dev_type;
-	struct drm_bridge *next_bridge;
 	struct drm_encoder *encoder;
 	struct drm_connector *connector;
 	const struct component_ops *ops;
-- 
2.34.1


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

* [PATCH v7 04/20] drm/bridge: analogix_dp: Restrict forced connected status to panel endpoints
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (2 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 03/20] drm/bridge: analogix_dp: Use bridge->next_bridge instead of plat_data field Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 05/20] drm/bridge: analogix_dp: Take a runtime PM reference in bridge detect Damon Ding
                   ` (15 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

Limit the forced connected status so that it only applies when the
bridge chain ends with a panel and no downstream bridge supports
DRM_BRIDGE_OP_DETECT, which is tracked by the new
&analogix_dp_device.force_connected_mode.  For all the other cases,
rely on analogix_dp_detect_hpd() to report the accurate hotplug
state.

Background for the special handling:
- If the chain ends with a DP connector bridge, the connector relies
  on Analogix DP to perform detection. We must avoid hardcoding
  connected status here.
- For intermediate bridges such as PS8625 / PTN3460 without detect
  support [1], historically the bridge connector defaults to connected
  via drm_helper_probe_detect() when no per-bridge detect callback
  exists.

[1] https://lore.kernel.org/all/4939d55e-b560-4235-8295-adf8e48d9b74@samsung.com/

Reported-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/all/5209243.oAaWjsssbx@diego/
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v3:
- Add missing drm_bridge_put() after drm_bridge_chain_get_last_bridge()
  to fix a reference count leak. (Sashiko)
- Report panel endpoints as always connected from
  analogix_dp_get_plug_in_status() via newly added
  &analogix_dp_device.force_connected_mode.

Changes in v4:
- Add Tested-by tag.

Changes in v5:
- Move the force_connected_mode check from
  analogix_dp_get_plug_in_status() to analogix_dp_bridge_detect(), as
  the hardware status reader is also used by the force HPD fallback
  and the AUX HPD waiting paths. (Sashiko)
- Hold a runtime PM reference in analogix_dp_bridge_detect(), since
  analogix_dp_detect_hpd() may access the registers while the device
  is runtime suspended. (Sashiko)

Changes in v6:
- Add Tested-by tag.

Changes in v7:
- Move the runtime PM reference handling in analogix_dp_bridge_detect()
  to a separate patch.
---
 .../drm/bridge/analogix/analogix_dp_core.c    | 29 ++++++++++++++++++-
 .../drm/bridge/analogix/analogix_dp_core.h    |  1 +
 2 files changed, 29 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index af7fc5afb8ec..46d4dd9d7cd7 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -905,7 +905,7 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
 	struct analogix_dp_device *dp = to_dp(bridge);
 	enum drm_connector_status status = connector_status_disconnected;
 
-	if (dp->bridge.next_bridge)
+	if (dp->force_connected_mode)
 		return connector_status_connected;
 
 	if (!analogix_dp_detect_hpd(dp))
@@ -914,6 +914,24 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
 	return status;
 }
 
+static bool analogix_dp_bridge_force_connected(struct analogix_dp_device *dp)
+{
+	struct drm_bridge *last_bridge;
+	bool force_connected = false;
+
+	drm_for_each_bridge_in_chain_from(dp->bridge.next_bridge, bridge) {
+		if (bridge->ops & DRM_BRIDGE_OP_DETECT)
+			return false;
+	}
+
+	last_bridge = drm_bridge_chain_get_last_bridge(dp->encoder);
+	if (last_bridge)
+		force_connected = drm_bridge_is_panel(last_bridge);
+	drm_bridge_put(last_bridge);
+
+	return force_connected;
+}
+
 static int analogix_dp_bridge_attach(struct drm_bridge *bridge,
 				     struct drm_encoder *encoder,
 				     enum drm_bridge_attach_flags flags)
@@ -933,6 +951,15 @@ static int analogix_dp_bridge_attach(struct drm_bridge *bridge,
 			dev_err(dp->dev, "failed to attach following panel or bridge (%d)\n", ret);
 			return ret;
 		}
+
+		/*
+		 * Only assume connected when the bridge chain ends with a panel.
+		 * Panel bridges lack a detect callback and historically rely on
+		 * this shortcut. For other next bridge types (e.g., DP connector
+		 * bridges), fall back to analogix_dp_detect_hpd() to report
+		 * accurate hotplug state.
+		 */
+		dp->force_connected_mode = analogix_dp_bridge_force_connected(dp);
 	}
 
 	return 0;
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
index 4560597604ad..64aaba67e669 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
@@ -170,6 +170,7 @@ struct analogix_dp_device {
 	bool			force_hpd;
 	bool			fast_train_enable;
 	bool			psr_supported;
+	bool			force_connected_mode;
 
 	u8 dpcd[DP_RECEIVER_CAP_SIZE];
 
-- 
2.34.1


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

* [PATCH v7 05/20] drm/bridge: analogix_dp: Take a runtime PM reference in bridge detect
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (3 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 04/20] drm/bridge: analogix_dp: Restrict forced connected status to panel endpoints Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 06/20] drm/bridge: analogix_dp: Return bitmask from analogix_dp_get_irq_type() Damon Ding
                   ` (14 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

The analogix_dp_bridge_detect() calls analogix_dp_detect_hpd(), which
reads the controller registers and may write them for the force HPD
fallback. The connector is polled and can be queried by userspace at
any time, so this runs while the device is runtime suspended when the
display is disabled.

Take a runtime PM reference around the HPD check, and report the
connector status as unknown when the device cannot be resumed.

Fixes: 2b77a2918c5d ("drm: bridge: analogix/dp: move hpd detect to connector detect function")
CC: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v7:
- Add this patch to take a runtime PM reference in
  analogix_dp_bridge_detect(), as the register accesses behind it may
  run while the device is runtime suspended.
---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 46d4dd9d7cd7..b9f4e5757fc5 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -908,9 +908,14 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
 	if (dp->force_connected_mode)
 		return connector_status_connected;
 
+	if (pm_runtime_resume_and_get(dp->dev) < 0)
+		return connector_status_unknown;
+
 	if (!analogix_dp_detect_hpd(dp))
 		status = connector_status_connected;
 
+	pm_runtime_put_autosuspend(dp->dev);
+
 	return status;
 }
 
-- 
2.34.1


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

* [PATCH v7 06/20] drm/bridge: analogix_dp: Return bitmask from analogix_dp_get_irq_type()
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (4 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 05/20] drm/bridge: analogix_dp: Take a runtime PM reference in bridge detect Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 07/20] drm/bridge: analogix_dp: Check all negative return values for &analogix_dp_device.irq Damon Ding
                   ` (13 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

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 <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v4:
- Add Tested-by tag.

Changes in v5:
- Simplify the commit msg.

Changes in v6:
- Add Tested-by tag.
---
 .../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 b9f4e5757fc5..3ab1cf6b51d1 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


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

* [PATCH v7 07/20] drm/bridge: analogix_dp: Check all negative return values for &analogix_dp_device.irq
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (5 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 06/20] drm/bridge: analogix_dp: Return bitmask from analogix_dp_get_irq_type() Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 08/20] drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling Damon Ding
                   ` (12 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding,
	Sashiko

Currently only -ENXIO is checked for dp->irq from gpiod_to_irq(),
which ignores other possible error codes like -EPROBE_DEFER, -ENOENT.

Check for any negative value instead, and propagate the actual error
code rather than hardcoding -ENODEV.

Reported-by: Sashiko <sashiko-bot@kernel.org>
Link: https://lore.kernel.org/all/20260804083307.84ECA1F000E9@smtp.kernel.org/
Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v4:
- Add Tested-by tag.

Changes in v5:
- Change the type of &analogix_dp_device.irq from unsigned int to int
  to fix the dead dp->irq < 0 check, which broke the probe deferral
  for the HPD GPIO. (Sashiko)

Changes in v6:
- Add Tested-by tag.
---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 4 ++--
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.h | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 3ab1cf6b51d1..749d63e55d2a 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -1514,9 +1514,9 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
 		irq_flags = IRQF_NO_AUTOEN;
 	}
 
-	if (dp->irq == -ENXIO) {
+	if (dp->irq < 0) {
 		dev_err(&pdev->dev, "failed to get irq\n");
-		return ERR_PTR(-ENODEV);
+		return ERR_PTR(dp->irq);
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, dp->irq,
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
index dc189f0b7a19..cc3466304531 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
@@ -159,7 +159,7 @@ struct analogix_dp_device {
 	struct drm_bridge	bridge;
 	struct drm_dp_aux	aux;
 	struct clk		*clock;
-	unsigned int		irq;
+	int			irq;
 	void __iomem		*reg_base;
 
 	struct video_info	video_info;
-- 
2.34.1


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

* [PATCH v7 08/20] drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (6 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 07/20] drm/bridge: analogix_dp: Check all negative return values for &analogix_dp_device.irq Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 09/20] drm/bridge: analogix_dp: Extend clear_hotplug_interrupts to accept IRQ bitmask Damon Ding
                   ` (11 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

The threaded IRQ is requested without IRQF_ONESHOT, allowing hardirq to
preempt the threaded handler. This creates a read-modify-write race on
HPD interrupt mask registers between the hardirq mute and thread unmute
operations.

Add IRQF_ONESHOT to keep the IRQ line masked during thread execution,
which eliminates the race and makes the per-event mute/unmute calls in
hardirq and thread handlers redundant. Move interrupt status clearing
to the beginning of the threaded handler, before
drm_helper_hpd_irq_event(), to avoid losing events that arrive during
the event handling.

Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v3:
- Split out a separate commit to improve the return value checking for
  &analogix_dp_device.irq. (Sashiko)

Changes in v4:
- Add Tested-by tag.

Changes in v6:
- Add Tested-by tag.
---
 .../gpu/drm/bridge/analogix/analogix_dp_core.c  | 17 +++++++----------
 1 file changed, 7 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 749d63e55d2a..ecc10a01cb48 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -707,10 +707,8 @@ static irqreturn_t analogix_dp_hardirq(int irq, void *arg)
 	u32 irq_type;
 
 	irq_type = analogix_dp_get_irq_type(dp);
-	if (irq_type) {
-		analogix_dp_mute_hpd_interrupt(dp);
+	if (irq_type)
 		ret = IRQ_WAKE_THREAD;
-	}
 
 	return ret;
 }
@@ -721,6 +719,9 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
 	u32 irq_type;
 
 	irq_type = analogix_dp_get_irq_type(dp);
+	if (irq_type)
+		analogix_dp_clear_hotplug_interrupts(dp);
+
 	if (irq_type & DP_IRQ_TYPE_HP_CABLE_IN ||
 	    irq_type & DP_IRQ_TYPE_HP_CABLE_OUT) {
 		dev_dbg(dp->dev, "Detected cable status changed!\n");
@@ -728,11 +729,6 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
 			drm_helper_hpd_irq_event(dp->drm_dev);
 	}
 
-	if (irq_type) {
-		analogix_dp_clear_hotplug_interrupts(dp);
-		analogix_dp_unmute_hpd_interrupt(dp);
-	}
-
 	return IRQ_HANDLED;
 }
 
@@ -1508,10 +1504,11 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
 		 * that we can get the current state of the GPIO.
 		 */
 		dp->irq = gpiod_to_irq(dp->hpd_gpiod);
-		irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN;
+		irq_flags = IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING | IRQF_NO_AUTOEN |
+			    IRQF_ONESHOT;
 	} else {
 		dp->irq = platform_get_irq(pdev, 0);
-		irq_flags = IRQF_NO_AUTOEN;
+		irq_flags = IRQF_NO_AUTOEN | IRQF_ONESHOT;
 	}
 
 	if (dp->irq < 0) {
-- 
2.34.1


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

* [PATCH v7 09/20] drm/bridge: analogix_dp: Extend clear_hotplug_interrupts to accept IRQ bitmask
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (7 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 08/20] drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 10/20] drm/bridge: analogix_dp: Extend mute/unmute HPD interrupts to accept irq bitmask Damon Ding
                   ` (10 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

Update analogix_dp_clear_hotplug_interrupts() to take an irq_type
bitmask argument. Instead of clearing all hotplug interrupt bits
unconditionally, only clear the interrupt flags corresponding to the
triggered events.

Pass the detected IRQ bitmask from the irq thread handler, and use the
full HPD_IRQ_ALL mask during HPD initialization.

Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v2:
- Add separate patch for IRQF_ONESHOT to resolve interrupt mask issues
  triggered by interrupt preemption. (Sashiko)

Changes in v3:
- Rename newly added macro HPD_IRQ to HPD_IRQ_ALL.

Changes in v4:
- Add Tested-by tag.

Changes in v6:
- Add Tested-by tag.
---
 .../drm/bridge/analogix/analogix_dp_core.c    |  2 +-
 .../drm/bridge/analogix/analogix_dp_core.h    |  2 +-
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 28 +++++++++++++------
 3 files changed, 22 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index ecc10a01cb48..44ccdf496bac 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -720,7 +720,7 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
 
 	irq_type = analogix_dp_get_irq_type(dp);
 	if (irq_type)
-		analogix_dp_clear_hotplug_interrupts(dp);
+		analogix_dp_clear_hotplug_interrupts(dp, irq_type);
 
 	if (irq_type & DP_IRQ_TYPE_HP_CABLE_IN ||
 	    irq_type & DP_IRQ_TYPE_HP_CABLE_OUT) {
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
index cc3466304531..068be3464521 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
@@ -197,7 +197,7 @@ 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);
 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_clear_hotplug_interrupts(struct analogix_dp_device *dp, u32 irq_type);
 void analogix_dp_reset_aux(struct analogix_dp_device *dp);
 void analogix_dp_init_aux(struct analogix_dp_device *dp);
 int analogix_dp_get_plug_in_status(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 49c1961e4326..2c1d4655114b 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
@@ -24,6 +24,11 @@
 #define COMMON_INT_MASK_4	(HOTPLUG_CHG | HPD_LOST | PLUG)
 #define INT_STA_MASK		INT_HPD
 
+#define HPD_IRQ_ALL		(DP_IRQ_TYPE_HP_CABLE_IN | DP_IRQ_TYPE_HP_CABLE_OUT | \
+				 DP_IRQ_TYPE_HP_CHANGE | DP_IRQ_TYPE_IRQ_HPD)
+#define COMMON_INT_4_HPD_IRQ	(DP_IRQ_TYPE_HP_CABLE_IN | DP_IRQ_TYPE_HP_CABLE_OUT | \
+				 DP_IRQ_TYPE_HP_CHANGE)
+
 void analogix_dp_enable_video_mute(struct analogix_dp_device *dp, bool enable)
 {
 	u32 reg;
@@ -375,18 +380,25 @@ int analogix_dp_init_analog_func(struct analogix_dp_device *dp)
 	return 0;
 }
 
-void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp)
+void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp, u32 irq_type)
 {
-	u32 reg;
+	u32 reg = 0;
 
-	if (dp->hpd_gpiod)
+	if (dp->hpd_gpiod || !irq_type)
 		return;
 
-	reg = HOTPLUG_CHG | HPD_LOST | PLUG;
-	writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_STA_4);
+	if (irq_type & COMMON_INT_4_HPD_IRQ) {
+		if (irq_type & DP_IRQ_TYPE_HP_CABLE_IN)
+			reg |= PLUG;
+		if (irq_type & DP_IRQ_TYPE_HP_CABLE_OUT)
+			reg |= HPD_LOST;
+		if (irq_type & DP_IRQ_TYPE_HP_CHANGE)
+			reg |= HOTPLUG_CHG;
+		writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_STA_4);
+	}
 
-	reg = INT_HPD;
-	writel(reg, dp->reg_base + ANALOGIX_DP_INT_STA);
+	if (irq_type & DP_IRQ_TYPE_IRQ_HPD)
+		writel(INT_HPD, dp->reg_base + ANALOGIX_DP_INT_STA);
 }
 
 void analogix_dp_init_hpd(struct analogix_dp_device *dp)
@@ -396,7 +408,7 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp)
 	if (dp->hpd_gpiod)
 		return;
 
-	analogix_dp_clear_hotplug_interrupts(dp);
+	analogix_dp_clear_hotplug_interrupts(dp, HPD_IRQ_ALL);
 
 	reg = readl(dp->reg_base + ANALOGIX_DP_SYS_CTL_3);
 	reg &= ~(F_HPD | HPD_CTRL);
-- 
2.34.1


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

* [PATCH v7 10/20] drm/bridge: analogix_dp: Extend mute/unmute HPD interrupts to accept irq bitmask
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (8 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 09/20] drm/bridge: analogix_dp: Extend clear_hotplug_interrupts to accept IRQ bitmask Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 11/20] drm/bridge: analogix_dp: Simplify analogix_dp_config_interrupt() Damon Ding
                   ` (9 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

Update the HPD interrupt mute/unmute routines to accept an irq_type
bitmask parameter, allowing selective per-bit mask control instead of
operating on all HPD interrupt bits unconditionally.

With IRQF_ONESHOT handling IRQ line masking during threaded handler
execution, these helpers are no longer needed in the runtime IRQ path.
They are retained for init-time use by analogix_dp_config_interrupt()
to configure platform-specific HPD interrupt masks.

Also extract the irq_type-to-COMMON_INT_STA_4 bit mapping into a shared
helper to avoid duplication in the clear/mute/unmute paths, and drop
the now unused COMMON_INT_4_HPD_IRQ macro.

Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v2:
- Update commit messages to align with newly added IRQF_ONESHOT related
  commit.

Changes in v3:
- Extract the irq_type bit mapping into a shared helper and document
  the mask register polarity once.
- Drop the unused COMMON_INT_4_HPD_IRQ macro.

Changes in v4:
- Add Tested-by tag.

Changes in v6:
- Add Tested-by tag.
---
 .../drm/bridge/analogix/analogix_dp_core.h    |  4 +-
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 80 ++++++++++++-------
 2 files changed, 55 insertions(+), 29 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
index 068be3464521..2ac92b2bac0a 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
@@ -186,8 +186,8 @@ void analogix_dp_init_interrupt(struct analogix_dp_device *dp);
 void analogix_dp_reset(struct analogix_dp_device *dp);
 void analogix_dp_swreset(struct analogix_dp_device *dp);
 void analogix_dp_config_interrupt(struct analogix_dp_device *dp);
-void analogix_dp_mute_hpd_interrupt(struct analogix_dp_device *dp);
-void analogix_dp_unmute_hpd_interrupt(struct analogix_dp_device *dp);
+void analogix_dp_mute_hpd_interrupt(struct analogix_dp_device *dp, u32 irq_type);
+void analogix_dp_unmute_hpd_interrupt(struct analogix_dp_device *dp, u32 irq_type);
 int analogix_dp_wait_pll_locked(struct analogix_dp_device *dp);
 void analogix_dp_set_pll_power_down(struct analogix_dp_device *dp, bool enable);
 void analogix_dp_set_analog_power_down(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 2c1d4655114b..6ac03a1aa512 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
@@ -26,8 +26,20 @@
 
 #define HPD_IRQ_ALL		(DP_IRQ_TYPE_HP_CABLE_IN | DP_IRQ_TYPE_HP_CABLE_OUT | \
 				 DP_IRQ_TYPE_HP_CHANGE | DP_IRQ_TYPE_IRQ_HPD)
-#define COMMON_INT_4_HPD_IRQ	(DP_IRQ_TYPE_HP_CABLE_IN | DP_IRQ_TYPE_HP_CABLE_OUT | \
-				 DP_IRQ_TYPE_HP_CHANGE)
+
+static u32 analogix_dp_irq_type_to_common_int_sta4(u32 irq_type)
+{
+	u32 reg = 0;
+
+	if (irq_type & DP_IRQ_TYPE_HP_CABLE_IN)
+		reg |= PLUG;
+	if (irq_type & DP_IRQ_TYPE_HP_CABLE_OUT)
+		reg |= HPD_LOST;
+	if (irq_type & DP_IRQ_TYPE_HP_CHANGE)
+		reg |= HOTPLUG_CHG;
+
+	return reg;
+}
 
 void analogix_dp_enable_video_mute(struct analogix_dp_device *dp, bool enable)
 {
@@ -196,30 +208,50 @@ void analogix_dp_config_interrupt(struct analogix_dp_device *dp)
 	writel(reg, dp->reg_base + ANALOGIX_DP_INT_STA_MASK);
 }
 
-void analogix_dp_mute_hpd_interrupt(struct analogix_dp_device *dp)
+/*
+ * Both ANALOGIX_DP_COMMON_INT_MASK_4 and ANALOGIX_DP_INT_STA_MASK use
+ * 0 to mask and 1 to unmask the corresponding interrupt sources.
+ */
+void analogix_dp_mute_hpd_interrupt(struct analogix_dp_device *dp, u32 irq_type)
 {
-	u32 reg;
+	u32 reg, mask;
 
-	/* 0: mask, 1: unmask */
-	reg = readl(dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_4);
-	reg &= ~COMMON_INT_MASK_4;
-	writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_4);
+	if (!irq_type)
+		return;
 
-	reg = readl(dp->reg_base + ANALOGIX_DP_INT_STA_MASK);
-	reg &= ~INT_STA_MASK;
-	writel(reg, dp->reg_base + ANALOGIX_DP_INT_STA_MASK);
+	mask = analogix_dp_irq_type_to_common_int_sta4(irq_type);
+	if (mask) {
+		reg = readl(dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_4);
+		reg &= ~mask;
+		writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_4);
+	}
+
+	if (irq_type & DP_IRQ_TYPE_IRQ_HPD) {
+		reg = readl(dp->reg_base + ANALOGIX_DP_INT_STA_MASK);
+		reg &= ~INT_HPD;
+		writel(reg, dp->reg_base + ANALOGIX_DP_INT_STA_MASK);
+	}
 }
 
-void analogix_dp_unmute_hpd_interrupt(struct analogix_dp_device *dp)
+void analogix_dp_unmute_hpd_interrupt(struct analogix_dp_device *dp, u32 irq_type)
 {
-	u32 reg;
+	u32 reg, mask;
 
-	/* 0: mask, 1: unmask */
-	reg = COMMON_INT_MASK_4;
-	writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_4);
+	if (!irq_type)
+		return;
 
-	reg = INT_STA_MASK;
-	writel(reg, dp->reg_base + ANALOGIX_DP_INT_STA_MASK);
+	mask = analogix_dp_irq_type_to_common_int_sta4(irq_type);
+	if (mask) {
+		reg = readl(dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_4);
+		reg |= mask;
+		writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_4);
+	}
+
+	if (irq_type & DP_IRQ_TYPE_IRQ_HPD) {
+		reg = readl(dp->reg_base + ANALOGIX_DP_INT_STA_MASK);
+		reg |= INT_HPD;
+		writel(reg, dp->reg_base + ANALOGIX_DP_INT_STA_MASK);
+	}
 }
 
 int analogix_dp_wait_pll_locked(struct analogix_dp_device *dp)
@@ -382,20 +414,14 @@ int analogix_dp_init_analog_func(struct analogix_dp_device *dp)
 
 void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp, u32 irq_type)
 {
-	u32 reg = 0;
+	u32 reg;
 
 	if (dp->hpd_gpiod || !irq_type)
 		return;
 
-	if (irq_type & COMMON_INT_4_HPD_IRQ) {
-		if (irq_type & DP_IRQ_TYPE_HP_CABLE_IN)
-			reg |= PLUG;
-		if (irq_type & DP_IRQ_TYPE_HP_CABLE_OUT)
-			reg |= HPD_LOST;
-		if (irq_type & DP_IRQ_TYPE_HP_CHANGE)
-			reg |= HOTPLUG_CHG;
+	reg = analogix_dp_irq_type_to_common_int_sta4(irq_type);
+	if (reg)
 		writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_STA_4);
-	}
 
 	if (irq_type & DP_IRQ_TYPE_IRQ_HPD)
 		writel(INT_HPD, dp->reg_base + ANALOGIX_DP_INT_STA);
-- 
2.34.1


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

* [PATCH v7 11/20] drm/bridge: analogix_dp: Simplify analogix_dp_config_interrupt()
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (9 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 10/20] drm/bridge: analogix_dp: Extend mute/unmute HPD interrupts to accept irq bitmask Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 12/20] drm/bridge: analogix_dp: Use platform-specific HPD detection scheme Damon Ding
                   ` (8 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

Simplify analogix_dp_config_interrupt() by removing the local
COMMON_INT_MASK and INT_STA_MASK macros, replacing the open-coded
writel(0) calls for COMMON_INT_MASK_1~3, and leveraging
analogix_dp_unmute_hpd_interrupt() with the full HPD_IRQ_ALL mask to
initialize the HPD interrupt state.

Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v3:
- Replace macro HPD_IRQ with HPD_IRQ_ALL.

Changes in v4:
- Add Tested-by tag.

Changes in v5:
- Simplify the commig msg.

Changes in v6:
- Add Tested-by tag.
---
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 25 +++----------------
 1 file changed, 4 insertions(+), 21 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
index 6ac03a1aa512..0f1406e4a5d3 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
@@ -18,12 +18,6 @@
 #include "analogix_dp_core.h"
 #include "analogix_dp_reg.h"
 
-#define COMMON_INT_MASK_1	0
-#define COMMON_INT_MASK_2	0
-#define COMMON_INT_MASK_3	0
-#define COMMON_INT_MASK_4	(HOTPLUG_CHG | HPD_LOST | PLUG)
-#define INT_STA_MASK		INT_HPD
-
 #define HPD_IRQ_ALL		(DP_IRQ_TYPE_HP_CABLE_IN | DP_IRQ_TYPE_HP_CABLE_OUT | \
 				 DP_IRQ_TYPE_HP_CHANGE | DP_IRQ_TYPE_IRQ_HPD)
 
@@ -189,23 +183,12 @@ void analogix_dp_swreset(struct analogix_dp_device *dp)
 
 void analogix_dp_config_interrupt(struct analogix_dp_device *dp)
 {
-	u32 reg;
-
 	/* 0: mask, 1: unmask */
-	reg = COMMON_INT_MASK_1;
-	writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_1);
-
-	reg = COMMON_INT_MASK_2;
-	writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_2);
-
-	reg = COMMON_INT_MASK_3;
-	writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_3);
-
-	reg = COMMON_INT_MASK_4;
-	writel(reg, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_4);
+	writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_1);
+	writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_2);
+	writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_3);
 
-	reg = INT_STA_MASK;
-	writel(reg, dp->reg_base + ANALOGIX_DP_INT_STA_MASK);
+	analogix_dp_unmute_hpd_interrupt(dp, HPD_IRQ_ALL);
 }
 
 /*
-- 
2.34.1


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

* [PATCH v7 12/20] drm/bridge: analogix_dp: Use platform-specific HPD detection scheme
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (10 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 11/20] drm/bridge: analogix_dp: Simplify analogix_dp_config_interrupt() Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 13/20] drm/bridge: analogix_dp: Skip native HPD interrupt ops for GPIO HPD Damon Ding
                   ` (7 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

The Analogix DP controller provides two sets of interrupt sources for
hotplug detection: HOTPLUG_CHG for any HPD level change, and the
PLUG/HPD_LOST pair for connect/disconnect transitions respectively.

On Rockchip platforms, configure the HPD deglitch filter and use
HOTPLUG_CHG interrupt for hotplug detection. Other platforms retain the
original PLUG + HPD_LOST scheme with unchanged deglitch values.

Move the HPD deglitch configuration into analogix_dp_reset() so that
platform-specific values are set alongside the existing register
defaults in a single location. Update the threaded IRQ handler to check
the corresponding interrupt flag based on platform type.

Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v2:
- Move ANALOGIX_DP_HPD_DEGLITCH_L/ANALOGIX_DP_HPD_DEGLITCH_H configs to
  analogix_dp_reset().

Changes in v3:
- Modify the commit msg.
- Replace macro HPD_IRQ with HPD_IRQ_ALL.

Changes in v4:
- Add Tested-by tag.

Changes in v6:
- Add Tested-by tag.
---
 .../drm/bridge/analogix/analogix_dp_core.c    |  9 ++++++--
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 22 ++++++++++++++++---
 2 files changed, 26 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 44ccdf496bac..f2ffa30e335f 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -717,13 +717,18 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
 {
 	struct analogix_dp_device *dp = arg;
 	u32 irq_type;
+	bool hpd_detected;
 
 	irq_type = analogix_dp_get_irq_type(dp);
 	if (irq_type)
 		analogix_dp_clear_hotplug_interrupts(dp, irq_type);
 
-	if (irq_type & DP_IRQ_TYPE_HP_CABLE_IN ||
-	    irq_type & DP_IRQ_TYPE_HP_CABLE_OUT) {
+	if (!dp->hpd_gpiod && analogix_dp_is_rockchip(dp->plat_data->dev_type))
+		hpd_detected = irq_type & DP_IRQ_TYPE_HP_CHANGE;
+	else
+		hpd_detected = (irq_type & DP_IRQ_TYPE_HP_CABLE_IN) ||
+			       (irq_type & DP_IRQ_TYPE_HP_CABLE_OUT);
+	if (hpd_detected) {
 		dev_dbg(dp->dev, "Detected cable status changed!\n");
 		if (dp->drm_dev)
 			drm_helper_hpd_irq_event(dp->drm_dev);
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
index 0f1406e4a5d3..025da25463a8 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
@@ -160,8 +160,13 @@ void analogix_dp_reset(struct analogix_dp_device *dp)
 	writel(0x0, dp->reg_base + ANALOGIX_DP_PKT_SEND_CTL);
 	writel(0x0, dp->reg_base + ANALOGIX_DP_HDCP_CTL);
 
-	writel(0x5e, dp->reg_base + ANALOGIX_DP_HPD_DEGLITCH_L);
-	writel(0x1a, dp->reg_base + ANALOGIX_DP_HPD_DEGLITCH_H);
+	if (analogix_dp_is_rockchip(dp->plat_data->dev_type)) {
+		writel(0x80, dp->reg_base + ANALOGIX_DP_HPD_DEGLITCH_L);
+		writel(0xbb, dp->reg_base + ANALOGIX_DP_HPD_DEGLITCH_H);
+	} else {
+		writel(0x5e, dp->reg_base + ANALOGIX_DP_HPD_DEGLITCH_L);
+		writel(0x1a, dp->reg_base + ANALOGIX_DP_HPD_DEGLITCH_H);
+	}
 
 	writel(0x10, dp->reg_base + ANALOGIX_DP_LINK_DEBUG_CTL);
 
@@ -188,7 +193,18 @@ void analogix_dp_config_interrupt(struct analogix_dp_device *dp)
 	writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_2);
 	writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_3);
 
-	analogix_dp_unmute_hpd_interrupt(dp, HPD_IRQ_ALL);
+	/*
+	 * Either HOTPLUG_CHG interrupt or PLUG + HPD_LOST interrupt
+	 * pair can be used to implement hotplug detection.
+	 *
+	 * On Rockchip platforms, configuring HPD deglitch to 2ms and
+	 * using HOTPLUG_CHG interrupt for hotplug detection is proven
+	 * as a better solution via engineering verification.
+	 */
+	if (analogix_dp_is_rockchip(dp->plat_data->dev_type))
+		analogix_dp_unmute_hpd_interrupt(dp, DP_IRQ_TYPE_HP_CHANGE);
+	else
+		analogix_dp_unmute_hpd_interrupt(dp, HPD_IRQ_ALL);
 }
 
 /*
-- 
2.34.1


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

* [PATCH v7 13/20] drm/bridge: analogix_dp: Skip native HPD interrupt ops for GPIO HPD
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (11 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 12/20] drm/bridge: analogix_dp: Use platform-specific HPD detection scheme Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 14/20] drm/rockchip: analogix_dp: Unbind bridge when connector init fails Damon Ding
                   ` (6 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

GPIO HPD does not rely on DP controller internal native HPD interrupts.
Skip native HPD register manipulations to avoid irrelevant operations.

Move the hpd_gpiod guard to its caller so the helper operates purely on
the given bitmask, and mute all native HPD interrupts for GPIO mode.

Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v2:
- Adapt to the newly added IRQF_ONESHOT related commit and expand the
  commit msg.

Changes in v3:
- Reorganize the branch layout for hpd_gpiod check.
- Simplify the commit msg.

Changes in v4:
- Add Tested-by tag.

Changes in v6:
- Add Tested-by tag.
---
 drivers/gpu/drm/bridge/analogix/analogix_dp_core.c | 2 +-
 drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c  | 7 ++++++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index f2ffa30e335f..af855f33cf6f 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -720,7 +720,7 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
 	bool hpd_detected;
 
 	irq_type = analogix_dp_get_irq_type(dp);
-	if (irq_type)
+	if (!dp->hpd_gpiod && irq_type)
 		analogix_dp_clear_hotplug_interrupts(dp, irq_type);
 
 	if (!dp->hpd_gpiod && analogix_dp_is_rockchip(dp->plat_data->dev_type))
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
index 025da25463a8..af5e5a8ec88d 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
@@ -193,6 +193,11 @@ void analogix_dp_config_interrupt(struct analogix_dp_device *dp)
 	writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_2);
 	writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_3);
 
+	if (dp->hpd_gpiod) {
+		analogix_dp_mute_hpd_interrupt(dp, HPD_IRQ_ALL);
+		return;
+	}
+
 	/*
 	 * Either HOTPLUG_CHG interrupt or PLUG + HPD_LOST interrupt
 	 * pair can be used to implement hotplug detection.
@@ -415,7 +420,7 @@ void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp, u32 irq
 {
 	u32 reg;
 
-	if (dp->hpd_gpiod || !irq_type)
+	if (!irq_type)
 		return;
 
 	reg = analogix_dp_irq_type_to_common_int_sta4(irq_type);
-- 
2.34.1


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

* [PATCH v7 14/20] drm/rockchip: analogix_dp: Unbind bridge when connector init fails
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (12 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 13/20] drm/bridge: analogix_dp: Skip native HPD interrupt ops for GPIO HPD Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 15/20] drm/exynos: exynos_dp: " Damon Ding
                   ` (5 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

The rockchip_dp_bind() returns without unwinding analogix_dp_bind()
when drm_bridge_connector_init() fails.  The aux device registered by
analogix_dp_bind() is then left behind with a dangling drm_dev
pointer, which could be accessed on later AUX transfers.

Call analogix_dp_unbind() in the error path to release the aux device.

Fixes: 99a49ff5ef7a ("drm/bridge: analogix_dp: Apply drm_bridge_connector helper")
Tested-by: Heiko Stuebner <heiko@sntech.de>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v6:
- Add Tested-by tag.

Changes in v7:
- Add Fixes tag.
---
 drivers/gpu/drm/rockchip/analogix_dp-rockchip.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
index 635146746b42..39eca3ec7160 100644
--- a/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
+++ b/drivers/gpu/drm/rockchip/analogix_dp-rockchip.c
@@ -419,6 +419,7 @@ static int rockchip_dp_bind(struct device *dev, struct device *master,
 	if (IS_ERR(connector)) {
 		ret = PTR_ERR(connector);
 		dev_err(dp->dev, "Failed to initialize bridge_connector\n");
+		analogix_dp_unbind(dp->adp);
 		goto err_cleanup_encoder;
 	}
 
-- 
2.34.1


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

* [PATCH v7 15/20] drm/exynos: exynos_dp: Unbind bridge when connector init fails
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (13 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 14/20] drm/rockchip: analogix_dp: Unbind bridge when connector init fails Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 16/20] drm/bridge: analogix_dp: Move IRQ enable/disable to bind/unbind Damon Ding
                   ` (4 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

The exynos_dp_bind() returns without unwinding analogix_dp_bind() when
drm_bridge_connector_init() fails.  The aux device registered by
analogix_dp_bind() is then left behind with a dangling drm_dev
pointer, which could be accessed on later AUX transfers.

Call analogix_dp_unbind() in the error path to release the aux device.

Fixes: 99a49ff5ef7a ("drm/bridge: analogix_dp: Apply drm_bridge_connector helper")
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v6:
- Add Tested-by tag.

Changes in v7:
- Add Fixes tag.
---
 drivers/gpu/drm/exynos/exynos_dp.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/gpu/drm/exynos/exynos_dp.c b/drivers/gpu/drm/exynos/exynos_dp.c
index 572e261e09da..86dc53014fff 100644
--- a/drivers/gpu/drm/exynos/exynos_dp.c
+++ b/drivers/gpu/drm/exynos/exynos_dp.c
@@ -121,6 +121,7 @@ static int exynos_dp_bind(struct device *dev, struct device *master, void *data)
 	if (IS_ERR(connector)) {
 		ret = PTR_ERR(connector);
 		dev_err(dp->dev, "Failed to initialize bridge_connector\n");
+		analogix_dp_unbind(dp->adp);
 		return ret;
 	}
 
-- 
2.34.1


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

* [PATCH v7 16/20] drm/bridge: analogix_dp: Move IRQ enable/disable to bind/unbind
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (14 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 15/20] drm/exynos: exynos_dp: " Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 17/20] drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection Damon Ding
                   ` (3 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

Move enable_irq()/disable_irq() from bridge enable/disable handlers
into analogix_dp_bind()/analogix_dp_unbind(). This keeps the IRQ
active throughout the device lifecycle rather than only during display
activity, which is a prerequisite for supporting HPD detection while
the display pipeline is inactive.

Make the interrupt fully threaded and hold a runtime PM reference in
the threaded handler, so that no register is accessed while the
controller is runtime suspended.

Tested-by: Heiko Stuebner <heiko@sntech.de>
Tested-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v3:
- Move this patch after mute/unmute related modification and detail the
  commit msg.

Changes in v4:
- Add Tested-by tag.

Changes in v5:
- Use a pure threaded IRQ handler and hold a runtime PM reference in
  it, so that no MMIO happens on the unclocked controller after
  runtime suspend. (Sashiko)
- Add prep patches to call analogix_dp_unbind() when
  drm_bridge_connector_init() fails, so that the IRQ enabled across
  the bind lifetime gets properly disabled on bind failures. (Sashiko)

Changes in v6:
- Skip the runtime PM reference in the IRQ thread for the GPIO HPD
  mode, since it only reads the GPIO level. (Sashiko)
- Add Tested-by tag.

Changes in v7:
- Do not add the redundant pm_runtime_mark_last_busy() call, as
  pm_runtime_put_autosuspend() updates the last busy stamp since
  commit b3db492e8335.
---
 .../drm/bridge/analogix/analogix_dp_core.c    | 38 ++++++++++---------
 1 file changed, 21 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index af855f33cf6f..46433ea73d67 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -700,24 +700,25 @@ static int analogix_dp_enable_scramble(struct analogix_dp_device *dp,
 	return ret < 0 ? ret : 0;
 }
 
-static irqreturn_t analogix_dp_hardirq(int irq, void *arg)
-{
-	struct analogix_dp_device *dp = arg;
-	irqreturn_t ret = IRQ_NONE;
-	u32 irq_type;
-
-	irq_type = analogix_dp_get_irq_type(dp);
-	if (irq_type)
-		ret = IRQ_WAKE_THREAD;
-
-	return ret;
-}
-
 static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
 {
 	struct analogix_dp_device *dp = arg;
 	u32 irq_type;
 	bool hpd_detected;
+	int ret;
+
+	/*
+	 * The device may have been runtime suspended since the interrupt was
+	 * raised. Hold a runtime PM reference before touching the registers,
+	 * as the controller clocks are only guaranteed to be enabled while
+	 * the device is runtime PM active. The GPIO HPD mode needs no such
+	 * reference, since it only reads the GPIO level.
+	 */
+	if (!dp->hpd_gpiod) {
+		ret = pm_runtime_resume_and_get(dp->dev);
+		if (ret)
+			return IRQ_HANDLED;
+	}
 
 	irq_type = analogix_dp_get_irq_type(dp);
 	if (!dp->hpd_gpiod && irq_type)
@@ -734,6 +735,9 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
 			drm_helper_hpd_irq_event(dp->drm_dev);
 	}
 
+	if (!dp->hpd_gpiod)
+		pm_runtime_put_autosuspend(dp->dev);
+
 	return IRQ_HANDLED;
 }
 
@@ -1053,7 +1057,6 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp)
 		goto out_dp_init;
 	}
 
-	enable_irq(dp->irq);
 	return 0;
 
 out_dp_init:
@@ -1195,8 +1198,6 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)
 	if (dp->dpms_mode != DRM_MODE_DPMS_ON)
 		return;
 
-	disable_irq(dp->irq);
-
 	analogix_dp_set_analog_power_down(dp, POWER_ALL, 1);
 
 	pm_runtime_put_sync(dp->dev);
@@ -1522,7 +1523,7 @@ analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data)
 	}
 
 	ret = devm_request_threaded_irq(&pdev->dev, dp->irq,
-					analogix_dp_hardirq,
+					NULL,
 					analogix_dp_irq_thread,
 					irq_flags, "analogix-dp", dp);
 	if (ret)
@@ -1608,6 +1609,8 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
 		goto err_unregister_aux;
 	}
 
+	enable_irq(dp->irq);
+
 	return 0;
 
 err_unregister_aux:
@@ -1619,6 +1622,7 @@ EXPORT_SYMBOL_GPL(analogix_dp_bind);
 
 void analogix_dp_unbind(struct analogix_dp_device *dp)
 {
+	disable_irq(dp->irq);
 	drm_dp_aux_unregister(&dp->aux);
 }
 EXPORT_SYMBOL_GPL(analogix_dp_unbind);
-- 
2.34.1


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

* [PATCH v7 17/20] drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (15 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 16/20] drm/bridge: analogix_dp: Move IRQ enable/disable to bind/unbind Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 18/20] drm/bridge: analogix_dp: Declare DRM_BRIDGE_OP_HPD for hotplug reporting Damon Ding
                   ` (2 subsequent siblings)
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

This commit holds the runtime PM reference across the bind/unbind
lifecycle on the RK3576 and RK3588 platforms, which rely on the native
controller interrupt for hotplug detection. The hotplug IRQ is enabled
only for the platforms which support hotplug detection, i.e., the GPIO
HPD mode or the native HPD mode on RK3576 and RK3588, so that the IRQ
thread is not run on the platforms without hotplug support.

The force-connected and force-HPD modes are excluded from the hotplug
detection support, since the HPD events shall not be reported for the
fixed panels.

Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v2:
- Split IRQ enable/disable logic, handle native HPD pin and
  GPIO/force-HPD modes separately to avoid unbalanced enable_irq()
  calls. (Sashiko)

Changes in v3:
- Modify the commit msg according to the previous commit for moving IRQ
  enabling/disabling.

Changes in v4:
- Add Tested-by tag.

Changes in v5:
- Limit the runtime PM holding to the RK3576/RK3588 platforms, which
  are the only ones confirmed to support the DP mode hotplug
  detection, and exclude the boards with a fixed panel, so that the
  runtime suspend still works when the screen is blanked. (Sashiko)
- Add a new commit declaring DRM_BRIDGE_OP_HPD on the Analogix DP
  bridge and reporting the hotplug events via drm_bridge_hpd_notify().
  (Sashiko)

Changes in v6:
- Enable the hotplug IRQ only for the platforms which support hotplug
  detection (the GPIO HPD mode, or the native HPD mode on RK3576 and
  RK3588). (Sashiko)
- Exclude the force-connected and force-HPD modes from the hotplug
  detection support check. (Sashiko)
- Simplify the commit msg.
- Add Tested-by tag.

Changes in v7:
- Derive analogix_dp_require_pm_for_hpd_irq() from
  analogix_dp_supports_hpd().
- Track the hotplug IRQ enable state for an idempotent enable/disable,
  and gate the IRQ around the runtime PM transitions only for the
  platforms which hold the runtime PM reference. (Sashiko)
- Drop the Tested-by tags, as the design of this patch changed
  significantly in this version.
---
 .../drm/bridge/analogix/analogix_dp_core.c    | 57 ++++++++++++++++++-
 .../drm/bridge/analogix/analogix_dp_core.h    |  1 +
 2 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 46433ea73d67..cda6e4c5cbc8 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -42,6 +42,33 @@
 
 static const bool verify_fast_training;
 
+/*
+ * The hotplug events are reported either through the optional GPIO HPD
+ * pin or through the native controller interrupt, which is confirmed
+ * to work only on the RK3576 and RK3588 platforms.
+ */
+static bool analogix_dp_supports_hpd(struct analogix_dp_device *dp)
+{
+	if (dp->force_connected_mode || dp->force_hpd)
+		return false;
+
+	if (dp->hpd_gpiod)
+		return true;
+
+	return dp->plat_data->dev_type == RK3576_EDP || dp->plat_data->dev_type == RK3588_EDP;
+}
+
+/*
+ * The native HPD interrupt relies on the controller staying powered
+ * and clocked to report the hotplug events, so a runtime PM reference
+ * is held for it.  The GPIO HPD mode needs no such reference, as it
+ * reads the GPIO level directly.
+ */
+static bool analogix_dp_require_pm_for_hpd_irq(struct analogix_dp_device *dp)
+{
+	return analogix_dp_supports_hpd(dp) && !dp->hpd_gpiod;
+}
+
 static void analogix_dp_init_dp(struct analogix_dp_device *dp)
 {
 	analogix_dp_reset(dp);
@@ -1547,6 +1574,11 @@ EXPORT_SYMBOL_GPL(analogix_dp_probe);
 
 int analogix_dp_suspend(struct analogix_dp_device *dp)
 {
+	if (analogix_dp_require_pm_for_hpd_irq(dp) && dp->hpd_irq_enabled) {
+		disable_irq(dp->irq);
+		dp->hpd_irq_enabled = false;
+	}
+
 	phy_power_off(dp->phy);
 
 	if (dp->plat_data->power_off)
@@ -1576,6 +1608,11 @@ int analogix_dp_resume(struct analogix_dp_device *dp)
 
 	analogix_dp_init_dp(dp);
 
+	if (analogix_dp_require_pm_for_hpd_irq(dp) && !dp->hpd_irq_enabled) {
+		enable_irq(dp->irq);
+		dp->hpd_irq_enabled = true;
+	}
+
 	return 0;
 }
 EXPORT_SYMBOL_GPL(analogix_dp_resume);
@@ -1609,7 +1646,16 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
 		goto err_unregister_aux;
 	}
 
-	enable_irq(dp->irq);
+	if (analogix_dp_require_pm_for_hpd_irq(dp)) {
+		ret = pm_runtime_resume_and_get(dp->dev);
+		if (ret)
+			goto err_unregister_aux;
+	}
+
+	if (analogix_dp_supports_hpd(dp) && !dp->hpd_irq_enabled) {
+		enable_irq(dp->irq);
+		dp->hpd_irq_enabled = true;
+	}
 
 	return 0;
 
@@ -1622,7 +1668,14 @@ EXPORT_SYMBOL_GPL(analogix_dp_bind);
 
 void analogix_dp_unbind(struct analogix_dp_device *dp)
 {
-	disable_irq(dp->irq);
+	if (dp->hpd_irq_enabled) {
+		disable_irq(dp->irq);
+		dp->hpd_irq_enabled = false;
+	}
+
+	if (analogix_dp_require_pm_for_hpd_irq(dp))
+		pm_runtime_put_sync(dp->dev);
+
 	drm_dp_aux_unregister(&dp->aux);
 }
 EXPORT_SYMBOL_GPL(analogix_dp_unbind);
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
index 2ac92b2bac0a..17ebb96d66ca 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
@@ -171,6 +171,7 @@ struct analogix_dp_device {
 	bool			fast_train_enable;
 	bool			psr_supported;
 	bool			force_connected_mode;
+	bool			hpd_irq_enabled;
 
 	u8 dpcd[DP_RECEIVER_CAP_SIZE];
 
-- 
2.34.1


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

* [PATCH v7 18/20] drm/bridge: analogix_dp: Declare DRM_BRIDGE_OP_HPD for hotplug reporting
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (16 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 17/20] drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 19/20] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge Damon Ding
  2026-11-25 11:21 ` [PATCH v7 20/20] MAINTAINERS: Add entry for Analogix DP controller bridge Damon Ding
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

This commit declares DRM_BRIDGE_OP_HPD for the analogix_dp bridge,
adds the hpd_enable/hpd_disable bridge callbacks and reports the
hotplug events through drm_bridge_hpd_notify() with the status read
from the HPD GPIO pin or the controller registers.

The DRM_BRIDGE_OP_HPD capability is declared only for the platforms
which support hotplug detection (the GPIO HPD mode, or the native HPD
mode on RK3576 and RK3588), since the drm core stops polling the
connector once DRM_BRIDGE_OP_HPD is declared.

Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v6:
- Declare DRM_BRIDGE_OP_HPD only for the platforms which support
  hotplug detection, since the drm core stops polling the connector
  once DRM_BRIDGE_OP_HPD is declared. (Sashiko)
- Add Tested-by tag.

Changes in v7:
- Set the bridge ops after the chain is attached, as the
  DRM_BRIDGE_OP_HPD declaration previously preceded the
  force_connected_mode initialization, leaving the hotplug detection
  broken on fixed panels with a wired HPD GPIO. (Sashiko)
- Drop the Tested-by tags, as the design of this patch changed
  significantly in this version.
---
 .../drm/bridge/analogix/analogix_dp_core.c    | 24 +++++++++++++++----
 1 file changed, 20 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index cda6e4c5cbc8..7ab183f72eb6 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -31,7 +31,6 @@
 #include <drm/drm_edid.h>
 #include <drm/drm_of.h>
 #include <drm/drm_print.h>
-#include <drm/drm_probe_helper.h>
 
 #include <video/of_display_timing.h>
 
@@ -757,9 +756,13 @@ static irqreturn_t analogix_dp_irq_thread(int irq, void *arg)
 		hpd_detected = (irq_type & DP_IRQ_TYPE_HP_CABLE_IN) ||
 			       (irq_type & DP_IRQ_TYPE_HP_CABLE_OUT);
 	if (hpd_detected) {
+		enum drm_connector_status status;
+
 		dev_dbg(dp->dev, "Detected cable status changed!\n");
-		if (dp->drm_dev)
-			drm_helper_hpd_irq_event(dp->drm_dev);
+
+		status = analogix_dp_get_plug_in_status(dp) == 0 ? connector_status_connected :
+								   connector_status_disconnected;
+		drm_bridge_hpd_notify(&dp->bridge, status);
 	}
 
 	if (!dp->hpd_gpiod)
@@ -1293,6 +1296,14 @@ static void analogix_dp_bridge_atomic_post_disable(struct drm_bridge *bridge,
 		DRM_ERROR("Failed to enable psr (%d)\n", ret);
 }
 
+static void analogix_dp_bridge_hpd_enable(struct drm_bridge *bridge)
+{
+}
+
+static void analogix_dp_bridge_hpd_disable(struct drm_bridge *bridge)
+{
+}
+
 static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
 	.atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
 	.atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
@@ -1305,6 +1316,8 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
 	.attach = analogix_dp_bridge_attach,
 	.edid_read = analogix_dp_bridge_edid_read,
 	.detect = analogix_dp_bridge_detect,
+	.hpd_enable = analogix_dp_bridge_hpd_enable,
+	.hpd_disable = analogix_dp_bridge_hpd_disable,
 };
 
 static int analogix_dp_dt_parse_lanes_map(struct analogix_dp_device *dp)
@@ -1633,7 +1646,6 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
 		return ret;
 	}
 
-	bridge->ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
 	bridge->of_node = dp->dev->of_node;
 	bridge->type = DRM_MODE_CONNECTOR_eDP;
 	ret = devm_drm_bridge_add(dp->dev, &dp->bridge);
@@ -1646,6 +1658,10 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev)
 		goto err_unregister_aux;
 	}
 
+	bridge->ops = DRM_BRIDGE_OP_EDID | DRM_BRIDGE_OP_DETECT;
+	if (analogix_dp_supports_hpd(dp))
+		bridge->ops |= DRM_BRIDGE_OP_HPD;
+
 	if (analogix_dp_require_pm_for_hpd_irq(dp)) {
 		ret = pm_runtime_resume_and_get(dp->dev);
 		if (ret)
-- 
2.34.1


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

* [PATCH v7 19/20] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (17 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 18/20] drm/bridge: analogix_dp: Declare DRM_BRIDGE_OP_HPD for hotplug reporting Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  2026-11-25 11:21 ` [PATCH v7 20/20] MAINTAINERS: Add entry for Analogix DP controller bridge Damon Ding
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

When the display pipeline includes a display-connector bridge with
hpd-gpios configured, the connector's hotplug status is managed by the
display-connector bridge through its GPIO, not by the Analogix DP
controller's native HPD. In this configuration, the DP controller's
internal HPD polling in analogix_dp_detect_hpd() does not reflect the
actual connection state.

At attach time, detect whether a downstream bridge provides HPD events
(DRM_BRIDGE_OP_HPD) while none of them provides detection
(DRM_BRIDGE_OP_DETECT). When found, switch to hpd notify mode: mute
the controller's native HPD interrupts and skip their initialization,
and use the downstream notifications only as a trigger to probe the
sink over the AUX channel, treating it as connected when its DPCD can
be read back. The probe result is cached and refreshed by both the
notify and the detect paths, so that the reported state always comes
from the hardware and the stale echo cannot overwrite it.

Suggested-by: Heiko Stuebner <heiko@sntech.de>
Link: https://lore.kernel.org/all/5609825.iZASKD2KPV@diego/
Signed-off-by: Damon Ding <damon.ding@rock-chips.com>

---

Changes in v3:
- Introduce hpd_notify_mode flag to skip native HPD operations when
  HPD comes from a downstream bridge.

Changes in v4:
- Add Tested-by tag.

Changes in v5:
- Return the connector status directly from analogix_dp_bridge_detect()
  in the hpd notify mode, to avoid the race where the hpd_notify() echo
  of the detect path overwrites a newer notification cached by
  analogix_dp_bridge_notify(). (Sashiko)

Changes in v6:
- Return the cached connection status instead of connector->status from
  analogix_dp_bridge_detect(), as connector->status may still be
  unknown before the first HPD notification or stale after the sysfs
  state forcing. (Sashiko)
- Add Tested-by tag.

Changes in v7:
- Probe the sink over the AUX channel in the hpd notify mode instead
  of relying on the notified status, refreshing the cached state in
  both the .hpd_notify and the detect path. (Sashiko)
- Exclude the hpd notify mode from analogix_dp_supports_hpd(), so
  that neither DRM_BRIDGE_OP_HPD is declared nor the hotplug IRQ is
  enabled for the muted native interrupts. (Sashiko)
- Skip the HPD polling and the AUX probe where they are not needed in
  the hpd notify mode and the other modes respectively.
- Drop the Tested-by tag, as the design of this patch changed
  significantly in this version.
---
 .../drm/bridge/analogix/analogix_dp_core.c    | 56 ++++++++++++++++++-
 .../drm/bridge/analogix/analogix_dp_core.h    |  2 +
 .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 21 ++++---
 3 files changed, 67 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
index 7ab183f72eb6..49d0eba74e7f 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c
@@ -48,7 +48,7 @@ static const bool verify_fast_training;
  */
 static bool analogix_dp_supports_hpd(struct analogix_dp_device *dp)
 {
-	if (dp->force_connected_mode || dp->force_hpd)
+	if (dp->force_connected_mode || dp->force_hpd || dp->hpd_notify_mode)
 		return false;
 
 	if (dp->hpd_gpiod)
@@ -86,10 +86,29 @@ static void analogix_dp_init_dp(struct analogix_dp_device *dp)
 	analogix_dp_init_aux(dp);
 }
 
+static bool analogix_dp_probe_sink(struct analogix_dp_device *dp)
+{
+	u8 dpcd_rev = 0;
+	int ret;
+
+	ret = pm_runtime_resume_and_get(dp->dev);
+	if (ret)
+		return false;
+
+	ret = drm_dp_dpcd_readb(&dp->aux, DP_DPCD_REV, &dpcd_rev);
+
+	pm_runtime_put_autosuspend(dp->dev);
+
+	return ret == 1 && dpcd_rev != 0;
+}
+
 static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)
 {
 	int timeout_loop = 0;
 
+	if (dp->hpd_notify_mode)
+		return 0;
+
 	while (timeout_loop < DP_TIMEOUT_LOOP_COUNT) {
 		if (analogix_dp_get_plug_in_status(dp) == 0)
 			return 0;
@@ -940,6 +959,13 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne
 	struct analogix_dp_device *dp = to_dp(bridge);
 	enum drm_connector_status status = connector_status_disconnected;
 
+	if (dp->hpd_notify_mode) {
+		dp->connection_notified = analogix_dp_probe_sink(dp);
+
+		return dp->connection_notified ? connector_status_connected :
+						 connector_status_disconnected;
+	}
+
 	if (dp->force_connected_mode)
 		return connector_status_connected;
 
@@ -972,6 +998,21 @@ static bool analogix_dp_bridge_force_connected(struct analogix_dp_device *dp)
 	return force_connected;
 }
 
+static bool analogix_dp_has_downstream_hpd(struct analogix_dp_device *dp)
+{
+	bool hpd_bridge = false;
+
+	drm_for_each_bridge_in_chain_from(dp->bridge.next_bridge, bridge) {
+		if (bridge->ops & DRM_BRIDGE_OP_DETECT)
+			return false;
+
+		if (bridge->ops & DRM_BRIDGE_OP_HPD)
+			hpd_bridge = true;
+	}
+
+	return hpd_bridge;
+}
+
 static int analogix_dp_bridge_attach(struct drm_bridge *bridge,
 				     struct drm_encoder *encoder,
 				     enum drm_bridge_attach_flags flags)
@@ -1000,6 +1041,7 @@ static int analogix_dp_bridge_attach(struct drm_bridge *bridge,
 		 * accurate hotplug state.
 		 */
 		dp->force_connected_mode = analogix_dp_bridge_force_connected(dp);
+		dp->hpd_notify_mode = analogix_dp_has_downstream_hpd(dp);
 	}
 
 	return 0;
@@ -1296,6 +1338,17 @@ static void analogix_dp_bridge_atomic_post_disable(struct drm_bridge *bridge,
 		DRM_ERROR("Failed to enable psr (%d)\n", ret);
 }
 
+static void analogix_dp_bridge_notify(struct drm_bridge *bridge, struct drm_connector *connector,
+				      enum drm_connector_status status)
+{
+	struct analogix_dp_device *dp = to_dp(bridge);
+
+	if (!dp->hpd_notify_mode)
+		return;
+
+	dp->connection_notified = analogix_dp_probe_sink(dp);
+}
+
 static void analogix_dp_bridge_hpd_enable(struct drm_bridge *bridge)
 {
 }
@@ -1316,6 +1369,7 @@ static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
 	.attach = analogix_dp_bridge_attach,
 	.edid_read = analogix_dp_bridge_edid_read,
 	.detect = analogix_dp_bridge_detect,
+	.hpd_notify = analogix_dp_bridge_notify,
 	.hpd_enable = analogix_dp_bridge_hpd_enable,
 	.hpd_disable = analogix_dp_bridge_hpd_disable,
 };
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
index 17ebb96d66ca..ebd0662aed5c 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.h
@@ -172,6 +172,8 @@ struct analogix_dp_device {
 	bool			psr_supported;
 	bool			force_connected_mode;
 	bool			hpd_irq_enabled;
+	bool			hpd_notify_mode;
+	bool			connection_notified;
 
 	u8 dpcd[DP_RECEIVER_CAP_SIZE];
 
diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
index af5e5a8ec88d..125f4fecbaa2 100644
--- a/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
+++ b/drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c
@@ -193,7 +193,7 @@ void analogix_dp_config_interrupt(struct analogix_dp_device *dp)
 	writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_2);
 	writel(0, dp->reg_base + ANALOGIX_DP_COMMON_INT_MASK_3);
 
-	if (dp->hpd_gpiod) {
+	if (dp->hpd_gpiod || dp->hpd_notify_mode) {
 		analogix_dp_mute_hpd_interrupt(dp, HPD_IRQ_ALL);
 		return;
 	}
@@ -435,7 +435,7 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp)
 {
 	u32 reg;
 
-	if (dp->hpd_gpiod)
+	if (dp->hpd_gpiod || dp->hpd_notify_mode)
 		return;
 
 	analogix_dp_clear_hotplug_interrupts(dp, HPD_IRQ_ALL);
@@ -533,16 +533,15 @@ int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp)
 {
 	u32 reg;
 
-	if (dp->hpd_gpiod) {
-		if (gpiod_get_value(dp->hpd_gpiod))
-			return 0;
-	} else {
-		reg = readl(dp->reg_base + ANALOGIX_DP_SYS_CTL_3);
-		if (reg & HPD_STATUS)
-			return 0;
-	}
+	if (dp->hpd_gpiod)
+		return gpiod_get_value(dp->hpd_gpiod) ? 0 : -EINVAL;
+
+	if (dp->hpd_notify_mode)
+		return dp->connection_notified ? 0 : -EINVAL;
+
+	reg = readl(dp->reg_base + ANALOGIX_DP_SYS_CTL_3);
 
-	return -EINVAL;
+	return (reg & HPD_STATUS) ? 0 : -EINVAL;
 }
 
 void analogix_dp_enable_sw_function(struct analogix_dp_device *dp)
-- 
2.34.1


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

* [PATCH v7 20/20] MAINTAINERS: Add entry for Analogix DP controller bridge
  2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
                   ` (18 preceding siblings ...)
  2026-11-25 11:21 ` [PATCH v7 19/20] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge Damon Ding
@ 2026-11-25 11:21 ` Damon Ding
  19 siblings, 0 replies; 21+ messages in thread
From: Damon Ding @ 2026-11-25 11:21 UTC (permalink / raw)
  To: Andrzej Hajda, Neil Armstrong, Robert Foss, Maarten Lankhorst,
	Maxime Ripard, Thomas Zimmermann, David Airlie, Simona Vetter,
	Jingoo Han, Inki Dae, Seung-Woo Kim, Kyungmin Park,
	Krzysztof Kozlowski, Peter Griffin, Alim Akhtar, Heiko Stuebner,
	Sandy Huang, Andy Yan
  Cc: Laurent Pinchart, Jonas Karlman, Jernej Skrabec, Luca Ceresoli,
	Dmitry Baryshkov, Marek Szyprowski, linux-kernel, dri-devel,
	linux-arm-kernel, linux-samsung-soc, linux-rockchip, Damon Ding

Add a MAINTAINERS entry for the Analogix DP controller bridge, covering
the core bridge driver, its register helpers, the public header and the
DT binding, so that get_maintainer.pl routes related patches correctly.

Signed-off-by: Damon Ding <damon.ding@rock-chips.com>
---
 MAINTAINERS | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/MAINTAINERS b/MAINTAINERS
index 95a897dee61b..fc839f2cfebf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8237,6 +8237,17 @@ S:	Supported
 T:	git https://gitlab.freedesktop.org/drm/misc/kernel.git
 F:	drivers/gpu/drm/sun4i/sun8i*
 
+DRM DRIVER FOR ANALOGIX DISPLAYPORT BRIDGE
+M:	Damon Ding <damon.ding@rock-chips.com>
+L:	dri-devel@lists.freedesktop.org
+S:	Maintained
+T:	git https://gitlab.freedesktop.org/drm/misc/kernel.git
+F:	Documentation/devicetree/bindings/display/bridge/analogix,dp.yaml
+F:	drivers/gpu/drm/bridge/analogix/Kconfig
+F:	drivers/gpu/drm/bridge/analogix/Makefile
+F:	drivers/gpu/drm/bridge/analogix/analogix_dp_*
+F:	include/drm/bridge/analogix_dp.h
+
 DRM DRIVER FOR APPLE TOUCH BARS
 M:	Aun-Ali Zaidi <admin@kodeit.net>
 M:	Aditya Garg <aditya.garg@linux.dev>
-- 
2.34.1


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

end of thread, other threads:[~2026-11-25 11:22 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-25 11:21 [PATCH v7 00/20] Add HPD support for Rockchip Analogix DP Damon Ding
2026-11-25 11:21 ` [PATCH v7 01/20] drm/bridge: Select VIDEOMODE_HELPERS for DRM_OF_DISPLAY_MODE_BRIDGE Damon Ding
2026-11-25 11:21 ` [PATCH v7 02/20] drm/bridge: analogix_dp: Drop the redundant pm_runtime_mark_last_busy() calls Damon Ding
2026-11-25 11:21 ` [PATCH v7 03/20] drm/bridge: analogix_dp: Use bridge->next_bridge instead of plat_data field Damon Ding
2026-11-25 11:21 ` [PATCH v7 04/20] drm/bridge: analogix_dp: Restrict forced connected status to panel endpoints Damon Ding
2026-11-25 11:21 ` [PATCH v7 05/20] drm/bridge: analogix_dp: Take a runtime PM reference in bridge detect Damon Ding
2026-11-25 11:21 ` [PATCH v7 06/20] drm/bridge: analogix_dp: Return bitmask from analogix_dp_get_irq_type() Damon Ding
2026-11-25 11:21 ` [PATCH v7 07/20] drm/bridge: analogix_dp: Check all negative return values for &analogix_dp_device.irq Damon Ding
2026-11-25 11:21 ` [PATCH v7 08/20] drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling Damon Ding
2026-11-25 11:21 ` [PATCH v7 09/20] drm/bridge: analogix_dp: Extend clear_hotplug_interrupts to accept IRQ bitmask Damon Ding
2026-11-25 11:21 ` [PATCH v7 10/20] drm/bridge: analogix_dp: Extend mute/unmute HPD interrupts to accept irq bitmask Damon Ding
2026-11-25 11:21 ` [PATCH v7 11/20] drm/bridge: analogix_dp: Simplify analogix_dp_config_interrupt() Damon Ding
2026-11-25 11:21 ` [PATCH v7 12/20] drm/bridge: analogix_dp: Use platform-specific HPD detection scheme Damon Ding
2026-11-25 11:21 ` [PATCH v7 13/20] drm/bridge: analogix_dp: Skip native HPD interrupt ops for GPIO HPD Damon Ding
2026-11-25 11:21 ` [PATCH v7 14/20] drm/rockchip: analogix_dp: Unbind bridge when connector init fails Damon Ding
2026-11-25 11:21 ` [PATCH v7 15/20] drm/exynos: exynos_dp: " Damon Ding
2026-11-25 11:21 ` [PATCH v7 16/20] drm/bridge: analogix_dp: Move IRQ enable/disable to bind/unbind Damon Ding
2026-11-25 11:21 ` [PATCH v7 17/20] drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection Damon Ding
2026-11-25 11:21 ` [PATCH v7 18/20] drm/bridge: analogix_dp: Declare DRM_BRIDGE_OP_HPD for hotplug reporting Damon Ding
2026-11-25 11:21 ` [PATCH v7 19/20] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge Damon Ding
2026-11-25 11:21 ` [PATCH v7 20/20] MAINTAINERS: Add entry for Analogix DP controller bridge Damon Ding

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

all inboxes | Powered by JetHome®