diff options
author | Michel Dänzer <[email protected]> | 2019-09-30 18:36:06 +0200 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2020-01-23 17:23:32 +0100 |
commit | f4010a6da9720b1593ca34faf0d8722ca85ed6c2 (patch) | |
tree | f2bcc12119f5d501217f1e5ee576edcbd15eeced /src/gallium/winsys | |
parent | 8d5203dad255b76501b74ac3cb5fcec977c7d21c (diff) |
winsys/amdgpu: Keep a list of amdgpu_screen_winsyses in amdgpu_winsys
v2:
* Add dedicated mutex for the list.
Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3202>
Diffstat (limited to 'src/gallium/winsys')
-rw-r--r-- | src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c | 22 | ||||
-rw-r--r-- | src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h | 7 |
2 files changed, 28 insertions, 1 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c index 2a341413033..dfdd6fb1631 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c @@ -138,6 +138,7 @@ static void do_winsys_deinit(struct amdgpu_winsys *ws) } pb_cache_deinit(&ws->bo_cache); util_hash_table_destroy(ws->bo_export_table); + simple_mtx_destroy(&ws->sws_list_lock); simple_mtx_destroy(&ws->global_bo_list_lock); simple_mtx_destroy(&ws->bo_export_table_lock); @@ -171,8 +172,21 @@ static void amdgpu_winsys_destroy(struct radeon_winsys *rws) simple_mtx_unlock(&dev_tab_mutex); - if (destroy) + if (destroy) { do_winsys_deinit(ws); + } else { + struct amdgpu_screen_winsys **sws_iter; + + /* Remove this amdgpu_screen_winsys from amdgpu_winsys' list */ + simple_mtx_lock(&ws->sws_list_lock); + for (sws_iter = &ws->sws_list; *sws_iter; sws_iter = &(*sws_iter)->next) { + if (*sws_iter == sws) { + *sws_iter = sws->next; + break; + } + } + simple_mtx_unlock(&ws->sws_list_lock); + } close(sws->fd); FREE(rws); @@ -385,6 +399,7 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config, list_inithead(&aws->global_bo_list); aws->bo_export_table = util_hash_table_create(hash_pointer, compare_pointers); + (void) simple_mtx_init(&aws->sws_list_lock, mtx_plain); (void) simple_mtx_init(&aws->global_bo_list_lock, mtx_plain); (void) simple_mtx_init(&aws->bo_fence_lock, mtx_plain); (void) simple_mtx_init(&aws->bo_export_table_lock, mtx_plain); @@ -435,6 +450,11 @@ amdgpu_winsys_create(int fd, const struct pipe_screen_config *config, return NULL; } + simple_mtx_lock(&aws->sws_list_lock); + ws->next = aws->sws_list; + aws->sws_list = ws; + simple_mtx_unlock(&aws->sws_list_lock); + /* We must unlock the mutex once the winsys is fully initialized, so that * other threads attempting to create the winsys from the same fd will * get a fully initialized winsys and not just half-way initialized. */ diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h index 1ff16072829..43e1df09ad5 100644 --- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h +++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.h @@ -87,6 +87,12 @@ struct amdgpu_winsys { struct list_head global_bo_list; unsigned num_buffers; + /* Single-linked list of all structs amdgpu_screen_winsys referencing this + * struct amdgpu_winsys + */ + simple_mtx_t sws_list_lock; + struct amdgpu_screen_winsys *sws_list; + /* For returning the same amdgpu_winsys_bo instance for exported * and re-imported buffers. */ struct util_hash_table *bo_export_table; @@ -97,6 +103,7 @@ struct amdgpu_screen_winsys { struct radeon_winsys base; struct amdgpu_winsys *aws; int fd; + struct amdgpu_screen_winsys *next; }; static inline struct amdgpu_screen_winsys * |