[PATCH] drm/amdgpu: Use the ALIGN() macro

Christian König ckoenig.leichtzumerken at gmail.com
Fri Oct 4 07:16:06 UTC 2019


Am 04.10.19 um 01:39 schrieb Tuikov, Luben:
> Use the ALIGN() macro to set "num_dw" to a
> multiple of 8, i.e. lower 3 bits cleared.
>
> Signed-off-by: Luben Tuikov <luben.tuikov at amd.com>

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

> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 11 ++---------
>   1 file changed, 2 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index 68c541e11189..73c628bc6a5b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -1923,10 +1923,7 @@ static int amdgpu_map_buffer(struct ttm_buffer_object *bo,
>   	*addr += (u64)window * AMDGPU_GTT_MAX_TRANSFER_SIZE *
>   		AMDGPU_GPU_PAGE_SIZE;
>   
> -	num_dw = adev->mman.buffer_funcs->copy_num_dw;
> -	while (num_dw & 0x7)
> -		num_dw++;
> -
> +	num_dw = ALIGN(adev->mman.buffer_funcs->copy_num_dw, 8);
>   	num_bytes = num_pages * 8;
>   
>   	r = amdgpu_job_alloc_with_ib(adev, num_dw * 4 + num_bytes, &job);
> @@ -1986,11 +1983,7 @@ int amdgpu_copy_buffer(struct amdgpu_ring *ring, uint64_t src_offset,
>   
>   	max_bytes = adev->mman.buffer_funcs->copy_max_bytes;
>   	num_loops = DIV_ROUND_UP(byte_count, max_bytes);
> -	num_dw = num_loops * adev->mman.buffer_funcs->copy_num_dw;
> -
> -	/* for IB padding */
> -	while (num_dw & 0x7)
> -		num_dw++;
> +	num_dw = ALIGN(num_loops * adev->mman.buffer_funcs->copy_num_dw, 8);
>   
>   	r = amdgpu_job_alloc_with_ib(adev, num_dw * 4, &job);
>   	if (r)



More information about the amd-gfx mailing list