summaryrefslogtreecommitdiff
path: root/armada_bufmgr.c
diff options
context:
space:
mode:
authorRussell King <rmk@arm.linux.org.uk>2014-10-12 19:47:43 +0100
committerRussell King <rmk@arm.linux.org.uk>2014-10-12 20:19:54 +0100
commit07d788ea1e7787c07ab5d3a4ac1c873e409bd50b (patch)
tree814df671bd65630e47b7227834cdcd060e8443a5 /armada_bufmgr.c
parent996c63e91604ae5980cfbb6f37adfb462619a36a (diff)
Better tracking of re-usable bos
Whether a bo can be re-used or not depends whether we have flink'd it, whether it was imported from a global name, or imported from a fd. Signed-off-by: Russell King <rmk@arm.linux.org.uk>
Diffstat (limited to 'armada_bufmgr.c')
-rw-r--r--armada_bufmgr.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/armada_bufmgr.c b/armada_bufmgr.c
index 938138f..0803309 100644
--- a/armada_bufmgr.c
+++ b/armada_bufmgr.c
@@ -74,6 +74,7 @@ struct armada_bo {
size_t alloc_size; /* Allocated size */
uint32_t ref; /* Reference count */
uint32_t name; /* Global name */
+ uint8_t reusable;
};
#define to_armada_bo(_bo) container_of(_bo, struct armada_bo, bo)
@@ -326,6 +327,7 @@ struct drm_armada_bo *drm_armada_bo_create(struct drm_armada_bufmgr *mgr,
bo->alloc_size = alloc_size;
bo->ref = 1;
bo->mgr = mgr;
+ bo->reusable = 1;
/* Add it to the handle hash table */
assert(drmHashInsert(mgr->handle_hash, bo->bo.handle, bo) == 0);
@@ -383,6 +385,7 @@ struct drm_armada_bo *drm_armada_bo_create_size(struct drm_armada_bufmgr *mgr,
bo->alloc_size = alloc_size;
bo->ref = 1;
bo->mgr = mgr;
+ bo->reusable = 1;
/* Add it to the handle hash table */
assert(drmHashInsert(mgr->handle_hash, bo->bo.handle, bo) == 0);
@@ -492,7 +495,7 @@ void drm_armada_bo_put(struct drm_armada_bo *dbo)
if (bo->ref-- == 1) {
int ret;
- if (bo->bo.type == DRM_ARMADA_BO_SHMEM)
+ if (bo->reusable)
armada_bo_cache_put(bo);
else
armada_bo_free(bo);
@@ -514,6 +517,7 @@ int drm_armada_bo_flink(struct drm_armada_bo *dbo, uint32_t *name)
if (ret)
return ret;
bo->name = flink.name;
+ bo->reusable = 0;
assert(drmHashInsert(bo->mgr->name_hash, bo->name, bo) == 0);
}