OpenSBI Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Anup Patel <apatel@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH 03/12] lib: utils: Introduce optional MPXY RPMI service group operations
Date: Thu, 16 Jan 2025 21:26:42 +0530	[thread overview]
Message-ID: <20250116155651.103782-4-apatel@ventanamicro.com> (raw)
In-Reply-To: <20250116155651.103782-1-apatel@ventanamicro.com>

Some of the RPMI service groups may additional contex and special
handling when transfering message to underlying mailbox channel
so introduce optional MPXY RPMI service group operations for this
purpose.

Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
 include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h | 18 ++++++++++++++++
 lib/utils/mpxy/fdt_mpxy_rpmi_clock.c        |  4 ++++
 lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c         | 24 +++++++++++++++++----
 3 files changed, 42 insertions(+), 4 deletions(-)

diff --git a/include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h b/include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h
index e4ca0151..08b32a0a 100644
--- a/include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h
+++ b/include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h
@@ -12,6 +12,7 @@
 
 #include <sbi/sbi_types.h>
 #include <sbi/sbi_mpxy.h>
+#include <sbi_utils/mailbox/fdt_mailbox.h>
 #include <sbi_utils/mailbox/rpmi_msgprot.h>
 #include <sbi_utils/mpxy/fdt_mpxy.h>
 
@@ -56,12 +57,29 @@ struct mpxy_rpmi_service_data {
 	u32 max_rx_len;
 };
 
+struct mpxy_rpmi_mbox_data;
+
+/** MPXY RPMI service group operations */
+struct mpxy_rpmi_service_group_ops {
+	/** Transfer RPMI service group message */
+	int (*xfer_group)(void *context, struct mbox_chan *chan,
+			  struct mbox_xfer *xfer);
+
+	/** Setup RPMI service group context for MPXY */
+	int (*setup_group)(void **context, struct mbox_chan *chan,
+			   const struct mpxy_rpmi_mbox_data *data);
+
+	/** Cleanup RPMI service group context for MPXY */
+	void (*cleanup_group)(void *context);
+};
+
 /** MPXY RPMI mbox data for each service group */
 struct mpxy_rpmi_mbox_data {
 	u32 servicegrp_id;
 	u32 num_services;
 	u32 notifications_support;
 	struct mpxy_rpmi_service_data *service_data;
+	struct mpxy_rpmi_service_group_ops *group_ops;
 };
 
 /** Common probe function for MPXY RPMI drivers */
diff --git a/lib/utils/mpxy/fdt_mpxy_rpmi_clock.c b/lib/utils/mpxy/fdt_mpxy_rpmi_clock.c
index 1f5c6e75..3d275cd8 100644
--- a/lib/utils/mpxy/fdt_mpxy_rpmi_clock.c
+++ b/lib/utils/mpxy/fdt_mpxy_rpmi_clock.c
@@ -10,6 +10,9 @@
 
 #include <sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h>
 
+static struct mpxy_rpmi_service_group_ops clock_ops = {
+};
+
 static struct mpxy_rpmi_service_data clock_services[] = {
 {
 	.id = RPMI_CLOCK_SRV_ENABLE_NOTIFICATION,
@@ -74,6 +77,7 @@ static struct mpxy_rpmi_mbox_data clock_data = {
 	.num_services = RPMI_CLOCK_SRV_MAX_COUNT,
 	.notifications_support = 1,
 	.service_data = clock_services,
+	.group_ops = &clock_ops,
 };
 
 static const struct fdt_match clock_match[] = {
diff --git a/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c b/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c
index 7034fb9e..8d892cef 100644
--- a/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c
+++ b/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c
@@ -13,7 +13,6 @@
 #include <sbi/sbi_heap.h>
 #include <sbi_utils/fdt/fdt_helper.h>
 #include <sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h>
-#include <sbi_utils/mailbox/fdt_mailbox.h>
 #include <sbi/sbi_console.h>
 
 /**
@@ -25,6 +24,7 @@ struct mpxy_rpmi_mbox {
 	const struct mpxy_rpmi_mbox_data *mbox_data;
 	struct mpxy_rpmi_channel_attrs msgprot_attrs;
 	struct sbi_mpxy_channel channel;
+	void *group_context;
 };
 
 /**
@@ -146,8 +146,9 @@ static int __mpxy_mbox_send_message(struct sbi_mpxy_channel *channel,
 	struct rpmi_message_args args = {0};
 	struct mpxy_rpmi_mbox *rmb =
 		container_of(channel, struct mpxy_rpmi_mbox, channel);
+	const struct mpxy_rpmi_mbox_data *data = rmb->mbox_data;
 	const struct mpxy_rpmi_service_data *srv =
-		mpxy_find_rpmi_srvid(message_id, rmb->mbox_data);
+		mpxy_find_rpmi_srvid(message_id, data);
 
 	if (!srv)
 		return SBI_ENOTSUPP;
@@ -183,7 +184,10 @@ static int __mpxy_mbox_send_message(struct sbi_mpxy_channel *channel,
 				  tx, tx_len, RPMI_DEF_TX_TIMEOUT);
 	}
 
-	ret = mbox_chan_xfer(rmb->chan, &xfer);
+	if (data->group_ops->xfer_group)
+		ret = data->group_ops->xfer_group(rmb->group_context, rmb->chan, &xfer);
+	else
+		ret = mbox_chan_xfer(rmb->chan, &xfer);
 	if (ret)
 		return ret;
 
@@ -303,9 +307,21 @@ int mpxy_rpmi_mbox_init(const void *fdt, int nodeoff, const struct fdt_match *ma
 	rmb->mbox_data = data;
 	rmb->chan = chan;
 
-	/* Register RPXY service group */
+	/* Setup RPMI service group context */
+	if (data->group_ops->setup_group) {
+		rc = data->group_ops->setup_group(&rmb->group_context, chan, data);
+		if (rc) {
+			mbox_controller_free_chan(chan);
+			sbi_free(rmb);
+			return rc;
+		}
+	}
+
+	/* Register RPMI service group */
 	rc = sbi_mpxy_register_channel(&rmb->channel);
 	if (rc) {
+		if (data->group_ops->cleanup_group)
+			data->group_ops->cleanup_group(rmb->group_context);
 		mbox_controller_free_chan(chan);
 		sbi_free(rmb);
 		return rc;
-- 
2.43.0



  parent reply	other threads:[~2025-01-16 15:56 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-01-16 15:56 [PATCH 00/12] More RPMI and MPXY updates Anup Patel
2025-01-16 15:56 ` [PATCH 01/12] lib: utils: Split the FDT MPXY RPMI mailbox client into two parts Anup Patel
2025-01-19 22:52   ` Samuel Holland
2025-01-20  4:49     ` Anup Patel
2025-01-16 15:56 ` [PATCH 02/12] lib: utils: Constantify mpxy_rpmi_mbox_data in mpxy_rpmi_mbox Anup Patel
2025-01-19 22:54   ` Samuel Holland
2025-01-20  5:12     ` Anup Patel
2025-01-16 15:56 ` Anup Patel [this message]
2025-01-19 22:58   ` [PATCH 03/12] lib: utils: Introduce optional MPXY RPMI service group operations Samuel Holland
2025-01-20  8:05     ` Anup Patel
2025-01-16 15:56 ` [PATCH 04/12] lib: sbi: Fix capability bit assignment in MPXY framework Anup Patel
2025-01-19 23:00   ` Samuel Holland
2025-01-16 15:56 ` [PATCH 05/12] lib: sbi: Improve local variable declarations " Anup Patel
2025-01-19 23:02   ` Samuel Holland
2025-01-16 15:56 ` [PATCH 06/12] lib: utils: Drop notifications from MPXY RPMI mailbox client Anup Patel
2025-01-19 23:02   ` Samuel Holland
2025-01-16 15:56 ` [PATCH 07/12] lib: utils: Improve variable declarations in " Anup Patel
2025-01-19 23:05   ` Samuel Holland
2025-01-20  8:37     ` Anup Patel
2025-01-16 15:56 ` [PATCH 08/12] include: sbi_utils: Include mailbox.h in rpmi_mailbox.h header Anup Patel
2025-01-19 23:05   ` Samuel Holland
2025-01-16 15:56 ` [PATCH 09/12] lib: utils: Implement get_attribute() for the RPMI shared memory mailbox Anup Patel
2025-01-16 15:56 ` [PATCH 10/12] lib: utils: Populate MPXY channel attributes from RPMI channel attributes Anup Patel
2025-01-16 15:56 ` [PATCH 11/12] include: sbi_utils: Update RPMI service group IDs and BASE service group Anup Patel
2025-01-19 23:07   ` Samuel Holland
2025-01-16 15:56 ` [PATCH 12/12] lib: utils: Add MPXY RPMI mailbox driver for System MSI " Anup Patel
2025-01-19 23:11   ` Samuel Holland
2025-01-20  9:16     ` Anup Patel

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=20250116155651.103782-4-apatel@ventanamicro.com \
    --to=apatel@ventanamicro.com \
    --cc=opensbi@lists.infradead.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