summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2021-02-03 00:03:22 -0500
committerMarge Bot <eric+marge@anholt.net>2021-02-06 05:41:23 +0000
commit96c188d023fa9fd634378b5053138f8b9f28cd05 (patch)
tree0b052065a9f3c473b92b25c06090c9594c589871
parent4bb9df366a74b0f691c971a674357beebad4e86d (diff)
winsys/amdgpu: move amdgpu_winsys_bo::is_shared to the u.real union
It's never true with slab and sparse buffers. 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>
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.c15
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.h10
2 files changed, 14 insertions, 11 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index fab526da6cf..a0e1d4d8074 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -66,9 +66,12 @@ static bool amdgpu_bo_wait(struct pb_buffer *_buf, uint64_t timeout,
return false;
}
- simple_mtx_lock(&bo->lock);
- bool is_shared = bo->is_shared;
- simple_mtx_unlock(&bo->lock);
+ bool is_shared = false;
+ if (bo->bo) {
+ simple_mtx_lock(&bo->lock);
+ is_shared = bo->u.real.is_shared;
+ simple_mtx_unlock(&bo->lock);
+ }
if (is_shared) {
/* We can't use user fences for shared buffers, because user fences
@@ -1584,7 +1587,7 @@ static struct pb_buffer *amdgpu_bo_from_handle(struct radeon_winsys *rws,
bo->base.placement = initial;
bo->base.usage = flags;
bo->unique_id = __sync_fetch_and_add(&ws->next_bo_unique_id, 1);
- bo->is_shared = true;
+ bo->u.real.is_shared = true;
if (bo->base.placement & RADEON_DOMAIN_VRAM)
ws->allocated_vram += align64(bo->base.size, ws->info.gart_page_size);
@@ -1636,7 +1639,7 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws,
whandle->handle = bo->u.real.kms_handle;
simple_mtx_lock(&bo->lock);
- bool is_shared = bo->is_shared;
+ bool is_shared = bo->u.real.is_shared;
simple_mtx_unlock(&bo->lock);
if (is_shared)
@@ -1686,7 +1689,7 @@ static bool amdgpu_bo_get_handle(struct radeon_winsys *rws,
simple_mtx_unlock(&ws->bo_export_table_lock);
simple_mtx_lock(&bo->lock);
- bo->is_shared = true;
+ bo->u.real.is_shared = true;
simple_mtx_unlock(&bo->lock);
return true;
}
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
index 9eb69ea7f72..98fb609153c 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
@@ -66,6 +66,11 @@ struct amdgpu_winsys_bo {
void *cpu_ptr; /* for user_ptr and permanent maps */
uint32_t kms_handle;
int map_count;
+
+ /* 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;
} real;
struct {
struct pb_slab_entry entry;
@@ -90,11 +95,6 @@ struct amdgpu_winsys_bo {
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;