diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-01 13:23:56 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-01 13:23:56 +0000 |
commit | c5632369cbd6473304c06e4230347abbe46513ec (patch) | |
tree | 523074c1ba8efa8603cdd1a259e60a90b60a3e4c | |
parent | 95f4da647a4055545b09cae0834df0fa2127a458 (diff) |
sna: Move the preservation of the io handle into the common destroy path
In order to capture and reuse all io buffers.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/kgem.c | 28 | ||||
-rw-r--r-- | src/sna/kgem.h | 1 |
2 files changed, 16 insertions, 13 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 959f97ca..ad08c6f6 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -611,7 +611,20 @@ static void __kgem_bo_destroy(struct kgem *kgem, struct kgem_bo *bo) if (NO_CACHE) goto destroy; - if(!bo->reusable) + if (bo->io) { + /* transfer the handle to a minimum bo */ + struct kgem_bo *base = malloc(sizeof(*base)); + if (base) { + memcpy(base, bo, sizeof (*base)); + base->reusable = true; + list_init(&base->list); + list_replace(&bo->request, &base->request); + free(bo); + bo = base; + } + } + + if (!bo->reusable) goto destroy; if (!bo->rq && !bo->needs_flush) { @@ -820,18 +833,6 @@ static void kgem_finish_partials(struct kgem *kgem) bo->need_io = 0; } - /* transfer the handle to a minimum bo */ - if (bo->base.refcnt == 1 && !bo->base.vmap) { - struct kgem_bo *base = malloc(sizeof(*base)); - if (base) { - memcpy(base, &bo->base, sizeof (*base)); - base->reusable = true; - list_init(&base->list); - list_replace(&bo->base.request, &base->request); - free(bo); - bo = (struct kgem_partial_bo *)base; - } - } kgem_bo_unref(kgem, &bo->base); } } @@ -2148,6 +2149,7 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, } } bo->need_io = write; + bo->base.io = write; } else { __kgem_bo_init(&bo->base, handle, alloc); bo->base.vmap = true; diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 112a91c3..59e64cf5 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -73,6 +73,7 @@ struct kgem_bo { uint32_t cpu_read : 1; uint32_t cpu_write : 1; uint32_t vmap : 1; + uint32_t io : 1; uint32_t flush : 1; uint32_t sync : 1; uint32_t purged : 1; |