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
Subject: Re: [Intel-gfx] [PATCH v2 1/4] drm/amdgpu: Use cursor start instead of ttm resource start
Date: Wed, 25 Jan 2023 12:41:43 +0100 [thread overview]
Message-ID: <9326e71e-5fa8-c99b-bfc2-ea74e8d02a59@amd.com> (raw)
In-Reply-To: <20230125104838.23596-1-Amaranath.Somalapuram@amd.com>
Am 25.01.23 um 11:48 schrieb Somalapuram Amaranath:
> cleanup PAGE_SHIFT operation and replacing
> ttm_resource resource->start with cursor start
> using amdgpu_res_first API.
> v1 -> v2: reorder patch sequence
>
> Signed-off-by: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 11 ++++++++---
> drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 10 +++++++---
> 2 files changed, 15 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> index 25a68d8888e0..2ab67ab204df 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_object.c
> @@ -1346,6 +1346,7 @@ vm_fault_t amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
> struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
> struct ttm_operation_ctx ctx = { false, false };
> struct amdgpu_bo *abo = ttm_to_amdgpu_bo(bo);
> + struct amdgpu_res_cursor cursor;
> unsigned long offset;
> int r;
>
> @@ -1355,7 +1356,8 @@ vm_fault_t amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
> if (bo->resource->mem_type != TTM_PL_VRAM)
> return 0;
>
> - offset = bo->resource->start << PAGE_SHIFT;
> + amdgpu_res_first(bo->resource, 0, bo->resource->size, &cursor);
> + offset = cursor.start;
That won't work like this. We use a virtual resource start for this
check here.
> if ((offset + bo->base.size) <= adev->gmc.visible_vram_size)
> return 0;
Just replace this whole test with calling amdgpu_bo_in_cpu_visible_vram().
>
> @@ -1378,7 +1380,8 @@ vm_fault_t amdgpu_bo_fault_reserve_notify(struct ttm_buffer_object *bo)
> else if (unlikely(r))
> return VM_FAULT_SIGBUS;
>
> - offset = bo->resource->start << PAGE_SHIFT;
> + amdgpu_res_first(bo->resource, 0, bo->resource->size, &cursor);
> + offset = cursor.start;
> /* this should never happen */
> if (bo->resource->mem_type == TTM_PL_VRAM &&
> (offset + bo->base.size) > adev->gmc.visible_vram_size)
Same here, just call amdgpu_bo_in_cpu_visible_vram() instead.
> @@ -1491,9 +1494,11 @@ u64 amdgpu_bo_gpu_offset(struct amdgpu_bo *bo)
> u64 amdgpu_bo_gpu_offset_no_check(struct amdgpu_bo *bo)
> {
> struct amdgpu_device *adev = amdgpu_ttm_adev(bo->tbo.bdev);
> + struct amdgpu_res_cursor cursor;
> uint64_t offset;
>
> - offset = (bo->tbo.resource->start << PAGE_SHIFT) +
> + amdgpu_res_first(bo->tbo.resource, 0, bo->tbo.resource->size, &cursor);
> + offset = cursor.start +
> amdgpu_ttm_domain_start(adev, bo->tbo.resource->mem_type);
>
> return amdgpu_gmc_sign_extend(offset);
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> index c5ef7f7bdc15..ffe6a1ab7f9a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
> @@ -849,6 +849,7 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
> {
> struct amdgpu_device *adev = amdgpu_ttm_adev(bdev);
> struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(ttm);
> + struct amdgpu_res_cursor cursor;
> uint64_t flags;
> int r;
>
> @@ -896,7 +897,8 @@ static int amdgpu_ttm_backend_bind(struct ttm_device *bdev,
> flags = amdgpu_ttm_tt_pte_flags(adev, ttm, bo_mem);
>
> /* bind pages into GART page tables */
> - gtt->offset = (u64)bo_mem->start << PAGE_SHIFT;
> + amdgpu_res_first(bo_mem, 0, bo_mem->size, &cursor);
> + gtt->offset = cursor.start;
> amdgpu_gart_bind(adev, gtt->offset, ttm->num_pages,
> gtt->ttm.dma_address, flags);
> gtt->bound = true;
> @@ -916,6 +918,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
> struct amdgpu_device *adev = amdgpu_ttm_adev(bo->bdev);
> struct ttm_operation_ctx ctx = { false, false };
> struct amdgpu_ttm_tt *gtt = ttm_to_amdgpu_ttm_tt(bo->ttm);
> + struct amdgpu_res_cursor cursor;
> struct ttm_placement placement;
> struct ttm_place placements;
> struct ttm_resource *tmp;
> @@ -927,7 +930,7 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
>
> addr = amdgpu_gmc_agp_addr(bo);
> if (addr != AMDGPU_BO_INVALID_OFFSET) {
> - bo->resource->start = addr >> PAGE_SHIFT;
> + bo->resource->start = addr;
This doesn't belong into this patch and would break if only this patch
is applied.
Please move it into a later patch.
Apart from those comments that looks good now,
Christian.
> return 0;
> }
>
> @@ -949,7 +952,8 @@ int amdgpu_ttm_alloc_gart(struct ttm_buffer_object *bo)
> flags = amdgpu_ttm_tt_pte_flags(adev, bo->ttm, tmp);
>
> /* Bind pages */
> - gtt->offset = (u64)tmp->start << PAGE_SHIFT;
> + amdgpu_res_first(tmp, 0, tmp->size, &cursor);
> + gtt->offset = cursor.start;
> amdgpu_ttm_gart_bind(adev, bo, flags);
> amdgpu_gart_invalidate_tlb(adev);
> ttm_resource_free(bo, &bo->resource);
next prev parent reply other threads:[~2023-01-25 11:42 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-25 10:48 [Intel-gfx] [PATCH v2 1/4] drm/amdgpu: Use cursor start instead of ttm resource start Somalapuram Amaranath
2023-01-25 10:48 ` [Intel-gfx] [PATCH v2 2/4] drm/amdkfd: " Somalapuram Amaranath
2023-01-25 11:43 ` Christian König
2023-01-25 10:48 ` [Intel-gfx] [PATCH v2 3/4] drm/amdgpu: Movie the amdgpu_gtt_mgr start and size from pages to bytes Somalapuram Amaranath
2023-01-25 10:48 ` [Intel-gfx] [PATCH v2 4/4] drm/amdgpu: Support allocate of amdgpu_gtt_mgr " Somalapuram Amaranath
2023-01-25 11:41 ` Christian König [this message]
2023-01-25 22:09 ` [Intel-gfx] ✗ Fi.CI.SPARSE: warning for series starting with [v2,1/4] drm/amdgpu: Use cursor start instead of ttm resource start Patchwork
2023-01-25 22:49 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2023-01-26 9:33 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
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=9326e71e-5fa8-c99b-bfc2-ea74e8d02a59@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 \
/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