{
struct amdgpu_winsys_bo *bo = amdgpu_winsys_bo(_buf);
struct amdgpu_winsys *ws = bo->ws;
- int64_t abs_timeout;
+ int64_t abs_timeout = 0;
if (timeout == 0) {
if (p_atomic_read(&bo->num_active_ioctls))
return false;
}
- if (bo->is_shared) {
+ simple_mtx_lock(&bo->lock);
+ bool is_shared = bo->is_shared;
+ simple_mtx_unlock(&bo->lock);
+
+ if (is_shared) {
/* We can't use user fences for shared buffers, because user fences
* are local to this process only. If we want to wait for all buffer
* uses in all processes, we have to use amdgpu_bo_wait_for_idle.
if (sws->fd == ws->fd) {
whandle->handle = bo->u.real.kms_handle;
- if (bo->is_shared)
+ simple_mtx_lock(&bo->lock);
+ bool is_shared = bo->is_shared;
+ simple_mtx_unlock(&bo->lock);
+
+ if (is_shared)
return true;
goto hash_table_set;
_mesa_hash_table_insert(ws->bo_export_table, bo->bo, bo);
simple_mtx_unlock(&ws->bo_export_table_lock);
+ simple_mtx_lock(&bo->lock);
bo->is_shared = true;
+ simple_mtx_unlock(&bo->lock);
return true;
}
amdgpu_bo_handle bo; /* NULL for slab entries and sparse buffers */
bool is_user_ptr;
bool use_reusable_pool;
+
+ /* Whether buffer_get_handle or buffer_from_handle has been called,
+ * it can only transition from false to true. Protected by lock.
+ */
+ bool is_shared;
+
uint32_t unique_id;
uint64_t va;
simple_mtx_t lock;
* thread, is this bo referenced in? */
volatile int num_active_ioctls;
- /* whether buffer_get_handle or buffer_from_handle was called,
- * it can only transition from false to true
- */
- volatile int is_shared; /* bool (int for atomicity) */
-
/* Fences for buffer synchronization. */
unsigned num_fences;
unsigned max_fences;