Lines Matching refs:cache
30 static void add_bucket(struct etna_bo_cache *cache, int size)
32 unsigned i = cache->num_buckets;
34 assert(i < ARRAY_SIZE(cache->cache_bucket));
36 list_inithead(&cache->cache_bucket[i].list);
37 cache->cache_bucket[i].size = size;
38 cache->num_buckets++;
41 void etna_bo_cache_init(struct etna_bo_cache *cache)
51 * get us useful cache hit rates anyway)
53 add_bucket(cache, 4096);
54 add_bucket(cache, 4096 * 2);
55 add_bucket(cache, 4096 * 3);
57 /* Initialize the linked lists for BO reuse cache. */
59 add_bucket(cache, size);
60 add_bucket(cache, size + size * 1 / 4);
61 add_bucket(cache, size + size * 2 / 4);
62 add_bucket(cache, size + size * 3 / 4);
67 void etna_bo_cache_cleanup(struct etna_bo_cache *cache, time_t time)
71 if (cache->time == time)
74 for (i = 0; i < cache->num_buckets; i++) {
75 struct etna_bo_bucket *bucket = &cache->cache_bucket[i];
81 /* keep things in cache for at least 1 second: */
91 cache->time = time;
94 static struct etna_bo_bucket *get_bucket(struct etna_bo_cache *cache, uint32_t size)
101 for (i = 0; i < cache->num_buckets; i++) {
102 struct etna_bo_bucket *bucket = &cache->cache_bucket[i];
148 struct etna_bo *etna_bo_cache_alloc(struct etna_bo_cache *cache, uint32_t *size,
155 bucket = get_bucket(cache, *size);
172 int etna_bo_cache_free(struct etna_bo_cache *cache, struct etna_bo *bo)
178 bucket = get_bucket(cache, bo->size);
189 etna_bo_cache_cleanup(cache, time.tv_sec);
191 /* bo's in the bucket cache don't have a ref and