Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1222051pxb; Sun, 21 Feb 2021 16:52:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJz1fynjLxB7koFtM0Va1J1wX3cRJVEkZLIJ+Y4T1omSbWRCPnCYr5jiwn/1uigwzYm74Me9 X-Received: by 2002:a17:906:c210:: with SMTP id d16mr14649765ejz.187.1613955161117; Sun, 21 Feb 2021 16:52:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1613955161; cv=none; d=google.com; s=arc-20160816; b=VW3EkhmmOGAx83VQdPjlRFnrj0ypuksmpB8iLyuDPyCYlwVhTHKYki2WrdhJY1pYmN bZqZR1xSNIQFuwd1zss68n+MeKvrGzbSUwnGtiq8m1GTFFWMipq29maMIcCjPue9MeXU Han8El0Ggh6WIHcg5/AOMP0HVKN3m8e/HjBHrpSl1sodxlD/G4FzvcE6AyaCPYNZbxU+ p1FJkqNoyB6Jm/4sDUWqonmmxPbIVgdmF71VPpHf+AlBPq/0GW6jzd5XxWFCobNOO2Yu gLIwPmDZgAKuZyF3+u5rpTxh++9cEipOzcjh5ZXeu5h1mTWVYBK6sQrRmJWveBYMAMSP VyXw== 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=P/43uU3LPJq6zjohiJO7p65mJ/ZkvYjrQUgL/JafvTA=; b=FFb9OBZCgrcJOJ6nebGm4006xW++BjR52W/W6sdCFQzGbp95Wg0dN82uEt9DWQMDGs jwBdYMCv7stcRzhPpgmDlZpID7TQhzjZkA3gy5D7Ss+3t9obxzEJzRlx8gIOMa4mMq2J Dow3lISjqDqg8uodzm1LnL6izQLT5sb4PGWE5PLfU64VfEfcupsEhObqvC+AKOGo2SOk /wrMQOZiQFfW+BSyqH5O0jyVCMMWpJxcAzkhjYH5K2ZHiBGutHTpQfJDz7mEAIW0ppc1 PMlsW7gWQNEKalNOnlVp26UpXYqjXOnet3lRfOoPuWXYiSgO5pwzkUliNNRPQr4VSIK3 PWzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="T1pRRi5/"; 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 o5si10995377ejm.1.2021.02.21.16.52.18; Sun, 21 Feb 2021 16:52:41 -0800 (PST) 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="T1pRRi5/"; 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 S229918AbhBUX4H (ORCPT + 99 others); Sun, 21 Feb 2021 18:56:07 -0500 Received: from mail.kernel.org ([198.145.29.99]:47938 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229717AbhBUX4C (ORCPT ); Sun, 21 Feb 2021 18:56:02 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 8493364E64; Sun, 21 Feb 2021 23:55:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1613951721; bh=pCV1sQy9uTqnFAmmvzP8ZG3dSUM5TF1WU3OUbHWIOv4=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=T1pRRi5/D/X7oVKcOmFHTJtXqE5RutVhZWk7CLVNL5XbPT8qLQytrs0gEhOLn4zd/ oMtzAGHyufc5EAcu9qpi67kgU5sFMf0THymI2PM4BPddsXq3IEgenfteJzQ7WsMpWg Fh++ylm32cIb7DV/46FFXRFy9poORUQIvjU8kqLcIl0MrLQppdq+Qg8jAVnNCwkeN8 /s3Qc9qVacn1oOqUcFUrQUhG+UfoVpF7MO9ssZOm1coRCCrCAsNKygsF8/yDUcW1cN zVRfdYaI0IFjAPoRJWcZeJb+WzRvA2sS0avXg/cZpzLDNODhVX8uiwhLavvKRoiERK 9eZgDdBOeY/sQ== Received: by mail-ed1-f51.google.com with SMTP id i14so19434588eds.8; Sun, 21 Feb 2021 15:55:21 -0800 (PST) X-Gm-Message-State: AOAM530Ig5p3dOBvdBDxynLTxJ9qlmFw4q4+RM928g2qYOdwaNLkZxdL PXgwHswInickGI+KBg28diwa945MO2Qwd0n5Vg== X-Received: by 2002:aa7:dd4b:: with SMTP id o11mr19989951edw.303.1613951719928; Sun, 21 Feb 2021 15:55:19 -0800 (PST) MIME-Version: 1.0 References: <1613728452-24871-1-git-send-email-yongqiang.niu@mediatek.com> <1613728452-24871-2-git-send-email-yongqiang.niu@mediatek.com> In-Reply-To: <1613728452-24871-2-git-send-email-yongqiang.niu@mediatek.com> From: Chun-Kuang Hu Date: Mon, 22 Feb 2021 07:55:10 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v1] drm/mediatek: move page flip handle into cmdq cb To: Yongqiang Niu Cc: CK Hu , Matthias Brugger , Philipp Zabel , David Airlie , Daniel Vetter , Rob Herring , Mark Rutland , DRI Development , DTML , linux-kernel , Linux ARM , "moderated list:ARM/Mediatek SoC support" , Project_Global_Chrome_Upstream_Group@mediatek.com, Hsin-Yi Wang , Chun-Kuang Hu 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=B42=E6=9C= =8819=E6=97=A5 =E9=80=B1=E4=BA=94 =E4=B8=8B=E5=8D=885:54=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 > > Signed-off-by: Yongqiang Niu > --- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 33 +++++++++++++++++++++++++++= ++---- > 1 file changed, 29 insertions(+), 4 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/me= diatek/mtk_drm_crtc.c > index bdd37ea..bece327 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; > @@ -241,7 +247,19 @@ 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; > + > + if (cb_data) { > + struct mtk_drm_crtc *mtk_crtc =3D cb_data->mtk_crtc; > + > + if (mtk_crtc) > + mtk_drm_finish_page_flip(mtk_crtc); > + > + if (cb_data->cmdq_handle) > + cmdq_pkt_destroy(cb_data->cmdq_handle); > + > + kfree(cb_data); > + } > } > #endif > > @@ -481,13 +499,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); > @@ -674,7 +699,7 @@ void mtk_crtc_ddp_irq(struct drm_crtc *crtc, struct m= tk_ddp_comp *comp) > #endif > mtk_crtc_ddp_config(crtc, NULL); > > - mtk_drm_finish_page_flip(mtk_crtc); > + drm_crtc_handle_vblank(&mtk_crtc->base); For CPU and shadow register case, where to handle page flip? The correct sequence should be: 1. set pending_needs_vblank to true 2. mtk_drm_crtc_hw_config 3. irq comes, handle page flip, and set pending_needs_vblank to false But now irq comes before 2, so this patch want to fix this bug. I think shadow register also have this problem. The control flow of shadow register is similar to cmdq, so I would like to fix both problem in the same way. Regards, Chun-Kuang. > } > > static int mtk_drm_crtc_num_comp_planes(struct mtk_drm_crtc *mtk_crtc, > -- > 1.8.1.1.dirty >