From db57624c0ca693fae38871787cabab50e58358d7 Mon Sep 17 00:00:00 2001 From: Pierre-Eric Pelloux-Prayer Date: Fri, 5 Jun 2020 14:40:01 +0200 Subject: [PATCH] winsys/radeon: do not cast bo->va as void* MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Using a util_hash_table_create_ptr_keys to store bo->va address doesn't work on 32 bits. This commit makes radeon_drm_winsys::bo_vas a hash_table_u64 instead. Tested by Miklós Máté. CC: 20.1 Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/3056 Reviewed-by: Marek Olšák Part-of: --- src/gallium/winsys/radeon/drm/radeon_drm_bo.c | 12 ++++++------ src/gallium/winsys/radeon/drm/radeon_drm_winsys.c | 4 ++-- src/gallium/winsys/radeon/drm/radeon_drm_winsys.h | 6 +++--- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c index 948e0b20ce3..f432b9bfe01 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_bo.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_bo.c @@ -718,14 +718,14 @@ static struct radeon_bo *radeon_create_bo(struct radeon_drm_winsys *rws, if (va.operation == RADEON_VA_RESULT_VA_EXIST) { struct pb_buffer *b = &bo->base; struct radeon_bo *old_bo = - util_hash_table_get(rws->bo_vas, (void*)(uintptr_t)va.offset); + _mesa_hash_table_u64_search(rws->bo_vas, va.offset); mtx_unlock(&rws->bo_handles_mutex); pb_reference(&b, &old_bo->base); return radeon_bo(b); } - _mesa_hash_table_insert(rws->bo_vas, (void*)(uintptr_t)bo->va, bo); + _mesa_hash_table_u64_insert(rws->bo_vas, bo->va, bo); mtx_unlock(&rws->bo_handles_mutex); } @@ -1164,14 +1164,14 @@ static struct pb_buffer *radeon_winsys_bo_from_ptr(struct radeon_winsys *rws, if (va.operation == RADEON_VA_RESULT_VA_EXIST) { struct pb_buffer *b = &bo->base; struct radeon_bo *old_bo = - util_hash_table_get(ws->bo_vas, (void*)(uintptr_t)va.offset); + _mesa_hash_table_u64_search(ws->bo_vas, va.offset); mtx_unlock(&ws->bo_handles_mutex); pb_reference(&b, &old_bo->base); return b; } - _mesa_hash_table_insert(ws->bo_vas, (void*)(uintptr_t)bo->va, bo); + _mesa_hash_table_u64_insert(ws->bo_vas, bo->va, bo); mtx_unlock(&ws->bo_handles_mutex); } @@ -1295,14 +1295,14 @@ done: if (va.operation == RADEON_VA_RESULT_VA_EXIST) { struct pb_buffer *b = &bo->base; struct radeon_bo *old_bo = - util_hash_table_get(ws->bo_vas, (void*)(uintptr_t)va.offset); + _mesa_hash_table_u64_search(ws->bo_vas, va.offset); mtx_unlock(&ws->bo_handles_mutex); pb_reference(&b, &old_bo->base); return b; } - _mesa_hash_table_insert(ws->bo_vas, (void*)(uintptr_t)bo->va, bo); + _mesa_hash_table_u64_insert(ws->bo_vas, bo->va, bo); mtx_unlock(&ws->bo_handles_mutex); } diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c index 5f52fda52dc..f2ed0d725d4 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.c @@ -628,7 +628,7 @@ static void radeon_winsys_destroy(struct radeon_winsys *rws) _mesa_hash_table_destroy(ws->bo_names, NULL); _mesa_hash_table_destroy(ws->bo_handles, NULL); - _mesa_hash_table_destroy(ws->bo_vas, NULL); + _mesa_hash_table_u64_destroy(ws->bo_vas, NULL); mtx_destroy(&ws->bo_handles_mutex); mtx_destroy(&ws->vm32.mutex); mtx_destroy(&ws->vm64.mutex); @@ -900,7 +900,7 @@ radeon_drm_winsys_create(int fd, const struct pipe_screen_config *config, ws->bo_names = util_hash_table_create_ptr_keys(); ws->bo_handles = util_hash_table_create_ptr_keys(); - ws->bo_vas = util_hash_table_create_ptr_keys(); + ws->bo_vas = _mesa_hash_table_u64_create(NULL); (void) mtx_init(&ws->bo_handles_mutex, mtx_plain); (void) mtx_init(&ws->vm32.mutex, mtx_plain); (void) mtx_init(&ws->vm64.mutex, mtx_plain); diff --git a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h index a45478f4244..da166192f95 100644 --- a/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h +++ b/src/gallium/winsys/radeon/drm/radeon_drm_winsys.h @@ -78,10 +78,10 @@ struct radeon_drm_winsys { /* List of buffer GEM names. Protected by bo_handles_mutex. */ struct hash_table *bo_names; - /* List of buffer handles. Protectded by bo_handles_mutex. */ + /* List of buffer handles. Protected by bo_handles_mutex. */ struct hash_table *bo_handles; - /* List of buffer virtual memory ranges. Protectded by bo_handles_mutex. */ - struct hash_table *bo_vas; + /* List of buffer virtual memory ranges. Protected by bo_handles_mutex. */ + struct hash_table_u64 *bo_vas; mtx_t bo_handles_mutex; mtx_t bo_fence_lock; -- 2.30.2