From 4e64e5539d152e202ad6eea2b6f65f3ab58d9428 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 2 Feb 2017 21:04:38 +0000 Subject: drm: Improve drm_mm search (and fix topdown allocation) with rbtrees MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The drm_mm range manager claimed to support top-down insertion, but it was neither searching for the top-most hole that could fit the allocation request nor fitting the request to the hole correctly. In order to search the range efficiently, we create a secondary index for the holes using either their size or their address. This index allows us to find the smallest hole or the hole at the bottom or top of the range efficiently, whilst keeping the hole stack to rapidly service evictions. v2: Search for holes both high and low. Rename flags to mode. v3: Discover rb_entry_safe() and use it! v4: Kerneldoc for enum drm_mm_insert_mode. Signed-off-by: Chris Wilson Reviewed-by: Joonas Lahtinen Cc: Alex Deucher Cc: "Christian König" Cc: David Airlie Cc: Russell King Cc: Daniel Vetter Cc: Jani Nikula Cc: Sean Paul Cc: Lucas Stach Cc: Christian Gmeiner Cc: Rob Clark Cc: Thierry Reding Cc: Stephen Warren Cc: Alexandre Courbot Cc: Eric Anholt Cc: Sinclair Yeh Cc: Thomas Hellstrom Reviewed-by: Alex Deucher Reviewed-by: Sinclair Yeh # vmwgfx Reviewed-by: Lucas Stach #etnaviv Signed-off-by: Daniel Vetter Link: http://patchwork.freedesktop.org/patch/msgid/20170202210438.28702-1-chris@chris-wilson.co.uk --- drivers/gpu/drm/msm/msm_gem_vma.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'drivers/gpu/drm/msm/msm_gem_vma.c') diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c index a311d26ccb21..b654eca7636a 100644 --- a/drivers/gpu/drm/msm/msm_gem_vma.c +++ b/drivers/gpu/drm/msm/msm_gem_vma.c @@ -45,8 +45,7 @@ msm_gem_map_vma(struct msm_gem_address_space *aspace, if (WARN_ON(drm_mm_node_allocated(&vma->node))) return 0; - ret = drm_mm_insert_node(&aspace->mm, &vma->node, npages, - 0, DRM_MM_SEARCH_DEFAULT); + ret = drm_mm_insert_node(&aspace->mm, &vma->node, npages); if (ret) return ret; -- cgit v1.2.3