diff mbox series

drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt

Message ID 20220421123442.1834102-1-KevinYang.Wang@amd.com (mailing list archive)
State New, archived
Headers show
Series drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt | expand

Commit Message

Wang, Yang(Kevin) April 21, 2022, 12:34 p.m. UTC
simplify programming with existing functions.

Signed-off-by: Yang Wang <KevinYang.Wang@amd.com>
---
 drivers/gpu/drm/ttm/ttm_tt.c | 21 ++++++++++++---------
 1 file changed, 12 insertions(+), 9 deletions(-)

Comments

Christian König April 21, 2022, 12:48 p.m. UTC | #1
Am 21.04.22 um 14:34 schrieb Yang Wang:
> simplify programming with existing functions.
>
> Signed-off-by: Yang Wang <KevinYang.Wang@amd.com>

With a minimal style change reviewed and pushed to drm-misc-next.

Thanks,
Christian.

> ---
>   drivers/gpu/drm/ttm/ttm_tt.c | 21 ++++++++++++---------
>   1 file changed, 12 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
> index 79c870a3bef8..cbb3d1fb4caf 100644
> --- a/drivers/gpu/drm/ttm/ttm_tt.c
> +++ b/drivers/gpu/drm/ttm/ttm_tt.c
> @@ -96,19 +96,20 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
>    */
>   static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
>   {
> -	ttm->pages = kvmalloc_array(ttm->num_pages, sizeof(void*),
> -			GFP_KERNEL | __GFP_ZERO);
> +	ttm->pages = kvcalloc(ttm->num_pages, sizeof(void*),
> +			      GFP_KERNEL);
>   	if (!ttm->pages)
>   		return -ENOMEM;
> +
>   	return 0;
>   }
>   
>   static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
>   {
> -	ttm->pages = kvmalloc_array(ttm->num_pages,
> -				    sizeof(*ttm->pages) +
> -				    sizeof(*ttm->dma_address),
> -				    GFP_KERNEL | __GFP_ZERO);
> +	ttm->pages = kvcalloc(ttm->num_pages,
> +			      sizeof(*ttm->pages) +
> +			      sizeof(*ttm->dma_address),
> +			      GFP_KERNEL);
>   	if (!ttm->pages)
>   		return -ENOMEM;
>   
> @@ -118,11 +119,13 @@ static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
>   
>   static int ttm_sg_tt_alloc_page_directory(struct ttm_tt *ttm)
>   {
> -	ttm->dma_address = kvmalloc_array(ttm->num_pages,
> -					  sizeof(*ttm->dma_address),
> -					  GFP_KERNEL | __GFP_ZERO);
> +	ttm->dma_address = kvcalloc(ttm->num_pages,
> +				    sizeof(*ttm->dma_address),
> +				    GFP_KERNEL);
>   	if (!ttm->dma_address)
>   		return -ENOMEM;
> +
> +
>   	return 0;
>   }
>
Wang, Yang(Kevin) April 21, 2022, 1:03 p.m. UTC | #2
[AMD Official Use Only]
diff mbox series

Patch

diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 79c870a3bef8..cbb3d1fb4caf 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -96,19 +96,20 @@  int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
  */
 static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
 {
-	ttm->pages = kvmalloc_array(ttm->num_pages, sizeof(void*),
-			GFP_KERNEL | __GFP_ZERO);
+	ttm->pages = kvcalloc(ttm->num_pages, sizeof(void*),
+			      GFP_KERNEL);
 	if (!ttm->pages)
 		return -ENOMEM;
+
 	return 0;
 }
 
 static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
 {
-	ttm->pages = kvmalloc_array(ttm->num_pages,
-				    sizeof(*ttm->pages) +
-				    sizeof(*ttm->dma_address),
-				    GFP_KERNEL | __GFP_ZERO);
+	ttm->pages = kvcalloc(ttm->num_pages,
+			      sizeof(*ttm->pages) +
+			      sizeof(*ttm->dma_address),
+			      GFP_KERNEL);
 	if (!ttm->pages)
 		return -ENOMEM;
 
@@ -118,11 +119,13 @@  static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
 
 static int ttm_sg_tt_alloc_page_directory(struct ttm_tt *ttm)
 {
-	ttm->dma_address = kvmalloc_array(ttm->num_pages,
-					  sizeof(*ttm->dma_address),
-					  GFP_KERNEL | __GFP_ZERO);
+	ttm->dma_address = kvcalloc(ttm->num_pages,
+				    sizeof(*ttm->dma_address),
+				    GFP_KERNEL);
 	if (!ttm->dma_address)
 		return -ENOMEM;
+
+
 	return 0;
 }