linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: "Anand K. Mistry" <amistry@chromium.org>
To: Chun-Kuang Hu <chunkuang.hu@kernel.org>
Cc: Matthias Brugger <matthias.bgg@gmail.com>,
	CK Hu <ck.hu@mediatek.com>,
	"moderated list:ARM/Mediatek SoC support"
	<linux-mediatek@lists.infradead.org>,
	Linux ARM <linux-arm-kernel@lists.infradead.org>,
	DRI Development <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH] drm/mediatek: stop iterating dma addresses when sg_dma_len() == 0
Date: Tue, 28 Apr 2020 11:54:28 +1000	[thread overview]
Message-ID: <CAATStaNwCyveF-fmrT=1m-BJh=8WOyaffFzVsC_Lo_rFkm6Z=Q@mail.gmail.com> (raw)
In-Reply-To: <CAAOTY_81qB+WJN_2-ZNqM63NOp+Es1qEmsp2qje2bfePg1O5Vw@mail.gmail.com>

On Sun, 26 Apr 2020 at 18:04, Chun-Kuang Hu <chunkuang.hu@kernel.org> wrote:
>
> Hi, Anand:
>
> Anand K Mistry <amistry@chromium.org> 於 2020年4月20日 週一 下午2:09寫道:
> >
> > 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() == 0.
> >
> > Signed-off-by: Anand K Mistry <amistry@google.com>
> > ---
> >  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 = 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) == 0 appears to be (one of)
the documented approach.

>
> Regards,
> Chun-Kuang.
>
> > +
> >                 if (sg_dma_address(s) != expected) {
> >                         DRM_ERROR("sg_table is not contiguous");
> >                         ret = -EINVAL;
> > --
> > 2.26.1.301.g55bc3eb7cb9-goog
> >
> >
> > _______________________________________________
> > Linux-mediatek mailing list
> > Linux-mediatek@lists.infradead.org
> > http://lists.infradead.org/mailman/listinfo/linux-mediatek

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2020-04-28  1:54 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-20  6:08 [PATCH] drm/mediatek: stop iterating dma addresses when sg_dma_len() == 0 Anand K Mistry
2020-04-26  8:03 ` Chun-Kuang Hu
2020-04-28  1:54   ` Anand K. Mistry [this message]
2020-04-28 16:37     ` Chun-Kuang Hu
2020-05-06  0:25       ` Chun-Kuang Hu
2020-05-06 11:03         ` Anand Mistry
2020-05-06 12:58           ` Chun-Kuang Hu
2020-05-07 12:04             ` Anand Mistry
     [not found]             ` <CAECpkiO9P1+GpQi+aH_B2B8d5Bsba5XJnUKJDfL-kZk455Edcg@mail.gmail.com>
2020-05-09 13:38               ` Chun-Kuang Hu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAATStaNwCyveF-fmrT=1m-BJh=8WOyaffFzVsC_Lo_rFkm6Z=Q@mail.gmail.com' \
    --to=amistry@chromium.org \
    --cc=chunkuang.hu@kernel.org \
    --cc=ck.hu@mediatek.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).