freedreno: support either coarse or fine-grained bucket sizes
authorRob Clark <robclark@freedesktop.org>
Wed, 1 Jun 2016 19:37:52 +0000 (15:37 -0400)
committerRob Clark <robclark@freedesktop.org>
Wed, 20 Jul 2016 23:42:21 +0000 (19:42 -0400)
The normal bo cache uses some intermediate steps between power of two
jumps to reduce memory wastage.  But for a ringbuffer bo cache, we do
not need this.

Signed-off-by: Rob Clark <robclark@freedesktop.org>
freedreno/freedreno_bo_cache.c
freedreno/freedreno_device.c
freedreno/freedreno_priv.h

index 58d171e..7becb0d 100644 (file)
@@ -49,8 +49,12 @@ add_bucket(struct fd_bo_cache *cache, int size)
        cache->num_buckets++;
 }
 
+/**
+ * @coarse: if true, only power-of-two bucket sizes, otherwise
+ *    fill in for a bit smoother size curve..
+ */
 drm_private void
-fd_bo_cache_init(struct fd_bo_cache *cache)
+fd_bo_cache_init(struct fd_bo_cache *cache, int course)
 {
        unsigned long size, cache_max_size = 64 * 1024 * 1024;
 
@@ -64,14 +68,17 @@ fd_bo_cache_init(struct fd_bo_cache *cache)
         */
        add_bucket(cache, 4096);
        add_bucket(cache, 4096 * 2);
-       add_bucket(cache, 4096 * 3);
+       if (!course)
+               add_bucket(cache, 4096 * 3);
 
        /* Initialize the linked lists for BO reuse cache. */
        for (size = 4 * 4096; size <= cache_max_size; size *= 2) {
                add_bucket(cache, size);
-               add_bucket(cache, size + size * 1 / 4);
-               add_bucket(cache, size + size * 2 / 4);
-               add_bucket(cache, size + size * 3 / 4);
+               if (!course) {
+                       add_bucket(cache, size + size * 1 / 4);
+                       add_bucket(cache, size + size * 2 / 4);
+                       add_bucket(cache, size + size * 3 / 4);
+               }
        }
 }
 
index b99bce2..fcbf140 100644 (file)
@@ -85,7 +85,7 @@ out:
        dev->fd = fd;
        dev->handle_table = drmHashCreate();
        dev->name_table = drmHashCreate();
-       fd_bo_cache_init(&dev->bo_cache);
+       fd_bo_cache_init(&dev->bo_cache, FALSE);
 
        return dev;
 }
index 5e8f03d..9737b32 100644 (file)
@@ -104,7 +104,7 @@ struct fd_device {
        int closefd;        /* call close(fd) upon destruction */
 };
 
-drm_private void fd_bo_cache_init(struct fd_bo_cache *cache);
+drm_private void fd_bo_cache_init(struct fd_bo_cache *cache, int coarse);
 drm_private void fd_bo_cache_cleanup(struct fd_bo_cache *cache, time_t time);
 drm_private struct fd_bo * fd_bo_cache_alloc(struct fd_bo_cache *cache,
                uint32_t *size, uint32_t flags);