All of lore.kernel.org
 help / color / mirror / Atom feed
From: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
To: <dri-devel@lists.freedesktop.org>,
	<amd-gfx@lists.freedesktop.org>,
	<intel-gfx@lists.freedesktop.org>
Cc: alexander.deucher@amd.com,
	Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>,
	arunpravin.paneerselvam@amd.com, christian.koenig@amd.com,
	shashank.sharma@amd.com
Subject: [PATCH v3 1/4] drm/ttm: Clean up page shift operation
Date: Wed, 11 Jan 2023 12:05:21 +0530	[thread overview]
Message-ID: <20230111063524.2374038-1-Amaranath.Somalapuram@amd.com> (raw)

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
v2 -> v3: separate patch’s based on driver module

Signed-off-by: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
---
 drivers/gpu/drm/ttm/ttm_range_manager.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
index ae11d07eb63a..3703cbc6d368 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;
 
 	return true;
-- 
2.32.0


WARNING: multiple messages have this Message-ID (diff)
From: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
To: <dri-devel@lists.freedesktop.org>,
	<amd-gfx@lists.freedesktop.org>,
	<intel-gfx@lists.freedesktop.org>
Cc: alexander.deucher@amd.com,
	Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>,
	arunpravin.paneerselvam@amd.com, christian.koenig@amd.com
Subject: [Intel-gfx] [PATCH v3 1/4] drm/ttm: Clean up page shift operation
Date: Wed, 11 Jan 2023 12:05:21 +0530	[thread overview]
Message-ID: <20230111063524.2374038-1-Amaranath.Somalapuram@amd.com> (raw)

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
v2 -> v3: separate patch’s based on driver module

Signed-off-by: Somalapuram Amaranath <Amaranath.Somalapuram@amd.com>
---
 drivers/gpu/drm/ttm/ttm_range_manager.c | 13 ++++++-------
 1 file changed, 6 insertions(+), 7 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_range_manager.c b/drivers/gpu/drm/ttm/ttm_range_manager.c
index ae11d07eb63a..3703cbc6d368 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;
 
 	return true;
-- 
2.32.0


             reply	other threads:[~2023-01-11  6:36 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-11  6:35 Somalapuram Amaranath [this message]
2023-01-11  6:35 ` [Intel-gfx] [PATCH v3 1/4] drm/ttm: Clean up page shift operation Somalapuram Amaranath
2023-01-11  6:35 ` [PATCH v3 2/4] drm/gem: Remove BUG_ON in drm_gem_private_object_init Somalapuram Amaranath
2023-01-11  6:35   ` [Intel-gfx] " Somalapuram Amaranath
2023-01-11  9:12   ` Christian König
2023-01-11  9:12     ` [Intel-gfx] " Christian König
2023-01-11  6:35 ` [PATCH v3 3/4] drm/amdgpu: Clean up page shift operation and GWS and OA Somalapuram Amaranath
2023-01-11  6:35   ` [Intel-gfx] " Somalapuram Amaranath
2023-01-11  9:11   ` Christian König
2023-01-11  9:11     ` [Intel-gfx] " Christian König
2023-01-11  6:35 ` [PATCH v3 4/4] drm/i915: Clean up page shift operation Somalapuram Amaranath
2023-01-11  6:35   ` [Intel-gfx] " Somalapuram Amaranath
2023-01-11  9:13 ` [PATCH v3 1/4] drm/ttm: " Christian König
2023-01-11  9:13   ` [Intel-gfx] " Christian König
2023-01-11 12:15 ` [Intel-gfx] ✗ Fi.CI.BAT: failure for series starting with [v3,1/4] " Patchwork
2023-01-15 16:23 ` [PATCH v3 1/4] " kernel test robot
2023-01-15 16:23   ` kernel test robot
2023-01-15 16:23   ` [Intel-gfx] " 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=20230111063524.2374038-1-Amaranath.Somalapuram@amd.com \
    --to=amaranath.somalapuram@amd.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arunpravin.paneerselvam@amd.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.