Add HPD support for Rockchip Analogix DP
Subsystems (4)
v2 cover Add HPD support for Rockchip Analogix DP
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.
Patch 1: Move enable_irq()/disable_irq() to bind/unbind and hold a
pm_runtime reference for Rockchip native HPD pin mode.
Patch 2: Convert analogix_dp_get_irq_type() to return a u32 bitmask
instead of an enum, accumulating all pending interrupt flags.
Patch 3: Add IRQF_ONESHOT to prevent hardirq from preempting the
threaded handler; remove redundant mute/unmute from runtime IRQ path; move status clearing before event handling.
Patch 4: Extend clear_hotplug_interrupts() to accept an irq_type
bitmask for per-event pending interrupt clearing.
Patch 5: Extend mute/unmute helpers to accept an irq_type bitmask for
init-time platform-specific interrupt mask configuration.
Patch 6: Simplify analogix_dp_config_interrupt() by removing redundant
local macros and leveraging the unmute helper.
Patch 7: Configure Rockchip platforms to use HOTPLUG_CHG interrupt with
2ms HPD deglitch; other platforms keep PLUG + HPD_LOST pair.
Patch 8: Skip native HPD interrupt register operations for GPIO HPD
mode, where hotplug is detected through an external GPIO.
Patch 9: Restrict the forced connected-status shortcut to panel
endpoints only, so DP connector bridges rely on HPD detection.
Patch 10: Handle HPD notification from downstream bridges (e.g.,
display-connector with hpd-gpios) to short-circuit analogix_dp_detect_hpd() when connection is already confirmed.
Tested on RK3576 with both native HPD pin and GPIO HPD configurations.
Native HPD pin mode:
&edp {
status = "okay";
pinctrl-names = "default";
pinctrl-0 = <&edp_txm0_pins>;
};GPIO HPD mode:
&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>;
};
};
};Display-connector mode (DP connector without HPD GPIO):
&edp_out_conn {
remote-endpoint = <&dp_con_in>;
};
dp-con {
compatible = "dp-connector";
label = "DP OUT";
type = "full-size"; port {
dp_con_in: endpoint {
remote-endpoint = <&edp_out_conn>;
};
};};
Display-connector mode (DP connector with HPD GPIO):
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 four configurations detect cable plug/unplug events correctly.
Damon Ding (10):
drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin
detection
drm/bridge: analogix_dp: Return bitmask from
analogix_dp_get_irq_type()
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/bridge: analogix_dp: Restrict forced connected status only for
panel endpoint
drm/bridge: analogix_dp: Handle HPD notification from downstream
bridge
.../drm/bridge/analogix/analogix_dp_core.c | 87 +++++++--- .../drm/bridge/analogix/analogix_dp_core.h | 12 +- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 152 ++++++++++++------ 3 files changed, 175 insertions(+), 76 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).
Signature · 1 line
2.34.1
PATCH v2 1/10 drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection
On Rockchip platforms, the Analogix DP native HPD pin IRQ functionality requires the DP controller to be powered, clocked and initialized to generate plug/unplug interrupts correctly.
To keep HPD detection active while the display is disabled, move enable_irq()/disable_irq() out of bridge enable/disable handlers and split IRQ management paths:
- Native HPD pin mode: enable IRQ in analogix_dp_bind() and disable in analogix_dp_unbind(). Hold runtime PM power to keep controller alive for hotplug interrupts.
- GPIO HPD and force-HPD modes: retain original logic, manage IRQ within bridge enable/disable callbacks.
Persistent power hold is only necessary for native HPD pin mode. It is not required for force-HPD or GPIO HPD modes. Add helper analogix_dp_require_pm_for_hpd_irq() to identify Rockchip native HPD pin configurations and switch IRQ handling accordingly.
---
Change in v2:
- Split IRQ enable/disable logic, handle native HPD pin and GPIO/force-HPD modes separately to avoid unbalanced enable_irq() calls.(Sashiko)
--- .../drm/bridge/analogix/analogix_dp_core.c | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +23 -2
@@ -40,6 +40,12 @@static const bool verify_fast_training; +static bool analogix_dp_require_pm_for_hpd_irq (struct analogix_dp_device *dp) +{ +return analogix_dp_is_rockchip (dp->plat_data->dev_type) && !dp->hpd_gpiod && + !dp->force_hpd; +} +static void analogix_dp_init_dp (struct analogix_dp_device *dp) {analogix_dp_reset (dp);
@@ -1014,7 +1020,8 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp) goto out_dp_init; } -enable_irq (dp->irq); +if (!analogix_dp_require_pm_for_hpd_irq (dp)) +enable_irq (dp->irq);return 0 ; out_dp_init:
@@ -1156,7 +1163,8 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)if (dp->dpms_mode !=DRM_MODE_DPMS_ON )return ; -disable_irq (dp->irq); +if (!analogix_dp_require_pm_for_hpd_irq (dp)) +disable_irq (dp->irq);analogix_dp_set_analog_power_down (dp,POWER_ALL ,1 );
@@ -1504,6 +1512,14 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev) goto err_unregister_aux; } +if (analogix_dp_require_pm_for_hpd_irq (dp)) { + ret =pm_runtime_resume_and_get (dp->dev); +if (ret) + goto err_unregister_aux; + +enable_irq (dp->irq); + } +return 0 ; err_unregister_aux:
@@ -1515,6 +1531,11 @@ EXPORT_SYMBOL_GPL(analogix_dp_bind);void analogix_dp_unbind (struct analogix_dp_device *dp) { +if (analogix_dp_require_pm_for_hpd_irq (dp)) { +disable_irq (dp->irq); +pm_runtime_put_sync (dp->dev); + } +drm_dp_aux_unregister (&dp->aux); }EXPORT_SYMBOL_GPL (analogix_dp_unbind);
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v2 01/10] drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 5 potential issue(s) to consider:
New issues:
- [High] The DP controller IRQ for native HPD mode is left enabled during system suspend, risking a kernel crash on hotplug events.
- [High] Component bind failure leaves HPD IRQ enabled and PM reference leaked, causing a Use-After-Free.
Pre-existing issues:
- [High] The return value of pm_runtime_get_sync() is ignored in analogix_dp_set_bridge(), potentially leading to hardware access on a suspended device.
- [High] Sleeping in atomic context via usleep_range() in bridge atomic enable callback.
- [High] Memory leak and list corruption due to devm_drm_bridge_add in component bind.
--
--- Patch [1]: [PATCH v2 01/10] drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection --- commit c884a0bafddd9bc289fdebe294b1a5fb1f401308
Author: Damon Ding <[email protected]>
drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection
This commit modifies the Analogix DP driver to keep the native HPD pin IRQ active while the display is disabled on Rockchip platforms. It splits the IRQ management paths so that native HPD pin mode holds a runtime PM power reference and enables the IRQ during bind/unbind, rather than during bridge enable/disable.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0
[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_set_bridge(struct analogix_dp_device *dp) · line 1028
Quoted 7 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +2
-1@@ -1018,7 +1024,8 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp) goto out_dp_init; } -enable_irq (dp->irq); +if (!analogix_dp_require_pm_for_hpd_irq (dp)) +enable_irq (dp->irq);
[Severity: High]
This is a pre-existing issue, but does this code ignore the return value of pm_runtime_get_sync()?
If pm_runtime_get_sync(dp->dev) fails earlier in analogix_dp_set_bridge() and returns a negative error code, the device remains suspended. The driver subsequently calls analogix_dp_init_analog_func(), which accesses hardware registers on the unpowered device.
Quoted 3 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0return 0 ; out_dp_init:
[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static void analogix_dp_bridge_disable(struct drm_bridge *bridge) · line 1171
Quoted 7 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +2
-1@@ -1160,7 +1167,8 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)if (dp->dpms_mode !=DRM_MODE_DPMS_ON )return ; -disable_irq (dp->irq); +if (!analogix_dp_require_pm_for_hpd_irq (dp)) +disable_irq (dp->irq);
[Severity: High]
Does skipping disable_irq() here leave the DP controller IRQ enabled during system suspend?
During dpm_suspend, pm_runtime_force_suspend() runs and calls analogix_dp_suspend(), which disables the DP clock. Device IRQs are not disabled by the IRQ core until dpm_suspend_noirq().
If a hotplug event occurs in this window, the active IRQ triggers the handler:
analogix_dp_hardirq() {
irq_type = analogix_dp_get_irq_type(dp);
...
}This reads MMIO registers while the DP clock is disabled, which can crash the system.
Quoted 2 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0analogix_dp_set_analog_power_down (dp,POWER_ALL ,1 );
[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev) · line 1518
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0@@ -1508,6 +1516,14 @@ int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev) goto err_unregister_aux; }
[Severity: High]
This is a pre-existing issue, but does using devm_drm_bridge_add() earlier in this component bind callback cause a memory leak and list corruption on failure?
If the component bind fails and is retried, the devm resources are tied to the physical platform device and are not freed between attempts. The retry will call devm_drm_bridge_add() on the same dp->bridge object again, causing list_add() on a node that is already part of the global bridge list.
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev) · line 1520
Quoted 6 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +6
-0+if (analogix_dp_require_pm_for_hpd_irq (dp)) { + ret =pm_runtime_resume_and_get (dp->dev); +if (ret) + goto err_unregister_aux; + +enable_irq (dp->irq);
[Severity: High]
Does this code leak the PM reference and leave the IRQ enabled if a subsequent setup step fails?
If the platform caller rockchip_dp_bind() fails at drm_bridge_connector_init() after analogix_dp_bind() succeeds, its error path is:
rockchip_dp_bind() {
...
err_cleanup_encoder:
dp->encoder.encoder.funcs->destroy(&dp->encoder.encoder);
return ret;
}Because analogix_dp_unbind() is not called in this error path, the PM reference is permanently leaked and the IRQ remains enabled. When the IRQ fires later, analogix_dp_irq_thread() dereferences the stale dp->drm_dev pointer.
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c int analogix_dp_bind(struct analogix_dp_device *dp, struct drm_device *drm_dev) · line 1525
Quoted 5 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +2
-0+ } +return 0 ; err_unregister_aux:
[ ... ]
[Severity: High]
This is a pre-existing issue, but does analogix_dp_bridge_atomic_enable() sleep in atomic context?
analogix_dp_bridge_atomic_enable() is called during the atomic commit sequence from drm_atomic_helper_commit_tail(). The driver explicitly calls usleep_range(10, 11) in a loop:
analogix_dp_bridge_atomic_enable() {
...
while (timeout_loop < MAX_PLL_LOCK_LOOP) {
if (analogix_dp_set_bridge(dp) == 0) {
...
}
...
usleep_range(10, 11);
}
}Calling sleeping functions in this atomic context violates DRM subsystem rules.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
PATCH v2 2/10 drm/bridge: analogix_dp: Return bitmask from analogix_dp_get_irq_type()
In reply to Damon DingAnalogix 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 and does not consume HOTPLUG_CHG, nor does it check for INT_HPD for IRQ_HPD events.
The existing analogix_dp_get_irq_type() returns on the first matched interrupt flag. This causes the hardirq handler to unconditionally mute all HPD interrupts, including HOTPLUG_CHG and INT_HPD, creating a limitation for future extensions.
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, and add detection for DP_IRQ_TYPE_IRQ_HPD. Remove DP_IRQ_TYPE_UNKNOWN sentinel; use zero to indicate no pending interrupts, which simplifies code and facilitates future extension for additional interrupt types.
This prepares subsequent changes to pass specific irq flags into mute/unmute helpers for selective interrupt control.
--- .../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(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +4 -4
@@ -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); }
drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +2 -2
@@ -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 {
@@ -193,7 +193,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);
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +10 -8
@@ -413,8 +413,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) {
@@ -426,17 +427,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; } }
Signature · 1 line
2.34.1
PATCH v2 3/10 drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling
In reply to Damon DingThe 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.
--- .../gpu/drm/bridge/analogix/analogix_dp_core.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +7 -10
@@ -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 ; }
@@ -1403,10 +1399,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 == -ENXIO ) {
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v2 03/10] drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 3 potential issue(s) to consider:
Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but the unconditional clearing of all hotplug interrupt status bits causes permanently lost plug/unplug events.
- [High] This problem wasn't introduced by this patch, but using devm_ allocation for bridge registration inside a component bind callback causes list corruption and memory leaks.
- [High] This problem wasn't introduced by this patch, but the driver translates -EPROBE_DEFER from platform_get_irq into -EINVAL, permanently breaking deferred probing. --
--- Patch [3]: [PATCH v2 03/10] drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling --- commit baa2e5313ef615e574d902fb610ffce244dfc46e
Author: Damon Ding <[email protected]>
drm/bridge: analogix_dp: Add IRQF_ONESHOT and simplify IRQ handling
This patch adds IRQF_ONESHOT to the threaded IRQ request to prevent hardirq preemption, avoiding a read-modify-write race on HPD interrupt mask registers. It also simplifies the IRQ handler by removing manual mute/unmute operations and reordering the interrupt clear call.
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0
[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static irqreturn_t analogix_dp_irq_thread(int irq, void *arg) · line 728
Quoted 7 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3
-0@@ -725,6 +723,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); +
[Severity: High]
This isn't a bug introduced by this patch, but does the unconditional clearing of all hotplug interrupt status bits cause permanently lost plug/unplug events?
If a new HPD interrupt (e.g., HPD_LOST) asserts in hardware after analogix_dp_get_irq_type() reads ANALOGIX_DP_COMMON_INT_STA_4, but before analogix_dp_clear_hotplug_interrupts() unconditionally writes the fixed mask HOTPLUG_CHG | HPD_LOST | PLUG to it, won't the new event be silently wiped?
Because this is a W1C (write-1-to-clear) register, writing 1s for bits that were not read or processed could cause the threaded handler to miss the new event entirely.
[ ... ]
Quoted 4 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0@@ -1407,10 +1403,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);
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_probe(struct device *dev, struct analogix_dp_plat_data *plat_data) · line 1413
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +3
-2- 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 == -ENXIO ) {
[Severity: High]
This is a pre-existing issue, but does this logic translate -EPROBE_DEFER from platform_get_irq() into -EINVAL, permanently breaking deferred probing?
platform_get_irq() returns -EPROBE_DEFER (-517) if the IRQ provider is not yet ready. Since the driver explicitly checks only if (dp->irq == -ENXIO) to catch errors, the -EPROBE_DEFER value is passed down to devm_request_threaded_irq().
devm_request_threaded_irq() rejects negative IRQ numbers and returns -EINVAL. By propagating -EINVAL instead of -EPROBE_DEFER, the driver core will not retry probing, and the display driver permanently fails to initialize.
[ ... ]
Quoted 7 lines
static int analogix_dp_bind(struct device *dev, struct device *master,
void *data){ ... ret = devm_drm_bridge_add(dp->dev, &dp->bridge); ... }
[Severity: High]
This isn't a bug introduced by this patch, but does using devm_ allocation for bridge registration inside a component bind callback cause list corruption and memory leaks?
analogix_dp_bind() is a component bind callback (triggered by the DRM master). Calling devm_drm_bridge_add() here binds the bridge's cleanup to the dp->dev platform device's probe/remove lifecycle, rather than the component bind/unbind lifecycle.
When the DRM master is unbound, analogix_dp_unbind() executes but the devres cleanup is not triggered, leaving the bridge in the global bridge_list.
When the DRM master binds again, analogix_dp_bind() calls devm_drm_bridge_add() on the same &dp->bridge object. Could this cause list_add_tail() to double-add a node that is already in the list, resulting in immediate list corruption?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
PATCH v2 4/10 drm/bridge: analogix_dp: Extend clear_hotplug_interrupts to accept IRQ bitmask
In reply to Damon DingUpdate 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 mask during HPD initialization.
This implements fine-grained pending interrupt clearing logic and removes limitations brought by unconditional register writes, supporting improved accuracy for HPD event handling.
---
Changes in v2:
- Add separate patch for IRQF_ONESHOT to resolve interrupt mask issues triggered by interrupt preemption.(Sashiko)
--- .../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(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1 -1
@@ -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 ) {
drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +1 -1
@@ -194,7 +194,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);
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +20 -8
@@ -24,6 +24,11 @@#define COMMON_INT_MASK_4 (HOTPLUG_CHG | HPD_LOST | PLUG)#define INT_STA_MASK INT_HPD +#define HPD_IRQ (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;
@@ -376,18 +381,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)
@@ -397,7 +409,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 ); reg =readl (dp->reg_base +ANALOGIX_DP_SYS_CTL_3 ); reg &= ~(F_HPD |HPD_CTRL );
Signature · 1 line
2.34.1
PATCH v2 5/10 drm/bridge: analogix_dp: Extend mute/unmute HPD interrupts to accept irq bitmask
In reply to Damon DingUpdate 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.
---
Changes in v2:
- Update commit messages to align with newly added IRQF_ONESHOT related commit.
--- .../drm/bridge/analogix/analogix_dp_core.h | 4 +- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 59 ++++++++++++++----- 2 files changed, 46 insertions(+), 17 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +2 -2
@@ -183,8 +183,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,
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +44 -15
74 lines not on this page · raw message
Signature · 1 line
2.34.1
PATCH v2 6/10 drm/bridge: analogix_dp: Simplify analogix_dp_config_interrupt()
In reply to Damon DingRemove local COMMON_INT_MASK and INT_STA_MASK macros. These constants are only used once inside this function and bring no reuse benefit.
Replace open-coded register writes for COMMON_INT_MASK_1~3 with direct writel(0) calls.
Leverage analogix_dp_unmute_hpd_interrupt() using the full HPD_IRQ mask to initialize HPD interrupt state, removing duplicated register handling.
--- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 25 +++---------------- 1 file changed, 4 insertions(+), 21 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +4 -21
@@ -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 (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 | \
@@ -178,23 +172,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 ); }void analogix_dp_mute_hpd_interrupt (struct analogix_dp_device *dp,u32 irq_type)
Signature · 1 line
2.34.1
PATCH v2 7/10 drm/bridge: analogix_dp: Use platform-specific HPD detection scheme
In reply to Damon DingHotplug detection can be implemented either via HOTPLUG_CHG interrupt, or the combination of PLUG and HPD_LOST interrupts.
For Rockchip platforms, configure HPD deglitch to 2ms and rely on HOTPLUG_CHG interrupt for hotplug events, which is verified as the optimal solution through engineering tests. Other platforms continue using PLUG + HPD_LOST pair.
Adjust analogix_dp_config_interrupt() to apply platform-specific interrupt masking and deglitch settings. Update threaded irq handler to check corresponding interrupt flags according to platform type.
---
Changes in v2:
- Move ANALOGIX_DP_HPD_DEGLITCH_L/ANALOGIX_DP_HPD_DEGLITCH_H configs to analogix_dp_reset().
--- .../drm/bridge/analogix/analogix_dp_core.c | 9 ++++++-- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 22 ++++++++++++++++--- 2 files changed, 26 insertions(+), 5 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +7 -2
@@ -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);
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +19 -3
@@ -149,8 +149,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 );
@@ -177,7 +182,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 ); +/* +* 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 ); }void analogix_dp_mute_hpd_interrupt (struct analogix_dp_device *dp,u32 irq_type)
Signature · 7 lines
2.34.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
[email protected]
AI reviewRe: [PATCH v2 07/10] drm/bridge: analogix_dp: Use platform-specific HPD detection scheme
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] The 2ms HPD deglitch filter (0xbb80) on Rockchip platforms completely filters out valid DP short pulses, breaking link loss detection and PSR.
Pre-existing issues:
- [High] The threaded IRQ handler ignores DP_IRQ_TYPE_IRQ_HPD (short pulses), preventing drm_helper_hpd_irq_event() from processing link loss or PSR events. --
--- Patch [7]: [PATCH v2 07/10] drm/bridge: analogix_dp: Use platform-specific HPD detection scheme --- commit 9400555d3cb8cd686c3464c5b0945a71464ab506
Author: Damon Ding <[email protected]>
drm/bridge: analogix_dp: Use platform-specific HPD detection scheme
Hotplug detection can be implemented either via HOTPLUG_CHG interrupt, or the combination of PLUG and HPD_LOST interrupts. This patch configures HPD deglitch to 2ms and uses HOTPLUG_CHG for hotplug detection on Rockchip platforms.
Quoted 12 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1
-0@@ -721,13 +721,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)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static irqreturn_t analogix_dp_irq_thread(int irq, void *arg) · line 735
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +6
-2analogix_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 ); +
[Severity: High]
This is a pre-existing issue, but does the calculation of hpd_detected in analogix_dp_irq_thread() miss DP_IRQ_TYPE_IRQ_HPD?
It appears that short pulse interrupts (DP_IRQ_TYPE_IRQ_HPD) are ignored in this threaded IRQ handler and never propagated to the DRM core via drm_helper_hpd_irq_event(). This could cause link loss events to go unhandled until a physical cable replug.
Quoted 9 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1
-0+if (hpd_detected) {dev_dbg (dp->dev,"Detected cable status changed!\n" );if (dp->drm_dev)drm_helper_hpd_irq_event (dp->drm_dev);drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +0
-0
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c void analogix_dp_reset(struct analogix_dp_device *dp) · line 154
Quoted 8 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +3
-2@@ -149,8 +149,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 );
[Severity: High]
Will configuring the HPD deglitch filter to 2ms (0xbb80) completely filter out valid DP short pulses?
The DP specification requires short pulses to be between 0.5ms and 1.0ms. It seems a 2.0ms filter will unconditionally drop them before they can trigger an interrupt, potentially breaking link loss recovery and PSR sink events on Rockchip platforms.
Quoted 5 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +4
-0+ }else { +writel (0x5e , dp->reg_base +ANALOGIX_DP_HPD_DEGLITCH_L ); +writel (0x1a , dp->reg_base +ANALOGIX_DP_HPD_DEGLITCH_H ); + }
[ ... ]
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=7
PATCH v2 8/10 drm/bridge: analogix_dp: Skip native HPD interrupt ops for GPIO HPD
In reply to Damon DingGPIO HPD does not rely on DP controller internal native HPD interrupts. Skip native HPD register manipulations to avoid irrelevant operations.
In analogix_dp_config_interrupt(), mute all native HPD interrupts when dp->hpd_gpiod is set. Move the dp->hpd_gpiod guard from inside analogix_dp_clear_hotplug_interrupts() to its caller in the threaded IRQ handler, so that the function operates purely on the given irq_type bitmask without implicit mode-dependent behavior. This makes it reusable for future callers that may need to clear specific interrupt status bits regardless of the HPD detection mode.
---
Changes in v2:
- Adapt to the newly added IRQF_ONESHOT related commit and expand the commit msg.
--- .../drm/bridge/analogix/analogix_dp_core.c | 2 +- .../gpu/drm/bridge/analogix/analogix_dp_reg.c | 30 +++++++++++-------- 2 files changed, 18 insertions(+), 14 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +1 -1
@@ -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))
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +17 -13
@@ -182,18 +182,22 @@ 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 ); -/* -* 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 ); +if (dp->hpd_gpiod) { +analogix_dp_mute_hpd_interrupt (dp,HPD_IRQ ); + }else { +/* +* 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 ); + } }void analogix_dp_mute_hpd_interrupt (struct analogix_dp_device *dp,u32 irq_type)
@@ -413,7 +417,7 @@ void analogix_dp_clear_hotplug_interrupts(struct analogix_dp_device *dp, u32 irq {u32 reg =0 ; -if (dp->hpd_gpiod || !irq_type) +if (!irq_type)return ;if (irq_type &COMMON_INT_4_HPD_IRQ ) {
Signature · 1 line
2.34.1
PATCH v2 9/10 drm/bridge: analogix_dp: Restrict forced connected status only for panel endpoint
In reply to Damon DingLimit the shortcut which unconditionally returns connected status when a next bridge exists. Only apply this logic if the last bridge in the chain is a panel. For all other cases, rely on analogix_dp_detect_hpd() to report 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. Maintain compatibility by keeping the shortcut exclusively for panel endpoints.
[1] https://lore.kernel.org/all/[email protected]/
--- .../gpu/drm/bridge/analogix/analogix_dp_core.c | 16 ++++++++++++++-- .../gpu/drm/bridge/analogix/analogix_dp_core.h | 1 + 2 files changed, 15 insertions(+), 2 deletions(-)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +14 -2
@@ -906,8 +906,15 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *connestruct analogix_dp_device *dp =to_dp (bridge);enum drm_connector_status status = connector_status_disconnected; -if (dp->plat_data->next_bridge) -return connector_status_connected; +/* +* 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 through to analogix_dp_detect_hpd() to report +* accurate hotplug state. +*/ +if (dp->plat_data->next_bridge && dp->last_bridge_is_panel) + status = connector_status_connected;if (!analogix_dp_detect_hpd (dp)) status = connector_status_connected;
@@ -920,6 +927,7 @@ static int analogix_dp_bridge_attach(struct drm_bridge *bridge, enum drm_bridge_attach_flags flags) {struct analogix_dp_device *dp =to_dp (bridge); +struct drm_bridge *last_bridge;int ret =0 ;if (!(flags &DRM_BRIDGE_ATTACH_NO_CONNECTOR )) {
@@ -934,6 +942,10 @@ 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; } + + last_bridge =drm_bridge_chain_get_last_bridge (dp->encoder); +if (drm_bridge_is_panel (last_bridge)) + dp->last_bridge_is_panel = true; }return 0 ;
drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +1 -0
@@ -168,6 +168,7 @@ struct analogix_dp_device {bool force_hpd;bool fast_train_enable;bool psr_supported; +bool last_bridge_is_panel;u8 dpcd[DP_RECEIVER_CAP_SIZE ];
Signature · 7 lines
2.34.1 _______________________________________________ Linux-rockchip mailing list [email protected] http://lists.infradead.org/mailman/listinfo/linux-rockchip
[email protected]
AI reviewRe: [PATCH v2 09/10] drm/bridge: analogix_dp: Restrict forced connected status only for panel endpoint
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider: - [High] Missing early return in analogix_dp_bridge_detect() causes unintended hardware accesses and…
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Missing early return in analogix_dp_bridge_detect() causes unintended hardware accesses and significant delays for panel bridges.
- [Medium] Missing drm_bridge_put() causes a reference count leak for the bridge returned by drm_bridge_chain_get_last_bridge(). --
--- Patch [9]: [PATCH v2 09/10] drm/bridge: analogix_dp: Restrict forced connected status only for panel endpoint --- commit 7e658941bfdab69a58f5d04d4acd4ae671e37ea8
Author: Damon Ding <[email protected]>
drm/bridge: analogix_dp: Restrict forced connected status only for panel endpoint
This commit limits the unconditional connected status shortcut to cases where the last bridge in the chain is a panel. For other cases, it relies on analogix_dp_detect_hpd() to report accurate hotplug state.
Quoted 12 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +2
-2@@ -910,8 +910,15 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *connestruct analogix_dp_device *dp =to_dp (bridge);enum drm_connector_status status = connector_status_disconnected; -if (dp->plat_data->next_bridge) -return connector_status_connected; +/* +* Only assume connected when the bridge chain ends with a panel.
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne · line 924
Quoted 10 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +7
-0+* Panel bridges lack a detect callback and historically rely on +* this shortcut. For other next bridge types (e.g., DP connector +* bridges), fall through to analogix_dp_detect_hpd() to report +* accurate hotplug state. +*/ +if (dp->plat_data->next_bridge && dp->last_bridge_is_panel) + status = connector_status_connected;if (!analogix_dp_detect_hpd (dp)) status = connector_status_connected;
[Severity: High]
Does this unintentionally fall through and execute analogix_dp_detect_hpd() even when the bridge chain ends with a panel?
Previously, analogix_dp_bridge_detect() returned early here. By just assigning the status without returning, it looks like panel bridges will now unconditionally execute analogix_dp_detect_hpd(). This can introduce an unnecessary 100ms delay and unintended register/AUX writes to manually force HPD on hardware that lacks an HPD signal.
Should there be an early return here instead of continuing execution?
[ ... ]
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_bridge_attach(struct drm_bridge *bridge, · line 955
Quoted 11 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +4
-0@@ -938,6 +946,10 @@ 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; } + + last_bridge =drm_bridge_chain_get_last_bridge (dp->encoder); +if (drm_bridge_is_panel (last_bridge)) + dp->last_bridge_is_panel = true; }return 0 ;
[Severity: Medium]
Does this leak the reference to the last bridge in analogix_dp_bridge_attach()?
drm_bridge_chain_get_last_bridge() increments the reference count of the returned bridge, but it doesn't appear that drm_bridge_put() is called before the function returns. Will this prevent proper cleanup when the device is unbound or the module is unloaded?
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=9
PATCH v2 10/10 drm/bridge: analogix_dp: Handle HPD notification from downstream bridge
In reply to Damon DingWhen 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.
Implement the .hpd_notify bridge callback to receive connection status updates from downstream bridges. Cache the connection status in a connection_notified flag, and use it to short-circuit analogix_dp_detect_hpd() when a downstream bridge has already confirmed the connection.
--- .../gpu/drm/bridge/analogix/analogix_dp_core.c | 16 ++++++++++++++++ .../gpu/drm/bridge/analogix/analogix_dp_core.h | 1 + 2 files changed, 17 insertions(+)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +16 -0
@@ -68,6 +68,13 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp) {int timeout_loop =0 ; +/* +* Trust connection status from downstream bridge (e.g., +* display-connector with hpd-gpios). +*/ +if (dp->plat_data->next_bridge && dp->connection_notified) +return 0 ; +while (timeout_loop <DP_TIMEOUT_LOOP_COUNT ) {if (analogix_dp_get_plug_in_status (dp) ==0 )return 0 ;
@@ -1247,6 +1254,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_notify (struct drm_bridge *bridge,struct drm_connector *connector, +enum drm_connector_status status) +{ +struct analogix_dp_device *dp =to_dp (bridge); + + dp->connection_notified = (status == connector_status_connected); +} +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,
@@ -1259,6 +1274,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, };static int analogix_dp_dt_parse_pdata (struct analogix_dp_device *dp)
drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +1 -0
@@ -169,6 +169,7 @@ struct analogix_dp_device {bool fast_train_enable;bool psr_supported;bool last_bridge_is_panel; +bool connection_notified;u8 dpcd[DP_RECEIVER_CAP_SIZE ];
Signature · 1 line
2.34.1
[email protected]
AI reviewRe: [PATCH v2 10/10] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Bypassing force_hpd initialization breaks AUX channel and link training
Pre-existing issues:
- [High] Sleeping in atomic context during bridge enable --
--- Patch [10]: [PATCH v2 10/10] drm/bridge: analogix_dp: Handle HPD notification from downstream bridge --- commit 9728fd12d41ed8de2891a5a3947c23bae76130a5
Author: Damon Ding <[email protected]>
drm/bridge: analogix_dp: Handle HPD notification from downstream bridge
The patch implements the .hpd_notify bridge callback to receive connection status updates from downstream bridges. It caches the connection status to short-circuit analogix_dp_detect_hpd() when a downstream bridge has already confirmed the connection.
Quoted 5 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_detect_hpd(struct analogix_dp_device *dp) · line 76
Quoted 9 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +6
-0@@ -68,6 +68,13 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp) {int timeout_loop =0 ; +/* +* Trust connection status from downstream bridge (e.g., +* display-connector with hpd-gpios). +*/ +if (dp->plat_data->next_bridge && dp->connection_notified) +return 0 ;
[Severity: High]
Does returning early here bypass the analogix_dp_force_hpd(dp) call needed to unblock the AUX channel?
If the downstream bridge manages HPD, the native HPD pin is typically unconnected, making the hardware HPD_STATUS register read 0. The Analogix DP hardware blocks all AUX transactions when HPD_STATUS is 0.
By returning 0 early, analogix_dp_force_hpd(dp) is skipped, leaving the F_HPD bit cleared and the AUX channel blocked. This could cause link training to fail because it cannot read DPCD over the AUX channel.
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)
Quoted 6 lines
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +0
-0while (timeout_loop <DP_TIMEOUT_LOOP_COUNT ) {if (analogix_dp_get_plug_in_status (dp) ==0 )return 0 ; timeout_loop++;usleep_range (1000 ,1100 );
[Severity: High]
This isn't a bug introduced by this patch, but does this usleep_range() violate atomic context requirements?
When the core DRM framework calls analogix_dp_bridge_atomic_enable() during a non-blocking atomic commit, it executes analogix_dp_set_bridge() which then calls analogix_dp_detect_hpd():
analogix_dp_bridge_atomic_enable()
analogix_dp_set_bridge()
analogix_dp_detect_hpd()
usleep_range(1000, 1100);Since atomic enable/disable callbacks execute in atomic context, sleeping functions like usleep_range() are not allowed and can cause kernel warnings (BUG: scheduling while atomic) or system instability.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=10
Heiko Stübner
maintainerHi Damon,
Am Dienstag, 4. August 2026, 10:17:07 Mitteleuropäische Sommerzeit schrieb Damon Ding:
Quoted 28 lines
Display-connector mode (DP connector without HPD GPIO):
&edp_out_conn { remote-endpoint = <&dp_con_in>; }; dp-con { compatible = "dp-connector"; label = "DP OUT"; type = "full-size";port { dp_con_in: endpoint { remote-endpoint = <&edp_out_conn>; }; };};
Display-connector mode (DP connector with HPD GPIO):
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>;
Quoted 8 lines
port { dp_con_in: endpoint { remote-endpoint = <&edp_out_conn>; }; };};
All four configurations detect cable plug/unplug events correctly.
hmm, it wasn't working entirely for me though and was still running into issues when the display was unplugged on boot.
I wiggled around a bit like in the diff below and am now getting correct plug and unplug events.
But of course, as the dp-variant of the connector does not provide a "detect" and just the "hpd" functionality, it's missing the initial state.
I'm currently not sure how to find out _if_ a panel is connected on boot.
In other review comments:
- the bridge could use devm_drm_of_get_bridge() as suggested in the documentation of drm_of_find_panel_or_bridge(), as that would remove the separate panel_bridge creation
- instead of using plat_data->next_bridge _inside_ the driver struct drm_bridge has a field next_bridge already.
Heiko
------- 8< -------
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +14 -6
@@ -43,7 +43,7 @@ static const bool verify_fast_training;static bool analogix_dp_require_pm_for_hpd_irq (struct analogix_dp_device *dp) {return analogix_dp_is_rockchip (dp->plat_data->dev_type) && !dp->hpd_gpiod && - !dp->force_hpd; + !dp->hpd_bridge && !dp->force_hpd; }static void analogix_dp_init_dp (struct analogix_dp_device *dp)
@@ -72,7 +72,7 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)* Trust connection status from downstream bridge (e.g., * display-connector with hpd-gpios). */ -if (dp->plat_data->next_bridge && dp->connection_notified) +if (dp->hpd_bridge && dp->connection_notified)return 0 ;while (timeout_loop <DP_TIMEOUT_LOOP_COUNT ) {
@@ -926,10 +926,10 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne*/ if (dp->plat_data->next_bridge && dp->last_bridge_is_panel) status = connector_status_connected; - -if (!analogix_dp_detect_hpd (dp)) +else if (!analogix_dp_detect_hpd (dp)) status = connector_status_connected; +printk ("---> %s status %d\n" , __func__, status);return status; }
@@ -1044,7 +1044,7 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp) goto out_dp_init; } -if (!analogix_dp_require_pm_for_hpd_irq (dp)) +if (!analogix_dp_require_pm_for_hpd_irq (dp) && !dp->hpd_bridge)enable_irq (dp->irq);return 0 ;
@@ -1187,7 +1187,7 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)if (dp->dpms_mode !=DRM_MODE_DPMS_ON )return ; -if (!analogix_dp_require_pm_for_hpd_irq (dp)) +if (!analogix_dp_require_pm_for_hpd_irq (dp) && !dp->hpd_bridge)disable_irq (dp->irq);analogix_dp_set_analog_power_down (dp,POWER_ALL ,1 );
@@ -1264,6 +1264,7 @@ static void analogix_dp_bridge_notify(struct drm_bridge *bridge, struct drm_connstruct analogix_dp_device *dp =to_dp (bridge); dp->connection_notified = (status == connector_status_connected); +printk ("---> %s connection_notified %d\n" , __func__, dp->connection_notified); }static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {
@@ -1641,6 +1642,13 @@ static int analogix_dp_aux_done_probing(struct drm_dp_aux *aux)if (ret && ret != -ENODEV )return ret; +/* +* There is a next link in the chain which is not a panel, we should +* expect hotplug-information coming from there. +*/ +if (plat_data->next_bridge && !drm_bridge_is_panel (plat_data->next_bridge)) + dp->hpd_bridge = true; +return component_add (dp->dev, plat_data->ops); }
drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +1 -0
@@ -169,6 +169,7 @@ struct analogix_dp_device {bool fast_train_enable;bool psr_supported;bool last_bridge_is_panel; +bool hpd_bridge;bool connection_notified;u8 dpcd[DP_RECEIVER_CAP_SIZE ];
drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +5 -2
@@ -182,7 +182,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_bridge) {analogix_dp_mute_hpd_interrupt (dp,HPD_IRQ ); }else {/*
@@ -438,7 +438,7 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp) {u32 reg; -if (dp->hpd_gpiod) +if (dp->hpd_gpiod || dp->hpd_bridge)return ;analogix_dp_clear_hotplug_interrupts (dp,HPD_IRQ );
@@ -539,6 +539,9 @@ int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp)if (dp->hpd_gpiod) {if (gpiod_get_value (dp->hpd_gpiod))return 0 ; + }else if (dp->hpd_bridge) { +if (dp->connection_notified) +return 0 ; }else { reg =readl (dp->reg_base +ANALOGIX_DP_SYS_CTL_3 );if (reg &HPD_STATUS )
Hi Heiko,
Quoted 39 lines · Heiko Stübner
Hi Damon,
Am Dienstag, 4. August 2026, 10:17:07 Mitteleuropäische Sommerzeit schrieb Damon Ding:
Quoted 36 lines
Display-connector mode (DP connector without HPD GPIO):
&edp_out_conn { remote-endpoint = <&dp_con_in>; }; dp-con { compatible = "dp-connector"; label = "DP OUT"; type = "full-size";port { dp_con_in: endpoint { remote-endpoint = <&edp_out_conn>; }; };};
Display-connector mode (DP connector with HPD GPIO):
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 four configurations detect cable plug/unplug events correctly.
Thanks a lot for your testing and feedback. :-)
It seems my test setup gave me the false impression that those cases worked well.
Quoted 4 lines
hmm, it wasn't working entirely for me though and was still running into issues when the display was unplugged on boot.
Are you seeing this boot‑unplug issue for both scenarios: DP‑connector with HPD‑gpio paired with eDP without HPD‑gpio, and DP‑connector without HPD‑gpio paired with eDP with HPD‑gpio? I.e. it wrongly reports connected even with no display plugged in and proceeds into DRM .atomic_enable()?
Quoted 2 lines
I wiggled around a bit like in the diff below and am now getting correct plug and unplug events.
Oh, I see. For the GPIO HPD case, the IRQ needs to be enabled early so that plug‑in interrupts can be properly responded to. However GPIO HPD does not require a runtime PM get. I will better separate these two scenarios in the next version.
Quoted 6 lines
But of course, as the dp-variant of the connector does not provide a "detect" and just the "hpd" functionality, it's missing the initial state.
I'm currently not sure how to find out _if_ a panel is connected on boot.
Based on Dmitry's commit cb640b2ca546 ("drm/bridge: display‑connector: don't set OP_DETECT for DisplayPorts"), HPD events from DP‑variant connector should be handled by the upstream DP controller. Hence I added analogix_dp_bridge_notify() to retrieve HPD status coming from downstream.
As expected, under the bridge‑connector framework, the detect result from Analogix DP should in theory reflect the actual connection status. Let's dig into this boot‑time initial‑state issue together.
Quoted 7 lines
In other review comments:
- the bridge could usedevm_drm_of_get_bridge()as suggested in the documentation ofdrm_of_find_panel_or_bridge(), as that would remove the separatepanel_bridgecreation
- instead of usingplat_data->next_bridge_inside_ the driver structdrm_bridgehas a fieldnext_bridgealready.
Great suggestions, I will incorporate them for the next version alongside Sashiko's comments.
Best regards,
Damon
Quoted 130 lines
Heiko
------- 8< -------
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +14
-6@@ -43,7 +43,7 @@ static const bool verify_fast_training;static bool analogix_dp_require_pm_for_hpd_irq (struct analogix_dp_device *dp) {return analogix_dp_is_rockchip (dp->plat_data->dev_type) && !dp->hpd_gpiod && - !dp->force_hpd; + !dp->hpd_bridge && !dp->force_hpd; }static void analogix_dp_init_dp (struct analogix_dp_device *dp)@@ -72,7 +72,7 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)* Trust connection status from downstream bridge (e.g., * display-connector with hpd-gpios). */ -if (dp->plat_data->next_bridge && dp->connection_notified) +if (dp->hpd_bridge && dp->connection_notified)return 0 ;while (timeout_loop <DP_TIMEOUT_LOOP_COUNT ) {@@ -926,10 +926,10 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne*/ if (dp->plat_data->next_bridge && dp->last_bridge_is_panel) status = connector_status_connected; - -if (!analogix_dp_detect_hpd (dp)) +else if (!analogix_dp_detect_hpd (dp)) status = connector_status_connected; +printk ("---> %s status %d\n" , __func__, status);return status; }@@ -1044,7 +1044,7 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp) goto out_dp_init; } -if (!analogix_dp_require_pm_for_hpd_irq (dp)) +if (!analogix_dp_require_pm_for_hpd_irq (dp) && !dp->hpd_bridge)enable_irq (dp->irq);return 0 ;@@ -1187,7 +1187,7 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)if (dp->dpms_mode !=DRM_MODE_DPMS_ON )return ; -if (!analogix_dp_require_pm_for_hpd_irq (dp)) +if (!analogix_dp_require_pm_for_hpd_irq (dp) && !dp->hpd_bridge)disable_irq (dp->irq);analogix_dp_set_analog_power_down (dp,POWER_ALL ,1 );@@ -1264,6 +1264,7 @@ static void analogix_dp_bridge_notify(struct drm_bridge *bridge, struct drm_connstruct analogix_dp_device *dp =to_dp (bridge); dp->connection_notified = (status == connector_status_connected); +printk ("---> %s connection_notified %d\n" , __func__, dp->connection_notified); }static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {@@ -1641,6 +1642,13 @@ static int analogix_dp_aux_done_probing(struct drm_dp_aux *aux)if (ret && ret != -ENODEV )return ret; +/* +* There is a next link in the chain which is not a panel, we should +* expect hotplug-information coming from there. +*/ +if (plat_data->next_bridge && !drm_bridge_is_panel (plat_data->next_bridge)) + dp->hpd_bridge = true; +return component_add (dp->dev, plat_data->ops); }drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +1
-0@@ -169,6 +169,7 @@ struct analogix_dp_device {bool fast_train_enable;bool psr_supported;bool last_bridge_is_panel; +bool hpd_bridge;bool connection_notified;u8 dpcd[DP_RECEIVER_CAP_SIZE ];drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +5
-2@@ -182,7 +182,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_bridge) {analogix_dp_mute_hpd_interrupt (dp,HPD_IRQ ); }else {/* @@ -438,7 +438,7 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp) {u32 reg; -if (dp->hpd_gpiod) +if (dp->hpd_gpiod || dp->hpd_bridge)return ;analogix_dp_clear_hotplug_interrupts (dp,HPD_IRQ );@@ -539,6 +539,9 @@ int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp)if (dp->hpd_gpiod) {if (gpiod_get_value (dp->hpd_gpiod))return 0 ; + }else if (dp->hpd_bridge) { +if (dp->connection_notified) +return 0 ; }else { reg =readl (dp->reg_base +ANALOGIX_DP_SYS_CTL_3 );if (reg &HPD_STATUS )
Heiko Stübner
maintainerAm Mittwoch, 5. August 2026, 06:06:48 Mitteleuropäische Sommerzeit schrieb Damon Ding:
Quoted 53 lines
Hi Heiko,
Quoted 39 lines · Heiko Stübner
Hi Damon,
Am Dienstag, 4. August 2026, 10:17:07 Mitteleuropäische Sommerzeit schrieb Damon Ding:
Quoted 36 lines
Display-connector mode (DP connector without HPD GPIO):
&edp_out_conn { remote-endpoint = <&dp_con_in>; }; dp-con { compatible = "dp-connector"; label = "DP OUT"; type = "full-size";port { dp_con_in: endpoint { remote-endpoint = <&edp_out_conn>; }; };};
Display-connector mode (DP connector with HPD GPIO):
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 four configurations detect cable plug/unplug events correctly.
Thanks a lot for your testing and feedback. :-)
It seems my test setup gave me the false impression that those cases worked well.
Quoted 4 lines
hmm, it wasn't working entirely for me though and was still running into issues when the display was unplugged on boot.
Quoted 5 lines
Are you seeing this boot‑unplug issue for both scenarios: DP‑connector with HPD‑gpio paired with eDP without HPD‑gpio, and DP‑connector without HPD‑gpio paired with eDP with HPD‑gpio? I.e. it wrongly reports connected even with no display plugged in and proceeds into DRM .atomic_enable()?
Yep it's different. The analogix-dp gpio-hpd works correctly, because the analogix driver can do gpiod_get_value() in analogix_dp_get_plug_in_status()
The dp-connector does not, as with the patch you pointed to, it lost that ability. So on boot a plugged in display is not detected correctly because there won't be a hotplug interrupt.
Quoted 16 lines
Quoted 3 lines
I wiggled around a bit like in the diff below and am now getting correct plug and unplug events.
Oh, I see. For the GPIO HPD case, the IRQ needs to be enabled early so that plug‑in interrupts can be properly responded to. However GPIO HPD does not require a runtime PM get. I will better separate these two scenarios in the next version.
Quoted 6 lines
But of course, as the dp-variant of the connector does not provide a "detect" and just the "hpd" functionality, it's missing the initial state.
I'm currently not sure how to find out _if_ a panel is connected on boot.
Quoted 8 lines
Based on Dmitry's commit
cb640b2ca546("drm/bridge: display‑connector:
don't setOP_DETECTfor DisplayPorts"), HPD events from DP‑variant connector should be handled by the upstream DP controller. Hence I addedanalogix_dp_bridge_notify()to retrieve HPD status coming from downstream.As expected, under the bridge‑connector framework, the detect result from Analogix DP should in theory reflect the actual connection status. Let's dig into this boot‑time initial‑state issue together.
One idea I had was, is it possible to do a drm_dp_read_dpcd_caps() read during bind/... to see if something answers?
Thanks for all your work
Heiko
Quoted 145 lines
Quoted 6 lines
In other review comments:
- the bridge could usedevm_drm_of_get_bridge()as suggested in the documentation ofdrm_of_find_panel_or_bridge(), as that would remove the separatepanel_bridgecreation
- instead of usingplat_data->next_bridge_inside_ the driver structdrm_bridgehas a fieldnext_bridgealready.Great suggestions, I will incorporate them for the next version alongside Sashiko's comments.
Best regards,
DamonQuoted 130 lines
Heiko
------- 8< -------
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +14
-6@@ -43,7 +43,7 @@ static const bool verify_fast_training;static bool analogix_dp_require_pm_for_hpd_irq (struct analogix_dp_device *dp) {return analogix_dp_is_rockchip (dp->plat_data->dev_type) && !dp->hpd_gpiod && - !dp->force_hpd; + !dp->hpd_bridge && !dp->force_hpd; }static void analogix_dp_init_dp (struct analogix_dp_device *dp)@@ -72,7 +72,7 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)* Trust connection status from downstream bridge (e.g., * display-connector with hpd-gpios). */ -if (dp->plat_data->next_bridge && dp->connection_notified) +if (dp->hpd_bridge && dp->connection_notified)return 0 ;while (timeout_loop <DP_TIMEOUT_LOOP_COUNT ) {@@ -926,10 +926,10 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne*/ if (dp->plat_data->next_bridge && dp->last_bridge_is_panel) status = connector_status_connected; - -if (!analogix_dp_detect_hpd (dp)) +else if (!analogix_dp_detect_hpd (dp)) status = connector_status_connected; +printk ("---> %s status %d\n" , __func__, status);return status; }@@ -1044,7 +1044,7 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp) goto out_dp_init; } -if (!analogix_dp_require_pm_for_hpd_irq (dp)) +if (!analogix_dp_require_pm_for_hpd_irq (dp) && !dp->hpd_bridge)enable_irq (dp->irq);return 0 ;@@ -1187,7 +1187,7 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)if (dp->dpms_mode !=DRM_MODE_DPMS_ON )return ; -if (!analogix_dp_require_pm_for_hpd_irq (dp)) +if (!analogix_dp_require_pm_for_hpd_irq (dp) && !dp->hpd_bridge)disable_irq (dp->irq);analogix_dp_set_analog_power_down (dp,POWER_ALL ,1 );@@ -1264,6 +1264,7 @@ static void analogix_dp_bridge_notify(struct drm_bridge *bridge, struct drm_connstruct analogix_dp_device *dp =to_dp (bridge); dp->connection_notified = (status == connector_status_connected); +printk ("---> %s connection_notified %d\n" , __func__, dp->connection_notified); }static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {@@ -1641,6 +1642,13 @@ static int analogix_dp_aux_done_probing(struct drm_dp_aux *aux)if (ret && ret != -ENODEV )return ret; +/* +* There is a next link in the chain which is not a panel, we should +* expect hotplug-information coming from there. +*/ +if (plat_data->next_bridge && !drm_bridge_is_panel (plat_data->next_bridge)) + dp->hpd_bridge = true; +return component_add (dp->dev, plat_data->ops); }drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +1
-0@@ -169,6 +169,7 @@ struct analogix_dp_device {bool fast_train_enable;bool psr_supported;bool last_bridge_is_panel; +bool hpd_bridge;bool connection_notified;u8 dpcd[DP_RECEIVER_CAP_SIZE ];drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +5
-2@@ -182,7 +182,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_bridge) {analogix_dp_mute_hpd_interrupt (dp,HPD_IRQ ); }else {/* @@ -438,7 +438,7 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp) {u32 reg; -if (dp->hpd_gpiod) +if (dp->hpd_gpiod || dp->hpd_bridge)return ;analogix_dp_clear_hotplug_interrupts (dp,HPD_IRQ );@@ -539,6 +539,9 @@ int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp)if (dp->hpd_gpiod) {if (gpiod_get_value (dp->hpd_gpiod))return 0 ; + }else if (dp->hpd_bridge) { +if (dp->connection_notified) +return 0 ; }else { reg =readl (dp->reg_base +ANALOGIX_DP_SYS_CTL_3 );if (reg &HPD_STATUS )
Hi Heiko,
Quoted 88 lines · Heiko Stübner
Am Mittwoch, 5. August 2026, 06:06:48 Mitteleuropäische Sommerzeit schrieb Damon Ding:
Quoted 53 lines
Hi Heiko,
Quoted 39 lines · Heiko Stübner
Hi Damon,
Am Dienstag, 4. August 2026, 10:17:07 Mitteleuropäische Sommerzeit schrieb Damon Ding:
Quoted 36 lines
Display-connector mode (DP connector without HPD GPIO):
&edp_out_conn { remote-endpoint = <&dp_con_in>; }; dp-con { compatible = "dp-connector"; label = "DP OUT"; type = "full-size"; port { dp_con_in: endpoint { remote-endpoint = <&edp_out_conn>; }; }; };Display-connector mode (DP connector with HPD GPIO):
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 four configurations detect cable plug/unplug events correctly.
Thanks a lot for your testing and feedback. :-)
It seems my test setup gave me the false impression that those cases worked well.
Quoted 4 lines
hmm, it wasn't working entirely for me though and was still running into issues when the display was unplugged on boot.
Quoted 5 lines
Are you seeing this boot‑unplug issue for both scenarios: DP‑connector with HPD‑gpio paired with eDP without HPD‑gpio, and DP‑connector without HPD‑gpio paired with eDP with HPD‑gpio? I.e. it wrongly reports connected even with no display plugged in and proceeds into DRM .atomic_enable()?
Yep it's different. The analogix-dp gpio-hpd works correctly, because the analogix driver can do
gpiod_get_value()inanalogix_dp_get_plug_in_status()The dp-connector does not, as with the patch you pointed to, it lost that ability. So on boot a plugged in display is not detected correctly because there won't be a hotplug interrupt.
Quoted 21 lines
Quoted 3 lines
I wiggled around a bit like in the diff below and am now getting correct plug and unplug events.
Oh, I see. For the GPIO HPD case, the IRQ needs to be enabled early so that plug‑in interrupts can be properly responded to. However GPIO HPD does not require a runtime PM get. I will better separate these two scenarios in the next version.
Quoted 6 lines
But of course, as the dp-variant of the connector does not provide a "detect" and just the "hpd" functionality, it's missing the initial state.
I'm currently not sure how to find out _if_ a panel is connected on boot.
Based on Dmitry's commit
cb640b2ca546("drm/bridge: display‑connector:
don't setOP_DETECTfor DisplayPorts"), HPD events from DP‑variant connector should be handled by the upstream DP controller. Hence I addedanalogix_dp_bridge_notify()to retrieve HPD status coming from downstream.
Quoted 7 lines
Quoted 3 lines
As expected, under the bridge‑connector framework, the detect result from Analogix DP should in theory reflect the actual connection status. Let's dig into this boot‑time initial‑state issue together.
One idea I had was, is it possible to do a
drm_dp_read_dpcd_caps()read during bind/... to see if something answers?
Sorry for the long delay to get back to this series. I was stuck on some tricky local issues.
I'll test your suggestion and try to send out v3 within next week.
Best regards,
Damon
Quoted 152 lines
Quoted 146 lines
Quoted 7 lines
In other review comments:
- the bridge could usedevm_drm_of_get_bridge()as suggested in the documentation ofdrm_of_find_panel_or_bridge(), as that would remove the separatepanel_bridgecreation
- instead of usingplat_data->next_bridge_inside_ the driver structdrm_bridgehas a fieldnext_bridgealready.Great suggestions, I will incorporate them for the next version alongside Sashiko's comments.
Best regards,
DamonQuoted 130 lines
Heiko
------- 8< -------
drivers/gpu/drm/bridge/analogix/analogix_dp_core.c +14
-6@@ -43,7 +43,7 @@ static const bool verify_fast_training;static bool analogix_dp_require_pm_for_hpd_irq (struct analogix_dp_device *dp) {return analogix_dp_is_rockchip (dp->plat_data->dev_type) && !dp->hpd_gpiod && - !dp->force_hpd; + !dp->hpd_bridge && !dp->force_hpd; }static void analogix_dp_init_dp (struct analogix_dp_device *dp)@@ -72,7 +72,7 @@ static int analogix_dp_detect_hpd(struct analogix_dp_device *dp)* Trust connection status from downstream bridge (e.g., * display-connector with hpd-gpios). */ -if (dp->plat_data->next_bridge && dp->connection_notified) +if (dp->hpd_bridge && dp->connection_notified)return 0 ;while (timeout_loop <DP_TIMEOUT_LOOP_COUNT ) {@@ -926,10 +926,10 @@ analogix_dp_bridge_detect(struct drm_bridge *bridge, struct drm_connector *conne*/ if (dp->plat_data->next_bridge && dp->last_bridge_is_panel) status = connector_status_connected; - -if (!analogix_dp_detect_hpd (dp)) +else if (!analogix_dp_detect_hpd (dp)) status = connector_status_connected; +printk ("---> %s status %d\n" , __func__, status);return status; }@@ -1044,7 +1044,7 @@ static int analogix_dp_set_bridge(struct analogix_dp_device *dp) goto out_dp_init; } -if (!analogix_dp_require_pm_for_hpd_irq (dp)) +if (!analogix_dp_require_pm_for_hpd_irq (dp) && !dp->hpd_bridge)enable_irq (dp->irq);return 0 ;@@ -1187,7 +1187,7 @@ static void analogix_dp_bridge_disable(struct drm_bridge *bridge)if (dp->dpms_mode !=DRM_MODE_DPMS_ON )return ; -if (!analogix_dp_require_pm_for_hpd_irq (dp)) +if (!analogix_dp_require_pm_for_hpd_irq (dp) && !dp->hpd_bridge)disable_irq (dp->irq);analogix_dp_set_analog_power_down (dp,POWER_ALL ,1 );@@ -1264,6 +1264,7 @@ static void analogix_dp_bridge_notify(struct drm_bridge *bridge, struct drm_connstruct analogix_dp_device *dp =to_dp (bridge); dp->connection_notified = (status == connector_status_connected); +printk ("---> %s connection_notified %d\n" , __func__, dp->connection_notified); }static const struct drm_bridge_funcs analogix_dp_bridge_funcs = {@@ -1641,6 +1642,13 @@ static int analogix_dp_aux_done_probing(struct drm_dp_aux *aux)if (ret && ret != -ENODEV )return ret; +/* +* There is a next link in the chain which is not a panel, we should +* expect hotplug-information coming from there. +*/ +if (plat_data->next_bridge && !drm_bridge_is_panel (plat_data->next_bridge)) + dp->hpd_bridge = true; +return component_add (dp->dev, plat_data->ops); }drivers/gpu/drm/bridge/analogix/analogix_dp_core.h +1
-0@@ -169,6 +169,7 @@ struct analogix_dp_device {bool fast_train_enable;bool psr_supported;bool last_bridge_is_panel; +bool hpd_bridge;bool connection_notified;u8 dpcd[DP_RECEIVER_CAP_SIZE ];drivers/gpu/drm/bridge/analogix/analogix_dp_reg.c +5
-2@@ -182,7 +182,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_bridge) {analogix_dp_mute_hpd_interrupt (dp,HPD_IRQ ); }else {/* @@ -438,7 +438,7 @@ void analogix_dp_init_hpd(struct analogix_dp_device *dp) {u32 reg; -if (dp->hpd_gpiod) +if (dp->hpd_gpiod || dp->hpd_bridge)return ;analogix_dp_clear_hotplug_interrupts (dp,HPD_IRQ );@@ -539,6 +539,9 @@ int analogix_dp_get_plug_in_status(struct analogix_dp_device *dp)if (dp->hpd_gpiod) {if (gpiod_get_value (dp->hpd_gpiod))return 0 ; + }else if (dp->hpd_bridge) { +if (dp->connection_notified) +return 0 ; }else { reg =readl (dp->reg_base +ANALOGIX_DP_SYS_CTL_3 );if (reg &HPD_STATUS )