Skip to content

Commit 8cdcb36

Browse files
author
Chun-Kuang Hu
committed
drm/mediatek: Detect CMDQ execution timeout
CMDQ is used to update display register in vblank period, so it should be execute in next vblank. If it fail to execute in next 2 vblank, tiemout happen. Signed-off-by: Chun-Kuang Hu <[email protected]>
1 parent f4be17c commit 8cdcb36

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

drivers/gpu/drm/mediatek/mtk_drm_crtc.c

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ struct mtk_drm_crtc {
5555
struct mbox_client cmdq_cl;
5656
struct mbox_chan *cmdq_chan;
5757
u32 cmdq_event;
58+
u32 cmdq_vblank_cnt;
5859
#endif
5960

6061
struct device *mmsys_dev;
@@ -269,6 +270,7 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
269270
struct mtk_drm_crtc *mtk_crtc = container_of(cl, struct mtk_drm_crtc, cmdq_cl);
270271
struct cmdq_cb_data *data = mssg;
271272

273+
mtk_crtc->cmdq_vblank_cnt = 0;
272274
mtk_drm_cmdq_pkt_destroy(mtk_crtc->cmdq_chan, data->pkt);
273275
}
274276
#endif
@@ -524,6 +526,11 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
524526
cmdq_handle->pa_base,
525527
cmdq_handle->cmd_buf_size,
526528
DMA_TO_DEVICE);
529+
/*
530+
* CMDQ command should execute in next vblank,
531+
* If it fail to execute in next 2 vblank, timeout happen.
532+
*/
533+
mtk_crtc->cmdq_vblank_cnt = 2;
527534
mbox_send_message(mtk_crtc->cmdq_chan, cmdq_handle);
528535
mbox_client_txdone(mtk_crtc->cmdq_chan, 0);
529536
}
@@ -540,11 +547,14 @@ static void mtk_crtc_ddp_irq(void *data)
540547

541548
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
542549
if (!priv->data->shadow_register && !mtk_crtc->cmdq_chan)
550+
mtk_crtc_ddp_config(crtc, NULL);
551+
else if (mtk_crtc->cmdq_vblank_cnt > 0 && --mtk_crtc->cmdq_vblank_cnt == 0)
552+
DRM_ERROR("mtk_crtc %d CMDQ execute command timeout!\n",
553+
drm_crtc_index(&mtk_crtc->base));
543554
#else
544555
if (!priv->data->shadow_register)
545-
#endif
546556
mtk_crtc_ddp_config(crtc, NULL);
547-
557+
#endif
548558
mtk_drm_finish_page_flip(mtk_crtc);
549559
}
550560

0 commit comments

Comments
 (0)