summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/drm_mm.c
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2016-12-22 09:36:31 +0100
committerDaniel Vetter <daniel.vetter@ffwll.ch>2016-12-28 11:50:28 +0100
commit2c4b389518fbe552188928aadcd3815d5116a05c (patch)
tree741bd09ab8f830f5a9cb984ce623f0a4595507fd /drivers/gpu/drm/drm_mm.c
parentdrm: Rename prev_node to hole in drm_mm_scan_add_block() (diff)
downloadlinux-2c4b389518fbe552188928aadcd3815d5116a05c.tar.xz
linux-2c4b389518fbe552188928aadcd3815d5116a05c.zip
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: Chris Wilson <chris@chris-wilson.co.uk> Reviewed-by: Joonas Lahtinen <joonas.lahtinen@linux.intel.com> Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch> Link: http://patchwork.freedesktop.org/patch/msgid/20161222083641.2691-29-chris@chris-wilson.co.uk
Diffstat (limited to 'drivers/gpu/drm/drm_mm.c')
-rw-r--r--drivers/gpu/drm/drm_mm.c53
1 files changed, 4 insertions, 49 deletions
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 459f10ca5714..c68f79149b9a 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -710,46 +710,6 @@ EXPORT_SYMBOL(drm_mm_replace_node);
*/
/**
- * 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
* @scan: scan state
* @mm: drm_mm to scan
@@ -788,7 +748,6 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan,
DRM_MM_BUG_ON(end <= start);
scan->range_start = start;
scan->range_end = end;
- scan->check_range = 1;
scan->hit_start = U64_MAX;
scan->hit_end = 0;
@@ -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;
scan->prev_scanned_node = node;
- adj_start = hole_start = drm_mm_hole_node_start(hole);
- adj_end = hole_end = drm_mm_hole_node_end(hole);
+ hole_start = drm_mm_hole_node_start(hole);
+ hole_end = drm_mm_hole_node_end(hole);
- if (scan->check_range) {
- if (adj_start < scan->range_start)
- adj_start = scan->range_start;
- if (adj_end > scan->range_end)
- adj_end = scan->range_end;
- }
+ adj_start = max(hole_start, scan->range_start);
+ adj_end = min(hole_end, scan->range_end);
if (mm->color_adjust)
mm->color_adjust(hole, scan->color, &adj_start, &adj_end);