aboutsummaryrefslogtreecommitdiffstats
path: root/include/drm/drm_mm.h
diff options
context:
space:
mode:
authorDaniel Vetter <daniel.vetter@ffwll.ch>2016-12-29 15:48:23 -0500
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-12-30 06:53:51 -0500
commit05fc03217e08b90bff1ff22792d5f86dd32f15a6 (patch)
tree6d8b566bfe4eec689beefd4a91b963b0eefe9fa0 /include/drm/drm_mm.h
parenta8182863438232dce79f76cc511d752a219ff33a (diff)
drm/mm: Some doc polish
Added some boilerplate for the structs, documented members where they are relevant and plenty of markup for hyperlinks all over. And a few small wording polish. Note that the intro needs some more love after the DRM_MM_INSERT_* patch from Chris has landed. v2: Spelling fixes (Chris). v3: Use &struct foo instead of &foo structure (Chris). Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Reviewed-by: David Herrmann <dh.herrmann@gmail.com> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: http://patchwork.freedesktop.org/patch/msgid/1483044517-5770-3-git-send-email-daniel.vetter@ffwll.ch
Diffstat (limited to 'include/drm/drm_mm.h')
-rw-r--r--include/drm/drm_mm.h84
1 files changed, 66 insertions, 18 deletions
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h
index 1383ac2328b8..3bddca8fd2b5 100644
--- a/include/drm/drm_mm.h
+++ b/include/drm/drm_mm.h
@@ -67,16 +67,29 @@ enum drm_mm_allocator_flags {
67#define DRM_MM_BOTTOMUP DRM_MM_SEARCH_DEFAULT, DRM_MM_CREATE_DEFAULT 67#define DRM_MM_BOTTOMUP DRM_MM_SEARCH_DEFAULT, DRM_MM_CREATE_DEFAULT
68#define DRM_MM_TOPDOWN DRM_MM_SEARCH_BELOW, DRM_MM_CREATE_TOP 68#define DRM_MM_TOPDOWN DRM_MM_SEARCH_BELOW, DRM_MM_CREATE_TOP
69 69
70/**
71 * struct drm_mm_node - allocated block in the DRM allocator
72 *
73 * This represents an allocated block in a &drm_mm allocator. Except for
74 * pre-reserved nodes inserted using drm_mm_reserve_node() the structure is
75 * entirely opaque and should only be accessed through the provided funcions.
76 * Since allocation of these nodes is entirely handled by the driver they can be
77 * embedded.
78 */
70struct drm_mm_node { 79struct drm_mm_node {
80 /** @color: Opaque driver-private tag. */
81 unsigned long color;
82 /** @start: Start address of the allocated block. */
83 u64 start;
84 /** @size: Size of the allocated block. */
85 u64 size;
86 /* private: */
71 struct list_head node_list; 87 struct list_head node_list;
72 struct list_head hole_stack; 88 struct list_head hole_stack;
73 struct rb_node rb; 89 struct rb_node rb;
74 unsigned hole_follows : 1; 90 unsigned hole_follows : 1;
75 unsigned allocated : 1; 91 unsigned allocated : 1;
76 bool scanned_block : 1; 92 bool scanned_block : 1;
77 unsigned long color;
78 u64 start;
79 u64 size;
80 u64 __subtree_last; 93 u64 __subtree_last;
81 struct drm_mm *mm; 94 struct drm_mm *mm;
82#ifdef CONFIG_DRM_DEBUG_MM 95#ifdef CONFIG_DRM_DEBUG_MM
@@ -84,7 +97,29 @@ struct drm_mm_node {
84#endif 97#endif
85}; 98};
86 99
100/**
101 * struct drm_mm - DRM allocator
102 *
103 * DRM range allocator with a few special functions and features geared towards
104 * managing GPU memory. Except for the @color_adjust callback the structure is
105 * entirely opaque and should only be accessed through the provided functions
106 * and macros. This structure can be embedded into larger driver structures.
107 */
87struct drm_mm { 108struct drm_mm {
109 /**
110 * @color_adjust:
111 *
112 * Optional driver callback to further apply restrictions on a hole. The
113 * node argument points at the node containing the hole from which the
114 * block would be allocated (see drm_mm_hole_follows() and friends). The
115 * other arguments are the size of the block to be allocated. The driver
116 * can adjust the start and end as needed to e.g. insert guard pages.
117 */
118 void (*color_adjust)(const struct drm_mm_node *node,
119 unsigned long color,
120 u64 *start, u64 *end);
121
122 /* private: */
88 /* List of all memory nodes that immediately precede a free hole. */ 123 /* List of all memory nodes that immediately precede a free hole. */
89 struct list_head hole_stack; 124 struct list_head hole_stack;
90 /* head_node.node_list is the list of all memory nodes, ordered 125 /* head_node.node_list is the list of all memory nodes, ordered
@@ -93,14 +128,20 @@ struct drm_mm {
93 /* Keep an interval_tree for fast lookup of drm_mm_nodes by address. */ 128 /* Keep an interval_tree for fast lookup of drm_mm_nodes by address. */
94 struct rb_root interval_tree; 129 struct rb_root interval_tree;
95 130
96 void (*color_adjust)(const struct drm_mm_node *node,
97 unsigned long color,
98 u64 *start, u64 *end);
99
100 unsigned long scan_active; 131 unsigned long scan_active;
101}; 132};
102 133
134/**
135 * struct drm_mm_scan - DRM allocator eviction roaster data
136 *
137 * This structure tracks data needed for the eviction roaster set up using
138 * drm_mm_scan_init(), and used with drm_mm_scan_add_block() and
139 * drm_mm_scan_remove_block(). The structure is entirely opaque and should only
140 * be accessed through the provided functions and macros. It is meant to be
141 * allocated temporarily by the driver on the stack.
142 */
103struct drm_mm_scan { 143struct drm_mm_scan {
144 /* private: */
104 struct drm_mm *mm; 145 struct drm_mm *mm;
105 146
106 u64 size; 147 u64 size;
@@ -159,7 +200,8 @@ static inline bool drm_mm_initialized(const struct drm_mm *mm)
159 * 200 *
160 * Holes are embedded into the drm_mm using the tail of a drm_mm_node. 201 * Holes are embedded into the drm_mm using the tail of a drm_mm_node.
161 * If you wish to know whether a hole follows this particular node, 202 * If you wish to know whether a hole follows this particular node,
162 * query this function. 203 * query this function. See also drm_mm_hole_node_start() and
204 * drm_mm_hole_node_end().
163 * 205 *
164 * Returns: 206 * Returns:
165 * True if a hole follows the @node. 207 * True if a hole follows the @node.
@@ -228,23 +270,23 @@ static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node)
228 270
229/** 271/**
230 * drm_mm_for_each_node - iterator to walk over all allocated nodes 272 * drm_mm_for_each_node - iterator to walk over all allocated nodes
231 * @entry: drm_mm_node structure to assign to in each iteration step 273 * @entry: &struct drm_mm_node to assign to in each iteration step
232 * @mm: drm_mm allocator to walk 274 * @mm: &drm_mm allocator to walk
233 * 275 *
234 * This iterator walks over all nodes in the range allocator. It is implemented 276 * This iterator walks over all nodes in the range allocator. It is implemented
235 * with list_for_each, so not save against removal of elements. 277 * with list_for_each(), so not save against removal of elements.
236 */ 278 */
237#define drm_mm_for_each_node(entry, mm) \ 279#define drm_mm_for_each_node(entry, mm) \
238 list_for_each_entry(entry, drm_mm_nodes(mm), node_list) 280 list_for_each_entry(entry, drm_mm_nodes(mm), node_list)
239 281
240/** 282/**
241 * drm_mm_for_each_node_safe - iterator to walk over all allocated nodes 283 * drm_mm_for_each_node_safe - iterator to walk over all allocated nodes
242 * @entry: drm_mm_node structure to assign to in each iteration step 284 * @entry: &struct drm_mm_node to assign to in each iteration step
243 * @next: drm_mm_node structure to store the next step 285 * @next: &struct drm_mm_node to store the next step
244 * @mm: drm_mm allocator to walk 286 * @mm: &drm_mm allocator to walk
245 * 287 *
246 * This iterator walks over all nodes in the range allocator. It is implemented 288 * This iterator walks over all nodes in the range allocator. It is implemented
247 * with list_for_each_safe, so save against removal of elements. 289 * with list_for_each_safe(), so save against removal of elements.
248 */ 290 */
249#define drm_mm_for_each_node_safe(entry, next, mm) \ 291#define drm_mm_for_each_node_safe(entry, next, mm) \
250 list_for_each_entry_safe(entry, next, drm_mm_nodes(mm), node_list) 292 list_for_each_entry_safe(entry, next, drm_mm_nodes(mm), node_list)
@@ -259,13 +301,13 @@ static inline u64 drm_mm_hole_node_end(const struct drm_mm_node *hole_node)
259 301
260/** 302/**
261 * drm_mm_for_each_hole - iterator to walk over all holes 303 * drm_mm_for_each_hole - iterator to walk over all holes
262 * @entry: drm_mm_node used internally to track progress 304 * @entry: &drm_mm_node used internally to track progress
263 * @mm: drm_mm allocator to walk 305 * @mm: &drm_mm allocator to walk
264 * @hole_start: ulong variable to assign the hole start to on each iteration 306 * @hole_start: ulong variable to assign the hole start to on each iteration
265 * @hole_end: ulong variable to assign the hole end to on each iteration 307 * @hole_end: ulong variable to assign the hole end to on each iteration
266 * 308 *
267 * This iterator walks over all holes in the range allocator. It is implemented 309 * This iterator walks over all holes in the range allocator. It is implemented
268 * with list_for_each, so not save against removal of elements. @entry is used 310 * with list_for_each(), so not save against removal of elements. @entry is used
269 * internally and will not reflect a real drm_mm_node for the very first hole. 311 * internally and will not reflect a real drm_mm_node for the very first hole.
270 * Hence users of this iterator may not access it. 312 * Hence users of this iterator may not access it.
271 * 313 *
@@ -334,6 +376,9 @@ static inline int drm_mm_insert_node_in_range(struct drm_mm *mm,
334 * @sflags: flags to fine-tune the allocation search 376 * @sflags: flags to fine-tune the allocation search
335 * @aflags: flags to fine-tune the allocation behavior 377 * @aflags: flags to fine-tune the allocation behavior
336 * 378 *
379 * This is a simplified version of drm_mm_insert_node_in_range_generic() with no
380 * range restrictions applied.
381 *
337 * The preallocated node must be cleared to 0. 382 * The preallocated node must be cleared to 0.
338 * 383 *
339 * Returns: 384 * Returns:
@@ -434,6 +479,9 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,
434 * @color: opaque tag value to use for the allocation 479 * @color: opaque tag value to use for the allocation
435 * @flags: flags to specify how the allocation will be performed afterwards 480 * @flags: flags to specify how the allocation will be performed afterwards
436 * 481 *
482 * This is a simplified version of drm_mm_scan_init_with_range() with no range
483 * restrictions applied.
484 *
437 * This simply sets up the scanning routines with the parameters for the desired 485 * This simply sets up the scanning routines with the parameters for the desired
438 * hole. 486 * hole.
439 * 487 *