int fd;
- mtx_t lock;
+ simple_mtx_t lock;
/** Array of lists of cached gem objects of power-of-two sizes */
struct bo_cache_bucket cache_bucket[14 * 4];
struct intel_aux_map_context *aux_map_ctx;
};
-static mtx_t global_bufmgr_list_mutex = _MTX_INITIALIZER_NP;
+static simple_mtx_t global_bufmgr_list_mutex = _SIMPLE_MTX_INITIALIZER_NP;
static struct list_head global_bufmgr_list = {
.next = &global_bufmgr_list,
.prev = &global_bufmgr_list,
enum iris_mmap_mode mmap_mode =
!local && is_coherent ? IRIS_MMAP_WB : IRIS_MMAP_WC;
- mtx_lock(&bufmgr->lock);
+ simple_mtx_lock(&bufmgr->lock);
/* Get a buffer out of the cache if available. First, we try to find
* one with a matching memory zone so we can avoid reallocating VMA.
flags, false);
}
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
if (!bo) {
bo = alloc_fresh_bo(bufmgr, bo_size, local);
}
if (bo->gtt_offset == 0ull) {
- mtx_lock(&bufmgr->lock);
+ simple_mtx_lock(&bufmgr->lock);
bo->gtt_offset = vma_alloc(bufmgr, memzone, bo->size, alignment);
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
if (bo->gtt_offset == 0ull)
goto err_free;
bo->bufmgr = bufmgr;
bo->kflags = EXEC_OBJECT_SUPPORTS_48B_ADDRESS | EXEC_OBJECT_PINNED;
- mtx_lock(&bufmgr->lock);
+ simple_mtx_lock(&bufmgr->lock);
bo->gtt_offset = vma_alloc(bufmgr, memzone, size, 1);
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
if (bo->gtt_offset == 0ull)
goto err_close;
* alternating names for the front/back buffer a linear search
* provides a sufficiently fast match.
*/
- mtx_lock(&bufmgr->lock);
+ simple_mtx_lock(&bufmgr->lock);
bo = find_and_ref_external_bo(bufmgr->name_table, handle);
if (bo)
goto out;
DBG("bo_create_from_handle: %d (%s)\n", handle, bo->name);
out:
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
return bo;
}
clock_gettime(CLOCK_MONOTONIC, &time);
- mtx_lock(&bufmgr->lock);
+ simple_mtx_lock(&bufmgr->lock);
if (p_atomic_dec_zero(&bo->refcount)) {
bo_unreference_final(bo, time.tv_sec);
cleanup_bo_cache(bufmgr, time.tv_sec);
}
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
}
}
/* bufmgr will no longer try to free VMA entries in the aux-map */
bufmgr->aux_map_ctx = NULL;
- mtx_destroy(&bufmgr->lock);
+ simple_mtx_destroy(&bufmgr->lock);
/* Free any cached buffer objects we were going to reuse */
for (int i = 0; i < bufmgr->num_buckets; i++) {
uint32_t handle;
struct iris_bo *bo;
- mtx_lock(&bufmgr->lock);
+ simple_mtx_lock(&bufmgr->lock);
int ret = drmPrimeFDToHandle(bufmgr->fd, prime_fd, &handle);
if (ret) {
DBG("import_dmabuf: failed to obtain handle from fd: %s\n",
strerror(errno));
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
return NULL;
}
_mesa_hash_table_insert(bufmgr->handle_table, &bo->gem_handle, bo);
out:
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
return bo;
}
return;
}
- mtx_lock(&bufmgr->lock);
+ simple_mtx_lock(&bufmgr->lock);
iris_bo_mark_exported_locked(bo);
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
}
int
if (intel_ioctl(bufmgr->fd, DRM_IOCTL_GEM_FLINK, &flink))
return -errno;
- mtx_lock(&bufmgr->lock);
+ simple_mtx_lock(&bufmgr->lock);
if (!bo->global_name) {
iris_bo_mark_exported_locked(bo);
bo->global_name = flink.name;
_mesa_hash_table_insert(bufmgr->name_table, &bo->global_name, bo);
}
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
}
*name = bo->global_name;
return err;
}
- mtx_lock(&bufmgr->lock);
+ simple_mtx_lock(&bufmgr->lock);
err = drmPrimeFDToHandle(drm_fd, dmabuf_fd, &export->gem_handle);
close(dmabuf_fd);
if (err) {
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
free(export);
return err;
}
if (!found)
list_addtail(&export->link, &bo->exports);
- mtx_unlock(&bufmgr->lock);
+ simple_mtx_unlock(&bufmgr->lock);
*out_handle = export->gem_handle;
p_atomic_set(&bufmgr->refcount, 1);
- if (mtx_init(&bufmgr->lock, mtx_plain) != 0) {
- close(bufmgr->fd);
- free(bufmgr);
- return NULL;
- }
+ simple_mtx_init(&bufmgr->lock, mtx_plain);
list_inithead(&bufmgr->zombie_list);
void
iris_bufmgr_unref(struct iris_bufmgr *bufmgr)
{
- mtx_lock(&global_bufmgr_list_mutex);
+ simple_mtx_lock(&global_bufmgr_list_mutex);
if (p_atomic_dec_zero(&bufmgr->refcount)) {
list_del(&bufmgr->link);
iris_bufmgr_destroy(bufmgr);
}
- mtx_unlock(&global_bufmgr_list_mutex);
+ simple_mtx_unlock(&global_bufmgr_list_mutex);
}
/**
struct iris_bufmgr *bufmgr = NULL;
- mtx_lock(&global_bufmgr_list_mutex);
+ simple_mtx_lock(&global_bufmgr_list_mutex);
list_for_each_entry(struct iris_bufmgr, iter_bufmgr, &global_bufmgr_list, link) {
struct stat iter_st;
if (fstat(iter_bufmgr->fd, &iter_st))
list_addtail(&bufmgr->link, &global_bufmgr_list);
unlock:
- mtx_unlock(&global_bufmgr_list_mutex);
+ simple_mtx_unlock(&global_bufmgr_list_mutex);
return bufmgr;
}