freedreno/msm: use private bo-cache for ringbuffer bo's
Since they get vmap'd on the kernel side, they are a bit more costly. Don't let them mingle with the riffraff. Signed-off-by: Rob Clark <robclark@freedesktop.org>main
parent
19b82b9817
commit
892141a321
|
@ -39,6 +39,7 @@
|
|||
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);
|
||||
}
|
||||
|
||||
|
@ -61,5 +62,7 @@ drm_private struct fd_device * msm_device_new(int fd)
|
|||
dev = &msm_dev->base;
|
||||
dev->funcs = &funcs;
|
||||
|
||||
fd_bo_cache_init(&msm_dev->ring_cache, TRUE);
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
|
||||
struct msm_device {
|
||||
struct fd_device base;
|
||||
struct fd_bo_cache ring_cache;
|
||||
};
|
||||
|
||||
static inline struct msm_device * to_msm_device(struct fd_device *x)
|
||||
|
|
|
@ -65,6 +65,39 @@ struct msm_ringbuffer {
|
|||
};
|
||||
|
||||
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)
|
||||
{
|
||||
|
@ -344,7 +377,7 @@ static void msm_ringbuffer_destroy(struct fd_ringbuffer *ring)
|
|||
{
|
||||
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);
|
||||
|
@ -377,7 +410,7 @@ drm_private struct fd_ringbuffer * msm_ringbuffer_new(struct fd_pipe *pipe,
|
|||
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;
|
||||
|
|
Loading…
Reference in New Issue