summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2012-01-12 01:38:18 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2012-01-12 02:21:26 +0000
commit112b8959261712aaa82f92af0aca4b97fa7c7f03 (patch)
tree6666b8a2d7997132045b9436b35c9f4803f6b618
parentb09ae4c20313fea7af11f77cd673039635d4dcc7 (diff)
sna: Prevent shrinking a partial buffer stolen for a read
If we reuse a partial buffer for a read, we cannot shrink it during upload to the device as we do not track how many bytes we actually need for the read operation. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 45700ea3..d9cc809c 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -112,6 +112,7 @@ struct kgem_partial_bo {
uint32_t used;
uint32_t need_io : 1;
uint32_t write : 1;
+ uint32_t shrink : 1;
};
static struct kgem_bo *__kgem_freed_bo;
@@ -1195,7 +1196,7 @@ static void kgem_finish_partials(struct kgem *kgem)
}
assert(bo->base.rq == kgem->next_request);
- if (bo->need_io && bo->used < bo->base.size / 2) {
+ if (bo->shrink && bo->used < bo->base.size / 2) {
struct kgem_bo *shrink;
shrink = search_linear_cache(kgem,
@@ -2886,11 +2887,13 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
DBG(("%s: reusing write buffer for read of %d bytes? used=%d, total=%d\n",
__FUNCTION__, size, bo->used, bo->base.size));
offset = 0;
+ bo->shrink = 0;
goto done;
} else if (bo->used + size <= bo->base.size) {
DBG(("%s: reusing unfinished write buffer for read of %d bytes? used=%d, total=%d\n",
__FUNCTION__, size, bo->used, bo->base.size));
offset = bo->used;
+ bo->shrink = 0;
goto done;
}
}
@@ -3036,6 +3039,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem,
bo->used = size;
bo->write = write;
+ bo->shrink = bo->need_io;
offset = 0;
list_add(&bo->base.list, &kgem->partial);