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
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;
bo = entry;
break;
}
- pthread_mutex_unlock(&screen->bo_cache_lock);
+ pthread_mutex_unlock(&screen->bo_cache.lock);
return 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;
/* 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;
}
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
{
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);
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();
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 *