From: Adam Young <admiyo@os.amperecomputing.com>
To: Sudeep Holla <sudeep.holla@arm.com>,
Jassi Brar <jassisinghbrar@gmail.com>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Robert Moore <robert.moore@intel.com>,
Len Brown <lenb@kernel.org>
Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
Jeremy Kerr <jk@codeconstruct.com.au>,
Matt Johnston <matt@codeconstruct.com.au>,
"David S . Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>,
Huisong Li <lihuisong@huawei.com>
Subject: [PATCH net-next v29 2/3] mailbox/pcc: use mailbox-api level rx_alloc callback
Date: Thu, 25 Sep 2025 15:00:25 -0400 [thread overview]
Message-ID: <20250925190027.147405-3-admiyo@os.amperecomputing.com> (raw)
In-Reply-To: <20250925190027.147405-1-admiyo@os.amperecomputing.com>
Uses the newly introduced mailbox_api rx_alloc callback. Since this
callback is registered in the call to request a channel, it prevents a
race condition. Without it, it is impossible to assign the callback before
activating the mailbox delivery of messages.
This patch also removes the flag pcc_mchan->manage_writes which
is not necessary: only type 3 and type 4 subspaces will have their
buffers managed by the mailbox. It is not required for the driver
to explicitly specify. If a future type 3 or type 4 drivers wishes
to manage the buffer directly, they can do so by passing NULL in
to mbox_send_message.
Signed-off-by: Adam Young <admiyo@os.amperecomputing.com>
---
drivers/mailbox/pcc.c | 16 ++++++++++------
include/acpi/pcc.h | 22 ----------------------
2 files changed, 10 insertions(+), 28 deletions(-)
diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index 0a00719b2482..4535cd208b9e 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -309,17 +309,20 @@ static void pcc_chan_acknowledge(struct pcc_chan_info *pchan)
static void *write_response(struct pcc_chan_info *pchan)
{
struct pcc_header pcc_header;
+ struct mbox_client *cl;
+ void *handle;
void *buffer;
int data_len;
+ cl = pchan->chan.mchan->cl;
memcpy_fromio(&pcc_header, pchan->chan.shmem,
sizeof(pcc_header));
data_len = pcc_header.length - sizeof(u32) + sizeof(struct pcc_header);
- buffer = pchan->chan.rx_alloc(pchan->chan.mchan->cl, data_len);
+ cl->rx_alloc(cl, &handle, &buffer, data_len);
if (buffer != NULL)
memcpy_fromio(buffer, pchan->chan.shmem, data_len);
- return buffer;
+ return handle;
}
/**
@@ -359,7 +362,7 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p)
*/
pchan->chan_in_use = false;
- if (pchan->chan.rx_alloc)
+ if (pchan->chan.mchan->cl->rx_alloc)
handle = write_response(pchan);
if (chan->active_req) {
@@ -415,8 +418,6 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
if (!pcc_mchan->shmem)
goto err;
- pcc_mchan->manage_writes = false;
-
/* This indicates that the channel is ready to accept messages.
* This needs to happen after the channel has registered
* its callback. There is no access point to do that in
@@ -466,7 +467,10 @@ static int pcc_write_to_buffer(struct mbox_chan *chan, void *data)
struct pcc_mbox_chan *pcc_mbox_chan = &pchan->chan;
struct pcc_header *pcc_header = data;
- if (!pchan->chan.manage_writes)
+ if (data == NULL)
+ return 0;
+ if (pchan->type < ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE ||
+ pchan->type > ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE)
return 0;
/* The PCC header length includes the command field
diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h
index 9af3b502f839..5506490e628c 100644
--- a/include/acpi/pcc.h
+++ b/include/acpi/pcc.h
@@ -17,28 +17,6 @@ struct pcc_mbox_chan {
u32 latency;
u32 max_access_rate;
u16 min_turnaround_time;
-
- /* Set to true to indicate that the mailbox should manage
- * writing the dat to the shared buffer. This differs from
- * the case where the drivesr are writing to the buffer and
- * using send_data only to ring the doorbell. If this flag
- * is set, then the void * data parameter of send_data must
- * point to a kernel-memory buffer formatted in accordance with
- * the PCC specification.
- *
- * The active buffer management will include reading the
- * notify_on_completion flag, and will then
- * call mbox_chan_txdone when the acknowledgment interrupt is
- * received.
- */
- bool manage_writes;
-
- /* Optional callback that allows the driver
- * to allocate the memory used for receiving
- * messages. The return value is the location
- * inside the buffer where the mailbox should write the data.
- */
- void *(*rx_alloc)(struct mbox_client *cl, int size);
};
struct pcc_header {
--
2.43.0
next prev parent reply other threads:[~2025-09-25 19:00 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-25 19:00 [PATCH net-next v29 0/3] MCTP Over PCC Transport Adam Young
2025-09-25 19:00 ` [PATCH net-next v29 1/3] mailbox: add callback function for rx buffer allocation Adam Young
2025-09-26 14:13 ` Simon Horman
2025-09-26 15:44 ` Sudeep Holla
2025-10-05 5:13 ` Adam Young
2025-10-05 23:34 ` Jassi Brar
2025-10-06 8:54 ` Sudeep Holla
2025-10-06 15:24 ` Adam Young
2025-10-06 15:48 ` Sudeep Holla
2025-09-25 19:00 ` Adam Young [this message]
2025-09-25 19:00 ` [PATCH net-next v29 3/3] mctp pcc: Implement MCTP over PCC Transport Adam Young
2025-09-26 14:16 ` Simon Horman
2025-09-26 16:06 ` [External] : " ALOK TIWARI
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=20250925190027.147405-3-admiyo@os.amperecomputing.com \
--to=admiyo@os.amperecomputing.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=jassisinghbrar@gmail.com \
--cc=jk@codeconstruct.com.au \
--cc=kuba@kernel.org \
--cc=lenb@kernel.org \
--cc=lihuisong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=matt@codeconstruct.com.au \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=rafael@kernel.org \
--cc=robert.moore@intel.com \
--cc=sudeep.holla@arm.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®