Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3424361pxv; Mon, 12 Jul 2021 17:27:05 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzrseHYBAjdFZzqUG6g/Oy4FZ2oCKGX9MYRv4/21eBoM6Gfbh82rHwDPC4jaw0JSUVJMgMY X-Received: by 2002:a6b:2b44:: with SMTP id r65mr1084864ior.99.1626136025466; Mon, 12 Jul 2021 17:27:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626136025; cv=none; d=google.com; s=arc-20160816; b=mOjPcqruYf5Oq4BQkSz+wpmWI2cWaPR9KKVpspJpHprpAQQRITGe1I99jEBDjjzvUH QGv5plDaLrmPVhjtXMGEBbTbLY7lf2u5DiHLMEr+1cfJmNTW/C1dZ1otEb6xObJtMlX0 p8UEEcuJDCdmA425G+Z+IIWfuxpqErwK1IY00IJRPJlZTwhtUwF52yYPTYIOdtex4MUN AoiqOemt06rHCJLRj3eBxCH71adzk1g79izJsaDlBiKA9PqOdn7OQMYz2KB4nMLiffGQ sZJANA9K01Ov7cHtehqOYw2mL+2zMlLHHNydLAK+7c/fvV3n8o8hfN9PVo5O0AArk9D6 wzZg== 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=s7bW/qjda6Ym8Ao7IQsn+jyZu+EQS1jBAhAjLOTm8gs=; b=unZ1JC995BKmDiHZrrgJNxu9l716bdoxoYMLQGW9YpkV7Mb490pMqPM9ahXLLg5b+q WTVPZuFzEf9YrarxeTttQvW9cYR6xJIA4eKfMYuPC0L/amXolW+449tsNQTWZZ7+P3ny JAq8I4inoag4rntdOUo8mzeyFb8ibZvP/1c4CwTH3disb3z6t56mJ8Gx6kF/bul5U6ZM G7PAJ+YqTWgu1zlty7VTQKSL1p1imDD0UrECOygE10oDxrKP9unObd0zP2VUb/K1b2B4 hLUQEjykCF9xG1PoRsoti6LW3anhaga5u6NNUldI4gZfINT5zCQg1TQMz2y0eDiH8WhC Bmug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=efNv2ZKO; 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 c18si9214354iod.12.2021.07.12.17.26.52; Mon, 12 Jul 2021 17:27:05 -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=efNv2ZKO; 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 S233778AbhGMA1h (ORCPT + 99 others); Mon, 12 Jul 2021 20:27:37 -0400 Received: from mail.kernel.org ([198.145.29.99]:42030 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233491AbhGMA1h (ORCPT ); Mon, 12 Jul 2021 20:27:37 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 577C461249; Tue, 13 Jul 2021 00:24:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626135888; bh=KexV+4F3TgN4PPH4fBSUjkTODP7+uxdjEVPvdNWA3ek=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=efNv2ZKOQmeZOzjaWJvY+GGdSdjEMfy1vzaR/X6ySrmMtOdN/rb6XSpLr2EssXBsa c0ht1ljsmxEqenKRNycCRiooGY2sogJkyPHIJ2T9LWcK2C+n7B3/kWWUcbtUMQh8YQ Ipc/JneCNEEMgTb1Z7tXZOopQwElPl3roo5YgVGHNj+uugtCGu0+tMCBUa71MaQeiv AFIU3EnPzs3XJzlTxRxVpsmGZIocKROZc39+qoOS7xG/BCQT6OOZluMXud37p0yjN9 d2WwQmrW/ULkhSZ18v4noIr5MP7g//aZ5rs2q7EagHbYPzXCTM4r+y61PcaTJ09a4I HtFMH2QFFBrIA== Received: by mail-ej1-f54.google.com with SMTP id i20so38086112ejw.4; Mon, 12 Jul 2021 17:24:48 -0700 (PDT) X-Gm-Message-State: AOAM530G4j+LFRagV5g/qlQeU7GrPGmxZI2xTQelUjmyfa1gTA1zcuZ9 ue6e8uzO9rxBRaAwInusTqbm6Yjac+V8lL+5NQ== X-Received: by 2002:a17:907:62a1:: with SMTP id nd33mr2043181ejc.303.1626135886765; Mon, 12 Jul 2021 17:24:46 -0700 (PDT) MIME-Version: 1.0 References: <1626072109-2657-1-git-send-email-yongqiang.niu@mediatek.com> <1626072109-2657-2-git-send-email-yongqiang.niu@mediatek.com> In-Reply-To: <1626072109-2657-2-git-send-email-yongqiang.niu@mediatek.com> From: Chun-Kuang Hu Date: Tue, 13 Jul 2021 08:24:35 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v2] drm/mediatek: clear pending flag when cmdq packet is done. To: Yongqiang Niu Cc: Chun-Kuang Hu , Rob Herring , Matthias Brugger , Philipp Zabel , David Airlie , Daniel Vetter , Jassi Brar , Fabien Parent , Dennis YC Hsieh , DTML , Linux ARM , "moderated list:ARM/Mediatek SoC support" , linux-kernel , DRI Development , Project_Global_Chrome_Upstream_Group@mediatek.com, Hsin-Yi Wang , CK 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=B47=E6=9C= =8812=E6=97=A5 =E9=80=B1=E4=B8=80 =E4=B8=8B=E5=8D=882:42=E5=AF=AB=E9=81=93= =EF=BC=9A > > In cmdq mode, packet may be flushed before it is executed, so > the pending flag should be cleared after cmdq packet is done. I would like this patch to base on the series [1] because that series use the standard mailbox callback interface. [1] https://patchwork.kernel.org/project/linux-mediatek/list/?series=3D5143= 69 Regards, Chun-Kuang. > > Signed-off-by: CK Hu > Signed-off-by: Yongqiang Niu > --- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 92 +++++++++++++++++++++++++++= +++--- > 1 file changed, 85 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/me= diatek/mtk_drm_crtc.c > index 40df2c8..8cd107b 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > @@ -73,6 +73,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); > @@ -224,7 +231,64 @@ 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; > + struct mtk_crtc_state *state; > + unsigned int i; > + > + if (!cb_data) { > + DRM_ERROR("cmdq callback data is null pointer!\n"); > + return; > + } > + > + if (data.sta !=3D 0) { > + DRM_WARN("cmdq callback error %d!!\n", data.sta); > + goto destroy_pkt; > + } > + > + mtk_crtc =3D cb_data->mtk_crtc; > + if (!mtk_crtc) { > + DRM_ERROR("cmdq callback mtk_crtc is null pointer!\n"); > + goto destroy_pkt; > + } > + > + state =3D to_mtk_crtc_state(mtk_crtc->base.state); > + > + if (state->pending_config) { > + state->pending_config =3D false; > + } > + > + if (mtk_crtc->pending_planes) { > + for (i =3D 0; i < mtk_crtc->layer_nr; i++) { > + struct drm_plane *plane =3D &mtk_crtc->planes[i]; > + struct mtk_plane_state *plane_state; > + > + plane_state =3D to_mtk_plane_state(plane->state); > + > + if (plane_state->pending.config) > + plane_state->pending.config =3D false; > + } > + mtk_crtc->pending_planes =3D false; > + } > + > + if (mtk_crtc->pending_async_planes) { > + for (i =3D 0; i < mtk_crtc->layer_nr; i++) { > + struct drm_plane *plane =3D &mtk_crtc->planes[i]; > + struct mtk_plane_state *plane_state; > + > + plane_state =3D to_mtk_plane_state(plane->state); > + > + if (plane_state->pending.async_config) > + plane_state->pending.async_config =3D fal= se; > + } > + mtk_crtc->pending_async_planes =3D false; > + } > + > +destroy_pkt: > + if (cb_data->cmdq_handle) > + cmdq_pkt_destroy(cb_data->cmdq_handle); > + > + kfree(cb_data); > } > #endif > > @@ -378,7 +442,8 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crtc= , > state->pending_vrefresh, 0, > cmdq_handle); > > - state->pending_config =3D false; > + if (!cmdq_handle) > + state->pending_config =3D false; > } > > if (mtk_crtc->pending_planes) { > @@ -398,9 +463,12 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crt= c, > mtk_ddp_comp_layer_config(comp, local_lay= er, > plane_state, > cmdq_handle); > - plane_state->pending.config =3D false; > + if (!cmdq_handle) > + plane_state->pending.config =3D false; > } > - mtk_crtc->pending_planes =3D false; > + > + if (!cmdq_handle) > + mtk_crtc->pending_planes =3D false; > } > > if (mtk_crtc->pending_async_planes) { > @@ -420,9 +488,13 @@ static void mtk_crtc_ddp_config(struct drm_crtc *crt= c, > mtk_ddp_comp_layer_config(comp, local_lay= er, > plane_state, > cmdq_handle); > - plane_state->pending.async_config =3D false; > + > + if (!cmdq_handle) > + plane_state->pending.async_config =3D fal= se; > } > - mtk_crtc->pending_async_planes =3D false; > + > + if (!cmdq_handle) > + mtk_crtc->pending_async_planes =3D false; > } > } > > @@ -469,13 +541,19 @@ static void mtk_drm_crtc_update_config(struct mtk_d= rm_crtc *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 > mtk_crtc->config_updating =3D false; > -- > 1.8.1.1.dirty >