drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt
Subsystems (3)
PATCH 1/1 drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt
simplify programming with existing functions.
--- drivers/gpu/drm/ttm/ttm_tt.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)
drivers/gpu/drm/ttm/ttm_tt.c +12 -9
@@ -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 ; }
Signature · 1 line
2.25.1
Am 21.04.22 um 14:34 schrieb Yang Wang:
Quoted 3 lines
simplify programming with existing functions.
Signed-off-by Yang Wang <[email protected]>
With a minimal style change reviewed and pushed to drm-misc-next.
Thanks,
Christian.
Quoted 52 lines
--- drivers/gpu/drm/ttm/ttm_tt.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)drivers/gpu/drm/ttm/ttm_tt.c +12
-9@@ -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 ; }
[AMD Official Use Only]
________________________________
From: Koenig, Christian <[email protected]>
Sent: Thursday, April 21, 2022 8:48 PM
To: Wang, Yang(Kevin) <[email protected]>; [email protected] <[email protected]>; [email protected] <[email protected]>
Cc: Kuehling, Felix <[email protected]>; Lazar, Lijo <[email protected]>
Subject: Re: [PATCH] drm/ttm: use kvcalloc() instead of kvmalloc_array() in ttm_tt
Am 21.04.22 um 14:34 schrieb Yang Wang:
Quoted 3 lines
simplify programming with existing functions.
Signed-off-by Yang Wang <[email protected]>
With a minimal style change reviewed and pushed to drm-misc-next.
Thanks,
Christian.
[kevin]:
it is ok, thanks.
Best Regards,
Kevin
Quoted 52 lines
--- drivers/gpu/drm/ttm/ttm_tt.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-)drivers/gpu/drm/ttm/ttm_tt.c +12
-9@@ -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 ; }