Lines Matching refs:bo
79 lima_bo_cache_remove(struct lima_bo *bo) in lima_bo_cache_remove() argument
81 list_del(&bo->size_list); in lima_bo_cache_remove()
82 list_del(&bo->time_list); in lima_bo_cache_remove()
95 lima_bo_free(struct lima_bo *bo) in lima_bo_free() argument
97 struct lima_screen *screen = bo->screen; in lima_bo_free()
101 bo, bo->size); in lima_bo_free()
105 (void *)(uintptr_t)bo->handle); in lima_bo_free()
106 if (bo->flink_name) in lima_bo_free()
108 (void *)(uintptr_t)bo->flink_name); in lima_bo_free()
111 if (bo->map) in lima_bo_free()
112 lima_bo_unmap(bo); in lima_bo_free()
114 lima_close_kms_handle(screen, bo->handle); in lima_bo_free()
115 free(bo); in lima_bo_free()
129 static bool lima_bo_get_info(struct lima_bo *bo) in lima_bo_get_info() argument
132 .handle = bo->handle, in lima_bo_get_info()
135 if(drmIoctl(bo->screen->fd, DRM_IOCTL_LIMA_GEM_INFO, &req)) in lima_bo_get_info()
138 bo->offset = req.offset; in lima_bo_get_info()
139 bo->va = req.va; in lima_bo_get_info()
204 lima_bo_cache_put(struct lima_bo *bo) in lima_bo_cache_put() argument
206 if (!bo->cacheable) in lima_bo_cache_put()
209 struct lima_screen *screen = bo->screen; in lima_bo_cache_put()
212 struct list_head *bucket = lima_bo_cache_get_bucket(screen, bo->size); in lima_bo_cache_put()
221 bo->free_time = time.tv_sec; in lima_bo_cache_put()
222 list_addtail(&bo->size_list, bucket); in lima_bo_cache_put()
223 list_addtail(&bo->time_list, &screen->bo_cache_time); in lima_bo_cache_put()
226 fprintf(stderr, "%s: put BO: %p (size=%d)\n", __func__, bo, bo->size); in lima_bo_cache_put()
241 struct lima_bo *bo = NULL; in lima_bo_cache_get() local
264 bo = entry; in lima_bo_cache_get()
267 __func__, bo, bo->size, size); in lima_bo_cache_get()
276 return bo; in lima_bo_cache_get()
282 struct lima_bo *bo; in lima_bo_create() local
287 bo = lima_bo_cache_get(screen, size, flags); in lima_bo_create()
288 if (bo) in lima_bo_create()
289 return bo; in lima_bo_create()
296 if (!(bo = calloc(1, sizeof(*bo)))) in lima_bo_create()
299 list_inithead(&bo->time_list); in lima_bo_create()
300 list_inithead(&bo->size_list); in lima_bo_create()
305 bo->screen = screen; in lima_bo_create()
306 bo->size = req.size; in lima_bo_create()
307 bo->flags = req.flags; in lima_bo_create()
308 bo->handle = req.handle; in lima_bo_create()
309 bo->cacheable = !(lima_debug & LIMA_DEBUG_NO_BO_CACHE || in lima_bo_create()
311 p_atomic_set(&bo->refcnt, 1); in lima_bo_create()
313 if (!lima_bo_get_info(bo)) in lima_bo_create()
318 bo, bo->size); in lima_bo_create()
320 return bo; in lima_bo_create()
323 lima_close_kms_handle(screen, bo->handle); in lima_bo_create()
325 free(bo); in lima_bo_create()
329 void lima_bo_unreference(struct lima_bo *bo) in lima_bo_unreference() argument
331 if (!p_atomic_dec_zero(&bo->refcnt)) in lima_bo_unreference()
335 if (lima_bo_cache_put(bo)) in lima_bo_unreference()
338 lima_bo_free(bo); in lima_bo_unreference()
341 void *lima_bo_map(struct lima_bo *bo) in lima_bo_map() argument
343 if (!bo->map) { in lima_bo_map()
344 bo->map = os_mmap(0, bo->size, PROT_READ | PROT_WRITE, in lima_bo_map()
345 MAP_SHARED, bo->screen->fd, bo->offset); in lima_bo_map()
346 if (bo->map == MAP_FAILED) in lima_bo_map()
347 bo->map = NULL; in lima_bo_map()
350 return bo->map; in lima_bo_map()
353 void lima_bo_unmap(struct lima_bo *bo) in lima_bo_unmap() argument
355 if (bo->map) { in lima_bo_unmap()
356 os_munmap(bo->map, bo->size); in lima_bo_unmap()
357 bo->map = NULL; in lima_bo_unmap()
361 bool lima_bo_export(struct lima_bo *bo, struct winsys_handle *handle) in lima_bo_export() argument
363 struct lima_screen *screen = bo->screen; in lima_bo_export()
366 bo->cacheable = false; in lima_bo_export()
370 if (!bo->flink_name) { in lima_bo_export()
372 .handle = bo->handle, in lima_bo_export()
378 bo->flink_name = flink.name; in lima_bo_export()
382 (void *)(uintptr_t)bo->flink_name, bo); in lima_bo_export()
385 handle->handle = bo->flink_name; in lima_bo_export()
391 (void *)(uintptr_t)bo->handle, bo); in lima_bo_export()
394 handle->handle = bo->handle; in lima_bo_export()
398 if (drmPrimeHandleToFD(screen->fd, bo->handle, DRM_CLOEXEC, in lima_bo_export()
404 (void *)(uintptr_t)bo->handle, bo); in lima_bo_export()
416 struct lima_bo *bo = NULL; in lima_bo_import() local
449 bo = util_hash_table_get(screen->bo_flink_names, in lima_bo_import()
454 bo = util_hash_table_get(screen->bo_handles, in lima_bo_import()
462 if (bo) { in lima_bo_import()
463 p_atomic_inc(&bo->refcnt); in lima_bo_import()
465 bo->cacheable = false; in lima_bo_import()
467 return bo; in lima_bo_import()
470 if (!(bo = calloc(1, sizeof(*bo)))) { in lima_bo_import()
478 bo->cacheable = false; in lima_bo_import()
479 list_inithead(&bo->time_list); in lima_bo_import()
480 list_inithead(&bo->size_list); in lima_bo_import()
481 bo->screen = screen; in lima_bo_import()
482 p_atomic_set(&bo->refcnt, 1); in lima_bo_import()
489 free(bo); in lima_bo_import()
492 bo->handle = req.handle; in lima_bo_import()
493 bo->flink_name = h; in lima_bo_import()
494 bo->size = req.size; in lima_bo_import()
497 bo->handle = h; in lima_bo_import()
498 bo->size = dma_buf_size; in lima_bo_import()
505 if (lima_bo_get_info(bo)) { in lima_bo_import()
508 (void *)(uintptr_t)bo->flink_name, bo); in lima_bo_import()
510 (void*)(uintptr_t)bo->handle, bo); in lima_bo_import()
513 lima_close_kms_handle(screen, bo->handle); in lima_bo_import()
514 free(bo); in lima_bo_import()
515 bo = NULL; in lima_bo_import()
520 return bo; in lima_bo_import()
523 bool lima_bo_wait(struct lima_bo *bo, uint32_t op, uint64_t timeout_ns) in lima_bo_wait() argument
536 .handle = bo->handle, in lima_bo_wait()
541 return drmIoctl(bo->screen->fd, DRM_IOCTL_LIMA_GEM_WAIT, &req) == 0; in lima_bo_wait()