diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2014-01-31 16:42:46 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2014-01-31 16:42:46 +0000 |
commit | bdb1a62ce21f3eb5e27e411b78f13ad2aea963a4 (patch) | |
tree | d633400a14a589bce5135521c1a6c4f36d59e2f5 | |
parent | f934ee78a000815e14e36bd0caa279cb35d07bfe (diff) |
sna: Balance memory accounting for buffer objects
A couple bugs ended up with CPU bo gradually accumulating whilst the
overall number of bo vanished.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/sna/kgem.c | 19 | ||||
-rw-r--r-- | src/sna/sna_accel.c | 4 |
2 files changed, 12 insertions, 11 deletions
diff --git a/src/sna/kgem.c b/src/sna/kgem.c index b3d3c4b0..f7404dfb 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -228,7 +228,6 @@ static void debug_alloc__bo(struct kgem *kgem, struct kgem_bo *bo) debug_alloc(kgem, bytes(bo)); } #else -#define debug_alloc(k, b) #define debug_alloc__bo(k, b) #endif @@ -4696,10 +4695,9 @@ create: bo->pitch = pitch; } else { if (flags & CREATE_EXACT) { - if (bo->pitch != pitch || bo->tiling != tiling) { - kgem_bo_free(kgem, bo); - return NULL; - } + gem_close(kgem->fd, handle); + free(bo); + return NULL; } } @@ -5949,8 +5947,8 @@ create_snoopable_buffer(struct kgem *kgem, unsigned alloc) return NULL; } - debug_alloc(kgem, alloc); __kgem_bo_init(&bo->base, handle, alloc); + debug_alloc__bo(kgem, &bo->base); DBG(("%s: created CPU (LLC) handle=%d for buffer, size %d\n", __FUNCTION__, bo->base.handle, alloc)); } @@ -5985,8 +5983,8 @@ create_snoopable_buffer(struct kgem *kgem, unsigned alloc) return NULL; } - debug_alloc(kgem, alloc); __kgem_bo_init(&bo->base, handle, alloc); + debug_alloc__bo(kgem, &bo->base); DBG(("%s: created CPU handle=%d for buffer, size %d\n", __FUNCTION__, bo->base.handle, alloc)); } @@ -6029,8 +6027,8 @@ free_caching: return NULL; } - debug_alloc(kgem, alloc); __kgem_bo_init(&bo->base, handle, alloc); + debug_alloc__bo(kgem, &bo->base); DBG(("%s: created snoop handle=%d for buffer\n", __FUNCTION__, bo->base.handle)); @@ -6200,10 +6198,9 @@ struct kgem_bo *kgem_create_buffer(struct kgem *kgem, goto skip_llc; } __kgem_bo_init(&bo->base, handle, alloc); + debug_alloc__bo(kgem, &bo->base); DBG(("%s: created LLC handle=%d for buffer\n", __FUNCTION__, bo->base.handle)); - - debug_alloc(kgem, alloc); } assert(bo->mmapped); @@ -6366,7 +6363,7 @@ skip_llc: __FUNCTION__, handle)); __kgem_bo_init(&bo->base, handle, alloc); - debug_alloc(kgem, alloc * PAGE_SIZE); + debug_alloc__bo(kgem, &bo->base); } assert(bo->mmapped); diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index bbb6e2be..c9033858 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3863,6 +3863,10 @@ sna_pixmap_move_to_gpu(PixmapPtr pixmap, unsigned flags) kgem_bo_convert_to_gpu(&sna->kgem, priv->cpu_bo)) { assert(!priv->mapped); assert(!IS_STATIC_PTR(priv->ptr)); +#ifdef DEBUG_MEMORY + sna->debug_memory.cpu_bo_allocs--; + sna->debug_memory.cpu_bo_bytes -= kgem_bo_size(priv->cpu_bo); +#endif priv->gpu_bo = priv->cpu_bo; priv->cpu_bo = NULL; priv->ptr = NULL; |