From: "Christian König" <ckoenig.leichtzumerken@gmail.com>
To: dri-devel@lists.freedesktop.org
Cc: daniel.vetter@ffwll.ch, matthew.william.auld@gmail.com
Subject: [PATCH 09/13] drm/amdgpu: switch the GTT backend to self alloc
Date: Fri, 30 Apr 2021 11:25:04 +0200 [thread overview]
Message-ID: <20210430092508.60710-9-christian.koenig@amd.com> (raw)
In-Reply-To: <20210430092508.60710-1-christian.koenig@amd.com>
Similar to the TTM range manager.
Signed-off-by: Christian König <christian.koenig@amd.com>
---
drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c | 36 +++++++++++++--------
1 file changed, 22 insertions(+), 14 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
index 55ca80133411..2e7dffd3614d 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gtt_mgr.c
@@ -22,11 +22,13 @@
* Authors: Christian König
*/
+#include <drm/ttm/ttm_range_manager.h>
+
#include "amdgpu.h"
struct amdgpu_gtt_node {
- struct drm_mm_node node;
struct ttm_buffer_object *tbo;
+ struct ttm_range_mgr_node base;
};
static inline struct amdgpu_gtt_mgr *
@@ -38,7 +40,8 @@ to_gtt_mgr(struct ttm_resource_manager *man)
static inline struct amdgpu_gtt_node *
to_amdgpu_gtt_node(struct ttm_resource *res)
{
- return container_of(res->mm_node, struct amdgpu_gtt_node, node);
+ return container_of(res->mm_node, struct amdgpu_gtt_node,
+ base.mm_nodes[0]);
}
/**
@@ -97,7 +100,7 @@ bool amdgpu_gtt_mgr_has_gart_addr(struct ttm_resource *mem)
{
struct amdgpu_gtt_node *node = to_amdgpu_gtt_node(mem);
- return drm_mm_node_allocated(&node->node);
+ return drm_mm_node_allocated(&node->base.mm_nodes[0]);
}
/**
@@ -128,16 +131,19 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
atomic64_sub(mem->num_pages, &mgr->available);
spin_unlock(&mgr->lock);
- node = kzalloc(sizeof(*node), GFP_KERNEL);
+ node = kzalloc(struct_size(node, base.mm_nodes, 1), GFP_KERNEL);
if (!node) {
r = -ENOMEM;
goto err_out;
}
node->tbo = tbo;
+ ttm_resource_init(tbo, place, &node->base.base);
+
if (place->lpfn) {
spin_lock(&mgr->lock);
- r = drm_mm_insert_node_in_range(&mgr->mm, &node->node,
+ r = drm_mm_insert_node_in_range(&mgr->mm,
+ &node->base.mm_nodes[0],
mem->num_pages,
tbo->page_alignment, 0,
place->fpfn, place->lpfn,
@@ -146,14 +152,14 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
if (unlikely(r))
goto err_free;
- mem->start = node->node.start;
+ mem->start = node->base.mm_nodes[0].start;
} else {
- node->node.start = 0;
- node->node.size = mem->num_pages;
+ node->base.mm_nodes[0].start = 0;
+ node->base.mm_nodes[0].size = mem->num_pages;
mem->start = AMDGPU_BO_INVALID_OFFSET;
}
- mem->mm_node = &node->node;
+ mem->mm_node = &node->base.mm_nodes[0];
return 0;
err_free:
@@ -176,15 +182,17 @@ static int amdgpu_gtt_mgr_new(struct ttm_resource_manager *man,
static void amdgpu_gtt_mgr_del(struct ttm_resource_manager *man,
struct ttm_resource *mem)
{
- struct amdgpu_gtt_node *node = to_amdgpu_gtt_node(mem);
struct amdgpu_gtt_mgr *mgr = to_gtt_mgr(man);
+ struct amdgpu_gtt_node *node;
- if (!node)
+ if (!mem->mm_node)
return;
+ node = to_amdgpu_gtt_node(mem);
+
spin_lock(&mgr->lock);
- if (drm_mm_node_allocated(&node->node))
- drm_mm_remove_node(&node->node);
+ if (drm_mm_node_allocated(&node->base.mm_nodes[0]))
+ drm_mm_remove_node(&node->base.mm_nodes[0]);
spin_unlock(&mgr->lock);
atomic64_add(mem->num_pages, &mgr->available);
@@ -222,7 +230,7 @@ int amdgpu_gtt_mgr_recover(struct ttm_resource_manager *man)
spin_lock(&mgr->lock);
drm_mm_for_each_node(mm_node, &mgr->mm) {
- node = container_of(mm_node, struct amdgpu_gtt_node, node);
+ node = container_of(mm_node, typeof(*node), base.mm_nodes[0]);
r = amdgpu_ttm_recover_gart(node->tbo);
if (r)
break;
--
2.25.1
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2021-04-30 9:25 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-30 9:24 [PATCH 01/13] drm/ttm: add ttm_sys_manager v2 Christian König
2021-04-30 9:24 ` [PATCH 02/13] drm/ttm: always initialize the full ttm_resource Christian König
2021-04-30 12:05 ` Matthew Auld
2021-04-30 12:51 ` Christian König
2021-04-30 9:24 ` [PATCH 03/13] drm/ttm: properly allocate sys resource during swapout Christian König
2021-04-30 10:22 ` Matthew Auld
2021-04-30 9:24 ` [PATCH 04/13] drm/ttm: rename bo->mem and make it a pointer Christian König
2021-04-30 9:25 ` [PATCH 05/13] drm/ttm: allocate resource object instead of embedding it Christian König
2021-04-30 11:19 ` Matthew Auld
2021-04-30 9:25 ` [PATCH 06/13] drm/ttm: flip over the range manager to self allocated nodes Christian König
2021-04-30 13:14 ` Matthew Auld
2021-05-29 15:48 ` Thomas Hellström (Intel)
2021-05-30 16:51 ` Christian König
2021-05-31 8:56 ` Thomas Hellström (Intel)
2021-04-30 9:25 ` [PATCH 07/13] drm/ttm: flip over the sys " Christian König
2021-04-30 13:16 ` Matthew Auld
2021-04-30 15:04 ` Matthew Auld
2021-05-03 11:08 ` Christian König
2021-04-30 9:25 ` [PATCH 08/13] drm/amdgpu: revert "drm/amdgpu: stop allocating dummy GTT nodes" Christian König
2021-05-05 16:48 ` Matthew Auld
2021-04-30 9:25 ` Christian König [this message]
2021-04-30 14:43 ` [PATCH 09/13] drm/amdgpu: switch the GTT backend to self alloc Matthew Auld
2021-04-30 9:25 ` [PATCH 10/13] drm/amdgpu: switch the VRAM " Christian König
2021-04-30 14:53 ` Matthew Auld
2021-04-30 9:25 ` [PATCH 11/13] drm/nouveau: switch the TTM backends " Christian König
2021-04-30 15:02 ` Matthew Auld
2021-05-03 11:14 ` Christian König
2021-05-05 16:46 ` Matthew Auld
2021-04-30 9:25 ` [PATCH 12/13] drm/vmwgfx: " Christian König
2021-05-05 16:49 ` Matthew Auld
2021-04-30 9:25 ` [PATCH 13/13] drm/ttm: flip the switch for driver allocated resources Christian König
2021-05-03 16:15 ` Nirmoy
2021-05-05 16:44 ` Matthew Auld
2021-04-30 10:09 ` [PATCH 01/13] drm/ttm: add ttm_sys_manager v2 Matthew Auld
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=20210430092508.60710-9-christian.koenig@amd.com \
--to=ckoenig.leichtzumerken@gmail.com \
--cc=daniel.vetter@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=matthew.william.auld@gmail.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).