[PATCH v2 1/2] drm/mediatek: add blocking config mode for crtc disable flow

jason-jh.lin jason-jh.lin at mediatek.com
Tue Nov 30 09:26:15 PST 2021


mtk_drm_crtc_atomic_disable will send an async cmd to cmdq driver,
so it may not finish when cmdq_suspend is called sometimes.

Change async cmd to blocking cmd for mtk_drm_crtc_atomic_disable
to make sure the lastest cmd is done before cmdq_suspend.

Signed-off-by: jason-jh.lin <jason-jh.lin at mediatek.com>
---
 drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
index 62529a954b62..e886d299813c 100644
--- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
+++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c
@@ -56,6 +56,8 @@ struct mtk_drm_crtc {
 	struct cmdq_pkt			cmdq_handle;
 	u32				cmdq_event;
 	u32				cmdq_vblank_cnt;
+	bool				blocking_config;
+	struct completion		cmplt;
 #endif
 
 	struct device			*mmsys_dev;
@@ -584,8 +586,16 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
 		 */
 		mtk_crtc->cmdq_vblank_cnt = 3;
 
+		if (mtk_crtc->blocking_config)
+			init_completion(&mtk_crtc->cmplt);
+
 		mbox_send_message(mtk_crtc->cmdq_client.chan, cmdq_handle);
 		mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0);
+
+		if (mtk_crtc->blocking_config) {
+			wait_for_completion(&mtk_crtc->cmplt);
+			mtk_crtc->blocking_config = false;
+		}
 	}
 #endif
 	mtk_crtc->config_updating = false;
@@ -698,7 +708,9 @@ static void mtk_drm_crtc_atomic_disable(struct drm_crtc *crtc,
 		plane_state->pending.config = true;
 	}
 	mtk_crtc->pending_planes = true;
-
+#if IS_REACHABLE(CONFIG_MTK_CMDQ)
+	mtk_crtc->blocking_config = true;
+#endif
 	mtk_drm_crtc_update_config(mtk_crtc, false);
 	/* Wait for planes to be disabled */
 	drm_crtc_wait_one_vblank(crtc);
-- 
2.18.0




More information about the Linux-mediatek mailing list