[PATCH] drm/mediatek: Fix missing configuration flags in mtk_crtc_ddp_config()

Jason-JH Lin (林睿祥) Jason-JH.Lin at mediatek.com
Mon Aug 19 03:06:38 PDT 2024


Hi CK,

> > --- a/drivers/gpu/drm/mediatek/mtk_crtc.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
> > @@ -314,30 +314,32 @@ static void ddp_cmdq_cb(struct mbox_client
> *cl, void *mssg)
> >
> >         state = to_mtk_crtc_state(mtk_crtc->base.state);
> >
> > -       state->pending_config = false;
> > +       if (!mtk_crtc->config_updating) {
> > +               state->pending_config = false;
> 
> I think if mtk_crtc->config_updating == true, the whole clear job
> could be skipped.
> And use spin_lock to protect the clear job in irq.
> 
> /*
> spin_lock():
> if (mtk_crtc->config_updating) {
>         spin_unlock();
>         goto out;
> }
> 
> /* clear job */
> 
> spin_unlock();
> */
> out:
> 
> In mtk_crtc_config_update(), use spin_lock to protect mtk_crtc-
> >config_updating:
> 
> spin_lock();
> mtk_crtc->config_updating = true;
> spin_unlock();
> ...
> spin_lock();
> mtk_crtc->config_updating = false;
> spin_unlock();
> 

Thanks for the reviews.

I think that's more solid to protect the updating config of cmd buffer.

I will also add spin_lock for the whole statement in
mtk_drm_finish_page_flip() because config_updating flag is covered the
pending_need_vblank flag.

Regards,
Jason-JH.Lin

> Regards,
> Chun-Kuang.
> 
> 
> >
> > -       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;
> > +               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);
> > +                               plane_state =
> to_mtk_plane_state(plane->state);
> >
> > -                       plane_state->pending.config = false;
> > +                               plane_state->pending.config =
> false;
> > +                       }
> > +                       mtk_crtc->pending_planes = 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;
> > +               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);
> > +                               plane_state =
> to_mtk_plane_state(plane->state);
> >
> > -                       plane_state->pending.async_config = false;
> > +                               plane_state->pending.async_config =
> false;
> > +                       }
> > +                       mtk_crtc->pending_async_planes = false;
> >                 }
> > -               mtk_crtc->pending_async_planes = false;
> >         }
> >
> >         mtk_crtc->cmdq_vblank_cnt = 0;
> > --
> > 2.18.0
> >


More information about the Linux-mediatek mailing list