From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.5 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A5F5FC38A2A for ; Fri, 8 May 2020 08:47:25 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 71D4A207DD for ; Fri, 8 May 2020 08:47:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ZaDlNUeM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 71D4A207DD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=chromium.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 0FA5D6E1F2; Fri, 8 May 2020 08:47:24 +0000 (UTC) Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by gabe.freedesktop.org (Postfix) with ESMTPS id 7B26E6E97A for ; Thu, 7 May 2020 11:56:51 +0000 (UTC) Received: by mail-wm1-x343.google.com with SMTP id r26so6511730wmh.0 for ; Thu, 07 May 2020 04:56:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=cwbndYePx6Sf4kvKBrk06EAK0VStwNUVTL2K+SJVvwI=; b=ZaDlNUeMLsuMD7531bd1nDMr7SL++ZBC8CeaJNNmJgZJeTsG2xe8QrypRYuV5wz8w2 UiZqLAoIUiFiLP15OFxtx3WEqGSaGH1TJTTI+yKEhTII41nX+1Fa1xZFxs6yL7DBIQUp mZi+9PEkyHlNOh8XX5FrEbw2i47OkWkMCpHpE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=cwbndYePx6Sf4kvKBrk06EAK0VStwNUVTL2K+SJVvwI=; b=J52ShS6oWRuyjoGfE82TH1GsX9F1A7Gka6rQxZawvYDQ5B8bQux9GzGA+aBUHvVdU1 sNf3C29rEobm6Py1rwRPjwKwH0vpzXqXv71FBgHnmrqNoewerr2kOK/A64weuaVSoEv/ Yb8Gpy0W69O4NdonqvXXTsoBi6bFYUyI6NJcACROy7B0spBozUvaWtJwIh2QHGIjpYVY nae+pf1Fklljm20whOb31QL78JTbaj8Eaw1/cEQoMNfe4PtauiIrbzHl7zsXWaeBqp6F /SgIWmOvu4zOzUNGQ1C9U+JBZCD6jZkc7l6h0RQiIDMONCWhb82qXoM4BRpGAZS1C4p+ Z2NA== X-Gm-Message-State: AGi0PuZ6hQfeZhRFvA1Gd6/Ma7uInGfehmMjQFnCCxW0kPFLSI81YGK+ aGPbQHBKURjt2/d7G9MytSa7goaD9wJGJwqoWkWgGQ== X-Google-Smtp-Source: APiQypKQjgXGPVpdtx8p9w+nrP8rvOLzevb6vFpHpUaJEVKIYzLAFAbdqna1vt22+43KryxqrLQnl31CR41crfy8aBQ= X-Received: by 2002:a1c:5419:: with SMTP id i25mr7061026wmb.156.1588852610069; Thu, 07 May 2020 04:56:50 -0700 (PDT) MIME-Version: 1.0 References: <20200420060834.44461-1-amistry@google.com> In-Reply-To: From: Anand Mistry Date: Thu, 7 May 2020 21:56:39 +1000 Message-ID: Subject: Re: [PATCH] drm/mediatek: stop iterating dma addresses when sg_dma_len() == 0 To: Chun-Kuang Hu X-Mailman-Approved-At: Fri, 08 May 2020 08:47:23 +0000 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Anand K Mistry , DRI Development , "moderated list:ARM/Mediatek SoC support" , Matthias Brugger , Linux ARM Content-Type: multipart/mixed; boundary="===============0241150126==" Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" --===============0241150126== Content-Type: multipart/alternative; boundary="0000000000006c8f1805a50d9359" --0000000000006c8f1805a50d9359 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, May 6, 2020 at 10:59 PM Chun-Kuang Hu wrote: > > Hi, Anand: > > Anand Mistry =E6=96=BC 2020=E5=B9=B45=E6=9C=886=E6= =97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8B=E5=8D=887:03=E5=AF=AB=E9=81=93=EF=BC=9A > > > > On Wed, May 6, 2020 at 10:25 AM Chun-Kuang Hu wrote: > > > > > > Hi, Anand, > > > > > > Chun-Kuang Hu =E6=96=BC 2020=E5=B9=B44=E6= =9C=8829=E6=97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8A=E5=8D=8812:37=E5=AF=AB=E9=81= =93=EF=BC=9A > > > > > > > > Hi, Anand, > > > > > > > > Anand K. Mistry =E6=96=BC 2020=E5=B9=B44=E6= =9C=8828=E6=97=A5 =E9=80=B1=E4=BA=8C =E4=B8=8A=E5=8D=889:54=E5=AF=AB=E9=81= =93=EF=BC=9A > > > > > > > > > > On Sun, 26 Apr 2020 at 18:04, Chun-Kuang Hu < chunkuang.hu@kernel.org> wrote: > > > > > > > > > > > > Hi, Anand: > > > > > > > > > > > > Anand K Mistry =E6=96=BC 2020=E5=B9=B44= =E6=9C=8820=E6=97=A5 =E9=80=B1=E4=B8=80 =E4=B8=8B=E5=8D=882:09=E5=AF=AB=E9= =81=93=EF=BC=9A > > > > > > > > > > > > > > If dma_map_sg() merges pages when creating the mapping, only the first > > > > > > > entries will have a valid sg_dma_address() and sg_dma_len(), followed by > > > > > > > entries with sg_dma_len() =3D=3D 0. > > > > > > > > > > > > > > Signed-off-by: Anand K Mistry > > > > > > Author should sign off this patch, please give a sign off tag by author. > > > > Sorry, email issues meant i sent the patch from a different account. > > Should I re-send the > > patch from the same account as the sign-off line? I'm still working my > > way through the kernel patch process. > > > > If you want to use chromium account, you could simply reply this email > with a sign-off-by tag of chromium account. Ack. As path of least resistance, here: Signed-off-by: Anand K Mistry > > Regards, > Chun-Kuang. > > > > > > > Regards, > > > Chun-Kuang. > > > > > > > > > > --- > > > > > > > drivers/gpu/drm/mediatek/mtk_drm_gem.c | 3 +++ > > > > > > > 1 file changed, 3 insertions(+) > > > > > > > > > > > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/drivers/gpu/drm/mediatek/mtk_drm_gem.c > > > > > > > index b04a3c2b111e09..f8fd8b98c30e3d 100644 > > > > > > > --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c > > > > > > > +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c > > > > > > > @@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_prime_import_sg_table(struct drm_device *dev, > > > > > > > > > > > > > > expected =3D sg_dma_address(sg->sgl); > > > > > > > for_each_sg(sg->sgl, s, sg->nents, i) { > > > > > > > + if (!sg_dma_len(s)) > > > > > > > + break; > > > > > > > > > > > > I think this should be 'continue' > > > > > > > > > > scatterlist.h has the comment: > > > > > /* > > > > > * These macros should be used after a dma_map_sg call has been done > > > > > * to get bus addresses of each of the SG entries and their lengths. > > > > > * You should only work with the number of sg entries dma_map_sg > > > > > * returns, or alternatively stop on the first sg_dma_len(sg) which > > > > > * is 0. > > > > > */ > > > > > > > > > > So breaking on the first sg_dma_len(sg) =3D=3D 0 appears to be (o= ne of) > > > > > the documented approach. > > > > > > > > > > > > > Okay, you're right. So > > > > > > > > Reviewed-by: Chun-Kuang Hu > > > > > > > > > > > > > > > > Regards, > > > > > > Chun-Kuang. > > > > > > > > > > > > > + > > > > > > > if (sg_dma_address(s) !=3D expected) { > > > > > > > DRM_ERROR("sg_table is not contiguous"); > > > > > > > ret =3D -EINVAL; > > > > > > > -- > > > > > > > 2.26.1.301.g55bc3eb7cb9-goog > > > > > > > > > > > > > > > > > > > > > _______________________________________________ > > > > > > > Linux-mediatek mailing list > > > > > > > Linux-mediatek@lists.infradead.org > > > > > > > http://lists.infradead.org/mailman/listinfo/linux-mediatek --0000000000006c8f1805a50d9359 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
On Wed, May 6, 2020 at 10:59 PM Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:<= br>>
> Hi, Anand:
>
> Anand Mistry <amistry@chromium.org> =E6=96=BC 2020=E5=B9= =B45=E6=9C=886=E6=97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8B=E5=8D=887:03=E5=AF=AB= =E9=81=93=EF=BC=9A
> >
> > On Wed, May 6, 2020 at 10:25 A= M Chun-Kuang Hu <chunkuang.hu= @kernel.org> wrote:
> > >
> > > Hi, Anand,> > >
> > > Chun-Kuang Hu <chunkuang.hu@kernel.org> =E6=96=BC 2020=E5=B9= =B44=E6=9C=8829=E6=97=A5 =E9=80=B1=E4=B8=89 =E4=B8=8A=E5=8D=8812:37=E5=AF= =AB=E9=81=93=EF=BC=9A
> > > >
> > > > Hi, Ana= nd,
> > > >
> > > > Anand K. Mistry <amistry@chromium.org> =E6=96=BC 2= 020=E5=B9=B44=E6=9C=8828=E6=97=A5 =E9=80=B1=E4=BA=8C =E4=B8=8A=E5=8D=889:54= =E5=AF=AB=E9=81=93=EF=BC=9A
> > > > >
> > > &= gt; > On Sun, 26 Apr 2020 at 18:04, Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
> >= ; > > > >
> > > > > > Hi, Anand:
> &= gt; > > > >
> > > > > > Anand K Mistry <= ;amistry@chromium.org> =E6= =96=BC 2020=E5=B9=B44=E6=9C=8820=E6=97=A5 =E9=80=B1=E4=B8=80 =E4=B8=8B=E5= =8D=882:09=E5=AF=AB=E9=81=93=EF=BC=9A
> > > > > > >=
> > > > > > > If dma_map_sg() merges pages when cr= eating the mapping, only the first
> > > > > > > en= tries will have a valid sg_dma_address() and sg_dma_len(), followed by
&= gt; > > > > > > entries with sg_dma_len() =3D=3D 0.
&g= t; > > > > > >
> > > > > > > Sign= ed-off-by: Anand K Mistry <amistry= @google.com>
> > >
> > > Author should sign = off this patch, please give a sign off tag by author.
> >
> = > Sorry, email issues meant i sent the patch from a different account.> > Should I re-send the
> > patch from the same account a= s the sign-off line? I'm still working my
> > way through the = kernel patch process.
> >
>
> If you want to use chrom= ium account, you could simply reply this email
> with a sign-off-by t= ag of chromium account.

Ack. As path of least resistance, here:
<= br>Signed-off-by: Anand K Mistry <amistry@chromium.org>


>
> Regards,
> Chu= n-Kuang.
>
> > >
> > > Regards,
> > = > Chun-Kuang.
> > >
> > > > > > > --= -
> > > > > > > =C2=A0drivers/gpu/drm/mediatek/mtk_= drm_gem.c | 3 +++
> > > > > > > =C2=A01 file change= d, 3 insertions(+)
> > > > > > >
> > > = > > > > diff --git a/drivers/gpu/drm/mediatek/mtk_drm_gem.c b/d= rivers/gpu/drm/mediatek/mtk_drm_gem.c
> > > > > > >= index b04a3c2b111e09..f8fd8b98c30e3d 100644
> > > > > &g= t; > --- a/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> > > >= > > > +++ b/drivers/gpu/drm/mediatek/mtk_drm_gem.c
> > &= gt; > > > > @@ -224,6 +224,9 @@ struct drm_gem_object *mtk_gem_= prime_import_sg_table(struct drm_device *dev,
> > > > > &= gt; >
> > > > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0 = expected =3D sg_dma_address(sg->sgl);
> > > > > > &= gt; =C2=A0 =C2=A0 =C2=A0 =C2=A0 for_each_sg(sg->sgl, s, sg->nents, i)= {
> > > > > > > + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2= =A0 =C2=A0 =C2=A0 if (!sg_dma_len(s))
> > > > > > >= + =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 break;
> > > > > >
> > > > > = > I think this should be 'continue'
> > > > ><= br>> > > > > scatterlist.h has the comment:
> > >= ; > > /*
> > > > > =C2=A0* These macros should be u= sed after a dma_map_sg call has been done
> > > > > =C2= =A0* to get bus addresses of each of the SG entries and their lengths.
&= gt; > > > > =C2=A0* You should only work with the number of sg = entries dma_map_sg
> > > > > =C2=A0* returns, or alternat= ively stop on the first sg_dma_len(sg) which
> > > > > = =C2=A0* is 0.
> > > > > =C2=A0*/
> > > > &= gt;
> > > > > So breaking on the first sg_dma_len(sg) =3D= =3D 0 appears to be (one of)
> > > > > the documented app= roach.
> > > > >
> > > >
> > >= > Okay, you're right. So
> > > >
> > > &= gt; Reviewed-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
> > > >
> > >= > > >
> > > > > > Regards,
> > >= > > > Chun-Kuang.
> > > > > >
> > &= gt; > > > > +
> > > > > > > =C2=A0 =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 if (sg_dma_address(s) !=3D ex= pected) {
> > > > > > > =C2=A0 =C2=A0 =C2=A0 =C2=A0= =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 DRM_ERROR("sg= _table is not contiguous");
> > > > > > > =C2= =A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 ret =3D -EINVAL;
> > > > > > > --
> &g= t; > > > > > 2.26.1.301.g55bc3eb7cb9-goog
> > > = > > > >
> > > > > > >
> > >= > > > > _______________________________________________
>= ; > > > > > > Linux-mediatek mailing list
> > &g= t; > > > > Linux-mediatek@lists.infradead.org
> > > > > > &= gt; = http://lists.infradead.org/mailman/listinfo/linux-mediatek
--0000000000006c8f1805a50d9359-- --===============0241150126== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel --===============0241150126==--