summaryrefslogtreecommitdiffstats
path: root/include/drm
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2021-06-08 11:13:21 +0200
committerChristian König <christian.koenig@amd.com>2022-03-28 20:05:32 +0200
commit5d05b988f1c0fddc4aaffa5fa3c3f5a9e7b84d5b (patch)
tree2f018edb9b2d7ef94ff04c7d36b527481d0d031b /include/drm
parent6a9b028994025f5033f10d1da30b29dfdc713384 (diff)
downloadlinux-5d05b988f1c0fddc4aaffa5fa3c3f5a9e7b84d5b.tar.gz
linux-5d05b988f1c0fddc4aaffa5fa3c3f5a9e7b84d5b.tar.bz2
linux-5d05b988f1c0fddc4aaffa5fa3c3f5a9e7b84d5b.zip
drm/ttm: add resource iterator v4
Instead of duplicating that at different places add an iterator over all the resources in a resource manager. v2: add lockdep annotation and kerneldoc v3: fix various bugs pointed out by Felix v4: simplify the code a bit more Signed-off-by: Christian König <christian.koenig@amd.com> Tested-by: Bas Nieuwenhuizen <bas@basnieuwenhuizen.nl> Reviewed-by: Daniel Vetter <daniel.vetter@ffwll.ch> (v2) Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com> Link: https://patchwork.freedesktop.org/patch/msgid/20220321132601.2161-2-christian.koenig@amd.com
Diffstat (limited to 'include/drm')
-rw-r--r--include/drm/ttm/ttm_resource.h23
1 files changed, 23 insertions, 0 deletions
diff --git a/include/drm/ttm/ttm_resource.h b/include/drm/ttm/ttm_resource.h
index f8f766b092a6..d8e880110dc6 100644
--- a/include/drm/ttm/ttm_resource.h
+++ b/include/drm/ttm/ttm_resource.h
@@ -189,6 +189,17 @@ struct ttm_resource {
};
/**
+ * struct ttm_resource_cursor
+ *
+ * @priority: the current priority
+ *
+ * Cursor to iterate over the resources in a manager.
+ */
+struct ttm_resource_cursor {
+ unsigned int priority;
+};
+
+/**
* struct ttm_lru_bulk_move_pos
*
* @first: first res in the bulk move range
@@ -333,6 +344,18 @@ uint64_t ttm_resource_manager_usage(struct ttm_resource_manager *man);
void ttm_resource_manager_debug(struct ttm_resource_manager *man,
struct drm_printer *p);
+struct ttm_resource *
+ttm_resource_manager_first(struct ttm_resource_manager *man,
+ struct ttm_resource_cursor *cursor);
+struct ttm_resource *
+ttm_resource_manager_next(struct ttm_resource_manager *man,
+ struct ttm_resource_cursor *cursor,
+ struct ttm_resource *res);
+
+#define ttm_resource_manager_for_each_res(man, cursor, res) \
+ for (res = ttm_resource_manager_first(man, cursor); res; \
+ res = ttm_resource_manager_next(man, cursor, res))
+
struct ttm_kmap_iter *
ttm_kmap_iter_iomap_init(struct ttm_kmap_iter_iomap *iter_io,
struct io_mapping *iomap,