Commit 8f97344a authored by Yang Wang's avatar Yang Wang Committed by Christian König

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

simplify programming with existing functions.

v2 (chk): minimal coding style cleanup
Signed-off-by: default avatarYang Wang <KevinYang.Wang@amd.com>
Reviewed-by: default avatarChristian König <christian.koenig@amd.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20220421123442.1834102-1-KevinYang.Wang@amd.comSigned-off-by: default avatarChristian König <christian.koenig@amd.com>
parent 9f15930b
...@@ -96,19 +96,17 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc) ...@@ -96,19 +96,17 @@ int ttm_tt_create(struct ttm_buffer_object *bo, bool zero_alloc)
*/ */
static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm) static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
{ {
ttm->pages = kvmalloc_array(ttm->num_pages, sizeof(void*), ttm->pages = kvcalloc(ttm->num_pages, sizeof(void*), GFP_KERNEL);
GFP_KERNEL | __GFP_ZERO);
if (!ttm->pages) if (!ttm->pages)
return -ENOMEM; return -ENOMEM;
return 0; return 0;
} }
static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm) static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
{ {
ttm->pages = kvmalloc_array(ttm->num_pages, ttm->pages = kvcalloc(ttm->num_pages, sizeof(*ttm->pages) +
sizeof(*ttm->pages) + sizeof(*ttm->dma_address), GFP_KERNEL);
sizeof(*ttm->dma_address),
GFP_KERNEL | __GFP_ZERO);
if (!ttm->pages) if (!ttm->pages)
return -ENOMEM; return -ENOMEM;
...@@ -118,11 +116,11 @@ static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm) ...@@ -118,11 +116,11 @@ static int ttm_dma_tt_alloc_page_directory(struct ttm_tt *ttm)
static int ttm_sg_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, ttm->dma_address = kvcalloc(ttm->num_pages, sizeof(*ttm->dma_address),
sizeof(*ttm->dma_address), GFP_KERNEL);
GFP_KERNEL | __GFP_ZERO);
if (!ttm->dma_address) if (!ttm->dma_address)
return -ENOMEM; return -ENOMEM;
return 0; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment