summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/ttm/ttm_resource.c
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2021-04-17 18:48:36 +0200
committerChristian König <christian.koenig@amd.com>2021-06-04 15:16:45 +0200
commit3eb7d96e94150304011d214750b45766cf62d9c9 (patch)
treeeaed91606a2a0bd30d82dbd993fc642efa5e2345 /drivers/gpu/drm/ttm/ttm_resource.c
parentbfa3357ef9abc9d56a2910222d2deeb9f15c91ff (diff)
drm/ttm: flip over the range manager to self allocated nodes
Start with the range manager to make the resource object the base class for the allocated nodes. While at it cleanup a lot of the code around that. Signed-off-by: Christian König <christian.koenig@amd.com> Reviewed-by: Matthew Auld <matthew.auld@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20210602100914.46246-2-christian.koenig@amd.com
Diffstat (limited to 'drivers/gpu/drm/ttm/ttm_resource.c')
-rw-r--r--drivers/gpu/drm/ttm/ttm_resource.c26
1 files changed, 17 insertions, 9 deletions
diff --git a/drivers/gpu/drm/ttm/ttm_resource.c b/drivers/gpu/drm/ttm/ttm_resource.c
index 65451e1bc303..2a51ace17614 100644
--- a/drivers/gpu/drm/ttm/ttm_resource.c
+++ b/drivers/gpu/drm/ttm/ttm_resource.c
@@ -25,6 +25,22 @@
#include <drm/ttm/ttm_resource.h>
#include <drm/ttm/ttm_bo_driver.h>
+void ttm_resource_init(struct ttm_buffer_object *bo,
+ const struct ttm_place *place,
+ struct ttm_resource *res)
+{
+ res->mm_node = NULL;
+ res->start = 0;
+ res->num_pages = PFN_UP(bo->base.size);
+ res->mem_type = place->mem_type;
+ res->placement = place->flags;
+ res->bus.addr = NULL;
+ res->bus.offset = 0;
+ res->bus.is_iomem = false;
+ res->bus.caching = ttm_cached;
+}
+EXPORT_SYMBOL(ttm_resource_init);
+
int ttm_resource_alloc(struct ttm_buffer_object *bo,
const struct ttm_place *place,
struct ttm_resource **res_ptr)
@@ -38,15 +54,7 @@ int ttm_resource_alloc(struct ttm_buffer_object *bo,
if (!res)
return -ENOMEM;
- res->mm_node = NULL;
- res->start = 0;
- res->num_pages = PFN_UP(bo->base.size);
- res->mem_type = place->mem_type;
- res->placement = place->flags;
- res->bus.addr = NULL;
- res->bus.offset = 0;
- res->bus.is_iomem = false;
- res->bus.caching = ttm_cached;
+ ttm_resource_init(bo, place, res);
r = man->func->alloc(man, bo, place, res);
if (r) {
kfree(res);