Message ID | 1619838819-11309-3-git-send-email-yongqiang.niu@mediatek.com (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | move page flip handle into cmdq cb | expand |
Hi, Yongqiang: Yongqiang Niu <yongqiang.niu@mediatek.com> 於 2021年5月1日 週六 上午11:13寫道: > > In cmdq mode, packet may be flushed before it is executed, so > the pending flag should be cleared after cmdq packet is done. > > Signed-off-by: CK Hu <ck.hu@mediatek.com> > Signed-off-by: Yongqiang Niu <yongqiang.niu@mediatek.com> > --- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 57 ++++++++++++++++++++++++++++++--- > 1 file changed, 52 insertions(+), 5 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > index c37881b..6a3cf47 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > @@ -231,18 +231,57 @@ static void ddp_cmdq_cb(struct cmdq_cb_data data) > { > struct mtk_cmdq_cb_data *cb_data = data.data; > struct mtk_drm_crtc *mtk_crtc; > + struct mtk_crtc_state *state; > + unsigned int i; > > if (!cb_data) { > DRM_ERROR("cmdq callback data is null pointer!\n"); > return; > } > > + if (data.sta == CMDQ_CB_ERROR) { I would like this patch to depend on [1]. [1] https://patchwork.kernel.org/project/linux-mediatek/patch/20210314233323.23377-2-chunkuang.hu@kernel.org/ Regards, Chun-Kuang. > + DRM_WARN("cmdq callback error!!\n"); > + goto destroy_pkt; > + } > + > mtk_crtc = cb_data->mtk_crtc; > if (!mtk_crtc) { > DRM_ERROR("cmdq callback mtk_crtc is null pointer!\n"); > goto destroy_pkt; > } > > + state = to_mtk_crtc_state(mtk_crtc->base.state); > + > + if (state->pending_config) { > + state->pending_config = false; > + } > + > + if (mtk_crtc->pending_planes) { > + for (i = 0; i < mtk_crtc->layer_nr; i++) { > + struct drm_plane *plane = &mtk_crtc->planes[i]; > + struct mtk_plane_state *plane_state; > + > + plane_state = to_mtk_plane_state(plane->state); > + > + if (plane_state->pending.config) > + plane_state->pending.config = false; > + } > + mtk_crtc->pending_planes = false; > + } > + > + if (mtk_crtc->pending_async_planes) { > + for (i = 0; i < mtk_crtc->layer_nr; i++) { > + struct drm_plane *plane = &mtk_crtc->planes[i]; > + struct mtk_plane_state *plane_state; > + > + plane_state = to_mtk_plane_state(plane->state); > + > + if (plane_state->pending.async_config) > + plane_state->pending.async_config = false; > + } > + mtk_crtc->pending_async_planes = false; > + } > + > mtk_drm_finish_page_flip(mtk_crtc); > > destroy_pkt: > @@ -403,7 +442,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, > state->pending_vrefresh, 0, > cmdq_handle); > > - state->pending_config = false; > + if (!cmdq_handle) > + state->pending_config = false; > } > > if (mtk_crtc->pending_planes) { > @@ -423,9 +463,12 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, > mtk_ddp_comp_layer_config(comp, local_layer, > plane_state, > cmdq_handle); > - plane_state->pending.config = false; > + if (!cmdq_handle) > + plane_state->pending.config = false; > } > - mtk_crtc->pending_planes = false; > + > + if (!cmdq_handle) > + mtk_crtc->pending_planes = false; > } > > if (mtk_crtc->pending_async_planes) { > @@ -445,9 +488,13 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, > mtk_ddp_comp_layer_config(comp, local_layer, > plane_state, > cmdq_handle); > - plane_state->pending.async_config = false; > + > + if (!cmdq_handle) > + plane_state->pending.async_config = false; > } > - mtk_crtc->pending_async_planes = false; > + > + if (!cmdq_handle) > + mtk_crtc->pending_async_planes = false; > } > } > > -- > 1.8.1.1.dirty >
diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c index c37881b..6a3cf47 100644 --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c @@ -231,18 +231,57 @@ static void ddp_cmdq_cb(struct cmdq_cb_data data) { struct mtk_cmdq_cb_data *cb_data = data.data; struct mtk_drm_crtc *mtk_crtc; + struct mtk_crtc_state *state; + unsigned int i; if (!cb_data) { DRM_ERROR("cmdq callback data is null pointer!\n"); return; } + if (data.sta == CMDQ_CB_ERROR) { + DRM_WARN("cmdq callback error!!\n"); + goto destroy_pkt; + } + mtk_crtc = cb_data->mtk_crtc; if (!mtk_crtc) { DRM_ERROR("cmdq callback mtk_crtc is null pointer!\n"); goto destroy_pkt; } + state = to_mtk_crtc_state(mtk_crtc->base.state); + + if (state->pending_config) { + state->pending_config = false; + } + + if (mtk_crtc->pending_planes) { + for (i = 0; i < mtk_crtc->layer_nr; i++) { + struct drm_plane *plane = &mtk_crtc->planes[i]; + struct mtk_plane_state *plane_state; + + plane_state = to_mtk_plane_state(plane->state); + + if (plane_state->pending.config) + plane_state->pending.config = false; + } + mtk_crtc->pending_planes = false; + } + + if (mtk_crtc->pending_async_planes) { + for (i = 0; i < mtk_crtc->layer_nr; i++) { + struct drm_plane *plane = &mtk_crtc->planes[i]; + struct mtk_plane_state *plane_state; + + plane_state = to_mtk_plane_state(plane->state); + + if (plane_state->pending.async_config) + plane_state->pending.async_config = false; + } + mtk_crtc->pending_async_planes = false; + } + mtk_drm_finish_page_flip(mtk_crtc); destroy_pkt: @@ -403,7 +442,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, state->pending_vrefresh, 0, cmdq_handle); - state->pending_config = false; + if (!cmdq_handle) + state->pending_config = false; } if (mtk_crtc->pending_planes) { @@ -423,9 +463,12 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, mtk_ddp_comp_layer_config(comp, local_layer, plane_state, cmdq_handle); - plane_state->pending.config = false; + if (!cmdq_handle) + plane_state->pending.config = false; } - mtk_crtc->pending_planes = false; + + if (!cmdq_handle) + mtk_crtc->pending_planes = false; } if (mtk_crtc->pending_async_planes) { @@ -445,9 +488,13 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc, mtk_ddp_comp_layer_config(comp, local_layer, plane_state, cmdq_handle); - plane_state->pending.async_config = false; + + if (!cmdq_handle) + plane_state->pending.async_config = false; } - mtk_crtc->pending_async_planes = false; + + if (!cmdq_handle) + mtk_crtc->pending_async_planes = false; } }