Lines Matching defs:vc4

44 static void vc4_bo_stats_print(struct drm_printer *p, struct vc4_dev *vc4)
48 for (i = 0; i < vc4->num_labels; i++) {
49 if (!vc4->bo_labels[i].num_allocated)
53 vc4->bo_labels[i].name,
54 vc4->bo_labels[i].size_allocated / 1024,
55 vc4->bo_labels[i].num_allocated);
58 mutex_lock(&vc4->purgeable.lock);
59 if (vc4->purgeable.num)
61 vc4->purgeable.size / 1024, vc4->purgeable.num);
63 if (vc4->purgeable.purged_num)
65 vc4->purgeable.purged_size / 1024,
66 vc4->purgeable.purged_num);
67 mutex_unlock(&vc4->purgeable.lock);
74 struct vc4_dev *vc4 = to_vc4_dev(dev);
77 vc4_bo_stats_print(&p, vc4);
90 static int vc4_get_user_label(struct vc4_dev *vc4, const char *name)
95 for (i = 0; i < vc4->num_labels; i++) {
96 if (!vc4->bo_labels[i].name) {
98 } else if (strcmp(vc4->bo_labels[i].name, name) == 0) {
105 WARN_ON(vc4->bo_labels[free_slot].num_allocated != 0);
106 vc4->bo_labels[free_slot].name = name;
109 u32 new_label_count = vc4->num_labels + 1;
111 krealloc(vc4->bo_labels,
120 free_slot = vc4->num_labels;
121 vc4->bo_labels = new_labels;
122 vc4->num_labels = new_label_count;
124 vc4->bo_labels[free_slot].name = name;
125 vc4->bo_labels[free_slot].num_allocated = 0;
126 vc4->bo_labels[free_slot].size_allocated = 0;
135 struct vc4_dev *vc4 = to_vc4_dev(gem_obj->dev);
137 lockdep_assert_held(&vc4->bo_lock);
140 vc4->bo_labels[label].num_allocated++;
141 vc4->bo_labels[label].size_allocated += gem_obj->size;
144 vc4->bo_labels[bo->label].num_allocated--;
145 vc4->bo_labels[bo->label].size_allocated -= gem_obj->size;
147 if (vc4->bo_labels[bo->label].num_allocated == 0 &&
154 kfree(vc4->bo_labels[bo->label].name);
155 vc4->bo_labels[bo->label].name = NULL;
169 struct vc4_dev *vc4 = to_vc4_dev(obj->dev);
171 lockdep_assert_held(&vc4->bo_lock);
188 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
190 lockdep_assert_held(&vc4->bo_lock);
198 struct vc4_dev *vc4 = to_vc4_dev(dev);
201 if (vc4->bo_cache.size_list_size <= page_index) {
202 uint32_t new_size = max(vc4->bo_cache.size_list_size * 2,
215 for (i = 0; i < vc4->bo_cache.size_list_size; i++) {
217 &vc4->bo_cache.size_list[i];
225 for (i = vc4->bo_cache.size_list_size; i < new_size; i++)
228 kfree(vc4->bo_cache.size_list);
229 vc4->bo_cache.size_list = new_list;
230 vc4->bo_cache.size_list_size = new_size;
233 return &vc4->bo_cache.size_list[page_index];
238 struct vc4_dev *vc4 = to_vc4_dev(dev);
240 mutex_lock(&vc4->bo_lock);
241 while (!list_empty(&vc4->bo_cache.time_list)) {
242 struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
247 mutex_unlock(&vc4->bo_lock);
252 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
254 if (WARN_ON_ONCE(vc4->is_vc5))
257 mutex_lock(&vc4->purgeable.lock);
258 list_add_tail(&bo->size_head, &vc4->purgeable.list);
259 vc4->purgeable.num++;
260 vc4->purgeable.size += bo->base.base.size;
261 mutex_unlock(&vc4->purgeable.lock);
266 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
268 if (WARN_ON_ONCE(vc4->is_vc5))
284 vc4->purgeable.num--;
285 vc4->purgeable.size -= bo->base.base.size;
290 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
292 mutex_lock(&vc4->purgeable.lock);
294 mutex_unlock(&vc4->purgeable.lock);
314 struct vc4_dev *vc4 = to_vc4_dev(dev);
316 mutex_lock(&vc4->purgeable.lock);
317 while (!list_empty(&vc4->purgeable.list)) {
318 struct vc4_bo *bo = list_first_entry(&vc4->purgeable.list,
330 mutex_unlock(&vc4->purgeable.lock);
349 mutex_lock(&vc4->purgeable.lock);
352 vc4->purgeable.purged_size += purged_size;
353 vc4->purgeable.purged_num++;
356 mutex_unlock(&vc4->purgeable.lock);
363 struct vc4_dev *vc4 = to_vc4_dev(dev);
367 mutex_lock(&vc4->bo_lock);
368 if (page_index >= vc4->bo_cache.size_list_size)
371 if (list_empty(&vc4->bo_cache.size_list[page_index]))
374 bo = list_first_entry(&vc4->bo_cache.size_list[page_index],
382 mutex_unlock(&vc4->bo_lock);
396 struct vc4_dev *vc4 = to_vc4_dev(dev);
399 if (WARN_ON_ONCE(vc4->is_vc5))
411 mutex_lock(&vc4->bo_lock);
413 vc4->bo_labels[VC4_BO_TYPE_KERNEL].num_allocated++;
414 vc4->bo_labels[VC4_BO_TYPE_KERNEL].size_allocated += size;
415 mutex_unlock(&vc4->bo_lock);
426 struct vc4_dev *vc4 = to_vc4_dev(dev);
430 if (WARN_ON_ONCE(vc4->is_vc5))
471 struct drm_printer p = drm_info_printer(vc4->base.dev);
473 vc4_bo_stats_print(&p, vc4);
484 mutex_lock(&vc4->bo_lock);
486 mutex_unlock(&vc4->bo_lock);
495 struct vc4_dev *vc4 = to_vc4_dev(dev);
499 if (WARN_ON_ONCE(vc4->is_vc5))
520 struct vc4_dev *vc4 = to_vc4_dev(dev);
523 lockdep_assert_held(&vc4->bo_lock);
525 while (!list_empty(&vc4->bo_cache.time_list)) {
526 struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
529 mod_timer(&vc4->bo_cache.time_timer,
546 struct vc4_dev *vc4 = to_vc4_dev(dev);
556 mutex_lock(&vc4->bo_lock);
599 list_add(&bo->unref_head, &vc4->bo_cache.time_list);
606 mutex_unlock(&vc4->bo_lock);
611 struct vc4_dev *vc4 =
613 struct drm_device *dev = &vc4->base;
615 mutex_lock(&vc4->bo_lock);
617 mutex_unlock(&vc4->bo_lock);
622 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
625 if (WARN_ON_ONCE(vc4->is_vc5))
662 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
664 if (WARN_ON_ONCE(vc4->is_vc5))
682 struct vc4_dev *vc4 = from_timer(vc4, t, bo_cache.time_timer);
684 schedule_work(&vc4->bo_cache.time_work);
766 static int vc4_grab_bin_bo(struct vc4_dev *vc4, struct vc4_file *vc4file)
768 if (!vc4->v3d)
774 return vc4_v3d_bin_bo_get(vc4, &vc4file->bin_bo_used);
782 struct vc4_dev *vc4 = to_vc4_dev(dev);
786 if (WARN_ON_ONCE(vc4->is_vc5))
789 ret = vc4_grab_bin_bo(vc4, vc4file);
812 struct vc4_dev *vc4 = to_vc4_dev(dev);
816 if (WARN_ON_ONCE(vc4->is_vc5))
838 struct vc4_dev *vc4 = to_vc4_dev(dev);
842 if (WARN_ON_ONCE(vc4->is_vc5))
861 ret = vc4_grab_bin_bo(vc4, vc4file);
915 struct vc4_dev *vc4 = to_vc4_dev(dev);
921 if (WARN_ON_ONCE(vc4->is_vc5))
962 struct vc4_dev *vc4 = to_vc4_dev(dev);
967 if (WARN_ON_ONCE(vc4->is_vc5))
993 struct vc4_dev *vc4 = to_vc4_dev(drm);
995 if (!vc4->v3d)
1006 struct vc4_dev *vc4 = to_vc4_dev(dev);
1010 if (WARN_ON_ONCE(vc4->is_vc5))
1017 vc4->bo_labels = kcalloc(VC4_BO_TYPE_COUNT, sizeof(*vc4->bo_labels),
1019 if (!vc4->bo_labels)
1021 vc4->num_labels = VC4_BO_TYPE_COUNT;
1025 vc4->bo_labels[i].name = bo_type_names[i];
1027 ret = drmm_mutex_init(dev, &vc4->bo_lock);
1029 kfree(vc4->bo_labels);
1033 INIT_LIST_HEAD(&vc4->bo_cache.time_list);
1035 INIT_WORK(&vc4->bo_cache.time_work, vc4_bo_cache_time_work);
1036 timer_setup(&vc4->bo_cache.time_timer, vc4_bo_cache_time_timer, 0);
1043 struct vc4_dev *vc4 = to_vc4_dev(dev);
1046 del_timer(&vc4->bo_cache.time_timer);
1047 cancel_work_sync(&vc4->bo_cache.time_work);
1051 for (i = 0; i < vc4->num_labels; i++) {
1052 if (vc4->bo_labels[i].num_allocated) {
1055 vc4->bo_labels[i].num_allocated,
1056 vc4->bo_labels[i].name);
1060 kfree(vc4->bo_labels[i].name);
1062 kfree(vc4->bo_labels);
1068 struct vc4_dev *vc4 = to_vc4_dev(dev);
1074 if (WARN_ON_ONCE(vc4->is_vc5))
1091 mutex_lock(&vc4->bo_lock);
1092 label = vc4_get_user_label(vc4, name);
1097 mutex_unlock(&vc4->bo_lock);