[PATCH 1/6] iosys-map: Add allocator flags

Thomas Zimmermann tzimmermann at suse.de
Fri Jun 14 13:21:55 UTC 2024


Add the public field alloc_flags to struct iosys_map. It allows for
the allocator of the mapping to store additional flags, such details
about the internal alloctor operations. This will be helpful with
DRM's TTM memory manager, which supports various types of memory in
it's vmap functions.

The new field fills existing padding bytes in struct iosys_map, so
instances of the type do not grow in size.

Signed-off-by: Thomas Zimmermann <tzimmermann at suse.de>
---
 include/linux/iosys-map.h | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/include/linux/iosys-map.h b/include/linux/iosys-map.h
index 4696abfd311cc..f3b351094bca0 100644
--- a/include/linux/iosys-map.h
+++ b/include/linux/iosys-map.h
@@ -97,6 +97,11 @@
  *
  *	iosys_map_memcpy_to(&map, src, len);
  *	iosys_map_incr(&map, len); // go to first byte after the memcpy
+ *
+ * The only public field in :c:type:`struct iosys_map <iosys_map>` is
+ * alloc_flags. It allows allocators to store additional information about the
+ * stored memory. Helpers will initialize or clear it to zero, but the values
+ * are only used by the allocator.
  */
 
 /**
@@ -105,6 +110,7 @@
  * @vaddr:		The buffer's address if in system memory
  * @is_iomem:		True if the buffer is located in I/O memory, or false
  *			otherwise.
+ * @alloc_flags		Allocator private flags
  */
 struct iosys_map {
 	union {
@@ -112,6 +118,7 @@ struct iosys_map {
 		void *vaddr;
 	};
 	bool is_iomem;
+	u16 alloc_flags;
 };
 
 /**
@@ -122,6 +129,7 @@ struct iosys_map {
 	{				\
 		.vaddr = (vaddr_),	\
 		.is_iomem = false,	\
+		.alloc_flags = 0,	\
 	}
 
 /**
@@ -132,6 +140,7 @@ struct iosys_map {
 	{						\
 		.vaddr_iomem = (vaddr_iomem_),		\
 		.is_iomem = true,			\
+		.alloc_flags = 0,			\
 	}
 
 /**
@@ -260,7 +269,8 @@ static inline bool iosys_map_is_set(const struct iosys_map *map)
  *
  * Clears all fields to zero, including struct iosys_map.is_iomem, so
  * mapping structures that were set to point to I/O memory are reset for
- * system memory. Pointers are cleared to NULL. This is the default.
+ * system memory. Pointers are cleared to NULL. The allocator flags in
+ * struct iosys_map.alloc_flags are cleared to zero.
  */
 static inline void iosys_map_clear(struct iosys_map *map)
 {
@@ -270,6 +280,7 @@ static inline void iosys_map_clear(struct iosys_map *map)
 	} else {
 		map->vaddr = NULL;
 	}
+	map->alloc_flags = 0;
 }
 
 /**
-- 
2.45.2



More information about the dri-devel mailing list