diff mbox series

[v7,07/36] drm: exynos: use common helper for a scatterlist contiguity check

Message ID 20200619103636.11974-8-m.szyprowski@samsung.com (mailing list archive)
State Not Applicable
Headers show
Series None | expand

Commit Message

Marek Szyprowski June 19, 2020, 10:36 a.m. UTC
Use common helper for checking the contiguity of the imported dma-buf.

Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
---
 drivers/gpu/drm/exynos/exynos_drm_gem.c | 23 +++--------------------
 1 file changed, 3 insertions(+), 20 deletions(-)

Comments

Andrzej Hajda July 7, 2020, 9:35 a.m. UTC | #1
Hi,

On 19.06.2020 12:36, Marek Szyprowski wrote:
> Use common helper for checking the contiguity of the imported dma-buf.
>
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
> ---
>   drivers/gpu/drm/exynos/exynos_drm_gem.c | 23 +++--------------------
>   1 file changed, 3 insertions(+), 20 deletions(-)
>
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> index efa476858db5..1716a023bca0 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> @@ -431,27 +431,10 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev,
>   {
>   	struct exynos_drm_gem *exynos_gem;
>   
> -	if (sgt->nents < 1)
> +	/* check if the entries in the sg_table are contiguous */
> +	if (drm_prime_get_contiguous_size(sgt) < attach->dmabuf->size) {
> +		DRM_ERROR("buffer chunks must be mapped contiguously");
>   		return ERR_PTR(-EINVAL);
> -
> -	/*
> -	 * Check if the provided buffer has been mapped as contiguous
> -	 * into DMA address space.
> -	 */
> -	if (sgt->nents > 1) {
> -		dma_addr_t next_addr = sg_dma_address(sgt->sgl);
> -		struct scatterlist *s;
> -		unsigned int i;
> -
> -		for_each_sg(sgt->sgl, s, sgt->nents, i) {
> -			if (!sg_dma_len(s))
> -				break;
> -			if (sg_dma_address(s) != next_addr) {
> -				DRM_ERROR("buffer chunks must be mapped contiguously");
> -				return ERR_PTR(-EINVAL);
> -			}
> -			next_addr = sg_dma_address(s) + sg_dma_len(s);
> -		}
>   	}


Reviewed-by <a.hajda@samsung.com>


Regards
Andrzej
>   
>   	exynos_gem = exynos_drm_gem_init(dev, attach->dmabuf->size);
Andrzej Hajda July 7, 2020, 3:04 p.m. UTC | #2
On 07.07.2020 11:35, Andrzej Hajda wrote:
> Hi,
>
> On 19.06.2020 12:36, Marek Szyprowski wrote:
>> Use common helper for checking the contiguity of the imported dma-buf.
>>
>> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

Just fixing my signature :)

Reviewed-by: Andrzej Hajda <a.hajda@samsung.com>

Regards
Andrzej
대인기/Tizen Platform Lab(SR)/삼성전자 July 14, 2020, 12:28 a.m. UTC | #3
20. 6. 19. 오후 7:36에 Marek Szyprowski 이(가) 쓴 글:
> Use common helper for checking the contiguity of the imported dma-buf.
> 
> Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>

Acked-by : Inki Dae <inki.dae@samsung.com>

Thanks,
Inki Dae

> ---
>  drivers/gpu/drm/exynos/exynos_drm_gem.c | 23 +++--------------------
>  1 file changed, 3 insertions(+), 20 deletions(-)
> 
> diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> index efa476858db5..1716a023bca0 100644
> --- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
> +++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
> @@ -431,27 +431,10 @@ exynos_drm_gem_prime_import_sg_table(struct drm_device *dev,
>  {
>  	struct exynos_drm_gem *exynos_gem;
>  
> -	if (sgt->nents < 1)
> +	/* check if the entries in the sg_table are contiguous */
> +	if (drm_prime_get_contiguous_size(sgt) < attach->dmabuf->size) {
> +		DRM_ERROR("buffer chunks must be mapped contiguously");
>  		return ERR_PTR(-EINVAL);
> -
> -	/*
> -	 * Check if the provided buffer has been mapped as contiguous
> -	 * into DMA address space.
> -	 */
> -	if (sgt->nents > 1) {
> -		dma_addr_t next_addr = sg_dma_address(sgt->sgl);
> -		struct scatterlist *s;
> -		unsigned int i;
> -
> -		for_each_sg(sgt->sgl, s, sgt->nents, i) {
> -			if (!sg_dma_len(s))
> -				break;
> -			if (sg_dma_address(s) != next_addr) {
> -				DRM_ERROR("buffer chunks must be mapped contiguously");
> -				return ERR_PTR(-EINVAL);
> -			}
> -			next_addr = sg_dma_address(s) + sg_dma_len(s);
> -		}
>  	}
>  
>  	exynos_gem = exynos_drm_gem_init(dev, attach->dmabuf->size);
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/exynos/exynos_drm_gem.c b/drivers/gpu/drm/exynos/exynos_drm_gem.c
index efa476858db5..1716a023bca0 100644
--- a/drivers/gpu/drm/exynos/exynos_drm_gem.c
+++ b/drivers/gpu/drm/exynos/exynos_drm_gem.c
@@ -431,27 +431,10 @@  exynos_drm_gem_prime_import_sg_table(struct drm_device *dev,
 {
 	struct exynos_drm_gem *exynos_gem;
 
-	if (sgt->nents < 1)
+	/* check if the entries in the sg_table are contiguous */
+	if (drm_prime_get_contiguous_size(sgt) < attach->dmabuf->size) {
+		DRM_ERROR("buffer chunks must be mapped contiguously");
 		return ERR_PTR(-EINVAL);
-
-	/*
-	 * Check if the provided buffer has been mapped as contiguous
-	 * into DMA address space.
-	 */
-	if (sgt->nents > 1) {
-		dma_addr_t next_addr = sg_dma_address(sgt->sgl);
-		struct scatterlist *s;
-		unsigned int i;
-
-		for_each_sg(sgt->sgl, s, sgt->nents, i) {
-			if (!sg_dma_len(s))
-				break;
-			if (sg_dma_address(s) != next_addr) {
-				DRM_ERROR("buffer chunks must be mapped contiguously");
-				return ERR_PTR(-EINVAL);
-			}
-			next_addr = sg_dma_address(s) + sg_dma_len(s);
-		}
 	}
 
 	exynos_gem = exynos_drm_gem_init(dev, attach->dmabuf->size);