sna: Guard against the upload buffer growing past the maximum bo size

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2012-01-27 23:18:05 +00:00
parent 2afd49a284
commit 03211f4b0b
1 changed files with 3 additions and 1 deletions

View File

@ -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)