diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2016-12-22 03:36:31 -0500 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2016-12-28 05:50:28 -0500 |
commit | 2c4b389518fbe552188928aadcd3815d5116a05c (patch) | |
tree | 741bd09ab8f830f5a9cb984ce623f0a4595507fd | |
parent | 4a6c156f56beaaf83102c8b29baeef070c697093 (diff) |
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
-rw-r--r-- | drivers/gpu/drm/drm_mm.c | 53 | ||||
-rw-r--r-- | drivers/gpu/drm/i915/i915_gem_evict.c | 10 | ||||
-rw-r--r-- | include/drm/drm_mm.h | 33 |
3 files changed, 34 insertions, 62 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); | |||
710 | */ | 710 | */ |
711 | 711 | ||
712 | /** | 712 | /** |
713 | * drm_mm_scan_init - initialize lru scanning | ||
714 | * @scan: scan state | ||
715 | * @mm: drm_mm to scan | ||
716 | * @size: size of the allocation | ||
717 | * @alignment: alignment of the allocation | ||
718 | * @color: opaque tag value to use for the allocation | ||
719 | * | ||
720 | * This simply sets up the scanning routines with the parameters for the desired | ||
721 | * hole. Note that there's no need to specify allocation flags, since they only | ||
722 | * change the place a node is allocated from within a suitable hole. | ||
723 | * | ||
724 | * Warning: | ||
725 | * As long as the scan list is non-empty, no other operations than | ||
726 | * adding/removing nodes to/from the scan list are allowed. | ||
727 | */ | ||
728 | void drm_mm_scan_init(struct drm_mm_scan *scan, | ||
729 | struct drm_mm *mm, | ||
730 | u64 size, | ||
731 | u64 alignment, | ||
732 | unsigned long color) | ||
733 | { | ||
734 | DRM_MM_BUG_ON(!size); | ||
735 | DRM_MM_BUG_ON(mm->scan_active); | ||
736 | |||
737 | scan->mm = mm; | ||
738 | |||
739 | scan->color = color; | ||
740 | scan->alignment = alignment; | ||
741 | scan->size = size; | ||
742 | |||
743 | scan->check_range = 0; | ||
744 | |||
745 | scan->hit_start = U64_MAX; | ||
746 | scan->hit_end = 0; | ||
747 | |||
748 | scan->prev_scanned_node = NULL; | ||
749 | } | ||
750 | EXPORT_SYMBOL(drm_mm_scan_init); | ||
751 | |||
752 | /** | ||
753 | * drm_mm_scan_init_with_range - initialize range-restricted lru scanning | 713 | * drm_mm_scan_init_with_range - initialize range-restricted lru scanning |
754 | * @scan: scan state | 714 | * @scan: scan state |
755 | * @mm: drm_mm to scan | 715 | * @mm: drm_mm to scan |
@@ -788,7 +748,6 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, | |||
788 | DRM_MM_BUG_ON(end <= start); | 748 | DRM_MM_BUG_ON(end <= start); |
789 | scan->range_start = start; | 749 | scan->range_start = start; |
790 | scan->range_end = end; | 750 | scan->range_end = end; |
791 | scan->check_range = 1; | ||
792 | 751 | ||
793 | scan->hit_start = U64_MAX; | 752 | scan->hit_start = U64_MAX; |
794 | scan->hit_end = 0; | 753 | scan->hit_end = 0; |
@@ -830,15 +789,11 @@ bool drm_mm_scan_add_block(struct drm_mm_scan *scan, | |||
830 | node->node_list.next = &scan->prev_scanned_node->node_list; | 789 | node->node_list.next = &scan->prev_scanned_node->node_list; |
831 | scan->prev_scanned_node = node; | 790 | scan->prev_scanned_node = node; |
832 | 791 | ||
833 | adj_start = hole_start = drm_mm_hole_node_start(hole); | 792 | hole_start = drm_mm_hole_node_start(hole); |
834 | adj_end = hole_end = drm_mm_hole_node_end(hole); | 793 | hole_end = drm_mm_hole_node_end(hole); |
835 | 794 | ||
836 | if (scan->check_range) { | 795 | adj_start = max(hole_start, scan->range_start); |
837 | if (adj_start < scan->range_start) | 796 | adj_end = min(hole_end, scan->range_end); |
838 | adj_start = scan->range_start; | ||
839 | if (adj_end > scan->range_end) | ||
840 | adj_end = scan->range_end; | ||
841 | } | ||
842 | 797 | ||
843 | if (mm->color_adjust) | 798 | if (mm->color_adjust) |
844 | mm->color_adjust(hole, scan->color, &adj_start, &adj_end); | 799 | mm->color_adjust(hole, scan->color, &adj_start, &adj_end); |
diff --git a/drivers/gpu/drm/i915/i915_gem_evict.c b/drivers/gpu/drm/i915/i915_gem_evict.c index ac2f4eea1846..a6d5bab6f237 100644 --- a/drivers/gpu/drm/i915/i915_gem_evict.c +++ b/drivers/gpu/drm/i915/i915_gem_evict.c | |||
@@ -126,13 +126,9 @@ i915_gem_evict_something(struct i915_address_space *vm, | |||
126 | * On each list, the oldest objects lie at the HEAD with the freshest | 126 | * On each list, the oldest objects lie at the HEAD with the freshest |
127 | * object on the TAIL. | 127 | * object on the TAIL. |
128 | */ | 128 | */ |
129 | if (start != 0 || end != vm->total) { | 129 | drm_mm_scan_init_with_range(&scan, &vm->mm, |
130 | drm_mm_scan_init_with_range(&scan, &vm->mm, min_size, | 130 | min_size, alignment, cache_level, |
131 | alignment, cache_level, | 131 | start, end); |
132 | start, end); | ||
133 | } else | ||
134 | drm_mm_scan_init(&scan, &vm->mm, min_size, | ||
135 | alignment, cache_level); | ||
136 | 132 | ||
137 | if (flags & PIN_NONBLOCK) | 133 | if (flags & PIN_NONBLOCK) |
138 | phases[1] = NULL; | 134 | phases[1] = NULL; |
diff --git a/include/drm/drm_mm.h b/include/drm/drm_mm.h index fcad718c5fb4..bae0f10da8e3 100644 --- a/include/drm/drm_mm.h +++ b/include/drm/drm_mm.h | |||
@@ -120,7 +120,6 @@ struct drm_mm_scan { | |||
120 | struct drm_mm_node *prev_scanned_node; | 120 | struct drm_mm_node *prev_scanned_node; |
121 | 121 | ||
122 | unsigned long color; | 122 | unsigned long color; |
123 | bool check_range : 1; | ||
124 | }; | 123 | }; |
125 | 124 | ||
126 | /** | 125 | /** |
@@ -387,11 +386,6 @@ __drm_mm_interval_first(const struct drm_mm *mm, u64 start, u64 last); | |||
387 | node__ && node__->start < (end__); \ | 386 | node__ && node__->start < (end__); \ |
388 | node__ = list_next_entry(node__, node_list)) | 387 | node__ = list_next_entry(node__, node_list)) |
389 | 388 | ||
390 | void drm_mm_scan_init(struct drm_mm_scan *scan, | ||
391 | struct drm_mm *mm, | ||
392 | u64 size, | ||
393 | u64 alignment, | ||
394 | unsigned long color); | ||
395 | void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, | 389 | void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, |
396 | struct drm_mm *mm, | 390 | struct drm_mm *mm, |
397 | u64 size, | 391 | u64 size, |
@@ -399,6 +393,33 @@ void drm_mm_scan_init_with_range(struct drm_mm_scan *scan, | |||
399 | unsigned long color, | 393 | unsigned long color, |
400 | u64 start, | 394 | u64 start, |
401 | u64 end); | 395 | u64 end); |
396 | |||
397 | /** | ||
398 | * drm_mm_scan_init - initialize lru scanning | ||
399 | * @scan: scan state | ||
400 | * @mm: drm_mm to scan | ||
401 | * @size: size of the allocation | ||
402 | * @alignment: alignment of the allocation | ||
403 | * @color: opaque tag value to use for the allocation | ||
404 | * | ||
405 | * This simply sets up the scanning routines with the parameters for the desired | ||
406 | * hole. Note that there's no need to specify allocation flags, since they only | ||
407 | * change the place a node is allocated from within a suitable hole. | ||
408 | * | ||
409 | * Warning: | ||
410 | * As long as the scan list is non-empty, no other operations than | ||
411 | * adding/removing nodes to/from the scan list are allowed. | ||
412 | */ | ||
413 | static inline void drm_mm_scan_init(struct drm_mm_scan *scan, | ||
414 | struct drm_mm *mm, | ||
415 | u64 size, | ||
416 | u64 alignment, | ||
417 | unsigned long color) | ||
418 | { | ||
419 | drm_mm_scan_init_with_range(scan, mm, size, alignment, color, | ||
420 | 0, U64_MAX); | ||
421 | } | ||
422 | |||
402 | bool drm_mm_scan_add_block(struct drm_mm_scan *scan, | 423 | bool drm_mm_scan_add_block(struct drm_mm_scan *scan, |
403 | struct drm_mm_node *node); | 424 | struct drm_mm_node *node); |
404 | bool drm_mm_scan_remove_block(struct drm_mm_scan *scan, | 425 | bool drm_mm_scan_remove_block(struct drm_mm_scan *scan, |