summaryrefslogtreecommitdiff
path: root/src/gallium/winsys
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
commit04f02e573cefb7eb26c574f971ce11460a2e18f9 (patch)
treec1d164479fe4f0b467678c39d723aa48a4897fd9 /src/gallium/winsys
parent96c188d023fa9fd634378b5053138f8b9f28cd05 (diff)
winsys/amdgpu: move amdgpu_winsys_bo::is_user_ptr 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>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.c19
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.h3
2 files changed, 13 insertions, 9 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index a0e1d4d8074..8cb785be064 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -177,11 +177,11 @@ void amdgpu_bo_destroy(struct pb_buffer *_buf)
assert(bo->bo && "must not be called for slab entries");
- if (!bo->is_user_ptr && bo->u.real.cpu_ptr) {
+ if (!bo->u.real.is_user_ptr && bo->u.real.cpu_ptr) {
bo->u.real.cpu_ptr = NULL;
amdgpu_bo_unmap(&bo->base);
}
- assert(bo->is_user_ptr || bo->u.real.map_count == 0);
+ assert(bo->u.real.is_user_ptr || bo->u.real.map_count == 0);
#if DEBUG
if (ws->debug_all_bos) {
@@ -256,7 +256,7 @@ static void amdgpu_clean_up_buffer_managers(struct amdgpu_winsys *ws)
static bool amdgpu_bo_do_map(struct amdgpu_winsys_bo *bo, void **cpu)
{
- assert(!(bo->base.usage & RADEON_FLAG_SPARSE) && bo->bo && !bo->is_user_ptr);
+ assert(!(bo->base.usage & RADEON_FLAG_SPARSE) && bo->bo && !bo->u.real.is_user_ptr);
int r = amdgpu_bo_cpu_map(bo->bo, cpu);
if (r) {
/* Clean up buffer managers and try again. */
@@ -380,7 +380,7 @@ void *amdgpu_bo_map(struct pb_buffer *buf,
}
if (usage & RADEON_MAP_TEMPORARY) {
- if (real->is_user_ptr) {
+ if (real->u.real.is_user_ptr) {
cpu = real->u.real.cpu_ptr;
} else {
if (!amdgpu_bo_do_map(real, &cpu))
@@ -414,10 +414,11 @@ void amdgpu_bo_unmap(struct pb_buffer *buf)
assert(!(bo->base.usage & RADEON_FLAG_SPARSE));
- if (bo->is_user_ptr)
+ real = bo->bo ? bo : bo->u.slab.real;
+
+ if (real->u.real.is_user_ptr)
return;
- real = bo->bo ? bo : bo->u.slab.real;
assert(real->u.real.map_count != 0 && "too many unmaps");
if (p_atomic_dec_zero(&real->u.real.map_count)) {
assert(!real->u.real.cpu_ptr &&
@@ -1724,7 +1725,7 @@ static struct pb_buffer *amdgpu_bo_from_ptr(struct radeon_winsys *rws,
goto error_va_map;
/* Initialize it. */
- bo->is_user_ptr = true;
+ bo->u.real.is_user_ptr = true;
pipe_reference_init(&bo->base.reference, 1);
simple_mtx_init(&bo->lock, mtx_plain);
bo->bo = buf_handle;
@@ -1759,7 +1760,9 @@ error:
static bool amdgpu_bo_is_user_ptr(struct pb_buffer *buf)
{
- return ((struct amdgpu_winsys_bo*)buf)->is_user_ptr;
+ struct amdgpu_winsys_bo *bo = (struct amdgpu_winsys_bo*)buf;
+
+ return bo->bo ? bo->u.real.is_user_ptr : false;
}
static bool amdgpu_bo_is_suballocated(struct pb_buffer *buf)
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
index 98fb609153c..176d2e1583b 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.h
@@ -67,6 +67,8 @@ struct amdgpu_winsys_bo {
uint32_t kms_handle;
int map_count;
+ bool is_user_ptr;
+
/* Whether buffer_get_handle or buffer_from_handle has been called,
* it can only transition from false to true. Protected by lock.
*/
@@ -92,7 +94,6 @@ struct amdgpu_winsys_bo {
struct amdgpu_winsys *ws;
amdgpu_bo_handle bo; /* NULL for slab entries and sparse buffers */
- bool is_user_ptr;
bool use_reusable_pool;
uint32_t unique_id;