[PATCH] drm/mediatek: stop iterating dma addresses when sg_dma_len() == 0

Chun-Kuang Hu chunkuang.hu at kernel.org
Wed May 6 00:25:19 UTC 2020


Hi, Anand,

Chun-Kuang Hu <chunkuang.hu at kernel.org> 於 2020年4月29日 週三 上午12:37寫道:
>
> Hi, Anand,
>
> Anand K. Mistry <amistry at chromium.org> 於 2020年4月28日 週二 上午9:54寫道:
> >
> > On Sun, 26 Apr 2020 at 18:04, Chun-Kuang Hu <chunkuang.hu at kernel.org> wrote:
> > >
> > > Hi, Anand:
> > >
> > > Anand K Mistry <amistry at 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 at google.com>

Author should sign off this patch, please give a sign off tag by author.

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 = 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.
> >
>
> Okay, you're right. So
>
> Reviewed-by: Chun-Kuang Hu <chunkuang.hu at kernel.org>
>
> > >
> > > 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 at lists.infradead.org
> > > > http://lists.infradead.org/mailman/listinfo/linux-mediatek


More information about the dri-devel mailing list