summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-02-01 14:52:56 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-02-01 14:52:56 +0000
commit2d0e7c7ecd7371ac7b5fe3f382fc5d04792f7019 (patch)
tree87a05dca14a7842a7eb6e872d4d588dd78d54f8e
parent55c7088f54655609fbb00106679a566b46ee8dba (diff)
sna: Search again for a just-large-enough mapping for inplace uploads
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c7
1 files changed, 7 insertions, 0 deletions
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));