Commit 2c4b3895 authored by Chris Wilson's avatar Chris Wilson Committed by Daniel Vetter

drm: Unconditionally do the range check in drm_mm_scan_add_block()

Doing the check is trivial (low cost in comparison to overall eviction)
and helps simplify the code.
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-29-chris@chris-wilson.co.uk
parent 4a6c156f
...@@ -709,46 +709,6 @@ EXPORT_SYMBOL(drm_mm_replace_node); ...@@ -709,46 +709,6 @@ EXPORT_SYMBOL(drm_mm_replace_node);
* objects. It doesn't seem to hurt badly. * objects. It doesn't seem to hurt badly.
*/ */
/**
* drm_mm_scan_init - initialize lru scanning
* @scan: scan state
* @mm: drm_mm to scan
* @size: size of the allocation
* @alignment: alignment of the allocation
* @color: opaque tag value to use for the allocation
*
* This simply sets up the scanning routines with the parameters for the desired
* hole. Note that there's no need to specify allocation flags, since they only
* change the place a node is allocated from within a suitable hole.
*
* Warning:
* As long as the scan list is non-empty, no other operations than
* adding/removing nodes to/from the scan list are allowed.
*/
void drm_mm_scan_init(struct drm_mm_scan *scan,
struct drm_mm *mm,
u64 size,
u64 alignment,
unsigned long color)
{
DRM_MM_BUG_ON(!size);
DRM_MM_BUG_ON(mm->scan_active);
scan->mm = mm;
scan->color = color;
scan->alignment = alignment;
scan->size = size;
scan->check_range = 0;
scan->hit_start = U64_MAX;
scan->hit_end = 0;
scan->prev_scanned_node = NULL;
}
EXPORT_SYMBOL(drm_mm_scan_init);
/** /**
* drm_mm_scan_init_with_range - initialize range-restricted lru scanning * drm_mm_scan_init_with_range - initialize range-restricted lru scanning
* @scan: scan state * @scan: scan state
...@@ -788,7 +748,6 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, ...@@ -788,7 +748,6 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,
DRM_MM_BUG_ON(end <= start); DRM_MM_BUG_ON(end <= start);
scan->range_start = start; scan->range_start = start;
scan->range_end = end; scan->range_end = end;
scan->check_range = 1;
scan->hit_start = U64_MAX; scan->hit_start = U64_MAX;
scan->hit_end = 0; scan->hit_end = 0;
...@@ -830,15 +789,11 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, ...@@ -830,15 +789,11 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan,
node->node_list.next = &scan->prev_scanned_node->node_list; node->node_list.next = &scan->prev_scanned_node->node_list;
scan->prev_scanned_node = node; scan->prev_scanned_node = node;
adj_start = hole_start = drm_mm_hole_node_start(hole); hole_start = drm_mm_hole_node_start(hole);
adj_end = hole_end = drm_mm_hole_node_end(hole); hole_end = drm_mm_hole_node_end(hole);
if (scan->check_range) { adj_start = max(hole_start, scan->range_start);
if (adj_start < scan->range_start) adj_end = min(hole_end, scan->range_end);
adj_start = scan->range_start;
if (adj_end > scan->range_end)
adj_end = scan->range_end;
}
if (mm->color_adjust) if (mm->color_adjust)
mm->color_adjust(hole, scan->color, &adj_start, &adj_end); mm->color_adjust(hole, scan->color, &adj_start, &adj_end);
......
...@@ -126,13 +126,9 @@ i915_gem_evict_something(struct i915_address_space *vm, ...@@ -126,13 +126,9 @@ i915_gem_evict_something(struct i915_address_space *vm,
* On each list, the oldest objects lie at the HEAD with the freshest * On each list, the oldest objects lie at the HEAD with the freshest
* object on the TAIL. * object on the TAIL.
*/ */
if (start != 0 || end != vm->total) { drm_mm_scan_init_with_range(&scan, &vm->mm,
drm_mm_scan_init_with_range(&scan, &vm->mm, min_size, min_size, alignment, cache_level,
alignment, cache_level, start, end);
start, end);
} else
drm_mm_scan_init(&scan, &vm->mm, min_size,
alignment, cache_level);
if (flags & PIN_NONBLOCK) if (flags & PIN_NONBLOCK)
phases[1] = NULL; phases[1] = NULL;
......
...@@ -120,7 +120,6 @@ struct drm_mm_scan { ...@@ -120,7 +120,6 @@ struct drm_mm_scan {
struct drm_mm_node *prev_scanned_node; struct drm_mm_node *prev_scanned_node;
unsigned long color; unsigned long color;
bool check_range : 1;
}; };
/** /**
...@@ -387,11 +386,6 @@ __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last); ...@@ -387,11 +386,6 @@ __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last);
node__ && node__->start < (end__); \ node__ && node__->start < (end__); \
node__ = list_next_entry(node__, node_list)) node__ = list_next_entry(node__, node_list))
void drm_mm_scan_init(struct drm_mm_scan *scan,
struct drm_mm *mm,
u64 size,
u64 alignment,
unsigned long color);
void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,
struct drm_mm *mm, struct drm_mm *mm,
u64 size, u64 size,
...@@ -399,6 +393,33 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, ...@@ -399,6 +393,33 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,
unsigned long color, unsigned long color,
u64 start, u64 start,
u64 end); u64 end);
/**
* drm_mm_scan_init - initialize lru scanning
* @scan: scan state
* @mm: drm_mm to scan
* @size: size of the allocation
* @alignment: alignment of the allocation
* @color: opaque tag value to use for the allocation
*
* This simply sets up the scanning routines with the parameters for the desired
* hole. Note that there's no need to specify allocation flags, since they only
* change the place a node is allocated from within a suitable hole.
*
* Warning:
* As long as the scan list is non-empty, no other operations than
* adding/removing nodes to/from the scan list are allowed.
*/
static inline void drm_mm_scan_init(struct drm_mm_scan *scan,
struct drm_mm *mm,
u64 size,
u64 alignment,
unsigned long color)
{
drm_mm_scan_init_with_range(scan, mm, size, alignment, color,
0, U64_MAX);
}
bool drm_mm_scan_add_block(struct drm_mm_scan *scan, bool drm_mm_scan_add_block(struct drm_mm_scan *scan,
struct drm_mm_node *node); struct drm_mm_node *node);
bool drm_mm_scan_remove_block(struct drm_mm_scan *scan, bool drm_mm_scan_remove_block(struct drm_mm_scan *scan,
......
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