[PATCH 2/3] udmabuf: use sgtable-based scatterlist wrappers

Kasireddy, Vivek vivek.kasireddy at intel.com
Wed May 7 02:41:36 UTC 2025


> Subject: [PATCH 2/3] udmabuf: use sgtable-based scatterlist wrappers
> 
> Use common wrappers operating directly on the struct sg_table objects to
> fix incorrect use of statterlists sync calls. dma_sync_sg_for_*()
> functions have to be called with the number of elements originally passed
> to dma_map_sg_*() function, not the one returned in sgtable's nents.
> 
> Fixes: 1ffe09590121 ("udmabuf: fix dma-buf cpu access")
> Signed-off-by: Marek Szyprowski <m.szyprowski at samsung.com>
> ---
>  drivers/dma-buf/udmabuf.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/dma-buf/udmabuf.c b/drivers/dma-buf/udmabuf.c
> index 7eee3eb47a8e..c9d0c68d2fcb 100644
> --- a/drivers/dma-buf/udmabuf.c
> +++ b/drivers/dma-buf/udmabuf.c
> @@ -264,8 +264,7 @@ static int begin_cpu_udmabuf(struct dma_buf *buf,
>  			ubuf->sg = NULL;
>  		}
>  	} else {
> -		dma_sync_sg_for_cpu(dev, ubuf->sg->sgl, ubuf->sg->nents,
> -				    direction);
> +		dma_sync_sgtable_for_cpu(dev, ubuf->sg, direction);
>  	}
> 
>  	return ret;
> @@ -280,7 +279,7 @@ static int end_cpu_udmabuf(struct dma_buf *buf,
>  	if (!ubuf->sg)
>  		return -EINVAL;
> 
> -	dma_sync_sg_for_device(dev, ubuf->sg->sgl, ubuf->sg->nents,
> direction);
> +	dma_sync_sgtable_for_device(dev, ubuf->sg, direction);
Acked-by: Vivek Kasireddy <vivek.kasireddy at intel.com>

Thanks,
Vivek

>  	return 0;
>  }
> 
> --
> 2.34.1



More information about the dri-devel mailing list