Lines Matching defs:cache
32 /* Default max size of the bo cache, in MB.
48 struct v3dv_bo_cache *cache = &device->bo_cache;
52 fprintf(stderr, " BOs cached: %d\n", cache->cache_count);
53 fprintf(stderr, " BOs cached size: %dkb\n", cache->cache_size / 1024);
55 if (!list_is_empty(&cache->time_list)) {
56 struct v3dv_bo *first = list_first_entry(&cache->time_list,
59 struct v3dv_bo *last = list_last_entry(&cache->time_list,
63 fprintf(stderr, " oldest cache time: %ld\n",
65 fprintf(stderr, " newest cache time: %ld\n",
74 if (cache->size_list_size) {
76 for (uint32_t i = 0; i < cache->size_list_size; i++) {
77 if (list_is_empty(&cache->size_list[i]))
85 bo_remove_from_cache(struct v3dv_bo_cache *cache, struct v3dv_bo *bo)
90 cache->cache_count--;
91 cache->cache_size -= bo->size;
97 struct v3dv_bo_cache *cache = &device->bo_cache;
100 if (cache->size_list_size <= page_index)
105 mtx_lock(&cache->lock);
106 if (!list_is_empty(&cache->size_list[page_index])) {
107 bo = list_first_entry(&cache->size_list[page_index],
115 mtx_unlock(&cache->lock);
119 bo_remove_from_cache(cache, bo);
123 mtx_unlock(&cache->lock);
168 struct v3dv_bo_cache *cache = &device->bo_cache;
171 mtx_lock(&cache->lock);
172 list_for_each_entry_safe(struct v3dv_bo, bo, &cache->time_list,
174 bo_remove_from_cache(cache, bo);
178 mtx_unlock(&cache->lock);
218 fprintf(stderr, "Allocated %s %dkb from cache:\n",
343 reallocate_size_list(struct v3dv_bo_cache *cache,
352 fprintf(stderr, "Failed to allocate host memory for cache bo list\n");
355 struct list_head *old_list = cache->size_list;
360 for (int i = 0; i < cache->size_list_size; i++) {
361 struct list_head *old_head = &cache->size_list[i];
371 for (int i = cache->size_list_size; i < size; i++)
374 cache->size_list = new_list;
375 cache->size_list_size = size;
424 struct v3dv_bo_cache *cache = &device->bo_cache;
427 list_for_each_entry_safe(struct v3dv_bo, bo, &cache->time_list,
437 bo_remove_from_cache(cache, bo);
464 struct v3dv_bo_cache *cache = &device->bo_cache;
468 bo->size > cache->max_cache_size - cache->cache_size) {
470 mtx_lock(&cache->lock);
472 mtx_unlock(&cache->lock);
476 bo->size > cache->max_cache_size - cache->cache_size) {
481 mtx_lock(&cache->lock);
483 if (cache->size_list_size <= page_index) {
484 if (!reallocate_size_list(cache, device, page_index + 1)) {
487 * memory, so we also free all the bo cache. We need to call it to
488 * not use the cache lock, as we are already under it.
491 mtx_unlock(&cache->lock);
497 list_addtail(&bo->size_list, &cache->size_list[page_index]);
498 list_addtail(&bo->time_list, &cache->time_list);
500 cache->cache_count++;
501 cache->cache_size += bo->size;
504 fprintf(stderr, "Freed %s %dkb to cache:\n",
512 mtx_unlock(&cache->lock);