From 9398932c2d4cd1dfd337337a82ca8dc9bae35487 Mon Sep 17 00:00:00 2001 From: Tomeu Vizoso Date: Thu, 8 Aug 2019 07:10:32 +0200 Subject: [PATCH] panfrost: Take into account flags when looking up in the BO cache 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 Reviewed-by: Alyssa Rosenzweig --- src/gallium/drivers/panfrost/pan_allocate.h | 2 ++ src/gallium/drivers/panfrost/pan_bo_cache.c | 5 ++--- src/gallium/drivers/panfrost/pan_drm.c | 1 + 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/panfrost/pan_allocate.h b/src/gallium/drivers/panfrost/pan_allocate.h index 8d925ee38a4..0e06567d206 100644 --- a/src/gallium/drivers/panfrost/pan_allocate.h +++ b/src/gallium/drivers/panfrost/pan_allocate.h @@ -59,6 +59,8 @@ struct panfrost_bo { size_t size; int gem_handle; + + uint32_t flags; }; struct panfrost_memory { diff --git a/src/gallium/drivers/panfrost/pan_bo_cache.c b/src/gallium/drivers/panfrost/pan_bo_cache.c index fba495c1dd6..7378d0a8abe 100644 --- a/src/gallium/drivers/panfrost/pan_bo_cache.c +++ b/src/gallium/drivers/panfrost/pan_bo_cache.c @@ -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); diff --git a/src/gallium/drivers/panfrost/pan_drm.c b/src/gallium/drivers/panfrost/pan_drm.c index a1f0bb446b5..8ae541ae11b 100644 --- a/src/gallium/drivers/panfrost/pan_drm.c +++ b/src/gallium/drivers/panfrost/pan_drm.c @@ -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 -- 2.30.2