* [PATCH libdrm 1/1] amdgpu: Take lock before removing devices from fd_tab hash table.
@ 2018-05-10 23:33 Jan Vesely
[not found] ` <20180510233316.21437-1-jan.vesely-kgbqMDwikbSVc3sceRu5cw@public.gmane.org>
0 siblings, 1 reply; 2+ messages in thread
From: Jan Vesely @ 2018-05-10 23:33 UTC (permalink / raw)
To: amd-gfx, dri-devel
Close the file descriptors under lock as well.
Signed-off-by: Jan Vesely <jan.vesely@rutgers.edu>
---
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(&fd_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(&fd_mutex);
+
amdgpu_vamgr_deinit(&dev->vamgr_32);
amdgpu_vamgr_deinit(&dev->vamgr);
amdgpu_vamgr_deinit(&dev->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(&dev->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
^ permalink raw reply related [flat|nested] 2+ messages in thread[parent not found: <20180510233316.21437-1-jan.vesely-kgbqMDwikbSVc3sceRu5cw@public.gmane.org>]
* Re: [PATCH libdrm 1/1] amdgpu: Take lock before removing devices from fd_tab hash table. [not found] ` <20180510233316.21437-1-jan.vesely-kgbqMDwikbSVc3sceRu5cw@public.gmane.org> @ 2018-05-18 0:47 ` Jan Vesely 0 siblings, 0 replies; 2+ messages in thread From: Jan Vesely @ 2018-05-18 0:47 UTC (permalink / raw) To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW [-- Attachment #1.1: Type: text/plain, Size: 1460 bytes --] 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 <jan.vesely-kgbqMDwikbSVc3sceRu5cw@public.gmane.org> > --- > 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(&fd_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(&fd_mutex); > + > amdgpu_vamgr_deinit(&dev->vamgr_32); > amdgpu_vamgr_deinit(&dev->vamgr); > amdgpu_vamgr_deinit(&dev->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(&dev->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 [-- Attachment #1.2: This is a digitally signed message part --] [-- Type: application/pgp-signature, Size: 488 bytes --] [-- Attachment #2: Type: text/plain, Size: 154 bytes --] _______________________________________________ amd-gfx mailing list amd-gfx@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/amd-gfx ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2018-05-18 0:47 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-05-10 23:33 [PATCH libdrm 1/1] amdgpu: Take lock before removing devices from fd_tab hash table Jan Vesely
[not found] ` <20180510233316.21437-1-jan.vesely-kgbqMDwikbSVc3sceRu5cw@public.gmane.org>
2018-05-18 0:47 ` Jan Vesely
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).