linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jonathan Marek <jonathan@marek.ca>
To: linux-arm-msm@vger.kernel.org
Cc: srinivas.kandagatla@linaro.org, Arnd Bergmann <arnd@arndb.de>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-kernel@vger.kernel.org (open list)
Subject: [PATCH 1/3] fastrpc: always use fl->lock and remove fl->mutex
Date: Wed, 17 Feb 2021 22:20:53 -0500	[thread overview]
Message-ID: <20210218032055.28247-2-jonathan@marek.ca> (raw)
In-Reply-To: <20210218032055.28247-1-jonathan@marek.ca>

Fix the broken behavior of having a separate mutex for locking at this
place, and use the same spinlock that is used to add/remove from the list.

Signed-off-by: Jonathan Marek <jonathan@marek.ca>
---
 drivers/misc/fastrpc.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index f12e909034ac..4fabea0c1551 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -230,8 +230,6 @@ struct fastrpc_user {
 	int pd;
 	/* Lock for lists */
 	spinlock_t lock;
-	/* lock for allocations */
-	struct mutex mutex;
 };
 
 static void fastrpc_free_map(struct kref *ref)
@@ -267,16 +265,16 @@ static int fastrpc_map_find(struct fastrpc_user *fl, int fd,
 {
 	struct fastrpc_map *map = NULL;
 
-	mutex_lock(&fl->mutex);
+	spin_lock(&fl->lock);
 	list_for_each_entry(map, &fl->maps, node) {
 		if (map->fd == fd) {
 			fastrpc_map_get(map);
 			*ppmap = map;
-			mutex_unlock(&fl->mutex);
+			spin_unlock(&fl->lock);
 			return 0;
 		}
 	}
-	mutex_unlock(&fl->mutex);
+	spin_unlock(&fl->lock);
 
 	return -ENOENT;
 }
@@ -1200,7 +1198,6 @@ static int fastrpc_device_release(struct inode *inode, struct file *file)
 	fastrpc_session_free(cctx, fl->sctx);
 	fastrpc_channel_ctx_put(cctx);
 
-	mutex_destroy(&fl->mutex);
 	kfree(fl);
 	file->private_data = NULL;
 
@@ -1222,7 +1219,6 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
 
 	filp->private_data = fl;
 	spin_lock_init(&fl->lock);
-	mutex_init(&fl->mutex);
 	INIT_LIST_HEAD(&fl->pending);
 	INIT_LIST_HEAD(&fl->maps);
 	INIT_LIST_HEAD(&fl->mmaps);
@@ -1233,7 +1229,6 @@ static int fastrpc_device_open(struct inode *inode, struct file *filp)
 	fl->sctx = fastrpc_session_alloc(cctx);
 	if (!fl->sctx) {
 		dev_err(&cctx->rpdev->dev, "No session available\n");
-		mutex_destroy(&fl->mutex);
 		kfree(fl);
 
 		return -EBUSY;
-- 
2.26.1


  reply	other threads:[~2021-02-18  3:23 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-18  3:20 [PATCH 0/3] fastrpc: fix dmabuf arguments Jonathan Marek
2021-02-18  3:20 ` Jonathan Marek [this message]
2021-02-18  3:20 ` [PATCH 2/3] fastrpc: move fl->maps list removal into fastrpc_free_map Jonathan Marek
2021-02-18  3:20 ` [PATCH 3/3] fastrpc: remove redundant fastrpc_map_create() call Jonathan Marek
2021-02-22 12:37   ` Srinivas Kandagatla
2021-02-22 13:53     ` Jonathan Marek
2021-02-23  9:43       ` Srinivas Kandagatla

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=20210218032055.28247-2-jonathan@marek.ca \
    --to=jonathan@marek.ca \
    --cc=arnd@arndb.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=srinivas.kandagatla@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).