Skip to content

Commit eaf8012

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 2 vblank. One vblank interrupt before send message (occasionally) and one vblank interrupt after cmdq done. If it fail to execute in next 3 vblank, tiemout happen. Signed-off-by: Chun-Kuang Hu <[email protected]> Signed-off-by: jason-jh.lin <[email protected]>
1 parent 563c9d4 commit eaf8012

File tree

1 file changed

+18
-2
lines changed

1 file changed

+18
-2
lines changed

drivers/gpu/drm/mediatek/mtk_drm_crtc.c

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ struct mtk_drm_crtc {
5454
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
5555
struct cmdq_client cmdq_client;
5656
u32 cmdq_event;
57+
u32 cmdq_vblank_cnt;
5758
#endif
5859

5960
struct device *mmsys_dev;
@@ -227,7 +228,10 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(struct drm_crtc *crtc,
227228
static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
228229
{
229230
struct cmdq_cb_data *data = mssg;
231+
struct cmdq_client *cmdq_cl = container_of(cl, struct cmdq_client, client);
232+
struct mtk_drm_crtc *mtk_crtc = container_of(cmdq_cl, struct mtk_drm_crtc, cmdq_client);
230233

234+
mtk_crtc->cmdq_vblank_cnt = 0;
231235
cmdq_pkt_destroy(data->pkt);
232236
}
233237
#endif
@@ -483,6 +487,15 @@ static void mtk_drm_crtc_update_config(struct mtk_drm_crtc *mtk_crtc,
483487
cmdq_handle->pa_base,
484488
cmdq_handle->cmd_buf_size,
485489
DMA_TO_DEVICE);
490+
/*
491+
* CMDQ command should execute in next 3 vblank.
492+
* One vblank interrupt before send message (occasionally)
493+
* and one vblank interrupt after cmdq done,
494+
* so it's timeout after 3 vblank interrupt.
495+
* If it fail to execute in next 3 vblank, timeout happen.
496+
*/
497+
mtk_crtc->cmdq_vblank_cnt = 3;
498+
486499
mbox_send_message(mtk_crtc->cmdq_client.chan, cmdq_handle);
487500
mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0);
488501
}
@@ -499,11 +512,14 @@ static void mtk_crtc_ddp_irq(void *data)
499512

500513
#if IS_REACHABLE(CONFIG_MTK_CMDQ)
501514
if (!priv->data->shadow_register && !mtk_crtc->cmdq_client.chan)
515+
mtk_crtc_ddp_config(crtc, NULL);
516+
else if (mtk_crtc->cmdq_vblank_cnt > 0 && --mtk_crtc->cmdq_vblank_cnt == 0)
517+
DRM_ERROR("mtk_crtc %d CMDQ execute command timeout!\n",
518+
drm_crtc_index(&mtk_crtc->base));
502519
#else
503520
if (!priv->data->shadow_register)
504-
#endif
505521
mtk_crtc_ddp_config(crtc, NULL);
506-
522+
#endif
507523
mtk_drm_finish_page_flip(mtk_crtc);
508524
}
509525

0 commit comments

Comments
 (0)