mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tudor Ambarus <tudor.ambarus@linaro.org>
To: Jassi Brar <jassisinghbrar@gmail.com>
Cc: linux-kernel@vger.kernel.org, andre.draszik@linaro.org,
	 peter.griffin@linaro.org, willmcvicker@google.com,
	kernel-team@android.com,
	 Tudor Ambarus <tudor.ambarus@linaro.org>
Subject: [PATCH v2 2/6] mailbox: don't protect of_parse_phandle_with_args with con_mutex
Date: Mon, 24 Feb 2025 08:27:14 +0000	[thread overview]
Message-ID: <20250224-mbox-mutex-v2-2-9d699148fe4e@linaro.org> (raw)
In-Reply-To: <20250224-mbox-mutex-v2-0-9d699148fe4e@linaro.org>

There are no concurrency problems if multiple consumers parse the
phandle, don't gratuiously protect the parsing with the mutex used
for the controllers list.

Signed-off-by: Tudor Ambarus <tudor.ambarus@linaro.org>
---
 drivers/mailbox/mailbox.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c
index cb174e788a96..784b56859a06 100644
--- a/drivers/mailbox/mailbox.c
+++ b/drivers/mailbox/mailbox.c
@@ -413,16 +413,15 @@ struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index)
 		return ERR_PTR(-ENODEV);
 	}
 
-	mutex_lock(&con_mutex);
-
 	ret = of_parse_phandle_with_args(dev->of_node, "mboxes", "#mbox-cells",
 					 index, &spec);
 	if (ret) {
 		dev_dbg(dev, "%s: can't parse \"mboxes\" property\n", __func__);
-		mutex_unlock(&con_mutex);
 		return ERR_PTR(ret);
 	}
 
+	mutex_lock(&con_mutex);
+
 	chan = ERR_PTR(-EPROBE_DEFER);
 	list_for_each_entry(mbox, &mbox_cons, node)
 		if (mbox->dev->of_node == spec.np) {

-- 
2.48.1.601.g30ceb7b040-goog


  parent reply	other threads:[~2025-02-24  8:27 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-24  8:27 [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus
2025-02-24  8:27 ` [PATCH v2 1/6] mailbox: use error ret code of of_parse_phandle_with_args() Tudor Ambarus
2025-02-24  8:27 ` Tudor Ambarus [this message]
2025-02-24  8:27 ` [PATCH v2 3/6] mailbox: sort headers alphabetically Tudor Ambarus
2025-02-24  8:27 ` [PATCH v2 4/6] mailbox: explicitly include <linux/bits.h> Tudor Ambarus
2025-02-24  8:27 ` [PATCH v2 5/6] mailbox: remove unused header files Tudor Ambarus
2025-02-24  8:27 ` [PATCH v2 6/6] MAINTAINERS: add mailbox API's tree type and location Tudor Ambarus
2025-02-24  8:28 ` [PATCH v2 0/6] mailbox: core cleanup patches Tudor Ambarus

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=20250224-mbox-mutex-v2-2-9d699148fe4e@linaro.org \
    --to=tudor.ambarus@linaro.org \
    --cc=andre.draszik@linaro.org \
    --cc=jassisinghbrar@gmail.com \
    --cc=kernel-team@android.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peter.griffin@linaro.org \
    --cc=willmcvicker@google.com \
    /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

all inboxes | Powered by JetHome®