diff mbox series

[v2,4/4] drm/i915/dmabuf: Use scatterlist for_each_sg API

Message ID 20221028155029.494736-4-matthew.auld@intel.com (mailing list archive)
State New, archived
Headers show
Series [v2,1/4] drm/i915/dmabuf: fix sg_table handling in map_dma_buf | expand

Commit Message

Matthew Auld Oct. 28, 2022, 3:50 p.m. UTC
From: "Michael J. Ruhl" <michael.j.ruhl@intel.com>

Update open coded for loop to use the standard scatterlist
for_each_sg API.

Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Matthew Auld <matthew.auld@intel.com>
---
 drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

Comments

Matthew Auld Oct. 28, 2022, 3:52 p.m. UTC | #1
On Fri, 28 Oct 2022 at 16:51, Matthew Auld <matthew.auld@intel.com> wrote:
>
> From: "Michael J. Ruhl" <michael.j.ruhl@intel.com>
>
> Update open coded for loop to use the standard scatterlist
> for_each_sg API.
>
> Cc: Tvrtko Ursulin <tvrtko.ursulin@intel.com>
> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Reviewed-by: Matthew Auld <matthew.auld@intel.com>

> Signed-off-by: Matthew Auld <matthew.auld@intel.com>
> ---
>  drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c | 4 +---
>  1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
> index 8342e01a0d27..ec6f7ae47783 100644
> --- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
> +++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
> @@ -47,12 +47,10 @@ static struct sg_table *i915_gem_map_dma_buf(struct dma_buf_attachment *attach,
>         if (ret)
>                 goto err_free;
>
> -       src = obj->mm.pages->sgl;
>         dst = sgt->sgl;
> -       for (i = 0; i < obj->mm.pages->orig_nents; i++) {
> +       for_each_sg(obj->mm.pages->sgl, src, obj->mm.pages->orig_nents, i) {
>                 sg_set_page(dst, sg_page(src), src->length, 0);
>                 dst = sg_next(dst);
> -               src = sg_next(src);
>         }
>
>         ret = dma_map_sgtable(attach->dev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);
> --
> 2.37.3
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
index 8342e01a0d27..ec6f7ae47783 100644
--- a/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
+++ b/drivers/gpu/drm/i915/gem/i915_gem_dmabuf.c
@@ -47,12 +47,10 @@  static struct sg_table *i915_gem_map_dma_buf(struct dma_buf_attachment *attach,
 	if (ret)
 		goto err_free;
 
-	src = obj->mm.pages->sgl;
 	dst = sgt->sgl;
-	for (i = 0; i < obj->mm.pages->orig_nents; i++) {
+	for_each_sg(obj->mm.pages->sgl, src, obj->mm.pages->orig_nents, i) {
 		sg_set_page(dst, sg_page(src), src->length, 0);
 		dst = sg_next(dst);
-		src = sg_next(src);
 	}
 
 	ret = dma_map_sgtable(attach->dev, sgt, dir, DMA_ATTR_SKIP_CPU_SYNC);