summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-27 23:18:05 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-27 23:20:36 +0000
commit03211f4b0b7e32b6d7dc28e60be72db204b8c8d4 (patch)
treea42b05e293bec785cc18712de2bcf1dc68d141d9
parent2afd49a28429cdeb36583cfc31cc9b1742c1fb83 (diff)
sna: Guard against the upload buffer growing past the maximum bo size
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index a5c47d60..86a43729 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -3010,7 +3010,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
!!(flags & KGEM_BUFFER_LAST)));
assert(size);
/* we should never be asked to create anything TOO large */
- assert(size < kgem->max_cpu_buffer);
+ assert(size < kgem->max_cpu_size);
list_for_each_entry(bo, &kgem->partial, base.list) {
if (flags == KGEM_BUFFER_LAST && bo->write) {
@@ -3053,6 +3053,8 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
#if !DBG_NO_MAP_UPLOAD
/* Be a little more generous and hope to hold fewer mmappings */
alloc = ALIGN(2*size, kgem->partial_buffer_size);
+ if (alloc >= kgem->max_cpu_size)
+ alloc = PAGE_ALIGN(size);
if (kgem->has_cpu_bo) {
bo = malloc(sizeof(*bo));
if (bo == NULL)