From: Anup Patel <apatel@ventanamicro.com>
To: opensbi@lists.infradead.org
Subject: [PATCH v2 10/13] lib: utils: Populate MPXY channel attributes from RPMI channel attributes
Date: Wed, 22 Jan 2025 12:14:37 +0530 [thread overview]
Message-ID: <20250122064441.272115-11-apatel@ventanamicro.com> (raw)
In-Reply-To: <20250122064441.272115-1-apatel@ventanamicro.com>
Use the RPMI mailbox channel attributes to populate MPXY channel
attributes instead of hard coding them.
Signed-off-by: Anup Patel <apatel@ventanamicro.com>
---
include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h | 3 -
lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c | 101 +++++++++++++-------
2 files changed, 65 insertions(+), 39 deletions(-)
diff --git a/include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h b/include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h
index 373b077a..068a1a55 100644
--- a/include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h
+++ b/include/sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h
@@ -16,9 +16,6 @@
#include <sbi_utils/mailbox/rpmi_msgprot.h>
#include <sbi_utils/mpxy/fdt_mpxy.h>
-#define MPXY_RPMI_MAJOR_VER (1)
-#define MPXY_RPMI_MINOR_VER (0)
-
/** Convert the mpxy attribute ID to attribute array index */
#define attr_id2index(attr_id) (attr_id - SBI_MPXY_ATTR_MSGPROTO_ATTR_START)
diff --git a/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c b/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c
index f8de91a5..48dfe476 100644
--- a/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c
+++ b/lib/utils/mpxy/fdt_mpxy_rpmi_mbox.c
@@ -212,14 +212,14 @@ static int mpxy_mbox_send_message_withoutresp(struct sbi_mpxy_channel *channel,
int mpxy_rpmi_mbox_init(const void *fdt, int nodeoff, const struct fdt_match *match)
{
+ u32 channel_id, servicegrp_ver, pro_ver, max_data_len, tx_tout, rx_tout;
const struct mpxy_rpmi_mbox_data *data = match->data;
struct mpxy_rpmi_mbox *rmb;
struct mbox_chan *chan;
const fdt32_t *val;
- u32 channel_id;
int rc, len;
- /* Allocate context for RPXY mbox client */
+ /* Allocate context for MPXY mbox client */
rmb = sbi_zalloc(sizeof(*rmb));
if (!rmb)
return SBI_ENOMEM;
@@ -230,29 +230,57 @@ int mpxy_rpmi_mbox_init(const void *fdt, int nodeoff, const struct fdt_match *ma
*/
rc = fdt_mailbox_request_chan(fdt, nodeoff, 0, &chan);
if (rc) {
- sbi_free(rmb);
- return SBI_ENODEV;
+ rc = SBI_ENODEV;
+ goto fail_free_client;
}
/* Match channel service group id */
if (data->servicegrp_id != chan->chan_args[0]) {
- mbox_controller_free_chan(chan);
- sbi_free(rmb);
- return SBI_EINVAL;
+ rc = SBI_EINVAL;
+ goto fail_free_chan;
}
+ /* Get channel protocol version */
+ rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_PROTOCOL_VERSION,
+ &pro_ver);
+ if (rc)
+ goto fail_free_chan;
+
+ /* Get channel maximum data length */
+ rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_MAX_DATA_LEN,
+ &max_data_len);
+ if (rc)
+ goto fail_free_chan;
+
+ /* Get channel Tx timeout */
+ rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_TX_TIMEOUT,
+ &tx_tout);
+ if (rc)
+ goto fail_free_chan;
+
+ /* Get channel Rx timeout */
+ rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_RX_TIMEOUT,
+ &rx_tout);
+ if (rc)
+ goto fail_free_chan;
+
+ /* Get channel service group version */
+ rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_SERVICEGROUP_VERSION,
+ &servicegrp_ver);
+ if (rc)
+ goto fail_free_chan;
+
/*
* The "riscv,sbi-mpxy-channel-id" DT property is mandatory
* for MPXY RPMI mailbox client driver so if this is not
* present then try other drivers.
*/
val = fdt_getprop(fdt, nodeoff, "riscv,sbi-mpxy-channel-id", &len);
- if (len > 0 && val)
+ if (len > 0 && val) {
channel_id = fdt32_to_cpu(*val);
- else {
- mbox_controller_free_chan(chan);
- sbi_free(rmb);
- return SBI_ENODEV;
+ } else {
+ rc = SBI_ENODEV;
+ goto fail_free_chan;
}
/* Setup MPXY mbox client */
@@ -271,23 +299,23 @@ int mpxy_rpmi_mbox_init(const void *fdt, int nodeoff, const struct fdt_match *ma
/* RPMI Message Protocol ID */
rmb->channel.attrs.msg_proto_id = SBI_MPXY_MSGPROTO_RPMI_ID;
/* RPMI Message Protocol Version */
- rmb->channel.attrs.msg_proto_version =
- SBI_MPXY_MSGPROTO_VERSION(MPXY_RPMI_MAJOR_VER, MPXY_RPMI_MINOR_VER);
-
- /* RPMI supported max message data length(bytes), same for
- * all service groups */
- rmb->channel.attrs.msg_data_maxlen =
- RPMI_MSG_DATA_SIZE(RPMI_SLOT_SIZE_MIN);
- /* RPMI message send timeout(milliseconds)
- * same for all service groups */
- rmb->channel.attrs.msg_send_timeout = RPMI_DEF_TX_TIMEOUT;
- rmb->channel.attrs.msg_completion_timeout =
- RPMI_DEF_TX_TIMEOUT + RPMI_DEF_RX_TIMEOUT;
-
- /* RPMI message protocol attributes */
+ rmb->channel.attrs.msg_proto_version = pro_ver;
+
+ /*
+ * RPMI supported max message data length(bytes), same for
+ * all service groups
+ */
+ rmb->channel.attrs.msg_data_maxlen = max_data_len;
+ /*
+ * RPMI message send timeout(milliseconds)
+ * same for all service groups
+ */
+ rmb->channel.attrs.msg_send_timeout = tx_tout;
+ rmb->channel.attrs.msg_completion_timeout = tx_tout + rx_tout;
+
+ /* RPMI service group attributes */
rmb->msgprot_attrs.servicegrp_id = data->servicegrp_id;
- rmb->msgprot_attrs.servicegrp_ver =
- SBI_MPXY_MSGPROTO_VERSION(MPXY_RPMI_MAJOR_VER, MPXY_RPMI_MINOR_VER);
+ rmb->msgprot_attrs.servicegrp_ver = servicegrp_ver;
rmb->mbox_data = data;
rmb->chan = chan;
@@ -295,11 +323,8 @@ int mpxy_rpmi_mbox_init(const void *fdt, int nodeoff, const struct fdt_match *ma
/* Setup RPMI service group context */
if (data->setup_group) {
rc = data->setup_group(&rmb->group_context, chan, data);
- if (rc) {
- mbox_controller_free_chan(chan);
- sbi_free(rmb);
- return rc;
- }
+ if (rc)
+ goto fail_free_chan;
}
/* Register RPMI service group */
@@ -307,10 +332,14 @@ int mpxy_rpmi_mbox_init(const void *fdt, int nodeoff, const struct fdt_match *ma
if (rc) {
if (data->cleanup_group)
data->cleanup_group(rmb->group_context);
- mbox_controller_free_chan(chan);
- sbi_free(rmb);
- return rc;
+ goto fail_free_chan;
}
return SBI_OK;
+
+fail_free_chan:
+ mbox_controller_free_chan(chan);
+fail_free_client:
+ sbi_free(rmb);
+ return rc;
}
--
2.43.0
next prev parent reply other threads:[~2025-01-22 6:44 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-22 6:44 [PATCH v2 00/13] More RPMI and MPXY updates Anup Patel
2025-01-22 6:44 ` [PATCH v2 01/13] lib: utils: Split the FDT MPXY RPMI mailbox client into two parts Anup Patel
2025-01-22 6:44 ` [PATCH v2 02/13] lib: utils: Constantify mpxy_rpmi_mbox_data in mpxy_rpmi_mbox Anup Patel
2025-01-22 6:44 ` [PATCH v2 03/13] lib: utils: Introduce optional MPXY RPMI service group operations Anup Patel
2025-01-22 6:44 ` [PATCH v2 04/13] lib: sbi: Fix capability bit assignment in MPXY framework Anup Patel
2025-01-22 6:44 ` [PATCH v2 05/13] lib: sbi: Improve local variable declarations " Anup Patel
2025-01-22 6:44 ` [PATCH v2 06/13] lib: utils: Drop notifications from MPXY RPMI mailbox client Anup Patel
2025-01-22 6:44 ` [PATCH v2 07/13] lib: utils: Improve variable declarations in " Anup Patel
2025-01-22 6:44 ` [PATCH v2 08/13] include: sbi_utils: Include mailbox.h in rpmi_mailbox.h header Anup Patel
2025-01-22 6:44 ` [PATCH v2 09/13] lib: utils: Implement get_attribute() for the RPMI shared memory mailbox Anup Patel
2025-01-22 6:44 ` Anup Patel [this message]
2025-01-22 6:44 ` [PATCH v2 11/13] include: sbi_utils: Update RPMI service group IDs and BASE service group Anup Patel
2025-01-22 6:44 ` [PATCH v2 12/13] lib: utils: Add MPXY RPMI mailbox driver for System MSI " Anup Patel
2025-01-22 6:44 ` [PATCH v2 13/13] lib: sbi: Update MPXY framework and SBI extension as per latest spec Anup Patel
2025-02-13 5:48 ` [PATCH v2 00/13] More RPMI and MPXY updates 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=20250122064441.272115-11-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