• Home
  • Raw
  • Download

Lines Matching refs:bo

50         list_for_each_entry(struct v3d_bo, bo, &cache->time_list, time_list) {  in v3d_bo_dump_stats()
52 cache_size += bo->size; in v3d_bo_dump_stats()
81 v3d_bo_remove_from_cache(struct v3d_bo_cache *cache, struct v3d_bo *bo) in v3d_bo_remove_from_cache() argument
83 list_del(&bo->time_list); in v3d_bo_remove_from_cache()
84 list_del(&bo->size_list); in v3d_bo_remove_from_cache()
96 struct v3d_bo *bo = NULL; in v3d_bo_from_cache() local
99 bo = list_first_entry(&cache->size_list[page_index], in v3d_bo_from_cache()
106 if (!v3d_bo_wait(bo, 0, NULL)) { in v3d_bo_from_cache()
111 pipe_reference_init(&bo->reference, 1); in v3d_bo_from_cache()
112 v3d_bo_remove_from_cache(cache, bo); in v3d_bo_from_cache()
114 bo->name = name; in v3d_bo_from_cache()
117 return bo; in v3d_bo_from_cache()
123 struct v3d_bo *bo; in v3d_bo_alloc() local
132 bo = v3d_bo_from_cache(screen, size, name); in v3d_bo_alloc()
133 if (bo) { in v3d_bo_alloc()
139 return bo; in v3d_bo_alloc()
142 bo = CALLOC_STRUCT(v3d_bo); in v3d_bo_alloc()
143 if (!bo) in v3d_bo_alloc()
146 pipe_reference_init(&bo->reference, 1); in v3d_bo_alloc()
147 bo->screen = screen; in v3d_bo_alloc()
148 bo->size = size; in v3d_bo_alloc()
149 bo->name = name; in v3d_bo_alloc()
150 bo->private = true; in v3d_bo_alloc()
161 bo->handle = create.handle; in v3d_bo_alloc()
162 bo->offset = create.offset; in v3d_bo_alloc()
172 free(bo); in v3d_bo_alloc()
177 screen->bo_size += bo->size; in v3d_bo_alloc()
183 return bo; in v3d_bo_alloc()
187 v3d_bo_last_unreference(struct v3d_bo *bo) in v3d_bo_last_unreference() argument
189 struct v3d_screen *screen = bo->screen; in v3d_bo_last_unreference()
194 v3d_bo_last_unreference_locked_timed(bo, time.tv_sec); in v3d_bo_last_unreference()
199 v3d_bo_free(struct v3d_bo *bo) in v3d_bo_free() argument
201 struct v3d_screen *screen = bo->screen; in v3d_bo_free()
203 if (bo->map) { in v3d_bo_free()
204 if (using_v3d_simulator && bo->name && in v3d_bo_free()
205 strcmp(bo->name, "winsys") == 0) { in v3d_bo_free()
206 free(bo->map); in v3d_bo_free()
208 munmap(bo->map, bo->size); in v3d_bo_free()
209 VG(VALGRIND_FREELIKE_BLOCK(bo->map, 0)); in v3d_bo_free()
215 c.handle = bo->handle; in v3d_bo_free()
218 fprintf(stderr, "close object %d: %s\n", bo->handle, strerror(errno)); in v3d_bo_free()
221 screen->bo_size -= bo->size; in v3d_bo_free()
225 bo->name ? bo->name : "", in v3d_bo_free()
226 bo->name ? " " : "", in v3d_bo_free()
227 bo->size / 1024); in v3d_bo_free()
231 free(bo); in v3d_bo_free()
240 list_for_each_entry_safe(struct v3d_bo, bo, &cache->time_list, in free_stale_bos()
243 if (time - bo->free_time > 2) { in free_stale_bos()
249 v3d_bo_remove_from_cache(cache, bo); in free_stale_bos()
250 v3d_bo_free(bo); in free_stale_bos()
266 list_for_each_entry_safe(struct v3d_bo, bo, &cache->time_list, in v3d_bo_cache_free_all()
268 v3d_bo_remove_from_cache(cache, bo); in v3d_bo_cache_free_all()
269 v3d_bo_free(bo); in v3d_bo_cache_free_all()
275 v3d_bo_last_unreference_locked_timed(struct v3d_bo *bo, time_t time) in v3d_bo_last_unreference_locked_timed() argument
277 struct v3d_screen *screen = bo->screen; in v3d_bo_last_unreference_locked_timed()
279 uint32_t page_index = bo->size / 4096 - 1; in v3d_bo_last_unreference_locked_timed()
281 if (!bo->private) { in v3d_bo_last_unreference_locked_timed()
282 v3d_bo_free(bo); in v3d_bo_last_unreference_locked_timed()
311 bo->free_time = time; in v3d_bo_last_unreference_locked_timed()
312 list_addtail(&bo->size_list, &cache->size_list[page_index]); in v3d_bo_last_unreference_locked_timed()
313 list_addtail(&bo->time_list, &cache->time_list); in v3d_bo_last_unreference_locked_timed()
316 bo->name, bo->size / 1024); in v3d_bo_last_unreference_locked_timed()
319 bo->name = NULL; in v3d_bo_last_unreference_locked_timed()
328 struct v3d_bo *bo; in v3d_bo_open_handle() local
334 bo = util_hash_table_get(screen->bo_handles, (void*)(uintptr_t)handle); in v3d_bo_open_handle()
335 if (bo) { in v3d_bo_open_handle()
336 pipe_reference(NULL, &bo->reference); in v3d_bo_open_handle()
340 bo = CALLOC_STRUCT(v3d_bo); in v3d_bo_open_handle()
341 pipe_reference_init(&bo->reference, 1); in v3d_bo_open_handle()
342 bo->screen = screen; in v3d_bo_open_handle()
343 bo->handle = handle; in v3d_bo_open_handle()
344 bo->size = size; in v3d_bo_open_handle()
345 bo->name = "winsys"; in v3d_bo_open_handle()
346 bo->private = false; in v3d_bo_open_handle()
349 v3d_simulator_open_from_handle(screen->fd, bo->handle, bo->size); in v3d_bo_open_handle()
350 bo->map = malloc(bo->size); in v3d_bo_open_handle()
360 free(bo->map); in v3d_bo_open_handle()
361 free(bo); in v3d_bo_open_handle()
362 bo = NULL; in v3d_bo_open_handle()
365 bo->offset = get.offset; in v3d_bo_open_handle()
366 assert(bo->offset != 0); in v3d_bo_open_handle()
368 _mesa_hash_table_insert(screen->bo_handles, (void *)(uintptr_t)handle, bo); in v3d_bo_open_handle()
371 screen->bo_size += bo->size; in v3d_bo_open_handle()
375 return bo; in v3d_bo_open_handle()
416 v3d_bo_get_dmabuf(struct v3d_bo *bo) in v3d_bo_get_dmabuf() argument
419 int ret = drmPrimeHandleToFD(bo->screen->fd, bo->handle, in v3d_bo_get_dmabuf()
423 bo->handle); in v3d_bo_get_dmabuf()
427 mtx_lock(&bo->screen->bo_handles_mutex); in v3d_bo_get_dmabuf()
428 bo->private = false; in v3d_bo_get_dmabuf()
429 _mesa_hash_table_insert(bo->screen->bo_handles, (void *)(uintptr_t)bo->handle, bo); in v3d_bo_get_dmabuf()
430 mtx_unlock(&bo->screen->bo_handles_mutex); in v3d_bo_get_dmabuf()
436 v3d_bo_flink(struct v3d_bo *bo, uint32_t *name) in v3d_bo_flink() argument
439 .handle = bo->handle, in v3d_bo_flink()
441 int ret = v3d_ioctl(bo->screen->fd, DRM_IOCTL_GEM_FLINK, &flink); in v3d_bo_flink()
444 bo->handle, strerror(errno)); in v3d_bo_flink()
445 free(bo); in v3d_bo_flink()
449 bo->private = false; in v3d_bo_flink()
470 v3d_bo_wait(struct v3d_bo *bo, uint64_t timeout_ns, const char *reason) in v3d_bo_wait() argument
472 struct v3d_screen *screen = bo->screen; in v3d_bo_wait()
475 if (v3d_wait_bo_ioctl(screen->fd, bo->handle, 0) == -ETIME) { in v3d_bo_wait()
477 bo->name, reason); in v3d_bo_wait()
481 int ret = v3d_wait_bo_ioctl(screen->fd, bo->handle, timeout_ns); in v3d_bo_wait()
495 v3d_bo_map_unsynchronized(struct v3d_bo *bo) in v3d_bo_map_unsynchronized() argument
500 if (bo->map) in v3d_bo_map_unsynchronized()
501 return bo->map; in v3d_bo_map_unsynchronized()
505 map.handle = bo->handle; in v3d_bo_map_unsynchronized()
506 ret = v3d_ioctl(bo->screen->fd, DRM_IOCTL_V3D_MMAP_BO, &map); in v3d_bo_map_unsynchronized()
513 bo->map = mmap(NULL, bo->size, PROT_READ | PROT_WRITE, MAP_SHARED, in v3d_bo_map_unsynchronized()
514 bo->screen->fd, offset); in v3d_bo_map_unsynchronized()
515 if (bo->map == MAP_FAILED) { in v3d_bo_map_unsynchronized()
517 bo->handle, (long long)offset, bo->size); in v3d_bo_map_unsynchronized()
520 VG(VALGRIND_MALLOCLIKE_BLOCK(bo->map, bo->size, 0, false)); in v3d_bo_map_unsynchronized()
522 return bo->map; in v3d_bo_map_unsynchronized()
526 v3d_bo_map(struct v3d_bo *bo) in v3d_bo_map() argument
528 void *map = v3d_bo_map_unsynchronized(bo); in v3d_bo_map()
530 bool ok = v3d_bo_wait(bo, PIPE_TIMEOUT_INFINITE, "bo map"); in v3d_bo_map()