From aafe03d3d1cfd5cbdf345cd51436de268ac27b6f Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Mon, 29 Aug 2011 16:47:48 +0100 Subject: [PATCH] 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 --- src/sna/kgem.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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); } }