nouveau.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: "Christian König" <christian.koenig@amd.com>
To: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org,
	intel-gfx@lists.freedesktop.org, nouveau@lists.freedesktop.org
Cc: alexander.deucher@amd.com, arunpravin.paneerselvam@amd.com,
	arvind.yadav@amd.com, shashank.sharma@amd.com
Subject: Re: [Nouveau] [PATCH v4 3/4] drm/amdgpu: Movie the amdgpu_gtt_mgr start and size from pages to bytes
Date: Thu, 26 Jan 2023 10:52:34 +0100	[thread overview]
Message-ID: <15b56780-5d10-4d4b-9915-017650e6b22d@amd.com> (raw)
In-Reply-To: <20230125152006.3945-3-Amaranath.Somalapuram@amd.com>

Am 25.01.23 um 16:20 schrieb Somalapuram Amaranath:
> To support GTT manager amdgpu_res_first, amdgpu_res_next
> from pages to bytes and clean up PAGE_SHIFT operation.
> Change the GTT manager init and allocate from pages to bytes
> v1 -> v2: reorder patch sequence
> v3 -> v4: reorder patch sequence

That won't work like this and break the driver because you only have 
halve of the necessary changes inside this patch here.

Please *never ever* again send out incomplete patches like this.

Christian.

>
> Signed-off-by: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
> ---
>   drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c    | 13 +++++++------
>   drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h |  8 ++++----
>   2 files changed, 11 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> index 44367f03316f..a1fbfc5984d8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
> @@ -116,7 +116,6 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
>   			      struct ttm_resource **res)
>   {
>   	struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
> -	uint32_t num_pages = PFN_UP(tbo->base.size);
>   	struct ttm_range_mgr_node *node;
>   	int r;
>   
> @@ -134,8 +133,10 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
>   	if (place->lpfn) {
>   		spin_lock(&mgr->lock);
>   		r = drm_mm_insert_node_in_range(&mgr->mm, &node->mm_nodes[0],
> -						num_pages, tbo->page_alignment,
> -						0, place->fpfn, place->lpfn,
> +						tbo->base.size,
> +						tbo->page_alignment << PAGE_SHIFT, 0,
> +						place->fpfn << PAGE_SHIFT,
> +						place->lpfn << PAGE_SHIFT,
>   						DRM_MM_INSERT_BEST);
>   		spin_unlock(&mgr->lock);
>   		if (unlikely(r))
> @@ -144,7 +145,7 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
>   		node->base.start = node->mm_nodes[0].start;
>   	} else {
>   		node->mm_nodes[0].start = 0;
> -		node->mm_nodes[0].size = PFN_UP(node->base.size);
> +		node->mm_nodes[0].size = node->base.size;
>   		node->base.start = AMDGPU_BO_INVALID_OFFSET;
>   	}
>   
> @@ -285,8 +286,8 @@ int amdgpu_gtt_mgr_init(struct amdgpu_device *adev, uint64_t gtt_size)
>   
>   	ttm_resource_manager_init(man, &adev->mman.bdev, gtt_size);
>   
> -	start = AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS;
> -	size = (adev->gmc.gart_size >> PAGE_SHIFT) - start;
> +	start = (AMDGPU_GTT_MAX_TRANSFER_SIZE * AMDGPU_GTT_NUM_TRANSFER_WINDOWS) << PAGE_SHIFT;
> +	size = adev->gmc.gart_size - start;
>   	drm_mm_init(&mgr->mm, start, size);
>   	spin_lock_init(&mgr->lock);
>   
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
> index 5c4f93ee0c57..5c78f0b09351 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h
> @@ -94,8 +94,8 @@ static inline void amdgpu_res_first(struct ttm_resource *res,
>   		while (start >= node->size << PAGE_SHIFT)
>   			start -= node++->size << PAGE_SHIFT;
>   
> -		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;


  reply	other threads:[~2023-01-26  9:52 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-25 15:20 [Nouveau] [PATCH v4 1/4] drm/amdgpu: Use cursor start instead of ttm resource start Somalapuram Amaranath
2023-01-25 15:20 ` [Nouveau] [PATCH v4 2/4] drm/amdkfd: " Somalapuram Amaranath
2023-01-25 15:20 ` [Nouveau] [PATCH v4 3/4] drm/amdgpu: Movie the amdgpu_gtt_mgr start and size from pages to bytes Somalapuram Amaranath
2023-01-26  9:52   ` Christian König [this message]
2023-01-25 15:20 ` [Nouveau] [PATCH v4 4/4] drm/amdgpu: Cleanup PAGE_SHIFT operation Somalapuram Amaranath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15b56780-5d10-4d4b-9915-017650e6b22d@amd.com \
    --to=christian.koenig@amd.com \
    --cc=Amaranath.Somalapuram@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arunpravin.paneerselvam@amd.com \
    --cc=arvind.yadav@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=nouveau@lists.freedesktop.org \
    --cc=shashank.sharma@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).