public inbox for linux-mediatek@lists.infradead.org
 help / color / mirror / Atom feed
From: "Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>
To: "CK Hu (胡俊光)" <ck.hu@mediatek.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>
Cc: "Singo Chang (張興國)" <Singo.Chang@mediatek.com>,
	"Zhenxing Qin (秦振兴)" <Zhenxing.Qin@mediatek.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"wenst@chromium.org" <wenst@chromium.org>,
	"Xavier Chang (張獻文)" <Xavier.Chang@mediatek.com>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"Paul-pl Chen (陳柏霖)" <Paul-pl.Chen@mediatek.com>,
	"Yongqiang Niu (牛永强)" <yongqiang.niu@mediatek.com>,
	"Sirius Wang (王皓昱)" <Sirius.Wang@mediatek.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>
Subject: Re: [PATCH] drm/mediatek: Add wait_event_timeout when disabling plane
Date: Tue, 24 Jun 2025 10:19:15 +0000	[thread overview]
Message-ID: <c4c97f7d81a7b2b76bd43665e409a972000be8a4.camel@mediatek.com> (raw)
In-Reply-To: <d46b431600ad2e5e2b3639b8bea784dd6c151bfd.camel@mediatek.com>

Hi CK,

Thanks for the reviews.

On Tue, 2025-06-24 at 09:39 +0000, CK Hu (胡俊光) wrote:
> On Thu, 2025-05-22 at 16:34 +0800, Jason-JH Lin wrote:
> > Our hardware registers are set through GCE, not by the CPU.
> > DRM might assume the hardware is disabled immediately after calling
> > atomic_disable() of drm_plane, but it is only truly disabled after
> > the
> > GCE IRQ is triggered.
> > 
> > Additionally, the cursor plane in DRM uses async_commit, so DRM
> > will
> > not wait for vblank and will free the buffer immediately after
> > calling
> > atomic_disable().
> > 
> > To prevent the framebuffer from being freed before the layer
> > disable
> > settings are configured into the hardware, which can cause an IOMMU
> > fault error, a wait_event_timeout has been added to wait for the
> > ddp_cmdq_cb() callback,indicating that the GCE IRQ has been
> > triggered.
> > 
> > Fixes: 119f5173628a ("drm/mediatek: Add DRM Driver for Mediatek SoC
> > MT8173.")
> > Signed-off-by: Jason-JH Lin <jason-jh.lin@mediatek.com>
> > ---
> >  drivers/gpu/drm/mediatek/mtk_crtc.c  | 30
> > ++++++++++++++++++++++++++++
> >  drivers/gpu/drm/mediatek/mtk_crtc.h  |  1 +
> >  drivers/gpu/drm/mediatek/mtk_plane.c |  5 +++++
> >  3 files changed, 36 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c
> > b/drivers/gpu/drm/mediatek/mtk_crtc.c
> > index 8f6fba4217ec..944a3d1e5ec9 100644
> > --- a/drivers/gpu/drm/mediatek/mtk_crtc.c
> > +++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
> > @@ -719,6 +719,36 @@ int mtk_crtc_plane_check(struct drm_crtc
> > *crtc, struct drm_plane *plane,
> >  	return 0;
> >  }
> >  
> > +void mtk_crtc_plane_disable(struct drm_crtc *crtc, struct
> > drm_plane *plane)
> > +{
> > +	struct mtk_crtc *mtk_crtc = to_mtk_crtc(crtc);
> > +	struct mtk_plane_state *plane_state =
> > to_mtk_plane_state(plane->state);
> > +	int i;
> > +
> > +	if (!mtk_crtc->enabled)
> > +		return;
> > +
> > +	/* set pending plane state to disabled */
> > +	for (i = 0; i < mtk_crtc->layer_nr; i++) {
> > +		struct drm_plane *mtk_plane = &mtk_crtc-
> > >planes[i];
> > +		struct mtk_plane_state *mtk_plane_state =
> > to_mtk_plane_state(mtk_plane->state);
> > +
> > +		if (mtk_plane->index == plane->index) {
> > +			memcpy(mtk_plane_state, plane_state,
> > sizeof(*plane_state));
> 
> In commit message, you mention GCE flow has problem.
> This also modify non-GCE flow.
> If non-GCE flow does not need this, move this to GCE flow.
> 

Yes, this API is only used for GCE flow.

I'll add the condition in the beginning of this API to avoid breaking
the non-GCE flow.

> > +			break;
> > +		}
> > +	}
> > +	mtk_crtc_update_config(mtk_crtc, false);
> > +
> > +#if IS_REACHABLE(CONFIG_MTK_CMDQ)
> > +	/* wait for planes to be disabled by cmdq */
> > +	if (mtk_crtc->cmdq_client.chan)
> > +		wait_event_timeout(mtk_crtc->cb_blocking_queue,
> > +				   mtk_crtc->cmdq_vblank_cnt == 0,
> 
> Check 'mtk_crtc->cmdq_vblank_cnt == 0' may be not good.
> If a video is playing and mtk_crtc_update_config() would be call
> every frame,
> mtk_crtc->cmdq_vblank_cnt may not be zero and cursor would be block
> until timeout.
> 

I think the cursor won't be blocked until timeout here.

mtk_crtc->cmdq_vblank_cnt will be reset to 0 in ddp_cmdq_cb(), so that
we can make sure GCE has configured all the HW settings.

Regards,
Jason-JH Lin

> Regards,
> CK
> 
> 

      reply	other threads:[~2025-06-24 10:22 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-22  8:34 [PATCH] drm/mediatek: Add wait_event_timeout when disabling plane Jason-JH Lin
2025-05-22 10:30 ` AngeloGioacchino Del Regno
2025-05-24 12:47 ` Daniel Stone
2025-05-26  3:23   ` Jason-JH Lin (林睿祥)
2025-06-24  9:39 ` CK Hu (胡俊光)
2025-06-24 10:19   ` Jason-JH Lin (林睿祥) [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c4c97f7d81a7b2b76bd43665e409a972000be8a4.camel@mediatek.com \
    --to=jason-jh.lin@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Paul-pl.Chen@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Singo.Chang@mediatek.com \
    --cc=Sirius.Wang@mediatek.com \
    --cc=Xavier.Chang@mediatek.com \
    --cc=Zhenxing.Qin@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=ck.hu@mediatek.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=wenst@chromium.org \
    --cc=yongqiang.niu@mediatek.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox