summaryrefslogtreecommitdiff
path: root/amdgpu
diff options
context:
space:
mode:
authorChristian König <christian.koenig@amd.com>2015-08-24 11:43:30 +0200
committerAlex Deucher <alexander.deucher@amd.com>2015-08-25 10:27:45 -0400
commita5ea0c64c5ce673662249557b03c412fcc53e6c1 (patch)
treef7bbbb78e2252c2b48876be5263cdec5cca622b7 /amdgpu
parentf6f25d67a9c0d26be9b8021a45f2acf3a4042ade (diff)
downloadlibdrm-a5ea0c64c5ce673662249557b03c412fcc53e6c1.tar.gz
libdrm-a5ea0c64c5ce673662249557b03c412fcc53e6c1.tar.bz2
libdrm-a5ea0c64c5ce673662249557b03c412fcc53e6c1.zip
amdgpu: serialize drmPrimeFDToHandle
Fixes the same problem as "intel: Serialize drmPrimeFDToHandle with struct_mutex". Reviewed-by: Jammy Zhou <Jammy.Zhou@amd.com> Signed-off-by: Christian König <christian.koenig@amd.com>
Diffstat (limited to 'amdgpu')
-rw-r--r--amdgpu/amdgpu_bo.c9
1 files changed, 5 insertions, 4 deletions
diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c
index 7607f2c7..220422d8 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -290,6 +290,10 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
int dma_fd;
uint64_t dma_buf_size = 0;
+ /* We must maintain a list of pairs <handle, bo>, so that we always
+ * return the same amdgpu_bo instance for the same handle. */
+ pthread_mutex_lock(&dev->bo_table_mutex);
+
/* Convert a DMA buf handle to a KMS handle now. */
if (type == amdgpu_bo_handle_type_dma_buf_fd) {
uint32_t handle;
@@ -304,6 +308,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
/* Query the buffer size. */
size = lseek(shared_handle, 0, SEEK_END);
if (size == (off_t)-1) {
+ pthread_mutex_unlock(&dev->bo_table_mutex);
amdgpu_close_kms_handle(dev, handle);
return -errno;
}
@@ -313,10 +318,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev,
shared_handle = handle;
}
- /* We must maintain a list of pairs <handle, bo>, so that we always
- * return the same amdgpu_bo instance for the same handle. */
- pthread_mutex_lock(&dev->bo_table_mutex);
-
/* If we have already created a buffer with this handle, find it. */
switch (type) {
case amdgpu_bo_handle_type_gem_flink_name: