From 2d0e7c7ecd7371ac7b5fe3f382fc5d04792f7019 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Wed, 1 Feb 2012 14:52:56 +0000 Subject: sna: Search again for a just-large-enough mapping for inplace uploads Signed-off-by: Chris Wilson --- src/sna/kgem.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index b4465583..d2580e6f 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -104,6 +104,8 @@ static inline void list_replace(struct list *old, #endif #define PAGE_ALIGN(x) ALIGN(x, PAGE_SIZE) +#define NUM_PAGES(x) (((x) + PAGE_SIZE-1) / PAGE_SIZE) + #define MAX_GTT_VMA_CACHE 512 #define MAX_CPU_VMA_CACHE INT16_MAX #define MAP_PRESERVE_TIME 10 @@ -3215,6 +3217,8 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, old = search_linear_cache(kgem, alloc, CREATE_CPU_MAP); if (old == NULL) old = search_linear_cache(kgem, alloc, CREATE_INACTIVE | CREATE_CPU_MAP); + if (old == NULL) + old = search_linear_cache(kgem, NUM_PAGES(size), CREATE_INACTIVE | CREATE_CPU_MAP); if (old) { DBG(("%s: reusing handle=%d for buffer\n", __FUNCTION__, old->handle)); @@ -3290,6 +3294,9 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, } } #endif + if (old == NULL) + old = search_linear_cache(kgem, NUM_PAGES(size), + CREATE_INACTIVE | CREATE_GTT_MAP); if (old) { DBG(("%s: reusing handle=%d for buffer\n", __FUNCTION__, old->handle)); -- cgit v1.2.3