RE: [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Both patches are Reviewed-by: Jammy Zhou <Jammy.Zhou@xxxxxxx>

Regards,
Jammy

-----Original Message-----
From: dri-devel [mailto:dri-devel-bounces@xxxxxxxxxxxxxxxxxxxxx] On Behalf Of Christian K?nig
Sent: Monday, August 24, 2015 5:44 PM
To: dri-devel@xxxxxxxxxxxxxxxxxxxxx
Subject: [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle

From: Christian König <christian.koenig@xxxxxxx>

Fixes the same problem as "intel: Serialize drmPrimeFDToHandle with struct_mutex".

Signed-off-by: Christian König <christian.koenig@xxxxxxx>
---
 amdgpu/amdgpu_bo.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index dab3804..adf4253 100644
--- a/amdgpu/amdgpu_bo.c
+++ b/amdgpu/amdgpu_bo.c
@@ -289,6 +289,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;
@@ -303,6 +307,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;
 		}
@@ -312,10 +317,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:
--
1.9.1

_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/dri-devel




[Index of Archives]     [Linux DRI Users]     [Linux Intel Graphics]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [XFree86]
  Powered by Linux