diff options
author | Varad Gautam <varadgautam@gmail.com> | 2015-08-30 15:30:58 +0530 |
---|---|---|
committer | Rob Clark <robclark@freedesktop.org> | 2015-08-31 11:54:23 -0400 |
commit | c3301d013444b7b5d02c58307e188e292d8cf18a (patch) | |
tree | 6d1de0f54f39e0dde332e6f6caba4aa9d1d8b969 /freedreno | |
parent | cc7db673fabb77cf8bb9a00dcb0864c4b125ab6f (diff) |
freedreno: serialize drmPrimeFDToHandle under table_lock
fixes the prime sharing race condition described by
"intel: Serialize drmPrimeFDToHandle with struct_mutex".
we inline fd_bo_from_handle() into fd_bo_from_dmabuf() and allow locking.
Signed-off-by: Varad Gautam <varadgautam@gmail.com>
Signed-off-by: Rob Clark <robclark@freedesktop.org>
Diffstat (limited to 'freedreno')
-rw-r--r-- | freedreno/freedreno_bo.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/freedreno/freedreno_bo.c b/freedreno/freedreno_bo.c index 45187459..80ecd3af 100644 --- a/freedreno/freedreno_bo.c +++ b/freedreno/freedreno_bo.c @@ -230,18 +230,26 @@ fd_bo_from_dmabuf(struct fd_device *dev, int fd) uint32_t handle; struct fd_bo *bo; + pthread_mutex_lock(&table_lock); ret = drmPrimeFDToHandle(dev->fd, fd, &handle); if (ret) { return NULL; } + bo = lookup_bo(dev->handle_table, handle); + if (bo) + goto out_unlock; + /* lseek() to get bo size */ size = lseek(fd, 0, SEEK_END); lseek(fd, 0, SEEK_CUR); - bo = fd_bo_from_handle(dev, handle, size); + bo = bo_from_handle(dev, size, handle); bo->fd = fd; +out_unlock: + pthread_mutex_unlock(&table_lock); + return bo; } |