static void msm_device_destroy(struct fd_device *dev)
{
struct msm_device *msm_dev = to_msm_device(dev);
+ fd_bo_cache_cleanup(&msm_dev->ring_cache, 0);
free(msm_dev);
}
dev = &msm_dev->base;
dev->funcs = &funcs;
+ fd_bo_cache_init(&msm_dev->ring_cache, TRUE);
+
return dev;
}
};
static pthread_mutex_t idx_lock = PTHREAD_MUTEX_INITIALIZER;
+drm_private extern pthread_mutex_t table_lock;
+
+static void ring_bo_del(struct fd_device *dev, struct fd_bo *bo)
+{
+ int ret;
+
+ pthread_mutex_lock(&table_lock);
+ ret = fd_bo_cache_free(&to_msm_device(dev)->ring_cache, bo);
+ pthread_mutex_unlock(&table_lock);
+
+ if (ret == 0)
+ return;
+
+ fd_bo_del(bo);
+}
+
+static struct fd_bo * ring_bo_new(struct fd_device *dev, uint32_t size)
+{
+ struct fd_bo *bo;
+
+ bo = fd_bo_cache_alloc(&to_msm_device(dev)->ring_cache, &size, 0);
+ if (bo)
+ return bo;
+
+ bo = fd_bo_new(dev, size, 0);
+ if (!bo)
+ return NULL;
+
+ /* keep ringbuffer bo's out of the normal bo cache: */
+ bo->bo_reuse = FALSE;
+
+ return bo;
+}
static void *grow(void *ptr, uint32_t nr, uint32_t *max, uint32_t sz)
{
{
struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
if (msm_ring->ring_bo)
- fd_bo_del(msm_ring->ring_bo);
+ ring_bo_del(ring->pipe->dev, msm_ring->ring_bo);
free(msm_ring->submit.relocs);
free(msm_ring->submit.cmds);
free(msm_ring->submit.bos);
ring = &msm_ring->base;
ring->funcs = &funcs;
- msm_ring->ring_bo = fd_bo_new(pipe->dev, size, 0);
+ msm_ring->ring_bo = ring_bo_new(pipe->dev, size);
if (!msm_ring->ring_bo) {
ERROR_MSG("ringbuffer allocation failed");
goto fail;