[PATCH v01] mailbox/pcc.c: add query channel function
Adam Young
admiyo at amperemail.onmicrosoft.com
Fri Jun 5 07:19:26 PDT 2026
MCTP-PCC. I was not sure if I should ad the Patch to this one or not,
as the MCTP-PCC is still going through review.
Essentially, it need two pieces of information before start up. 1, it
needs to be able to check the sizes of the two shared memory buffers in
order to set the MTU. 2, it confirms that the Channels are indeed Type3
and Type4.
The base patch for that is
https://lore.kernel.org/lkml/20260522193610.234166-1-admiyo@os.amperecomputing.com/
This is the diff that would use them.
commit c02159450cf38cb778105f10a11708d358a3b633
(admiyo/mctp-pcc-v45-net-next, mctp-pcc-v45-net-next)
Author: Adam Young <admiyo at os.amperecomputing.com>
Date: Thu Apr 30 10:48:41 2026 -0700
mctp-pcc query channel information without opening channel.
Opening the channel can trigger the sending of
a message from the remote side before the driver
is ready to read it. Take advantage of the API that allows
querying of the channel data without opening the channel.
diff --git a/drivers/net/mctp/mctp-pcc.c b/drivers/net/mctp/mctp-pcc.c
index bb5d53ee3d7c..01a9966eddd2 100644
--- a/drivers/net/mctp/mctp-pcc.c
+++ b/drivers/net/mctp/mctp-pcc.c
@@ -318,25 +318,50 @@ static void mctp_cleanup_netdev(void *data)
mctp_unregister_netdev(ndev);
}
+static int check_channel_types(struct mctp_pcc_ndev *mctp_pcc_ndev)
+{
+ struct mctp_pcc_mailbox *outbox;
+ struct mctp_pcc_mailbox *inbox;
+ struct pcc_mbox_chan chan;
+ int actual_type;
+
+ outbox = &mctp_pcc_ndev->outbox;
+ if (pcc_mbox_query_channel(&chan, outbox->index))
+ return -EINVAL;
+ actual_type = chan.type;
+ if (actual_type != ACPI_PCCT_TYPE_EXT_PCC_MASTER_SUBSPACE){
+ pr_err("MCTP-PCC outbox channel wrong type:
%d",actual_type);
+ return -EINVAL;
+ }
+
+ inbox = &mctp_pcc_ndev->inbox;
+ if (pcc_mbox_query_channel(&chan, inbox->index))
+ return -EINVAL;
+ actual_type = chan.type;
+ if (actual_type != ACPI_PCCT_TYPE_EXT_PCC_SLAVE_SUBSPACE){
+ pr_err("MCTP-PCC inbox channel wrong type: %d",actual_type);
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
static int initialize_mtu(struct net_device *ndev)
{
struct mctp_pcc_ndev *mctp_pcc_ndev;
struct mctp_pcc_mailbox *outbox;
struct pcc_mbox_chan *pchan;
+ struct pcc_mbox_chan chan;
int mctp_pcc_max_mtu;
mctp_pcc_ndev = netdev_priv(ndev);
outbox = &mctp_pcc_ndev->outbox;
- pchan = pcc_mbox_request_channel(&outbox->client, outbox->index);
- if (IS_ERR(pchan))
- return PTR_ERR(pchan);
- if (pchan->shmem_size < MCTP_MIN_MTU + sizeof(struct
acpi_pcct_ext_pcc_shared_memory)) {
- pcc_mbox_free_channel(pchan);
+ if (pcc_mbox_query_channel(&chan, outbox->index))
+ return -EINVAL;
+ if (chan.shmem_size < MCTP_MIN_MTU + sizeof(struct
acpi_pcct_ext_pcc_shared_memory)) {
return -EINVAL;
}
- mctp_pcc_max_mtu = pchan->shmem_size - sizeof(struct
acpi_pcct_ext_pcc_shared_memory);
- pcc_mbox_free_channel(pchan);
-
+ mctp_pcc_max_mtu = chan.shmem_size - sizeof(struct
acpi_pcct_ext_pcc_shared_memory);
ndev->mtu = MCTP_MIN_MTU;
ndev->max_mtu = mctp_pcc_max_mtu;
ndev->min_mtu = MCTP_MIN_MTU;
@@ -378,7 +403,6 @@ static int mctp_pcc_driver_add(struct acpi_device
*acpi_dev)
return -ENOMEM;
mctp_pcc_ndev = netdev_priv(ndev);
-
mctp_pcc_ndev->inbox.index = context.inbox_index;
mctp_pcc_ndev->inbox.client.dev = dev;
mctp_pcc_ndev->outbox.index = context.outbox_index;
On 6/5/26 03:55, Sudeep Holla wrote:
> On Thu, Jun 04, 2026 at 04:37:48PM -0400, Adam Young wrote:
>> Drivers need information about a channel prior to creating a channel
>> or they risk triggering message delivery on the remote side of a
>> connection.
>>
>> One of those pieces of infomration is the type of channel.
>>
>> Add PCC channel type to records and expose PCC channel type to client.
>>
> Please point me to the user of this interface.
>
More information about the linux-arm-kernel
mailing list