Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp699081pxb; Wed, 29 Sep 2021 07:57:36 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzDdw2dG9MwWSbAgVAE67nLzXFJ2Noj/bdfkUnm1g8tbzkSPrw8ZeDM5/GvO33qRpc/n21Q X-Received: by 2002:a17:906:a0da:: with SMTP id bh26mr118280ejb.505.1632927456120; Wed, 29 Sep 2021 07:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632927456; cv=none; d=google.com; s=arc-20160816; b=PGfkFKVHKZQ4fhQF+mCTrsZ3Mjui06R0WR58f4F7f5jAhCT7dvJQTcX+wtSgMtxu/u WbdLED1AIa4GVNqAErT1n3o8AiDfl0jfSo8PP5wceI+W2PtaOMdUki3AA5FEN/MjuEeh TgMAZg0TU2DLceESTM7GAAMcBjyBxWM+K+wFgPlr4NbYbbUIMfWlVOy2i3v4uDT81S9Q MSa9b9Ni7bpN4P7vy8oroGk3xBcgcBAVI4Xrh8SxoszjMU4VNHMrtYECnVzGBKckm8hj 6mhLhZEiCXTBVI++OPP527eRIQz18jqVgSQnzz/FEpFmIIsnEyELW5EVzxWxLdzJzDI0 vTvQ== 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=3OGGY7nul5ZuC85BV6thJOVFHsh1OLmvDbZ/bYObQrI=; b=toohBGzoELMtxzWSib3i10K/dDVlQTwl4znw3k++2MV/9Nvig8UQv3VVU3fYBMLzo7 d3rar2ti7PImuHhkRIcrvWQg7s+NWLG/vG4UhfeyqEWzyMH2o6m5toyHUZzP/c+tIOET xO0zvyztjO39WSf934Og9XJ7Z+jiC6PIQwkeey4GAy2rl6zTc2JmS9QVgtR6LOgBggQF ZoCyp+tGuLCJ4Jh+eNVBXE49lbzkytdFvRvkWznge+SdhLgbVyARLw+xCR67DmcOU/5C JEtn6/ENmjCA1U1suhtemCdfJUaWN6Tr1vDxaobcZRjBrqbJe4MnaE2uXFPjsD60AUZu TXrg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=a1gaUb6z; 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 k10si40804ejk.439.2021.09.29.07.57.11; Wed, 29 Sep 2021 07:57:36 -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=a1gaUb6z; 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 S1344775AbhI2O4K (ORCPT + 99 others); Wed, 29 Sep 2021 10:56:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:39484 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1344674AbhI2O4G (ORCPT ); Wed, 29 Sep 2021 10:56:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 85E606140F for ; Wed, 29 Sep 2021 14:54:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1632927265; bh=VvAbMG+fnKitKsMFsoHEqUuGjgvoQuGWlE5pTALcwRU=; h=References:In-Reply-To:From:Date:Subject:To:Cc:From; b=a1gaUb6ze+1WM3/GwU4CE6bXvxoyhbdhNewX/rbyUW+qrBaCZxN6/fDBlK+q544t8 +sXJrLCDQQ08jLbVMsmevcsqyK5tK4wJCuzFvUyhi9DBrvmwJhsbeiqBhDjlEjTKGj OmZsxYwHAUN8sCLkCnuOmcDJuzPUQG2Iv/9YFPRnMJBsxgZpltmr1YlHP8BYG0CtaQ rkEm84Gbqd7J2tJpX94Rgscp9q71vxQB1vCnYTacvcvMIdKq4/czsKZwQ+cbY9nyzC YMAAg4Ha4CcT3OpHX+FvnEGBE//5GS5Xj7FWgGfAiZP9IDtHrQdYKqp+PPWEWwjhYa VfVXzmLk8Pxew== Received: by mail-ed1-f47.google.com with SMTP id bd28so9631089edb.9 for ; Wed, 29 Sep 2021 07:54:25 -0700 (PDT) X-Gm-Message-State: AOAM5309lx11bqqSshCltmFPuXsMVUkppPtGWA+U1DiO+IzM3iqxTiEu ZPWK0CPZN/t8Ab4TBVAINTb8C+uEUXlR6X2wmQ== X-Received: by 2002:a17:907:3e21:: with SMTP id hp33mr121802ejc.205.1632927200231; Wed, 29 Sep 2021 07:53:20 -0700 (PDT) MIME-Version: 1.0 References: <20210929070235.4290-1-jason-jh.lin@mediatek.com> <20210929070235.4290-3-jason-jh.lin@mediatek.com> In-Reply-To: <20210929070235.4290-3-jason-jh.lin@mediatek.com> From: Chun-Kuang Hu Date: Wed, 29 Sep 2021 22:53:08 +0800 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] drm/mediatek: Fix pkt buf alloc once but free many times To: "jason-jh.lin" Cc: Chun-Kuang Hu , Philipp Zabel , David Airlie , Daniel Vetter , Matthias Brugger , Yongqiang Niu , DRI Development , "moderated list:ARM/Mediatek SoC support" , Linux ARM , linux-kernel , Hsin-Yi Wang , fshao@chromium.org, Nancy Lin , singo.chang@mediatek.com 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, Jason: jason-jh.lin =E6=96=BC 2021=E5=B9=B49=E6=9C=882= 9=E6=97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8B=E5=8D=883:02=E5=AF=AB=E9=81=93=EF= =BC=9A > > Because mtk_drm_crt_cmdq_pkt_create is called once > in mtk_drm_crtc_create, the pkt should not be destroy > at ddp_cmdq_cb. > > So move mtk_drm_crtc_pkt_destroy to mtk_drm_crtc_destroy. Reviewed-by: Chun-Kuang Hu > > Fixes: bc9241be73d9 ("drm/mediatek: Add cmdq_handle in mtk_crtc") > Signed-off-by: jason-jh.lin > --- > drivers/gpu/drm/mediatek/mtk_drm_crtc.c | 29 +++++++++++++++---------- > 1 file changed, 18 insertions(+), 11 deletions(-) > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c b/drivers/gpu/drm/me= diatek/mtk_drm_crtc.c > index e98871a8c961..06342df2a0be 100644 > --- a/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > +++ b/drivers/gpu/drm/mediatek/mtk_drm_crtc.c > @@ -108,12 +108,30 @@ static void mtk_drm_finish_page_flip(struct mtk_drm= _crtc *mtk_crtc) > } > } > > +#if IS_REACHABLE(CONFIG_MTK_CMDQ) > +static void mtk_drm_cmdq_pkt_destroy(struct cmdq_pkt *pkt) > +{ > + struct cmdq_client *client =3D (struct cmdq_client *)pkt->cl; > + > + dma_unmap_single(client->chan->mbox->dev, pkt->pa_base, pkt->buf_= size, > + DMA_TO_DEVICE); > + kfree(pkt->va_base); > + kfree(pkt); > +} > +#endif > + > static void mtk_drm_crtc_destroy(struct drm_crtc *crtc) > { > struct mtk_drm_crtc *mtk_crtc =3D to_mtk_crtc(crtc); > > mtk_mutex_put(mtk_crtc->mutex); > +#if IS_REACHABLE(CONFIG_MTK_CMDQ) > + mtk_drm_cmdq_pkt_destroy(&mtk_crtc->cmdq_handle); > > + if (mtk_crtc->cmdq_client.chan) > + mbox_free_channel(mtk_crtc->cmdq_client.chan); > + mtk_crtc->cmdq_client.chan =3D NULL; > +#endif > drm_crtc_cleanup(crtc); > } > > @@ -255,16 +273,6 @@ static int mtk_drm_cmdq_pkt_create(struct cmdq_clien= t *client, struct cmdq_pkt * > return 0; > } > > -static void mtk_drm_cmdq_pkt_destroy(struct cmdq_pkt *pkt) > -{ > - struct cmdq_client *client =3D (struct cmdq_client *)pkt->cl; > - > - dma_unmap_single(client->chan->mbox->dev, pkt->pa_base, pkt->buf_= size, > - DMA_TO_DEVICE); > - kfree(pkt->va_base); > - kfree(pkt); > -} > - > static void ddp_cmdq_cb(struct mbox_client *cl, void *mssg) > { > struct cmdq_cb_data *data =3D mssg; > @@ -302,7 +310,6 @@ static void ddp_cmdq_cb(struct mbox_client *cl, void = *mssg) > } > > mtk_crtc->cmdq_vblank_cnt =3D 0; > - mtk_drm_cmdq_pkt_destroy(pkt); > } > #endif > > -- > 2.18.0 >