mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-25 00:00:11 +01:00
winsys/amdgpu: pack amdgpu_winsys_bo::is_shared and protect it by a mutex
The initialization of abs_timeout fixes a warning that started appearing with this commit. Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com> Reviewed-by: Zoltán Böszörményi <zboszor@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8849>
This commit is contained in:
parent
ff311df6b5
commit
c3778b8fe1
2 changed files with 19 additions and 8 deletions
|
|
@ -52,7 +52,7 @@ static bool amdgpu_bo_wait(struct pb_buffer *_buf, uint64_t timeout,
|
|||
{
|
||||
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))
|
||||
|
|
@ -66,7 +66,11 @@ static bool amdgpu_bo_wait(struct pb_buffer *_buf, uint64_t timeout,
|
|||
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.
|
||||
|
|
@ -1631,7 +1635,11 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws,
|
|||
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;
|
||||
|
|
@ -1677,7 +1685,9 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws,
|
|||
_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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -89,6 +89,12 @@ struct amdgpu_winsys_bo {
|
|||
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;
|
||||
|
|
@ -97,11 +103,6 @@ struct amdgpu_winsys_bo {
|
|||
* 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;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue