[PATCH 37/40] drm: Apply range restriction after color adjustment when allocation
Chris Wilson
chris at chris-wilson.co.uk
Thu Dec 15 16:40:51 UTC 2016
mm->color_adjust() compares the hole with its neighbouring nodes. They
only abutt before we restrict the hole, so we have to apply color_adjust
before we apply the range restriction.
Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>
---
drivers/gpu/drm/drm_mm.c | 20 ++++++++------------
1 file changed, 8 insertions(+), 12 deletions(-)
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index da9f98690e97..a6d01258b577 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -410,14 +410,12 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,
DRM_MM_BUG_ON(!drm_mm_hole_follows(hole_node) || node->allocated);
- if (adj_start < start)
- adj_start = start;
- if (adj_end > end)
- adj_end = end;
-
if (mm->color_adjust)
mm->color_adjust(hole_node, color, &adj_start, &adj_end);
+ adj_start = max(adj_start, range_start);
+ adj_end = min(adj_end, range_end);
+
if (flags & DRM_MM_CREATE_TOP)
adj_start = adj_end - size;
@@ -606,8 +604,8 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
u64 size,
u64 alignment,
unsigned long color,
- u64 start,
- u64 end,
+ u64 range_start,
+ u64 range_end,
enum drm_mm_search_flags flags)
{
struct drm_mm_node *entry;
@@ -625,17 +623,15 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
flags & DRM_MM_SEARCH_BELOW) {
u64 hole_size = adj_end - adj_start;
- if (adj_start < start)
- adj_start = start;
- if (adj_end > end)
- adj_end = end;
-
if (mm->color_adjust) {
mm->color_adjust(entry, color, &adj_start, &adj_end);
if (adj_end <= adj_start)
continue;
}
+ adj_start = max(adj_start, range_start);
+ adj_end = min(adj_end, range_end);
+
if (!check_free_hole(adj_start, adj_end, size, alignment))
continue;
--
2.11.0
More information about the Intel-gfx-trybot
mailing list