[PATCH] drm/mediatek: dp: Disable HPD IRQ before cancelling debounce timer

Hank Liou via B4 Relay devnull+hank.liou.mediatek.com at kernel.org
Wed Nov 25 19:15:43 PST 2026


From: Hank Liou <hank.liou at mediatek.com>

mtk_dp_remove() cancels debounce_timer with timer_delete_sync(), but the
HPD interrupt that re-arms it from mtk_dp_hpd_event_thread() is
requested with devm_request_threaded_irq() and stays enabled until
devres runs after .remove returns. An HPD falling edge between the
timer cancellation and the IRQ release re-arms the timer, which can
then expire after the driver has been unbound, when the struct mtk_dp
that embeds it may already be freed.

Disable the IRQ first, which also waits for a running hard or threaded
handler, then cancel the timer. Do this before the runtime PM calls so
the interrupt is quiesced while the hardware is still powered.

Fixes: 4652e95e7ea6 ("drm/mediatek: dp: Add hpd debounce")
Signed-off-by: Hank Liou <hank.liou at mediatek.com>
---
Fix the ordering of the HPD IRQ disable and the debounce timer cancellation in mtk_dp_remove().
---
 drivers/gpu/drm/mediatek/mtk_dp.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_dp.c b/drivers/gpu/drm/mediatek/mtk_dp.c
index 974c4fff6..7a5e380fd 100644
--- a/drivers/gpu/drm/mediatek/mtk_dp.c
+++ b/drivers/gpu/drm/mediatek/mtk_dp.c
@@ -2865,10 +2865,13 @@ static void mtk_dp_remove(struct platform_device *pdev)
 {
 	struct mtk_dp *mtk_dp = platform_get_drvdata(pdev);
 
+	if (mtk_dp->data->bridge_type != DRM_MODE_CONNECTOR_eDP) {
+		disable_irq(mtk_dp->irq);
+		timer_delete_sync(&mtk_dp->debounce_timer);
+	}
+
 	pm_runtime_put(&pdev->dev);
 	pm_runtime_disable(&pdev->dev);
-	if (mtk_dp->data->bridge_type != DRM_MODE_CONNECTOR_eDP)
-		timer_delete_sync(&mtk_dp->debounce_timer);
 	platform_device_unregister(mtk_dp->phy_dev);
 	if (mtk_dp->audio_pdev)
 		platform_device_unregister(mtk_dp->audio_pdev);

---
base-commit: ebb7a8dc1e74c705daffe11c2faf38ec2628f838
change-id: 20261126-mtk-dp-hpd-irq-5fc8b6f72e6e

Best regards,
-- 
Hank Liou <hank.liou at mediatek.com>





More information about the linux-arm-kernel mailing list