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 <tomeu.vizoso@collabora.com>
Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
Tomeu Vizoso 2019-08-08 07:10:32 +02:00
parent 950b5fc596
commit 9398932c2d
3 changed files with 5 additions and 3 deletions

View file

@ -59,6 +59,8 @@ struct panfrost_bo {
size_t size;
int gem_handle;
uint32_t flags;
};
struct panfrost_memory {

View 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);

View 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