Skip to content

Commit f0d8fb7

Browse files
icklegregkh
authored andcommitted
drm: Apply range restriction after color adjustment when allocation
[ Upstream commit 3db93756b501e5f0a3951c79cfa9ed43c26d3455 ] 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@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-36-chris@chris-wilson.co.uk Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 31447eb commit f0d8fb7

1 file changed

Lines changed: 6 additions & 10 deletions

File tree

drivers/gpu/drm/drm_mm.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -262,14 +262,12 @@ static void drm_mm_insert_helper_range(struct drm_mm_node *hole_node,
262262

263263
BUG_ON(!hole_node->hole_follows || node->allocated);
264264

265-
if (adj_start < start)
266-
adj_start = start;
267-
if (adj_end > end)
268-
adj_end = end;
269-
270265
if (mm->color_adjust)
271266
mm->color_adjust(hole_node, color, &adj_start, &adj_end);
272267

268+
adj_start = max(adj_start, start);
269+
adj_end = min(adj_end, end);
270+
273271
if (flags & DRM_MM_CREATE_TOP)
274272
adj_start = adj_end - size;
275273

@@ -475,17 +473,15 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
475473
flags & DRM_MM_SEARCH_BELOW) {
476474
u64 hole_size = adj_end - adj_start;
477475

478-
if (adj_start < start)
479-
adj_start = start;
480-
if (adj_end > end)
481-
adj_end = end;
482-
483476
if (mm->color_adjust) {
484477
mm->color_adjust(entry, color, &adj_start, &adj_end);
485478
if (adj_end <= adj_start)
486479
continue;
487480
}
488481

482+
adj_start = max(adj_start, start);
483+
adj_end = min(adj_end, end);
484+
489485
if (!check_free_hole(adj_start, adj_end, size, alignment))
490486
continue;
491487

0 commit comments

Comments
 (0)