Lines Matching defs:vc4

40 static void vc4_bo_stats_print(struct drm_printer *p, struct vc4_dev *vc4)
44 for (i = 0; i < vc4->num_labels; i++) {
45 if (!vc4->bo_labels[i].num_allocated)
49 vc4->bo_labels[i].name,
50 vc4->bo_labels[i].size_allocated / 1024,
51 vc4->bo_labels[i].num_allocated);
54 mutex_lock(&vc4->purgeable.lock);
55 if (vc4->purgeable.num)
57 vc4->purgeable.size / 1024, vc4->purgeable.num);
59 if (vc4->purgeable.purged_num)
61 vc4->purgeable.purged_size / 1024,
62 vc4->purgeable.purged_num);
63 mutex_unlock(&vc4->purgeable.lock);
70 struct vc4_dev *vc4 = to_vc4_dev(dev);
73 vc4_bo_stats_print(&p, vc4);
86 static int vc4_get_user_label(struct vc4_dev *vc4, const char *name)
91 for (i = 0; i < vc4->num_labels; i++) {
92 if (!vc4->bo_labels[i].name) {
94 } else if (strcmp(vc4->bo_labels[i].name, name) == 0) {
101 WARN_ON(vc4->bo_labels[free_slot].num_allocated != 0);
102 vc4->bo_labels[free_slot].name = name;
105 u32 new_label_count = vc4->num_labels + 1;
107 krealloc(vc4->bo_labels,
116 free_slot = vc4->num_labels;
117 vc4->bo_labels = new_labels;
118 vc4->num_labels = new_label_count;
120 vc4->bo_labels[free_slot].name = name;
121 vc4->bo_labels[free_slot].num_allocated = 0;
122 vc4->bo_labels[free_slot].size_allocated = 0;
131 struct vc4_dev *vc4 = to_vc4_dev(gem_obj->dev);
133 lockdep_assert_held(&vc4->bo_lock);
136 vc4->bo_labels[label].num_allocated++;
137 vc4->bo_labels[label].size_allocated += gem_obj->size;
140 vc4->bo_labels[bo->label].num_allocated--;
141 vc4->bo_labels[bo->label].size_allocated -= gem_obj->size;
143 if (vc4->bo_labels[bo->label].num_allocated == 0 &&
150 kfree(vc4->bo_labels[bo->label].name);
151 vc4->bo_labels[bo->label].name = NULL;
165 struct vc4_dev *vc4 = to_vc4_dev(obj->dev);
167 lockdep_assert_held(&vc4->bo_lock);
183 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
185 lockdep_assert_held(&vc4->bo_lock);
193 struct vc4_dev *vc4 = to_vc4_dev(dev);
196 if (vc4->bo_cache.size_list_size <= page_index) {
197 uint32_t new_size = max(vc4->bo_cache.size_list_size * 2,
210 for (i = 0; i < vc4->bo_cache.size_list_size; i++) {
212 &vc4->bo_cache.size_list[i];
220 for (i = vc4->bo_cache.size_list_size; i < new_size; i++)
223 kfree(vc4->bo_cache.size_list);
224 vc4->bo_cache.size_list = new_list;
225 vc4->bo_cache.size_list_size = new_size;
228 return &vc4->bo_cache.size_list[page_index];
233 struct vc4_dev *vc4 = to_vc4_dev(dev);
235 mutex_lock(&vc4->bo_lock);
236 while (!list_empty(&vc4->bo_cache.time_list)) {
237 struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
242 mutex_unlock(&vc4->bo_lock);
247 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
249 mutex_lock(&vc4->purgeable.lock);
250 list_add_tail(&bo->size_head, &vc4->purgeable.list);
251 vc4->purgeable.num++;
252 vc4->purgeable.size += bo->base.base.size;
253 mutex_unlock(&vc4->purgeable.lock);
258 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
273 vc4->purgeable.num--;
274 vc4->purgeable.size -= bo->base.base.size;
279 struct vc4_dev *vc4 = to_vc4_dev(bo->base.base.dev);
281 mutex_lock(&vc4->purgeable.lock);
283 mutex_unlock(&vc4->purgeable.lock);
303 struct vc4_dev *vc4 = to_vc4_dev(dev);
305 mutex_lock(&vc4->purgeable.lock);
306 while (!list_empty(&vc4->purgeable.list)) {
307 struct vc4_bo *bo = list_first_entry(&vc4->purgeable.list,
319 mutex_unlock(&vc4->purgeable.lock);
338 mutex_lock(&vc4->purgeable.lock);
341 vc4->purgeable.purged_size += purged_size;
342 vc4->purgeable.purged_num++;
345 mutex_unlock(&vc4->purgeable.lock);
352 struct vc4_dev *vc4 = to_vc4_dev(dev);
358 mutex_lock(&vc4->bo_lock);
359 if (page_index >= vc4->bo_cache.size_list_size)
362 if (list_empty(&vc4->bo_cache.size_list[page_index]))
365 bo = list_first_entry(&vc4->bo_cache.size_list[page_index],
373 mutex_unlock(&vc4->bo_lock);
387 struct vc4_dev *vc4 = to_vc4_dev(dev);
397 mutex_lock(&vc4->bo_lock);
399 vc4->bo_labels[VC4_BO_TYPE_KERNEL].num_allocated++;
400 vc4->bo_labels[VC4_BO_TYPE_KERNEL].size_allocated += size;
401 mutex_unlock(&vc4->bo_lock);
410 struct vc4_dev *vc4 = to_vc4_dev(dev);
452 struct drm_printer p = drm_info_printer(vc4->base.dev);
454 vc4_bo_stats_print(&p, vc4);
465 mutex_lock(&vc4->bo_lock);
467 mutex_unlock(&vc4->bo_lock);
500 struct vc4_dev *vc4 = to_vc4_dev(dev);
503 lockdep_assert_held(&vc4->bo_lock);
505 while (!list_empty(&vc4->bo_cache.time_list)) {
506 struct vc4_bo *bo = list_last_entry(&vc4->bo_cache.time_list,
509 mod_timer(&vc4->bo_cache.time_timer,
526 struct vc4_dev *vc4 = to_vc4_dev(dev);
536 mutex_lock(&vc4->bo_lock);
579 list_add(&bo->unref_head, &vc4->bo_cache.time_list);
586 mutex_unlock(&vc4->bo_lock);
591 struct vc4_dev *vc4 =
593 struct drm_device *dev = &vc4->base;
595 mutex_lock(&vc4->bo_lock);
597 mutex_unlock(&vc4->bo_lock);
653 struct vc4_dev *vc4 = from_timer(vc4, t, bo_cache.time_timer);
655 schedule_work(&vc4->bo_cache.time_work);
796 static int vc4_grab_bin_bo(struct vc4_dev *vc4, struct vc4_file *vc4file)
800 if (!vc4->v3d)
806 ret = vc4_v3d_bin_bo_get(vc4, &vc4file->bin_bo_used);
818 struct vc4_dev *vc4 = to_vc4_dev(dev);
822 ret = vc4_grab_bin_bo(vc4, vc4file);
867 struct vc4_dev *vc4 = to_vc4_dev(dev);
887 ret = vc4_grab_bin_bo(vc4, vc4file);
1011 struct vc4_dev *vc4 = to_vc4_dev(dev);
1018 vc4->bo_labels = kcalloc(VC4_BO_TYPE_COUNT, sizeof(*vc4->bo_labels),
1020 if (!vc4->bo_labels)
1022 vc4->num_labels = VC4_BO_TYPE_COUNT;
1026 vc4->bo_labels[i].name = bo_type_names[i];
1028 mutex_init(&vc4->bo_lock);
1032 INIT_LIST_HEAD(&vc4->bo_cache.time_list);
1034 INIT_WORK(&vc4->bo_cache.time_work, vc4_bo_cache_time_work);
1035 timer_setup(&vc4->bo_cache.time_timer, vc4_bo_cache_time_timer, 0);
1042 struct vc4_dev *vc4 = to_vc4_dev(dev);
1045 del_timer(&vc4->bo_cache.time_timer);
1046 cancel_work_sync(&vc4->bo_cache.time_work);
1050 for (i = 0; i < vc4->num_labels; i++) {
1051 if (vc4->bo_labels[i].num_allocated) {
1054 vc4->bo_labels[i].num_allocated,
1055 vc4->bo_labels[i].name);
1059 kfree(vc4->bo_labels[i].name);
1061 kfree(vc4->bo_labels);
1067 struct vc4_dev *vc4 = to_vc4_dev(dev);
1087 mutex_lock(&vc4->bo_lock);
1088 label = vc4_get_user_label(vc4, name);
1093 mutex_unlock(&vc4->bo_lock);