[PATCH v3 3/4] drm/amdgpu: Clean up page shift operation and GWS and OA

Christian König christian.koenig at amd.com
Wed Jan 11 09:11:29 UTC 2023


Am 11.01.23 um 07:35 schrieb Somalapuram Amaranath:
> Remove page shift operations as ttm_resource moved
> from num_pages to size_t size in bytes.

This patch here is at least missing to remove the shifts in 
amdgpu_job_set_resources():


         if (gds) {
                 job->gds_base = amdgpu_bo_gpu_offset(gds) >> PAGE_SHIFT;
                 job->gds_size = amdgpu_bo_size(gds) >> PAGE_SHIFT;
         }
         if (gws) {
                 job->gws_base = amdgpu_bo_gpu_offset(gws) >> PAGE_SHIFT;
                 job->gws_size = amdgpu_bo_size(gws) >> PAGE_SHIFT;
         }
         if (oa) {
                 job->oa_base = amdgpu_bo_gpu_offset(oa) >> PAGE_SHIFT;
                 job->oa_size = amdgpu_bo_size(oa) >> PAGE_SHIFT;
         }

As well as adjusting the call to amdgpu_ttm_init_on_chip() to be in 
bytes and not pages.

There are probably more places which I missed to mention as well.

Regards,
Christian.

>
> Signed-off-by: Somalapuram Amaranath <Amaranath.Somalapuram at amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_object.c     |  4 +---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h | 12 ++++++------
>   2 files changed, 7 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 974e85d8b6cc..19ad365dc159 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -541,12 +541,10 @@ int amdgpu_bo_create(struct amdgpu_device *adev,
>   	if (bp->domain & (AMDGPU_GEM_DOMAIN_GWS | AMDGPU_GEM_DOMAIN_OA)) {
>   		/* GWS and OA don't need any alignment. */
>   		page_align = bp->byte_align;
> -		size <<= PAGE_SHIFT;
> -
>   	} else if (bp->domain & AMDGPU_GEM_DOMAIN_GDS) {
>   		/* Both size and alignment must be a multiple of 4. */
>   		page_align = ALIGN(bp->byte_align, 4);
> -		size = ALIGN(size, 4) << PAGE_SHIFT;
> +		size = ALIGN(size, 4);
>   	} else {
>   		/* Memory should be aligned at least to a page size. */
>   		page_align = ALIGN(bp->byte_align, PAGE_SIZE) >> PAGE_SHIFT;
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
> index 5c4f93ee0c57..f92b61350efe 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
> @@ -91,11 +91,11 @@ static inline void amdgpu_res_first(struct ttm_resource *res,
>   		break;
>   	case TTM_PL_TT:
>   		node = to_ttm_range_mgr_node(res)->mm_nodes;
> -		while (start >= node->size << PAGE_SHIFT)
> -			start -= node++->size << PAGE_SHIFT;
> +		while (start >= node->size)
> +			start -= node++->size;
>   
> -		cur->start = (node->start << PAGE_SHIFT) + start;
> -		cur->size = min((node->size << PAGE_SHIFT) - start, size);
> +		cur->start = (node->start) + start;
> +		cur->size = min(node->size - start, size);
>   		cur->remaining = size;
>   		cur->node = node;
>   		break;
> @@ -155,8 +155,8 @@ static inline void amdgpu_res_next(struct amdgpu_res_cursor *cur, uint64_t size)
>   		node = cur->node;
>   
>   		cur->node = ++node;
> -		cur->start = node->start << PAGE_SHIFT;
> -		cur->size = min(node->size << PAGE_SHIFT, cur->remaining);
> +		cur->start = node->start;
> +		cur->size = min(node->size, cur->remaining);
>   		break;
>   	default:
>   		return;



More information about the dri-devel mailing list