aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRob Clark2016-06-01 15:11:52 -0500
committerRob Clark2016-07-20 18:42:21 -0500
commit892141a321c7acd32000e145916217eda2da14bb (patch)
treef9f0e26dceae9892f1b385eed0b16c627e976cb7 /freedreno
parent19b82b9817b696cfe06d32340cb65231775b203b (diff)
downloadexternal-libdrm-892141a321c7acd32000e145916217eda2da14bb.tar.gz
external-libdrm-892141a321c7acd32000e145916217eda2da14bb.tar.xz
external-libdrm-892141a321c7acd32000e145916217eda2da14bb.zip
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>
Diffstat (limited to 'freedreno')
-rw-r--r--freedreno/msm/msm_device.c3
-rw-r--r--freedreno/msm/msm_priv.h1
-rw-r--r--freedreno/msm/msm_ringbuffer.c37
3 files changed, 39 insertions, 2 deletions
diff --git a/freedreno/msm/msm_device.c b/freedreno/msm/msm_device.c
index 25c097c2..727baa44 100644
--- a/freedreno/msm/msm_device.c
+++ b/freedreno/msm/msm_device.c
@@ -39,6 +39,7 @@
39static void msm_device_destroy(struct fd_device *dev) 39static void msm_device_destroy(struct fd_device *dev)
40{ 40{
41 struct msm_device *msm_dev = to_msm_device(dev); 41 struct msm_device *msm_dev = to_msm_device(dev);
42 fd_bo_cache_cleanup(&msm_dev->ring_cache, 0);
42 free(msm_dev); 43 free(msm_dev);
43} 44}
44 45
@@ -61,5 +62,7 @@ drm_private struct fd_device * msm_device_new(int fd)
61 dev = &msm_dev->base; 62 dev = &msm_dev->base;
62 dev->funcs = &funcs; 63 dev->funcs = &funcs;
63 64
65 fd_bo_cache_init(&msm_dev->ring_cache, TRUE);
66
64 return dev; 67 return dev;
65} 68}
diff --git a/freedreno/msm/msm_priv.h b/freedreno/msm/msm_priv.h
index e499b3b8..1f44398d 100644
--- a/freedreno/msm/msm_priv.h
+++ b/freedreno/msm/msm_priv.h
@@ -39,6 +39,7 @@
39 39
40struct msm_device { 40struct msm_device {
41 struct fd_device base; 41 struct fd_device base;
42 struct fd_bo_cache ring_cache;
42}; 43};
43 44
44static inline struct msm_device * to_msm_device(struct fd_device *x) 45static inline struct msm_device * to_msm_device(struct fd_device *x)
diff --git a/freedreno/msm/msm_ringbuffer.c b/freedreno/msm/msm_ringbuffer.c
index 32ed8b49..66ae1463 100644
--- a/freedreno/msm/msm_ringbuffer.c
+++ b/freedreno/msm/msm_ringbuffer.c
@@ -65,6 +65,39 @@ struct msm_ringbuffer {
65}; 65};
66 66
67static pthread_mutex_t idx_lock = PTHREAD_MUTEX_INITIALIZER; 67static pthread_mutex_t idx_lock = PTHREAD_MUTEX_INITIALIZER;
68drm_private extern pthread_mutex_t table_lock;
69
70static void ring_bo_del(struct fd_device *dev, struct fd_bo *bo)
71{
72 int ret;
73
74 pthread_mutex_lock(&table_lock);
75 ret = fd_bo_cache_free(&to_msm_device(dev)->ring_cache, bo);
76 pthread_mutex_unlock(&table_lock);
77
78 if (ret == 0)
79 return;
80
81 fd_bo_del(bo);
82}
83
84static struct fd_bo * ring_bo_new(struct fd_device *dev, uint32_t size)
85{
86 struct fd_bo *bo;
87
88 bo = fd_bo_cache_alloc(&to_msm_device(dev)->ring_cache, &size, 0);
89 if (bo)
90 return bo;
91
92 bo = fd_bo_new(dev, size, 0);
93 if (!bo)
94 return NULL;
95
96 /* keep ringbuffer bo's out of the normal bo cache: */
97 bo->bo_reuse = FALSE;
98
99 return bo;
100}
68 101
69static void *grow(void *ptr, uint32_t nr, uint32_t *max, uint32_t sz) 102static void *grow(void *ptr, uint32_t nr, uint32_t *max, uint32_t sz)
70{ 103{
@@ -344,7 +377,7 @@ static void msm_ringbuffer_destroy(struct fd_ringbuffer *ring)
344{ 377{
345 struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring); 378 struct msm_ringbuffer *msm_ring = to_msm_ringbuffer(ring);
346 if (msm_ring->ring_bo) 379 if (msm_ring->ring_bo)
347 fd_bo_del(msm_ring->ring_bo); 380 ring_bo_del(ring->pipe->dev, msm_ring->ring_bo);
348 free(msm_ring->submit.relocs); 381 free(msm_ring->submit.relocs);
349 free(msm_ring->submit.cmds); 382 free(msm_ring->submit.cmds);
350 free(msm_ring->submit.bos); 383 free(msm_ring->submit.bos);
@@ -377,7 +410,7 @@ drm_private struct fd_ringbuffer * msm_ringbuffer_new(struct fd_pipe *pipe,
377 ring = &msm_ring->base; 410 ring = &msm_ring->base;
378 ring->funcs = &funcs; 411 ring->funcs = &funcs;
379 412
380 msm_ring->ring_bo = fd_bo_new(pipe->dev, size, 0); 413 msm_ring->ring_bo = ring_bo_new(pipe->dev, size);
381 if (!msm_ring->ring_bo) { 414 if (!msm_ring->ring_bo) {
382 ERROR_MSG("ringbuffer allocation failed"); 415 ERROR_MSG("ringbuffer allocation failed");
383 goto fail; 416 goto fail;