diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_bo.c | 18 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_screen.c | 8 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_screen.h | 13 |
3 files changed, 21 insertions, 18 deletions
diff --git a/src/gallium/drivers/panfrost/pan_bo.c b/src/gallium/drivers/panfrost/pan_bo.c index aa60620ccdf..1fe7e225b8a 100644 --- a/src/gallium/drivers/panfrost/pan_bo.c +++ b/src/gallium/drivers/panfrost/pan_bo.c @@ -186,7 +186,7 @@ pan_bucket_index(unsigned size) static struct list_head * pan_bucket(struct panfrost_screen *screen, unsigned size) { - return &screen->bo_cache[pan_bucket_index(size)]; + return &screen->bo_cache.buckets[pan_bucket_index(size)]; } /* Tries to fetch a BO of sufficient size with the appropriate flags from the @@ -198,7 +198,7 @@ static struct panfrost_bo * panfrost_bo_cache_fetch(struct panfrost_screen *screen, size_t size, uint32_t flags, bool dontwait) { - pthread_mutex_lock(&screen->bo_cache_lock); + pthread_mutex_lock(&screen->bo_cache.lock); struct list_head *bucket = pan_bucket(screen, size); struct panfrost_bo *bo = NULL; @@ -229,7 +229,7 @@ panfrost_bo_cache_fetch(struct panfrost_screen *screen, bo = entry; break; } - pthread_mutex_unlock(&screen->bo_cache_lock); + pthread_mutex_unlock(&screen->bo_cache.lock); return bo; } @@ -245,7 +245,7 @@ panfrost_bo_cache_put(struct panfrost_bo *bo) if (bo->flags & PAN_BO_DONT_REUSE) return false; - pthread_mutex_lock(&screen->bo_cache_lock); + pthread_mutex_lock(&screen->bo_cache.lock); struct list_head *bucket = pan_bucket(screen, bo->size); struct drm_panfrost_madvise madv; @@ -257,7 +257,7 @@ panfrost_bo_cache_put(struct panfrost_bo *bo) /* Add us to the bucket */ list_addtail(&bo->link, bucket); - pthread_mutex_unlock(&screen->bo_cache_lock); + pthread_mutex_unlock(&screen->bo_cache.lock); return true; } @@ -272,16 +272,16 @@ void panfrost_bo_cache_evict_all( struct panfrost_screen *screen) { - pthread_mutex_lock(&screen->bo_cache_lock); - for (unsigned i = 0; i < ARRAY_SIZE(screen->bo_cache); ++i) { - struct list_head *bucket = &screen->bo_cache[i]; + pthread_mutex_lock(&screen->bo_cache.lock); + for (unsigned i = 0; i < ARRAY_SIZE(screen->bo_cache.buckets); ++i) { + struct list_head *bucket = &screen->bo_cache.buckets[i]; list_for_each_entry_safe(struct panfrost_bo, entry, bucket, link) { list_del(&entry->link); panfrost_bo_free(entry); } } - pthread_mutex_unlock(&screen->bo_cache_lock); + pthread_mutex_unlock(&screen->bo_cache.lock); } void diff --git a/src/gallium/drivers/panfrost/pan_screen.c b/src/gallium/drivers/panfrost/pan_screen.c index 8d54f8c0aa1..9e98cf3375c 100644 --- a/src/gallium/drivers/panfrost/pan_screen.c +++ b/src/gallium/drivers/panfrost/pan_screen.c @@ -547,7 +547,7 @@ panfrost_destroy_screen(struct pipe_screen *pscreen) { struct panfrost_screen *screen = pan_screen(pscreen); panfrost_bo_cache_evict_all(screen); - pthread_mutex_destroy(&screen->bo_cache_lock); + pthread_mutex_destroy(&screen->bo_cache.lock); pthread_mutex_destroy(&screen->active_bos_lock); drmFreeVersion(screen->kernel_version); ralloc_free(screen); @@ -754,9 +754,9 @@ panfrost_create_screen(int fd, struct renderonly *ro) screen->active_bos = _mesa_set_create(screen, panfrost_active_bos_hash, panfrost_active_bos_cmp); - pthread_mutex_init(&screen->bo_cache_lock, NULL); - for (unsigned i = 0; i < ARRAY_SIZE(screen->bo_cache); ++i) - list_inithead(&screen->bo_cache[i]); + pthread_mutex_init(&screen->bo_cache.lock, NULL); + for (unsigned i = 0; i < ARRAY_SIZE(screen->bo_cache.buckets); ++i) + list_inithead(&screen->bo_cache.buckets[i]); if (pan_debug & PAN_DBG_TRACE) pandecode_initialize(); diff --git a/src/gallium/drivers/panfrost/pan_screen.h b/src/gallium/drivers/panfrost/pan_screen.h index 2e613fbe60f..dde745fb0ed 100644 --- a/src/gallium/drivers/panfrost/pan_screen.h +++ b/src/gallium/drivers/panfrost/pan_screen.h @@ -89,13 +89,16 @@ struct panfrost_screen { pthread_mutex_t active_bos_lock; struct set *active_bos; - pthread_mutex_t bo_cache_lock; + struct { + pthread_mutex_t lock; - /* The BO cache is a set of buckets with power-of-two sizes ranging - * from 2^12 (4096, the page size) to 2^(12 + MAX_BO_CACHE_BUCKETS). - * Each bucket is a linked list of free panfrost_bo objects. */ + /* The BO cache is a set of buckets with power-of-two sizes + * ranging from 2^12 (4096, the page size) to + * 2^(12 + MAX_BO_CACHE_BUCKETS). + * Each bucket is a linked list of free panfrost_bo objects. */ - struct list_head bo_cache[NR_BO_CACHE_BUCKETS]; + struct list_head buckets[NR_BO_CACHE_BUCKETS]; + } bo_cache; }; static inline struct panfrost_screen * |