diff mbox series

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

Message ID 20250507160913.2084079-3-m.szyprowski@samsung.com
State Superseded
Headers show
Series media: fix incorrect use of dma_sync_sg_*() calls | expand

Commit Message

Marek Szyprowski May 7, 2025, 4:09 p.m. UTC
Use common wrappers operating directly on the struct sg_table objects to
fix incorrect use of scatterlists 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")
CC: stable@vger.kernel.org
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
---
 drivers/dma-buf/udmabuf.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

Comments

Christian König May 8, 2025, 9:57 a.m. UTC | #1
On 5/7/25 18:09, Marek Szyprowski wrote:
> Use common wrappers operating directly on the struct sg_table objects to
> fix incorrect use of scatterlists 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")
> CC: stable@vger.kernel.org
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>

Reviewed-by: Christian König <christian.koenig@amd.com>

Should I push this one to drm-misc-fixes for upstreaming?

Regards,
Christian.

> ---
>  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);
>  	return 0;
>  }
>
Marek Szyprowski May 14, 2025, 1:44 p.m. UTC | #2
On 08.05.2025 11:57, Christian König wrote:
> On 5/7/25 18:09, Marek Szyprowski wrote:
>> Use common wrappers operating directly on the struct sg_table objects to
>> fix incorrect use of scatterlists 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")
>> CC: stable@vger.kernel.org
>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
>> Acked-by: Vivek Kasireddy <vivek.kasireddy@intel.com>
> Reviewed-by: Christian König <christian.koenig@amd.com>
>
> Should I push this one to drm-misc-fixes for upstreaming?

Yes, please. The other 2 patches have been taken by the media maintainers.

Best regards
diff mbox series

Patch

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);
 	return 0;
 }