summaryrefslogtreecommitdiffstats
path: root/src/gallium
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2020-01-28 11:12:24 +0100
committerMarge Bot <[email protected]>2020-01-29 15:51:01 +0000
commitca6a22305b275b49fbc88b8f4cba2fefb24c2a5d (patch)
treef862de0d2fdca5d372499a90778e14abcf07cd8c /src/gallium
parent9f2bed49d476a15af0df270307f9051d810ea0ab (diff)
winsys/amdgpu: Close KMS handles for other DRM file descriptions
When a BO or amdgpu_screen_winsys is destroyed. Should fix leaking such BOs in other DRM file descriptions. v2: * Pass the correct file descriptor to drmIoctl (Pierre-Eric Pelloux-Prayer) * Use _mesa_hash_table_remove v3: * Close handles in amdgpu_winsys_unref as well v4: * Adapt to amdgpu_winsys::sws_list_lock. Closes: https://gitlab.freedesktop.org/mesa/mesa/issues/2270 Fixes: 11a3679e3aba "winsys/amdgpu: Make KMS handles valid for original DRM file descriptor" Reviewed-by: Pierre-Eric Pelloux-Prayer <[email protected]> Reviewed-by: Marek Olšák <[email protected]> Tested-by: Marge Bot <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3582> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3582>
Diffstat (limited to 'src/gallium')
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_bo.c15
-rw-r--r--src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c9
2 files changed, 21 insertions, 3 deletions
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
index 3762b9d0c44..18ed3aaa596 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_bo.c
@@ -179,10 +179,21 @@ void amdgpu_bo_destroy(struct pb_buffer *_buf)
simple_mtx_unlock(&ws->global_bo_list_lock);
}
+ /* Close all KMS handles retrieved for other DRM file descriptions */
simple_mtx_lock(&ws->sws_list_lock);
for (sws_iter = ws->sws_list; sws_iter; sws_iter = sws_iter->next) {
- if (sws_iter->kms_handles)
- _mesa_hash_table_remove_key(sws_iter->kms_handles, bo);
+ struct hash_entry *entry;
+
+ if (!sws_iter->kms_handles)
+ continue;
+
+ entry = _mesa_hash_table_search(sws_iter->kms_handles, bo);
+ if (entry) {
+ struct drm_gem_close args = { .handle = (uintptr_t)entry->data };
+
+ drmIoctl(sws_iter->fd, DRM_IOCTL_GEM_CLOSE, &args);
+ _mesa_hash_table_remove(sws_iter->kms_handles, entry);
+ }
}
simple_mtx_unlock(&ws->sws_list_lock);
diff --git a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
index 89d3d93bb5f..4bbd50664ba 100644
--- a/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
+++ b/src/gallium/winsys/amdgpu/drm/amdgpu_winsys.c
@@ -304,8 +304,15 @@ static bool amdgpu_winsys_unref(struct radeon_winsys *rws)
simple_mtx_unlock(&aws->sws_list_lock);
- if (ret && sws->kms_handles)
+ if (ret && sws->kms_handles) {
+ struct drm_gem_close args;
+
+ hash_table_foreach(sws->kms_handles, entry) {
+ args.handle = (uintptr_t)entry->data;
+ drmIoctl(sws->fd, DRM_IOCTL_GEM_CLOSE, &args);
+ }
_mesa_hash_table_destroy(sws->kms_handles, NULL);
+ }
return ret;
}