summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2011-08-29 16:47:48 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2011-08-29 16:50:12 +0100
commitaafe03d3d1cfd5cbdf345cd51436de268ac27b6f (patch)
tree926ce71cee8fc9bb42a4c6a8eacb48aa787d52e6
parent28c8c5ca14c5b4eab7e2dc58c87050c1019037bb (diff)
sna: Retain the GTT space used for an upload buffer
In order to retain the GTT space without keeping hold of the memory used for the upload buffer, we have to create a new bo and copy the relevant details across. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--src/sna/kgem.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index ef829fe8..947fac4e 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -701,15 +701,29 @@ static void kgem_finish_partials(struct kgem *kgem)
continue;
}
+ list_del(&bo->base.list);
+
if (bo->write && bo->need_io) {
DBG(("%s: handle=%d, uploading %d/%d\n",
__FUNCTION__, bo->base.handle, bo->used, bo->alloc));
gem_write(kgem->fd, bo->base.handle,
0, bo->used, bo+1);
bo->need_io = 0;
+
+ /* transfer the handle to a minimum bo */
+ if (bo->base.refcnt == 1) {
+ struct kgem_bo *base = malloc(sizeof(*base));
+ if (base) {
+ memcpy(base, &bo->base, sizeof (*base));
+ list_init(&base->list);
+ list_replace(&bo->base.request,
+ &base->request);
+ free(bo);
+ bo = (struct kgem_partial_bo *)base;
+ }
+ }
}
- list_del(&bo->base.list);
kgem_bo_unref(kgem, &bo->base);
}
}