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
Cc: alexander.deucher@amd.com, arunpravin.paneerselvam@amd.com
Subject: Re: [Intel-gfx] [PATCH v1] drm/ttm: Clean up page shift operation
Date: Tue, 22 Nov 2022 09:00:24 +0100 [thread overview]
Message-ID: <e6104ecf-96c3-7895-6986-ee9fafbac4ac@amd.com> (raw)
In-Reply-To: <20221122075144.505736-1-Amaranath.Somalapuram@amd.com>
Am 22.11.22 um 08:51 schrieb Somalapuram Amaranath:
> Remove page shift operations as ttm_resource moved
> from num_pages to size_t size in bytes.
> v1 -> v2: fix missing page shift to fpfn and lpfn
>
> Signed-off-by: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
> ---
> drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 4 +---
> drivers/gpu/drm/ttm/ttm_range_manager.c | 13 ++++++-------
> 2 files changed, 7 insertions(+), 10 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);
The amdgpu changes should probably be a separate patch.
> } 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/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
> index 0a8bc0b7f380..6ac38092dd2a 100644
> --- a/drivers/gpu/drm/ttm/ttm_range_manager.c
> +++ b/drivers/gpu/drm/ttm/ttm_range_manager.c
> @@ -83,9 +83,10 @@ static int ttm_range_man_alloc(struct ttm_resource_manager *man,
>
> spin_lock(&rman->lock);
> ret = drm_mm_insert_node_in_range(mm, &node->mm_nodes[0],
> - PFN_UP(node->base.size),
> + node->base.size,
> bo->page_alignment, 0,
> - place->fpfn, lpfn, mode);
> + place->fpfn << PAGE_SHIFT,
> + lpfn << PAGE_SHIFT, mode);
> spin_unlock(&rman->lock);
>
> if (unlikely(ret)) {
> @@ -119,11 +120,10 @@ static bool ttm_range_man_intersects(struct ttm_resource_manager *man,
> size_t size)
> {
> struct drm_mm_node *node = &to_ttm_range_mgr_node(res)->mm_nodes[0];
> - u32 num_pages = PFN_UP(size);
>
> /* Don't evict BOs outside of the requested placement range */
> - if (place->fpfn >= (node->start + num_pages) ||
> - (place->lpfn && place->lpfn <= node->start))
> + if ((place->fpfn << PAGE_SHIFT) >= (node->start + size) ||
> + (place->lpfn && (place->lpfn << PAGE_SHIFT) <= node->start))
> return false;
>
> return true;
> @@ -135,10 +135,9 @@ static bool ttm_range_man_compatible(struct ttm_resource_manager *man,
> size_t size)
> {
> struct drm_mm_node *node = &to_ttm_range_mgr_node(res)->mm_nodes[0];
> - u32 num_pages = PFN_UP(size);
>
> if (node->start < place->fpfn ||
> - (place->lpfn && (node->start + num_pages) > place->lpfn))
> + (place->lpfn && (node->start + size) > place->lpfn << PAGE_SHIFT))
> return false;
This looks good but can't be complete. We have a couple of place where
node->start and node->size is used outside of TTM.
See drivers/gpu/drm/amd/amdgpu/amdgpu_res_cursor.h and
drivers/gpu/drm/i915/intel_region_ttm.c for example.
Those need to be updated as well.
Regards,
Christian.
>
> return true;
next prev parent reply other threads:[~2022-11-22 8:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-22 7:51 [Intel-gfx] [PATCH v1] drm/ttm: Clean up page shift operation Somalapuram Amaranath
2022-11-22 8:00 ` Christian König [this message]
2022-11-22 13:06 ` [Intel-gfx] ✓ Fi.CI.BAT: success for " Patchwork
2022-11-22 19:08 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork
2022-11-24 7:47 ` [Intel-gfx] [PATCH v1] " kernel test robot
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=e6104ecf-96c3-7895-6986-ee9fafbac4ac@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=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@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