[PATCH] drm/amdgpu: Use kvcalloc instead of kvmalloc_array in amdgpu_cs_parser_bos()

Christian König christian.koenig at amd.com
Wed Dec 20 14:14:02 UTC 2023


Am 20.12.23 um 15:10 schrieb Srinivasan Shanmugam:
> kvmalloc_array + __GFP_ZERO is the same with kvcalloc.
>
> Fixes the below:
> drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c:873 amdgpu_cs_parser_bos() warn: Please consider using kvcalloc instead of kvmalloc_array
>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>

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

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c | 6 +++---
>   1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> index e50be6500030..83c7fc09218c 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_cs.c
> @@ -870,9 +870,9 @@ static int amdgpu_cs_parser_bos(struct amdgpu_cs_parser *p,
>   		struct amdgpu_bo *bo = e->bo;
>   		int i;
>   
> -		e->user_pages = kvmalloc_array(bo->tbo.ttm->num_pages,
> -					sizeof(struct page *),
> -					GFP_KERNEL | __GFP_ZERO);
> +		e->user_pages = kvcalloc(bo->tbo.ttm->num_pages,
> +					 sizeof(struct page *),
> +					 GFP_KERNEL);
>   		if (!e->user_pages) {
>   			DRM_ERROR("kvmalloc_array failure\n");
>   			r = -ENOMEM;



More information about the amd-gfx mailing list