Received: by 2002:a05:6a10:a852:0:0:0:0 with SMTP id d18csp913748pxy; Fri, 30 Apr 2021 21:11:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx5EBfkHQN4rStVxItqQ7/30mU32czWL9lBzaEjS4S3aHiK6Mra7M0Ybhjr0W3tXC2W0GLH X-Received: by 2002:aa7:dd96:: with SMTP id g22mr9810792edv.222.1619842297632; Fri, 30 Apr 2021 21:11:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619842297; cv=none; d=google.com; s=arc-20160816; b=l/z5np42CEcdDmYVa+9K5Aw5s7zTqKom7N7nzAfJ8HLC8TiQBRgbpxaGiki0bGKmr1 kPJonxbAq0fgWIIIJkluNez6Bi+QsvdjY528lgKg4y9cwBNiJzQhFA5OZM7xGoLgln1m iHAQuUxwHgY6/jggHThOlnhrDQy1lpx2SCPTVNghxOE9PY2WxP01dOrVmOAxmvZ4+Xxx Y8fqcHyiey7dIlqGu37auwL9Xc31jYyhZES6rUWXxktDDtMsmcKdhVl1PIhKEt2vrKWG pT+XMOrmuMhWC9ylGDFsgY2bROP1CRypdDIeZ+7G9QcbNcQ7tbHpuKmM+L/1MmjwQ0GY KYRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=BhMcUwkhffNas85am8YpXhNIyyWVNRi9qTqiWjiIrNA=; b=kl+n7S5p++HifltMA5nywmY3OrgA6Z3RdRRHAvTpzYtBQeRGL5zJcZwxyDmeqTXlLa ErczEMLt8EBlSXIl+vU1ueQorwBe8+VNR17O8hUORfe7v1sDF0DtBPnhfIHwr9/bCdxF iVx813N0uIWZBWMHPj2MagiaOsG0f4OmG3hVxRuVYnWj9JybrQJzYjoxMrcTxatBAkP7 cuZ2TKWIJ+RH61CmQinR8UHNrJGJHKC6KiVjLpsIKsCuNQavfoLcipDAI/9crxHlhbJN BTXdJSeMji6oVv9TOuLHW2FY6q1P3cZDD5AANBPYHfF5oietdSZWjVxrmE8jSI2XTzkz YOaw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Laf32iss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id t2si3562977edy.589.2021.04.30.21.11.13; Fri, 30 Apr 2021 21:11:37 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Laf32iss; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229733AbhEAEHU (ORCPT + 99 others); Sat, 1 May 2021 00:07:20 -0400 Received: from mail.kernel.org ([198.145.29.99]:48150 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbhEAEHS (ORCPT ); Sat, 1 May 2021 00:07:18 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 38948613F4; Sat, 1 May 2021 04:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1619841989; bh=F+isvP/CISEBur6+0efALgnBlYarHdry2+xf4t13CSQ=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=Laf32isseyoxoRlwVduDmzQloyXdmi8KFQvzoQbIpm//+nG2tKgMZKOTmZw8KhEws h6wXYysAUKvIXNy263+Fvjl8rRAFB4laVwWX1qKIHBMo/SjncrB4+CTzUTB7S6y627 DxhBXP5/UnFst/UMWoLRlmOegqns5crpye1SjT/hWXaVMYxLsfi5bUELL+6AfbJb4d NGk15pJuP75yQG5eDN+1RqAtDA4yDmdjB9IlB2pB4arlDX0rqtLqoChA2GTNzlAjvR d+85ImFDiGyEBKS5WQGChN3HEOpOXgRquTqTWP/mIZcXoAwWEf1P+34T4T8tBkYGtn HjSucjlZ8y8EA== Received: by mail-ed1-f49.google.com with SMTP id g10so394407edb.0; Fri, 30 Apr 2021 21:06:29 -0700 (PDT) X-Gm-Message-State: AOAM5320yRVZJv41J5MRrONIxI4DC5f3kYAraCZDp866lI4TXCVIviq5 Ar8MBkJ2J2DU7Lz2pfKhyPULT3xium+/e92tUA== X-Received: by 2002:aa7:db0c:: with SMTP id t12mr9503414eds.72.1619841987818; Fri, 30 Apr 2021 21:06:27 -0700 (PDT) MIME-Version: 1.0 References: <1619838819-11309-1-git-send-email-yongqiang.niu@mediatek.com> <1619838819-11309-2-git-send-email-yongqiang.niu@mediatek.com> In-Reply-To: <1619838819-11309-2-git-send-email-yongqiang.niu@mediatek.com> From: Chun-Kuang Hu Date: Sat, 1 May 2021 12:06:15 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 1/2] drm/mediatek: move page flip handle into cmdq cb To: Yongqiang Niu Cc: Chun-Kuang Hu , Rob Herring , Philipp Zabel , David Airlie , Daniel Vetter , Mark Rutland , Matthias Brugger , DRI Development , DTML , Linux ARM , "moderated list:ARM/Mediatek SoC support" , linux-kernel , Project_Global_Chrome_Upstream_Group@mediatek.com, Chun-Hung Wu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Yongqiang: Yongqiang Niu =E6=96=BC 2021=E5=B9=B45=E6=9C= =881=E6=97=A5 =E9=80=B1=E5=85=AD =E4=B8=8A=E5=8D=8811:13=E5=AF=AB=E9=81=93= =EF=BC=9A > > move page flip handle into cmdq cb > irq callback will before cmdq flush ddp register > into hardware, that will cause the display frame page > flip event before it realy display out time After apply patch [1], we don't need to care about which one (irq or cmdq_cb) come first. Even though cmdq_cb come later, GCE would have already write register in vblank. [1] https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/com= mit/?h=3Dnext-20210430&id=3D368166ec7600ba83587cfcb31d817cf6479cf006 Regards, Chun-Kuang. > > Signed-off-by: Yongqiang Niu > --- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 46 +++++++++++++++++++++++++++= +++--- > 1 file changed, 43 insertions(+), 3 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/me= diatek/mtk_drm_crtc.c > index 8b0de90..c37881b 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > @@ -72,6 +72,13 @@ struct mtk_crtc_state { > unsigned int pending_vrefresh; > }; > > +#if IS_REACHABLE(CONFIG_MTK_CMDQ) > +struct mtk_cmdq_cb_data { > + struct cmdq_pkt *cmdq_handle; > + struct mtk_drm_crtc *mtk_crtc; > +}; > +#endif > + > static inline struct mtk_drm_crtc *to_mtk_crtc(struct drm_crtc *c) > { > return container_of(c, struct mtk_drm_crtc, base); > @@ -96,7 +103,6 @@ static void mtk_drm_crtc_finish_page_flip(struct mtk_d= rm_crtc *mtk_crtc) > > static void mtk_drm_finish_page_flip(struct mtk_drm_crtc *mtk_crtc) > { > - drm_crtc_handle_vblank(&mtk_crtc->base); > if (mtk_crtc->pending_needs_vblank) { > mtk_drm_crtc_finish_page_flip(mtk_crtc); > mtk_crtc->pending_needs_vblank =3D false; > @@ -223,7 +229,27 @@ struct mtk_ddp_comp *mtk_drm_ddp_comp_for_plane(stru= ct drm_crtc *crtc, > #if IS_REACHABLE(CONFIG_MTK_CMDQ) > static void ddp_cmdq_cb(struct cmdq_cb_data data) > { > - cmdq_pkt_destroy(data.data); > + struct mtk_cmdq_cb_data *cb_data =3D data.data; > + struct mtk_drm_crtc *mtk_crtc; > + > + if (!cb_data) { > + DRM_ERROR("cmdq callback data is null pointer!\n"); > + return; > + } > + > + mtk_crtc =3D cb_data->mtk_crtc; > + if (!mtk_crtc) { > + DRM_ERROR("cmdq callback mtk_crtc is null pointer!\n"); > + goto destroy_pkt; > + } > + > + mtk_drm_finish_page_flip(mtk_crtc); > + > +destroy_pkt: > + if (cb_data->cmdq_handle) > + cmdq_pkt_destroy(cb_data->cmdq_handle); > + > + kfree(cb_data); > } > #endif > > @@ -463,13 +489,20 @@ static void mtk_drm_crtc_hw_config(struct mtk_drm_c= rtc *mtk_crtc) > } > #if IS_REACHABLE(CONFIG_MTK_CMDQ) > if (mtk_crtc->cmdq_client) { > + struct mtk_cmdq_cb_data *cb_data; > + > mbox_flush(mtk_crtc->cmdq_client->chan, 2000); > cmdq_handle =3D cmdq_pkt_create(mtk_crtc->cmdq_client, PA= GE_SIZE); > cmdq_pkt_clear_event(cmdq_handle, mtk_crtc->cmdq_event); > cmdq_pkt_wfe(cmdq_handle, mtk_crtc->cmdq_event, false); > mtk_crtc_ddp_config(crtc, cmdq_handle); > cmdq_pkt_finalize(cmdq_handle); > - cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cmdq_handl= e); > + > + cb_data =3D kmalloc(sizeof(*cb_data), GFP_KERNEL); > + cb_data->cmdq_handle =3D cmdq_handle; > + cb_data->mtk_crtc =3D mtk_crtc; > + > + cmdq_pkt_flush_async(cmdq_handle, ddp_cmdq_cb, cb_data); > } > #endif > mutex_unlock(&mtk_crtc->hw_lock); > @@ -488,7 +521,14 @@ static void mtk_crtc_ddp_irq(void *data) > #endif > mtk_crtc_ddp_config(crtc, NULL); > > + drm_crtc_handle_vblank(&mtk_crtc->base); > + > +#if IS_REACHABLE(CONFIG_MTK_CMDQ) > + if (!priv->data->shadow_register && !mtk_crtc->cmdq_client) > + mtk_drm_finish_page_flip(mtk_crtc); > +#else > mtk_drm_finish_page_flip(mtk_crtc); > +#endif > } > > static int mtk_drm_crtc_enable_vblank(struct drm_crtc *crtc) > -- > 1.8.1.1.dirty >