[PATCH libdrm 2/2] freedreno: simplify locking in fd_bo_from_dmabuf

Philipp Zabel p.zabel at pengutronix.de
Mon Aug 21 10:57:05 UTC 2017


There should be no reason to call drmPrimeFDToHandle under the
table_lock mutex. Instead of taking the lock early and releasing it in
two places, just take it after trying to obtain the handle.

Signed-off-by: Philipp Zabel <p.zabel at pengutronix.de>
---
 freedreno/freedreno_bo.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/freedreno/freedreno_bo.c b/freedreno/freedreno_bo.c
index 7f8ea59c..2eb38e45 100644
--- a/freedreno/freedreno_bo.c
+++ b/freedreno/freedreno_bo.c
@@ -135,13 +135,13 @@ 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) {
-		pthread_mutex_unlock(&table_lock);
 		return NULL;
 	}
 
+	pthread_mutex_lock(&table_lock);
+
 	bo = lookup_bo(dev->handle_table, handle);
 	if (bo)
 		goto out_unlock;
-- 
2.11.0



More information about the dri-devel mailing list