* [PATCH v01] mailbox/pcc.c: add query channel function
@ 2026-06-04 20:37 Adam Young
0 siblings, 0 replies; only message in thread
From: Adam Young @ 2026-06-04 20:37 UTC (permalink / raw)
To: Sudeep Holla, Jassi Brar, Rafael J. Wysocki, Saket Dumbre,
Len Brown
Cc: linux-kernel, linux-hwmon, linux-acpi, Andi Shyti, Guenter Roeck,
Huisong Li, MyungJoo Ham, Kyungmin Park, Chanwoo Choi,
linux-arm-kernel
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.
Signed-off-by: Adam Young <admiyo@os•amperecomputing.com>
---
drivers/mailbox/pcc.c | 39 +++++++++++++++++++++++++++++++++++++++
include/acpi/pcc.h | 12 ++++++++++++
2 files changed, 51 insertions(+)
diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c
index 0deaf7907ed6..c27bea426967 100644
--- a/drivers/mailbox/pcc.c
+++ b/drivers/mailbox/pcc.c
@@ -348,6 +348,44 @@ 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.
+ *
+ * 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 (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
@@ -834,6 +872,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..8d0fada6e31f 100644
--- a/include/acpi/pcc.h
+++ b/include/acpi/pcc.h
@@ -8,6 +8,10 @@
#include <linux/mailbox_controller.h>
#include <linux/mailbox_client.h>
+#include <linux/acpi.h>
+//#include <acpi/actypes.h>
+//#include <acpi/actbl.h>
+//#include <acpi/actbl2.h>
struct pcc_mbox_chan {
struct mbox_chan *mchan;
@@ -17,6 +21,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 +42,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 +51,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
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-06-04 20:38 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-06-04 20:37 [PATCH v01] mailbox/pcc.c: add query channel function Adam Young
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox