summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2013-06-25 22:25:25 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2013-06-26 10:02:41 +0100
commit77fa8ab08b441934218ddb8f690be1a919f0ec64 (patch)
tree742d7f463f913c25658d8713ccfaff553a78f7f6
parent273716029e5318f1670e7111be2085c950995d42 (diff)
sna: Free just-allocated bo if we fail to set-tiling on CREATE_EXACT
If the caller requires an exactly constructed bo, abandon the attempt if we cannot set the tiling as specified. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 8e056d32..a9724e10 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -3777,6 +3777,7 @@ large_inactive:
list_del(&bo->list);
+ assert(bo->domain != DOMAIN_GPU);
bo->unique_id = kgem_get_unique_id(kgem);
bo->pitch = pitch;
bo->delta = 0;
@@ -3827,9 +3828,11 @@ large_inactive:
break;
}
+ assert(bo->tiling == tiling);
bo->pitch = pitch;
bo->delta = 0;
bo->unique_id = kgem_get_unique_id(kgem);
+ bo->domain = DOMAIN_NONE;
kgem_bo_remove_from_inactive(kgem, bo);
@@ -4092,18 +4095,26 @@ create:
return NULL;
}
- bo->domain = DOMAIN_CPU;
- bo->unique_id = kgem_get_unique_id(kgem);
- bo->pitch = pitch;
- if (tiling != I915_TILING_NONE &&
- gem_set_tiling(kgem->fd, handle, tiling, pitch))
- bo->tiling = tiling;
if (bucket >= NUM_CACHE_BUCKETS) {
DBG(("%s: marking large bo for automatic flushing\n",
__FUNCTION__));
bo->flush = true;
}
+ bo->unique_id = kgem_get_unique_id(kgem);
+ if (tiling == I915_TILING_NONE ||
+ gem_set_tiling(kgem->fd, handle, tiling, pitch)) {
+ bo->tiling = tiling;
+ bo->pitch = pitch;
+ } else {
+ if (flags & CREATE_EXACT) {
+ if (bo->pitch != pitch || bo->tiling != tiling) {
+ kgem_bo_free(kgem, bo);
+ return NULL;
+ }
+ }
+ }
+
assert(bytes(bo) >= bo->pitch * kgem_aligned_height(kgem, height, bo->tiling));
debug_alloc__bo(kgem, bo);