Re: [PATCH libdrm 1/1] amdgpu: Take lock before removing devices from fd_tab hash table.

2018-05-17 Thread Jan Vesely
On Thu, 2018-05-10 at 19:33 -0400, Jan Vesely wrote:
> Close the file descriptors under lock as well.
> 
> Signed-off-by: Jan Vesely 
> ---
>  amdgpu/amdgpu_device.c | 11 +++
>  1 file changed, 7 insertions(+), 4 deletions(-)
> 
> diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
> index 983b19ab..f71fc050 100644
> --- a/amdgpu/amdgpu_device.c
> +++ b/amdgpu/amdgpu_device.c
> @@ -126,6 +126,13 @@ static int amdgpu_get_auth(int fd, int *auth)
>  
>  static void amdgpu_device_free_internal(amdgpu_device_handle dev)
>  {
> + pthread_mutex_lock(_mutex);
> + close(dev->fd);
> + if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
> + close(dev->flink_fd);
> + util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd));
> + pthread_mutex_unlock(_mutex);
> +
>   amdgpu_vamgr_deinit(>vamgr_32);
>   amdgpu_vamgr_deinit(>vamgr);
>   amdgpu_vamgr_deinit(>vamgr_high_32);
> @@ -133,10 +140,6 @@ static void 
> amdgpu_device_free_internal(amdgpu_device_handle dev)
>   util_hash_table_destroy(dev->bo_flink_names);
>   util_hash_table_destroy(dev->bo_handles);
>   pthread_mutex_destroy(>bo_table_mutex);
> - util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd));
> - close(dev->fd);
> - if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
> - close(dev->flink_fd);
>   free(dev->marketing_name);
>   free(dev);
>  }
ping.

Jan

signature.asc
Description: This is a digitally signed message part
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH libdrm 1/1] amdgpu: Take lock before removing devices from fd_tab hash table.

2018-05-10 Thread Jan Vesely
Close the file descriptors under lock as well.

Signed-off-by: Jan Vesely 
---
 amdgpu/amdgpu_device.c | 11 +++
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/amdgpu/amdgpu_device.c b/amdgpu/amdgpu_device.c
index 983b19ab..f71fc050 100644
--- a/amdgpu/amdgpu_device.c
+++ b/amdgpu/amdgpu_device.c
@@ -126,6 +126,13 @@ static int amdgpu_get_auth(int fd, int *auth)
 
 static void amdgpu_device_free_internal(amdgpu_device_handle dev)
 {
+   pthread_mutex_lock(_mutex);
+   close(dev->fd);
+   if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
+   close(dev->flink_fd);
+   util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd));
+   pthread_mutex_unlock(_mutex);
+
amdgpu_vamgr_deinit(>vamgr_32);
amdgpu_vamgr_deinit(>vamgr);
amdgpu_vamgr_deinit(>vamgr_high_32);
@@ -133,10 +140,6 @@ static void 
amdgpu_device_free_internal(amdgpu_device_handle dev)
util_hash_table_destroy(dev->bo_flink_names);
util_hash_table_destroy(dev->bo_handles);
pthread_mutex_destroy(>bo_table_mutex);
-   util_hash_table_remove(fd_tab, UINT_TO_PTR(dev->fd));
-   close(dev->fd);
-   if ((dev->flink_fd >= 0) && (dev->fd != dev->flink_fd))
-   close(dev->flink_fd);
free(dev->marketing_name);
free(dev);
 }
-- 
2.17.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel