Lines Matching refs:screen
43 bool lima_bo_table_init(struct lima_screen *screen)
45 screen->bo_handles = util_hash_table_create_ptr_keys();
46 if (!screen->bo_handles)
49 screen->bo_flink_names = util_hash_table_create_ptr_keys();
50 if (!screen->bo_flink_names)
53 mtx_init(&screen->bo_table_lock, mtx_plain);
57 _mesa_hash_table_destroy(screen->bo_handles, NULL);
61 bool lima_bo_cache_init(struct lima_screen *screen)
63 mtx_init(&screen->bo_cache_lock, mtx_plain);
64 list_inithead(&screen->bo_cache_time);
66 list_inithead(&screen->bo_cache_buckets[i]);
71 void lima_bo_table_fini(struct lima_screen *screen)
73 mtx_destroy(&screen->bo_table_lock);
74 _mesa_hash_table_destroy(screen->bo_handles, NULL);
75 _mesa_hash_table_destroy(screen->bo_flink_names, NULL);
85 static void lima_close_kms_handle(struct lima_screen *screen, uint32_t handle)
91 drmIoctl(screen->fd, DRM_IOCTL_GEM_CLOSE, &args);
97 struct lima_screen *screen = bo->screen;
103 mtx_lock(&screen->bo_table_lock);
104 _mesa_hash_table_remove_key(screen->bo_handles,
107 _mesa_hash_table_remove_key(screen->bo_flink_names,
109 mtx_unlock(&screen->bo_table_lock);
114 lima_close_kms_handle(screen, bo->handle);
118 void lima_bo_cache_fini(struct lima_screen *screen)
120 mtx_destroy(&screen->bo_cache_lock);
123 &screen->bo_cache_time, time_list) {
135 if(drmIoctl(bo->screen->fd, DRM_IOCTL_LIMA_GEM_INFO, &req))
160 lima_bo_cache_get_bucket(struct lima_screen *screen, unsigned size)
162 return &screen->bo_cache_buckets[lima_bucket_index(size)];
166 lima_bo_cache_free_stale_bos(struct lima_screen *screen, time_t time)
170 &screen->bo_cache_time, time_list) {
184 lima_bo_cache_print_stats(struct lima_screen *screen)
190 struct list_head *bucket = &screen->bo_cache_buckets[i];
209 struct lima_screen *screen = bo->screen;
211 mtx_lock(&screen->bo_cache_lock);
212 struct list_head *bucket = lima_bo_cache_get_bucket(screen, bo->size);
215 mtx_unlock(&screen->bo_cache_lock);
223 list_addtail(&bo->time_list, &screen->bo_cache_time);
224 lima_bo_cache_free_stale_bos(screen, time.tv_sec);
227 lima_bo_cache_print_stats(screen);
229 mtx_unlock(&screen->bo_cache_lock);
235 lima_bo_cache_get(struct lima_screen *screen, uint32_t size, uint32_t flags)
242 mtx_lock(&screen->bo_cache_lock);
243 struct list_head *bucket = lima_bo_cache_get_bucket(screen, size);
246 mtx_unlock(&screen->bo_cache_lock);
268 lima_bo_cache_print_stats(screen);
274 mtx_unlock(&screen->bo_cache_lock);
279 struct lima_bo *lima_bo_create(struct lima_screen *screen,
287 bo = lima_bo_cache_get(screen, size, flags);
302 if (drmIoctl(screen->fd, DRM_IOCTL_LIMA_GEM_CREATE, &req))
305 bo->screen = screen;
323 lima_close_kms_handle(screen, bo->handle);
345 MAP_SHARED, bo->screen->fd, bo->offset);
363 struct lima_screen *screen = bo->screen;
375 if (drmIoctl(screen->fd, DRM_IOCTL_GEM_FLINK, &flink))
380 mtx_lock(&screen->bo_table_lock);
381 _mesa_hash_table_insert(screen->bo_flink_names,
383 mtx_unlock(&screen->bo_table_lock);
389 mtx_lock(&screen->bo_table_lock);
390 _mesa_hash_table_insert(screen->bo_handles,
392 mtx_unlock(&screen->bo_table_lock);
398 if (drmPrimeHandleToFD(screen->fd, bo->handle, DRM_CLOEXEC,
402 mtx_lock(&screen->bo_table_lock);
403 _mesa_hash_table_insert(screen->bo_handles,
405 mtx_unlock(&screen->bo_table_lock);
413 struct lima_bo *lima_bo_import(struct lima_screen *screen,
421 mtx_lock(&screen->bo_table_lock);
429 if (drmPrimeFDToHandle(screen->fd, h, &prime_handle)) {
430 mtx_unlock(&screen->bo_table_lock);
437 mtx_unlock(&screen->bo_table_lock);
438 lima_close_kms_handle(screen, prime_handle);
449 bo = util_hash_table_get(screen->bo_flink_names,
454 bo = util_hash_table_get(screen->bo_handles,
458 mtx_unlock(&screen->bo_table_lock);
466 mtx_unlock(&screen->bo_table_lock);
471 mtx_unlock(&screen->bo_table_lock);
473 lima_close_kms_handle(screen, h);
481 bo->screen = screen;
487 if (drmIoctl(screen->fd, DRM_IOCTL_GEM_OPEN, &req)) {
488 mtx_unlock(&screen->bo_table_lock);
507 _mesa_hash_table_insert(screen->bo_flink_names,
509 _mesa_hash_table_insert(screen->bo_handles,
513 lima_close_kms_handle(screen, bo->handle);
518 mtx_unlock(&screen->bo_table_lock);
541 return drmIoctl(bo->screen->fd, DRM_IOCTL_LIMA_GEM_WAIT, &req) == 0;