aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu
diff options
context:
space:
mode:
authorMichel Dänzer <michel.daenzer@amd.com>2014-03-19 04:37:14 -0400
committerDave Airlie <airlied@redhat.com>2014-04-03 20:12:21 -0400
commit145bccd2397b53f2163c37e73413d80bfcbb8e35 (patch)
tree2dd49386d2a4a2a500badc1f9dedc41c0c3d2b95 /drivers/gpu
parent740c22ae516c22f07ac275713d684581df08a386 (diff)
drm/mm: Fix search for smallest hole satisfying constraints
entry->size is the size of the node, not the size of the hole after it. So the code would actually find the hole which can satisfy the constraints and which is preceded by the smallest node, not the smallest hole satisfying the constraints. Reported-by: "Huang, FrankR" <FrankR.Huang@amd.com> Signed-off-by: Michel Dänzer <michel.daenzer@amd.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
Diffstat (limited to 'drivers/gpu')
-rw-r--r--drivers/gpu/drm/drm_mm.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/drivers/gpu/drm/drm_mm.c b/drivers/gpu/drm/drm_mm.c
index 8f64be44bfe7..71e2d3fcd6ee 100644
--- a/drivers/gpu/drm/drm_mm.c
+++ b/drivers/gpu/drm/drm_mm.c
@@ -423,6 +423,8 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,
423 423
424 __drm_mm_for_each_hole(entry, mm, adj_start, adj_end, 424 __drm_mm_for_each_hole(entry, mm, adj_start, adj_end,
425 flags & DRM_MM_SEARCH_BELOW) { 425 flags & DRM_MM_SEARCH_BELOW) {
426 unsigned long hole_size = adj_end - adj_start;
427
426 if (mm->color_adjust) { 428 if (mm->color_adjust) {
427 mm->color_adjust(entry, color, &adj_start, &adj_end); 429 mm->color_adjust(entry, color, &adj_start, &adj_end);
428 if (adj_end <= adj_start) 430 if (adj_end <= adj_start)
@@ -435,9 +437,9 @@ static struct drm_mm_node *drm_mm_search_free_generic(const struct drm_mm *mm,
435 if (!(flags & DRM_MM_SEARCH_BEST)) 437 if (!(flags & DRM_MM_SEARCH_BEST))
436 return entry; 438 return entry;
437 439
438 if (entry->size < best_size) { 440 if (hole_size < best_size) {
439 best = entry; 441 best = entry;
440 best_size = entry->size; 442 best_size = hole_size;
441 } 443 }
442 } 444 }
443 445
@@ -465,6 +467,8 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
465 467
466 __drm_mm_for_each_hole(entry, mm, adj_start, adj_end, 468 __drm_mm_for_each_hole(entry, mm, adj_start, adj_end,
467 flags & DRM_MM_SEARCH_BELOW) { 469 flags & DRM_MM_SEARCH_BELOW) {
470 unsigned long hole_size = adj_end - adj_start;
471
468 if (adj_start < start) 472 if (adj_start < start)
469 adj_start = start; 473 adj_start = start;
470 if (adj_end > end) 474 if (adj_end > end)
@@ -482,9 +486,9 @@ static struct drm_mm_node *drm_mm_search_free_in_range_generic(const struct drm_
482 if (!(flags & DRM_MM_SEARCH_BEST)) 486 if (!(flags & DRM_MM_SEARCH_BEST))
483 return entry; 487 return entry;
484 488
485 if (entry->size < best_size) { 489 if (hole_size < best_size) {
486 best = entry; 490 best = entry;
487 best_size = entry->size; 491 best_size = hole_size;
488 } 492 }
489 } 493 }
490 494