panfrost: Implement panfrost_bo_cache_get
authorAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 15 Jul 2019 16:08:32 +0000 (09:08 -0700)
committerAlyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
Mon, 15 Jul 2019 23:12:56 +0000 (16:12 -0700)
Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_bo_cache.c

index 2b7a5d208a66e299f2f90eb513111509e5f5feed..4cbec51a2c1866a15c91fdf003a1191d3dbeba41 100644 (file)
@@ -82,7 +82,22 @@ panfrost_bo_cache_fetch(
                 struct panfrost_screen *screen,
                 size_t size, uint32_t flags)
 {
-        /* Stub */
+        struct list_head *bucket = pan_bucket(screen, size);
+
+        /* TODO: Honour flags? */
+
+        /* Iterate the bucket looking for something suitable */
+        list_for_each_entry_safe(struct panfrost_bo, entry, bucket, link) {
+                if (entry->size >= size) {
+                        /* This one works, splice it out of the cache */
+                        list_del(&entry->link);
+
+                        /* Let's go! */
+                        return entry;
+                }
+        }
+
+        /* We didn't find anything */
         return NULL;
 }