Commit f29051f1 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm: Simplify drm_mm scan-list manipulation

Since we mandate a strict reverse-order of drm_mm_scan_remove_block()
after drm_mm_scan_add_block() we can further simplify the list
manipulations when generating the temporary scan-hole.

v2: Highlight the games being played with the lists to track the scan
holes without allocation.
Signed-off-by: default avatarChris Wilson <chris@chris-wilson.co.uk>
Reviewed-by: default avatarJoonas Lahtinen <joonas.lahtinen@linux.intel.com>
Signed-off-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-33-chris@chris-wilson.co.uk
parent 9a956b15
...@@ -518,9 +518,7 @@ void drm_mm_remove_node(struct drm_mm_node *node) ...@@ -518,9 +518,7 @@ void drm_mm_remove_node(struct drm_mm_node *node)
struct drm_mm_node *prev_node; struct drm_mm_node *prev_node;
DRM_MM_BUG_ON(!node->allocated); DRM_MM_BUG_ON(!node->allocated);
DRM_MM_BUG_ON(node->scanned_block || DRM_MM_BUG_ON(node->scanned_block);
node->scanned_prev_free ||
node->scanned_next_free);
prev_node = prev_node =
list_entry(node->node_list.prev, struct drm_mm_node, node_list); list_entry(node->node_list.prev, struct drm_mm_node, node_list);
...@@ -757,8 +755,6 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, ...@@ -757,8 +755,6 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,
scan->hit_start = U64_MAX; scan->hit_start = U64_MAX;
scan->hit_end = 0; scan->hit_end = 0;
scan->prev_scanned_node = NULL;
} }
EXPORT_SYMBOL(drm_mm_scan_init_with_range); EXPORT_SYMBOL(drm_mm_scan_init_with_range);
...@@ -787,14 +783,14 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, ...@@ -787,14 +783,14 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan,
node->scanned_block = true; node->scanned_block = true;
mm->scan_active++; mm->scan_active++;
/* Remove this block from the node_list so that we enlarge the hole
* (distance between the end of our previous node and the start of
* or next), without poisoning the link so that we can restore it
* later in drm_mm_scan_remove_block().
*/
hole = list_prev_entry(node, node_list); hole = list_prev_entry(node, node_list);
DRM_MM_BUG_ON(list_next_entry(hole, node_list) != node);
node->scanned_preceeds_hole = hole->hole_follows; __list_del_entry(&node->node_list);
hole->hole_follows = 1;
list_del(&node->node_list);
node->node_list.prev = &hole->node_list;
node->node_list.next = &scan->prev_scanned_node->node_list;
scan->prev_scanned_node = node;
hole_start = __drm_mm_hole_node_start(hole); hole_start = __drm_mm_hole_node_start(hole);
hole_end = __drm_mm_hole_node_end(hole); hole_end = __drm_mm_hole_node_end(hole);
...@@ -888,9 +884,17 @@ bool drm_mm_scan_remove_block(struct drm_mm_scan *scan, ...@@ -888,9 +884,17 @@ bool drm_mm_scan_remove_block(struct drm_mm_scan *scan,
DRM_MM_BUG_ON(!node->mm->scan_active); DRM_MM_BUG_ON(!node->mm->scan_active);
node->mm->scan_active--; node->mm->scan_active--;
/* During drm_mm_scan_add_block() we decoupled this node leaving
* its pointers intact. Now that the caller is walking back along
* the eviction list we can restore this block into its rightful
* place on the full node_list. To confirm that the caller is walking
* backwards correctly we check that prev_node->next == node->next,
* i.e. both believe the same node should be on the other side of the
* hole.
*/
prev_node = list_prev_entry(node, node_list); prev_node = list_prev_entry(node, node_list);
DRM_MM_BUG_ON(list_next_entry(prev_node, node_list) !=
prev_node->hole_follows = node->scanned_preceeds_hole; list_next_entry(node, node_list));
list_add(&node->node_list, &prev_node->node_list); list_add(&node->node_list, &prev_node->node_list);
return (node->start + node->size > scan->hit_start && return (node->start + node->size > scan->hit_start &&
...@@ -917,9 +921,6 @@ void drm_mm_init(struct drm_mm *mm, u64 start, u64 size) ...@@ -917,9 +921,6 @@ void drm_mm_init(struct drm_mm *mm, u64 start, u64 size)
INIT_LIST_HEAD(&mm->head_node.node_list); INIT_LIST_HEAD(&mm->head_node.node_list);
mm->head_node.allocated = 0; mm->head_node.allocated = 0;
mm->head_node.hole_follows = 1; mm->head_node.hole_follows = 1;
mm->head_node.scanned_block = 0;
mm->head_node.scanned_prev_free = 0;
mm->head_node.scanned_next_free = 0;
mm->head_node.mm = mm; mm->head_node.mm = mm;
mm->head_node.start = start + size; mm->head_node.start = start + size;
mm->head_node.size = start - mm->head_node.start; mm->head_node.size = start - mm->head_node.start;
......
...@@ -74,11 +74,8 @@ struct drm_mm_node { ...@@ -74,11 +74,8 @@ struct drm_mm_node {
struct list_head hole_stack; struct list_head hole_stack;
struct rb_node rb; struct rb_node rb;
unsigned hole_follows : 1; unsigned hole_follows : 1;
unsigned scanned_block : 1;
unsigned scanned_prev_free : 1;
unsigned scanned_next_free : 1;
unsigned scanned_preceeds_hole : 1;
unsigned allocated : 1; unsigned allocated : 1;
bool scanned_block : 1;
unsigned long color; unsigned long color;
u64 start; u64 start;
u64 size; u64 size;
...@@ -118,8 +115,6 @@ struct drm_mm_scan { ...@@ -118,8 +115,6 @@ struct drm_mm_scan {
u64 hit_start; u64 hit_start;
u64 hit_end; u64 hit_end;
struct drm_mm_node *prev_scanned_node;
unsigned long color; unsigned long color;
unsigned int flags; unsigned int flags;
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment