diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-12-29 15:48:23 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-12-30 06:53:51 -0500 |
commit | 05fc03217e08b90bff1ff22792d5f86dd32f15a6 (patch) | |
tree | 6d8b566bfe4eec689beefd4a91b963b0eefe9fa0 /drivers/gpu | |
parent | a8182863438232dce79f76cc511d752a219ff33a (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 'drivers/gpu')
-rw-r--r-- | drivers/gpu/drm/drm_mm.c | 41 |
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c index e54aa3fa538f..229b3f525dee 100644 --- a/drivers/gpu/drm/drm_mm.c +++ b/drivers/gpu/drm/drm_mm.c | |||
@@ -59,8 +59,8 @@ | |||
59 | * | 59 | * |
60 | * The main data struct is &drm_mm, allocations are tracked in &drm_mm_node. | 60 | * The main data struct is &drm_mm, allocations are tracked in &drm_mm_node. |
61 | * Drivers are free to embed either of them into their own suitable | 61 | * Drivers are free to embed either of them into their own suitable |
62 | * datastructures. drm_mm itself will not do any allocations of its own, so if | 62 | * datastructures. drm_mm itself will not do any memory allocations of its own, |
63 | * drivers choose not to embed nodes they need to still allocate them | 63 | * so if drivers choose not to embed nodes they need to still allocate them |
64 | * themselves. | 64 | * themselves. |
65 | * | 65 | * |
66 | * The range allocator also supports reservation of preallocated blocks. This is | 66 | * The range allocator also supports reservation of preallocated blocks. This is |
@@ -78,7 +78,7 @@ | |||
78 | * steep cliff not a real concern. Removing a node again is O(1). | 78 | * steep cliff not a real concern. Removing a node again is O(1). |
79 | * | 79 | * |
80 | * drm_mm supports a few features: Alignment and range restrictions can be | 80 | * drm_mm supports a few features: Alignment and range restrictions can be |
81 | * supplied. Further more every &drm_mm_node has a color value (which is just an | 81 | * supplied. Furthermore every &drm_mm_node has a color value (which is just an |
82 | * opaque unsigned long) which in conjunction with a driver callback can be used | 82 | * opaque unsigned long) which in conjunction with a driver callback can be used |
83 | * to implement sophisticated placement restrictions. The i915 DRM driver uses | 83 | * to implement sophisticated placement restrictions. The i915 DRM driver uses |
84 | * this to implement guard pages between incompatible caching domains in the | 84 | * this to implement guard pages between incompatible caching domains in the |
@@ -296,11 +296,11 @@ static void drm_mm_insert_helper(struct drm_mm_node *hole_node, | |||
296 | * @mm: drm_mm allocator to insert @node into | 296 | * @mm: drm_mm allocator to insert @node into |
297 | * @node: drm_mm_node to insert | 297 | * @node: drm_mm_node to insert |
298 | * | 298 | * |
299 | * This functions inserts an already set-up drm_mm_node into the allocator, | 299 | * This functions inserts an already set-up &drm_mm_node into the allocator, |
300 | * meaning that start, size and color must be set by the caller. This is useful | 300 | * meaning that start, size and color must be set by the caller. All other |
301 | * to initialize the allocator with preallocated objects which must be set-up | 301 | * fields must be cleared to 0. This is useful to initialize the allocator with |
302 | * before the range allocator can be set-up, e.g. when taking over a firmware | 302 | * preallocated objects which must be set-up before the range allocator can be |
303 | * framebuffer. | 303 | * set-up, e.g. when taking over a firmware framebuffer. |
304 | * | 304 | * |
305 | * Returns: | 305 | * Returns: |
306 | * 0 on success, -ENOSPC if there's no hole where @node is. | 306 | * 0 on success, -ENOSPC if there's no hole where @node is. |
@@ -375,7 +375,7 @@ EXPORT_SYMBOL(drm_mm_reserve_node); | |||
375 | * @sflags: flags to fine-tune the allocation search | 375 | * @sflags: flags to fine-tune the allocation search |
376 | * @aflags: flags to fine-tune the allocation behavior | 376 | * @aflags: flags to fine-tune the allocation behavior |
377 | * | 377 | * |
378 | * The preallocated node must be cleared to 0. | 378 | * The preallocated @node must be cleared to 0. |
379 | * | 379 | * |
380 | * Returns: | 380 | * Returns: |
381 | * 0 on success, -ENOSPC if there's no suitable hole. | 381 | * 0 on success, -ENOSPC if there's no suitable hole. |
@@ -537,7 +537,7 @@ void drm_mm_replace_node(struct drm_mm_node *old, struct drm_mm_node *new) | |||
537 | EXPORT_SYMBOL(drm_mm_replace_node); | 537 | EXPORT_SYMBOL(drm_mm_replace_node); |
538 | 538 | ||
539 | /** | 539 | /** |
540 | * DOC: lru scan roaster | 540 | * DOC: lru scan roster |
541 | * | 541 | * |
542 | * Very often GPUs need to have continuous allocations for a given object. When | 542 | * Very often GPUs need to have continuous allocations for a given object. When |
543 | * evicting objects to make space for a new one it is therefore not most | 543 | * evicting objects to make space for a new one it is therefore not most |
@@ -549,9 +549,11 @@ EXPORT_SYMBOL(drm_mm_replace_node); | |||
549 | * The DRM range allocator supports this use-case through the scanning | 549 | * The DRM range allocator supports this use-case through the scanning |
550 | * interfaces. First a scan operation needs to be initialized with | 550 | * interfaces. First a scan operation needs to be initialized with |
551 | * drm_mm_scan_init() or drm_mm_scan_init_with_range(). The driver adds | 551 | * drm_mm_scan_init() or drm_mm_scan_init_with_range(). The driver adds |
552 | * objects to the roster (probably by walking an LRU list, but this can be | 552 | * objects to the roster, probably by walking an LRU list, but this can be |
553 | * freely implemented) (using drm_mm_scan_add_block()) until a suitable hole | 553 | * freely implemented. Eviction candiates are added using |
554 | * is found or there are no further evictable objects. | 554 | * drm_mm_scan_add_block() until a suitable hole is found or there are no |
555 | * further evictable objects. Eviction roster metadata is tracked in struct | ||
556 | * &drm_mm_scan. | ||
555 | * | 557 | * |
556 | * The driver must walk through all objects again in exactly the reverse | 558 | * The driver must walk through all objects again in exactly the reverse |
557 | * order to restore the allocator state. Note that while the allocator is used | 559 | * order to restore the allocator state. Note that while the allocator is used |
@@ -559,7 +561,7 @@ EXPORT_SYMBOL(drm_mm_replace_node); | |||
559 | * | 561 | * |
560 | * Finally the driver evicts all objects selected (drm_mm_scan_remove_block() | 562 | * Finally the driver evicts all objects selected (drm_mm_scan_remove_block() |
561 | * reported true) in the scan, and any overlapping nodes after color adjustment | 563 | * reported true) in the scan, and any overlapping nodes after color adjustment |
562 | * (drm_mm_scan_evict_color()). Adding and removing an object is O(1), and | 564 | * (drm_mm_scan_color_evict()). Adding and removing an object is O(1), and |
563 | * since freeing a node is also O(1) the overall complexity is | 565 | * since freeing a node is also O(1) the overall complexity is |
564 | * O(scanned_objects). So like the free stack which needs to be walked before a | 566 | * O(scanned_objects). So like the free stack which needs to be walked before a |
565 | * scan operation even begins this is linear in the number of objects. It | 567 | * scan operation even begins this is linear in the number of objects. It |
@@ -705,14 +707,15 @@ EXPORT_SYMBOL(drm_mm_scan_add_block); | |||
705 | * @scan: the active drm_mm scanner | 707 | * @scan: the active drm_mm scanner |
706 | * @node: drm_mm_node to remove | 708 | * @node: drm_mm_node to remove |
707 | * | 709 | * |
708 | * Nodes _must_ be removed in exactly the reverse order from the scan list as | 710 | * Nodes **must** be removed in exactly the reverse order from the scan list as |
709 | * they have been added (e.g. using list_add as they are added and then | 711 | * they have been added (e.g. using list_add() as they are added and then |
710 | * list_for_each over that eviction list to remove), otherwise the internal | 712 | * list_for_each() over that eviction list to remove), otherwise the internal |
711 | * state of the memory manager will be corrupted. | 713 | * state of the memory manager will be corrupted. |
712 | * | 714 | * |
713 | * When the scan list is empty, the selected memory nodes can be freed. An | 715 | * When the scan list is empty, the selected memory nodes can be freed. An |
714 | * immediately following drm_mm_search_free with !DRM_MM_SEARCH_BEST will then | 716 | * immediately following drm_mm_insert_node_in_range_generic() or one of the |
715 | * return the just freed block (because its at the top of the free_stack list). | 717 | * simpler versions of that function with !DRM_MM_SEARCH_BEST will then return |
718 | * the just freed block (because its at the top of the free_stack list). | ||
716 | * | 719 | * |
717 | * Returns: | 720 | * Returns: |
718 | * True if this block should be evicted, false otherwise. Will always | 721 | * True if this block should be evicted, false otherwise. Will always |