[PATCH v45 4/7] mailbox/pcc.c: add query channel function
From: Adam Young <hidden>
Date: 2026-07-21 17:53:22
Also in:
lkml
Subsystem:
acpi, acpi component architecture (acpica), acpi pcc(platform communication channel) mailbox driver, mailbox api, the rest · Maintainers:
"Rafael J. Wysocki", Saket Dumbre, Sudeep Holla, Jassi Brar, Linus Torvalds
Drivers need information about a channel prior to creating a channel or they risk triggering message delivery on the remote side of a connection. Add PCC channel type to records and expose PCC channel type to client. Signed-off-by: Adam Young <redacted> --- drivers/mailbox/pcc.c | 45 +++++++++++++++++++++++++++++++++++++++++++ include/acpi/pcc.h | 9 +++++++++ 2 files changed, 54 insertions(+)
diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index b1c7d3e4c5e3..b9a01bfdc95d 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c@@ -349,6 +349,50 @@ static irqreturn_t pcc_mbox_irq(int irq, void *p) return IRQ_HANDLED; } +/** + * pcc_mbox_query_channel - returns information about the channel + * without activating the channel. + * + * @q_chan: a pointer to an already allocated struct pcc_mbox_chan + * that will be populated with the channel data. + * @subspace_id: The PCC Subspace index as parsed in the PCC client + * ACPI package. This is used to lookup the array of PCC + * subspaces as parsed by the PCC Mailbox controller. + * + * Return: 0 upon success or non-zero upon error. + */ +int +pcc_mbox_query_channel(struct pcc_mbox_chan *q_chan, int subspace_id) +{ + struct pcc_mbox_chan *pcc_mchan; + struct pcc_chan_info *pchan; + struct mbox_chan *chan; + + if (!q_chan) + return -EINVAL; + + if (subspace_id < 0 || subspace_id >= pcc_chan_count) + return -ENOENT; + pchan = chan_info + subspace_id; + chan = pchan->chan.mchan; + if (IS_ERR(chan)) { + pr_err("Channel not found for idx: %d\n", subspace_id); + return -EBUSY; + } + pcc_mchan = &pchan->chan; + + q_chan->shmem_base_addr = pcc_mchan->shmem_base_addr; + q_chan->shmem = NULL; + q_chan->shmem_size = pcc_mchan->shmem_size; + q_chan->latency = pcc_mchan->latency; + q_chan->max_access_rate = pcc_mchan->max_access_rate; + q_chan->min_turnaround_time = pcc_mchan->min_turnaround_time; + q_chan->type = pcc_mchan->type; + + return 0; +} +EXPORT_SYMBOL_GPL(pcc_mbox_query_channel); + /** * pcc_mbox_request_channel - PCC clients call this function to * request a pointer to their PCC subspace, from which they
@@ -833,6 +877,7 @@ static int pcc_mbox_probe(struct platform_device *pdev) pcc_parse_subspace_shmem(pchan, pcct_entry); pchan->type = pcct_entry->type; + pchan->chan.type = pcct_entry->type; pcct_entry = (struct acpi_subtable_header *) ((unsigned long) pcct_entry + pcct_entry->length); }
diff --git a/include/acpi/pcc.h b/include/acpi/pcc.h
index 840bfc95bae3..bf97f407683d 100644
--- a/include/acpi/pcc.h
+++ b/include/acpi/pcc.h@@ -8,6 +8,7 @@ #include <linux/mailbox_controller.h> #include <linux/mailbox_client.h> +#include <linux/acpi.h> struct pcc_mbox_chan { struct mbox_chan *mchan;
@@ -17,6 +18,7 @@ struct pcc_mbox_chan { u32 latency; u32 max_access_rate; u16 min_turnaround_time; + enum acpi_pcct_type type; }; /* Generic Communications Channel Shared Memory Region */
@@ -37,6 +39,8 @@ struct pcc_mbox_chan { extern struct pcc_mbox_chan * pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id); extern void pcc_mbox_free_channel(struct pcc_mbox_chan *chan); +extern int +pcc_mbox_query_channel(struct pcc_mbox_chan *q_chan, int subspace_id); #else static inline struct pcc_mbox_chan * pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id)
@@ -44,6 +48,11 @@ pcc_mbox_request_channel(struct mbox_client *cl, int subspace_id) return ERR_PTR(-ENODEV); } static inline void pcc_mbox_free_channel(struct pcc_mbox_chan *chan) { } +static inline int +pcc_mbox_query_channel(struct pcc_mbox_chan *q_chan, int subspace_id) +{ + return -ENODEV; +} #endif #endif /* _PCC_H */
--
2.43.0