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