Thank you for your contribution! Sashiko AI review found 2 potential issues to consider: - [High] drm/bridge: analogix_dp: premature IRQ enable in analogix_dp_resume() - [Medium] drm/bridge: analogix_dp: deadlock between analogix_dp_suspend() and IRQ --
commit 2148ea987a79afc2769bfb9bcea363df9810b9e9 Author: Damon Ding <[email protected]> drm/bridge: analogix_dp: Manage pm runtime and IRQ for native HPD pin detection This commit holds a runtime PM reference across bind and unbind on RK3576 and RK3588 for native hotplug detection, and gates the hotplug IRQ on hotplug support and runtime PM transitions. > diff --git a/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > b/drivers/gpu/drm/bridge/analogix/analogix_dp_core.c > index 46433ea73d678..cda6e4c5cbc8d 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; > + } > + [Severity: Medium] Can calling disable_irq(dp->irq) inside the runtime_suspend callback cause an ABBA deadlock with analogix_dp_irq_thread()? If dp->dev is runtime-resumed while no persistent runtime PM reference is held (for example, during pre-bind AUX transfers in analogix_dp_finish_probe(), or after analogix_dp_unbind()), analogix_dp_resume() enables dp->irq. When the autosuspend timer later fires and an HPD interrupt arrives at the same time: CPU0 (pm_wq) CPU1 (irq/analogix-dp) ------------ ---------------------- rpm_suspend(dp->dev) runtime_status = RPM_SUSPENDING ... analogix_dp_suspend(dp) analogix_dp_irq_thread() pm_runtime_resume_and_get(dp->dev) rpm_resume(dp->dev, RPM_GET_PUT) /* waits for RPM_SUSPENDING */ disable_irq(dp->irq) synchronize_irq(dp->irq) /* waits for IRQ thread */ *** DEADLOCK *** > 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); [Severity: High] Does enabling dp->irq in analogix_dp_resume() leave the HPD IRQ permanently enabled across runtime suspend on RK3576 and RK3588 boards with an eDP panel on the DP AUX bus? dp->force_connected_mode is not initialized in analogix_dp_probe(); it is set later during analogix_dp_bind() -> drm_bridge_attach() -> analogix_dp_bridge_attach(): drivers/gpu/drm/bridge/analogix/analogix_dp_core.c:analogix_dp_bridge_attach() { ... if (dp->bridge.next_bridge) { ... dp->force_connected_mode = analogix_dp_bridge_force_connected(dp); } } Before analogix_dp_bind() runs, analogix_dp_finish_probe() populates the DP AUX bus. Probing the panel child runtime-resumes dp->dev while dp->force_connected_mode is still false, so analogix_dp_require_pm_for_hpd_irq(dp) returns true and analogix_dp_resume() enables dp->irq. Once analogix_dp_bridge_attach() sets dp->force_connected_mode = true, analogix_dp_require_pm_for_hpd_irq(dp) becomes false. When the 100 ms autosuspend delay expires, analogix_dp_suspend() skips disable_irq(dp->irq) and leaves dp->irq enabled while the PHY, power and clock are turned off. In addition, because analogix_dp_resume() does not check whether the bridge is bound, any runtime resume during or after analogix_dp_unbind() (such as during drm_dp_aux_unregister(&dp->aux)) re-enables dp->irq while unbound, allowing analogix_dp_irq_thread() to use a stale dp->drm_dev. -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=17
