summaryrefslogtreecommitdiff
path: root/include/drm/ttm/ttm_range_manager.h
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2021-04-17 19:48:36 +0300
committerChristian König <christian.koenig@amd.com>2021-06-04 16:16:45 +0300
commit3eb7d96e94150304011d214750b45766cf62d9c9 (patch)
treeeaed91606a2a0bd30d82dbd993fc642efa5e2345 /include/drm/ttm/ttm_range_manager.h
parentbfa3357ef9abc9d56a2910222d2deeb9f15c91ff (diff)
downloadlinux-3eb7d96e94150304011d214750b45766cf62d9c9.tar.xz
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 'include/drm/ttm/ttm_range_manager.h')
-rw-r--r--include/drm/ttm/ttm_range_manager.h43
1 files changed, 43 insertions, 0 deletions
diff --git a/include/drm/ttm/ttm_range_manager.h b/include/drm/ttm/ttm_range_manager.h
new file mode 100644
index 000000000000..983f452ce54b
--- /dev/null
+++ b/include/drm/ttm/ttm_range_manager.h
@@ -0,0 +1,43 @@
+/* SPDX-License-Identifier: GPL-2.0 OR MIT */
+
+#ifndef _TTM_RANGE_MANAGER_H_
+#define _TTM_RANGE_MANAGER_H_
+
+#include <drm/ttm/ttm_resource.h>
+#include <drm/drm_mm.h>
+
+/**
+ * struct ttm_range_mgr_node
+ *
+ * @base: base clase we extend
+ * @mm_nodes: MM nodes, usually 1
+ *
+ * Extending the ttm_resource object to manage an address space allocation with
+ * one or more drm_mm_nodes.
+ */
+struct ttm_range_mgr_node {
+ struct ttm_resource base;
+ struct drm_mm_node mm_nodes[];
+};
+
+/**
+ * to_ttm_range_mgr_node
+ *
+ * @res: the resource to upcast
+ *
+ * Upcast the ttm_resource object into a ttm_range_mgr_node object.
+ */
+static inline struct ttm_range_mgr_node *
+to_ttm_range_mgr_node(struct ttm_resource *res)
+{
+ return container_of(res->mm_node, struct ttm_range_mgr_node,
+ mm_nodes[0]);
+}
+
+int ttm_range_man_init(struct ttm_device *bdev,
+ unsigned type, bool use_tt,
+ unsigned long p_size);
+int ttm_range_man_fini(struct ttm_device *bdev,
+ unsigned type);
+
+#endif