mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "CK Hu (胡俊光)" <ck.hu@mediatek.com>
To: "Jason-JH Lin (林睿祥)" <Jason-JH.Lin@mediatek.com>,
	"chunkuang.hu@kernel.org" <chunkuang.hu@kernel.org>,
	"AngeloGioacchino Del Regno"
	<angelogioacchino.delregno@collabora.com>
Cc: "Singo Chang (張興國)" <Singo.Chang@mediatek.com>,
	Project_Global_Chrome_Upstream_Group
	<Project_Global_Chrome_Upstream_Group@mediatek.com>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"Nancy Lin (林欣螢)" <Nancy.Lin@mediatek.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"Shawn Sung (宋孝謙)" <Shawn.Sung@mediatek.com>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"fshao@chromium.org" <fshao@chromium.org>
Subject: Re: [PATCH v4] drm/mediatek: Move mtk_crtc_finish_page_flip() to ddp_cmdq_cb()
Date: Mon, 23 Dec 2024 09:34:51 +0000	[thread overview]
Message-ID: <cee38f690b71d9a5ebfe749bf31d473ef2a9e716.camel@mediatek.com> (raw)
In-Reply-To: <20241211034716.29241-1-jason-jh.lin@mediatek.com>

Hi, Jason:

On Wed, 2024-12-11 at 11:47 +0800, Jason-JH.Lin wrote:
> mtk_crtc_finish_page_flip() is used to notify userspace that a
> page flip has been completed, allowing userspace to free the frame
> buffer of the last frame and commit the next frame.
> 
> In MediaTek's hardware design for configuring display hardware by using
> GCE, `DRM_EVENT_FLIP_COMPLETE` should be notified to userspace after
> GCE has finished configuring all display hardware settings for each
> atomic_commit().
> 
> Currently, mtk_crtc_finish_page_flip() cannot guarantee that GCE has
> configured all the display hardware settings of the last frame.
> Therefore, to increase the accuracy of the timing for notifying
> `DRM_EVENT_FLIP_COMPLETE` to userspace, mtk_crtc_finish_page_flip()
> should be moved to ddp_cmdq_cb().

Reviewed-by: CK Hu <ck.hu@mediatek.com>

> 
> Fixes: 7f82d9c43879 ("drm/mediatek: Clear pending flag when cmdq packet is done")
> Signed-off-by: Jason-JH.Lin <jason-jh.lin@mediatek.com>
> ---
>  drivers/gpu/drm/mediatek/mtk_crtc.c | 25 +++++++++++++++++++------
>  1 file changed, 19 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/gpu/drm/mediatek/mtk_crtc.c b/drivers/gpu/drm/mediatek/mtk_crtc.c
> index eb0e1233ad04..5674f5707cca 100644
> --- a/drivers/gpu/drm/mediatek/mtk_crtc.c
> +++ b/drivers/gpu/drm/mediatek/mtk_crtc.c
> @@ -112,6 +112,11 @@ static void mtk_drm_finish_page_flip(struct mtk_crtc *mtk_crtc)
>  
>  	drm_crtc_handle_vblank(&mtk_crtc->base);
>  
> +#if IS_REACHABLE(CONFIG_MTK_CMDQ)
> +	if (mtk_crtc->cmdq_client.chan)
> +		return;
> +#endif
> +
>  	spin_lock_irqsave(&mtk_crtc->config_lock, flags);
>  	if (!mtk_crtc->config_updating && mtk_crtc->pending_needs_vblank) {
>  		mtk_crtc_finish_page_flip(mtk_crtc);
> @@ -284,10 +289,8 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
>  	state = to_mtk_crtc_state(mtk_crtc->base.state);
>  
>  	spin_lock_irqsave(&mtk_crtc->config_lock, flags);
> -	if (mtk_crtc->config_updating) {
> -		spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
> +	if (mtk_crtc->config_updating)
>  		goto ddp_cmdq_cb_out;
> -	}
>  
>  	state->pending_config = false;
>  
> @@ -315,10 +318,15 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg)
>  		mtk_crtc->pending_async_planes = false;
>  	}
>  
> -	spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
> -
>  ddp_cmdq_cb_out:
>  
> +	if (mtk_crtc->pending_needs_vblank) {
> +		mtk_crtc_finish_page_flip(mtk_crtc);
> +		mtk_crtc->pending_needs_vblank = false;
> +	}
> +
> +	spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
> +
>  	mtk_crtc->cmdq_vblank_cnt = 0;
>  	wake_up(&mtk_crtc->cb_blocking_queue);
>  }
> @@ -606,13 +614,18 @@ static void mtk_crtc_update_config(struct mtk_crtc *mtk_crtc, bool needs_vblank)
>  		 */
>  		mtk_crtc->cmdq_vblank_cnt = 3;
>  
> +		spin_lock_irqsave(&mtk_crtc->config_lock, flags);
> +		mtk_crtc->config_updating = false;
> +		spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
> +
>  		mbox_send_message(mtk_crtc->cmdq_client.chan, cmdq_handle);
>  		mbox_client_txdone(mtk_crtc->cmdq_client.chan, 0);
>  	}
> -#endif
> +#else
>  	spin_lock_irqsave(&mtk_crtc->config_lock, flags);
>  	mtk_crtc->config_updating = false;
>  	spin_unlock_irqrestore(&mtk_crtc->config_lock, flags);
> +#endif
>  
>  	mutex_unlock(&mtk_crtc->hw_lock);
>  }


  reply	other threads:[~2024-12-23  9:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-11  3:47 Jason-JH.Lin
2024-12-23  9:34 ` CK Hu (胡俊光) [this message]
2024-12-25 15:09 ` Chun-Kuang Hu

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=cee38f690b71d9a5ebfe749bf31d473ef2a9e716.camel@mediatek.com \
    --to=ck.hu@mediatek.com \
    --cc=Jason-JH.Lin@mediatek.com \
    --cc=Nancy.Lin@mediatek.com \
    --cc=Project_Global_Chrome_Upstream_Group@mediatek.com \
    --cc=Shawn.Sung@mediatek.com \
    --cc=Singo.Chang@mediatek.com \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=chunkuang.hu@kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=fshao@chromium.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    /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

all inboxes | Powered by JetHome®