panfrost: Take into account flags when looking up in the BO cache
authorTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 8 Aug 2019 05:10:32 +0000 (07:10 +0200)
committerTomeu Vizoso <tomeu.vizoso@collabora.com>
Thu, 8 Aug 2019 05:42:52 +0000 (07:42 +0200)
This will be useful right now so we avoid retrieving a non-executable
buffer when a executable one is needed.

As we support more flags, this logic will need to be extended to
consider the different trade-offs to be made when matching BO
specifications to BOs in the cache.

Signed-off-by: Tomeu Vizoso <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
src/gallium/drivers/panfrost/pan_allocate.h
src/gallium/drivers/panfrost/pan_bo_cache.c
src/gallium/drivers/panfrost/pan_drm.c

index 8d925ee38a4c9c2842c1ce02e92631ff2536a7c3..0e06567d206983520f5f2578a777f9f30c5bf525 100644 (file)
@@ -59,6 +59,8 @@ struct panfrost_bo {
         size_t size;
 
         int gem_handle;
+
+        uint32_t flags;
 };
 
 struct panfrost_memory {
index fba495c1dd6927410fa57e68b23037c8320eb38e..7378d0a8abea19ca1bb7ae195f027dc17c28b1f7 100644 (file)
@@ -84,11 +84,10 @@ panfrost_bo_cache_fetch(
 {
         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) {
+                if (entry->size >= size &&
+                    entry->flags == flags) {
                         /* This one works, splice it out of the cache */
                         list_del(&entry->link);
 
index a1f0bb446b58a7484ac4121efe249b646270864c..8ae541ae11b6256fef105b43d55e2de2daeac403 100644 (file)
@@ -123,6 +123,7 @@ panfrost_drm_create_bo(struct panfrost_screen *screen, size_t size,
                 bo->size = create_bo.size;
                 bo->gpu = create_bo.offset;
                 bo->gem_handle = create_bo.handle;
+                bo->flags = flags;
         }
 
         /* Only mmap now if we know we need to. For CPU-invisible buffers, we