drm: Add support for two-ended allocation, v3
Clients like i915 need to segregate cache domains within the GTT which can lead to small amounts of fragmentation. By allocating the uncached buffers from the bottom and the cacheable buffers from the top, we can reduce the amount of wasted space and also optimize allocation of the mappable portion of the GTT to only those buffers that require CPU access through the GTT. For other drivers, allocating small bos from one end and large ones from the other helps improve the quality of fragmentation. Based on drm_mm work by Chris Wilson. v3: Changed to use a TTM placement flag v2: Updated kerneldoc Cc: Chris Wilson <chris@chris-wilson.co.uk> Cc: Ben Widawsky <ben@bwidawsk.net> Cc: Christian König <deathsimple@vodafone.de> Signed-off-by: Lauri Kasanen <cand@gmx.com> Signed-off-by: David Airlie <airlied@redhat.com>
This commit is contained in:

committed by
Dave Airlie

vanhempi
2614dc6683
commit
62347f9e0f
@@ -55,6 +55,7 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
|
||||
struct ttm_range_manager *rman = (struct ttm_range_manager *) man->priv;
|
||||
struct drm_mm *mm = &rman->mm;
|
||||
struct drm_mm_node *node = NULL;
|
||||
enum drm_mm_allocator_flags aflags = DRM_MM_CREATE_DEFAULT;
|
||||
unsigned long lpfn;
|
||||
int ret;
|
||||
|
||||
@@ -66,11 +67,15 @@ static int ttm_bo_man_get_node(struct ttm_mem_type_manager *man,
|
||||
if (!node)
|
||||
return -ENOMEM;
|
||||
|
||||
if (bo->mem.placement & TTM_PL_FLAG_TOPDOWN)
|
||||
aflags = DRM_MM_CREATE_TOP;
|
||||
|
||||
spin_lock(&rman->lock);
|
||||
ret = drm_mm_insert_node_in_range(mm, node, mem->num_pages,
|
||||
mem->page_alignment,
|
||||
ret = drm_mm_insert_node_in_range_generic(mm, node, mem->num_pages,
|
||||
mem->page_alignment, 0,
|
||||
placement->fpfn, lpfn,
|
||||
DRM_MM_SEARCH_BEST);
|
||||
DRM_MM_SEARCH_BEST,
|
||||
aflags);
|
||||
spin_unlock(&rman->lock);
|
||||
|
||||
if (unlikely(ret)) {
|
||||
|
Viittaa uudesa ongelmassa
Block a user