From: Christian Loehle <christian.loehle@arm.com>
To: Sudeep Holla <sudeep.holla@kernel.org>,
Jassi Brar <jassisinghbrar@gmail.com>
Cc: breno Leitao <leitao@debian.org>,
linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org,
stable@vger.kernel.org,
Christian Loehle <christian.loehle@arm.com>
Subject: [PATCH 2/2] mailbox: pcc: Serialize channel updates with shared memory teardown
Date: Thu, 3 Sep 2026 12:13:28 +0100 [thread overview]
Message-ID: <20260903111328.805352-3-christian.loehle@arm.com> (raw)
In-Reply-To: <20260903111328.805352-1-christian.loehle@arm.com>
mbox_free_channel() makes a PCC channel available before the subsequent
shared-memory unmap. Without serialization, a concurrent request can bind a
new client and replace the mapping, which the old release then unmaps.
Serialize PCC channel acquisition and release. Keep the channel unavailable
until the old shared-memory mapping has been removed.
Suggested-by: Sudeep Holla <sudeep.holla@kernel.org>
Signed-off-by: Christian Loehle <christian.loehle@arm.com>
---
drivers/mailbox/pcc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index db30812c5051..14dc4a187bfc 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -53,6 +53,7 @@
#include <linux/interrupt.h>
#include <linux/list.h>
#include <linux/log2.h>
+#include <linux/mutex.h>
#include <linux/platform_device.h>
#include <linux/mailbox_controller.h>
#include <linux/mailbox_client.h>
@@ -113,6 +114,7 @@ struct pcc_chan_info {
#define to_pcc_chan_info(c) container_of(c, struct pcc_chan_info, chan)
static struct pcc_chan_info *chan_info;
static int pcc_chan_count;
+static DEFINE_MUTEX(pcc_chan_mutex);
/*
* PCC can be used with perf critical drivers such as CPPC
@@ -392,6 +394,8 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
if (subspace_id < 0 || subspace_id >= pcc_chan_count)
return ERR_PTR(-ENOENT);
+ guard(mutex)(&pcc_chan_mutex);
+
pchan = chan_info + subspace_id;
chan = pchan->chan.mchan;
if (IS_ERR(chan) || chan->cl) {
@@ -434,6 +438,8 @@ void pcc_mbox_free_channel(struct pcc_mbox_chan *pchan)
struct pcc_chan_info *pchan_info;
struct pcc_mbox_chan *pcc_mbox_chan;
+ guard(mutex)(&pcc_chan_mutex);
+
if (!chan || !chan->cl)
return;
pchan_info = chan->con_priv;
--
2.34.1
next prev parent reply other threads:[~2026-09-03 11:13 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-03 11:13 [PATCH 0/2] mailbox: pcc: Fix shared-memory teardown race Christian Loehle
2026-09-03 11:13 ` [PATCH 1/2] mailbox: pcc: Free the channel before unmapping the shared memory Christian Loehle
2026-09-03 11:13 ` Christian Loehle [this message]
2026-09-03 12:40 ` [PATCH 2/2] mailbox: pcc: Serialize channel updates with shared memory teardown Sudeep Holla
2026-09-03 12:42 ` [PATCH 0/2] mailbox: pcc: Fix shared-memory teardown race Sudeep Holla
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=20260903111328.805352-3-christian.loehle@arm.com \
--to=christian.loehle@arm.com \
--cc=jassisinghbrar@gmail.com \
--cc=leitao@debian.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=sudeep.holla@kernel.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