All of lore.kernel.org
 help / color / mirror / Atom feed
From: Philipp Zabel <p.zabel@pengutronix.de>
To: dri-devel@lists.freedesktop.org
Cc: etnaviv@lists.freedesktop.org
Subject: [PATCH libdrm 2/2] freedreno: simplify locking in fd_bo_from_dmabuf
Date: Mon, 21 Aug 2017 12:57:05 +0200	[thread overview]
Message-ID: <20170821105705.4822-2-p.zabel@pengutronix.de> (raw)
In-Reply-To: <20170821105705.4822-1-p.zabel@pengutronix.de>

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@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

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

  reply	other threads:[~2017-08-21 10:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-08-21 10:57 [PATCH libdrm 1/2] etnaviv: prevent deadlock in error path Philipp Zabel
2017-08-21 10:57 ` Philipp Zabel [this message]
2017-08-21 11:01 ` Christian Gmeiner
2017-08-21 11:05 ` Emil Velikov
2017-08-21 12:24   ` Philipp Zabel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170821105705.4822-2-p.zabel@pengutronix.de \
    --to=p.zabel@pengutronix.de \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=etnaviv@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.