From a79566175c01e369d9c5536aa9accbb5c17e2376 Mon Sep 17 00:00:00 2001 From: Anup Patel Date: Mon, 12 May 2025 14:08:25 +0530 Subject: [PATCH] lib: utils/mailbox: Parse P2A doorbell system MSI index from DT The P2A doorbell system MSI index is expected to be discovered from device tree instead of RPMI system MSI service group attribute. This is based on ARC feedback before RPMI spec was frozen. Let's parse P2A doorbell system MSI index from device tree and also expose it as rpmi channel attribute to RPMI client drivers. Signed-off-by: Anup Patel Link: https://lore.kernel.org/r/20250512083827.804151-3-apatel@ventanamicro.com Signed-off-by: Anup Patel --- include/sbi_utils/mailbox/rpmi_msgprot.h | 1 + lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/sbi_utils/mailbox/rpmi_msgprot.h b/include/sbi_utils/mailbox/rpmi_msgprot.h index 8d8fa5e5..058b7e90 100644 --- a/include/sbi_utils/mailbox/rpmi_msgprot.h +++ b/include/sbi_utils/mailbox/rpmi_msgprot.h @@ -193,6 +193,7 @@ struct rpmi_message_args { enum rpmi_channel_attribute_id { RPMI_CHANNEL_ATTR_PROTOCOL_VERSION = 0, RPMI_CHANNEL_ATTR_MAX_DATA_LEN, + RPMI_CHANNEL_ATTR_P2A_DOORBELL_SYSMSI_INDEX, RPMI_CHANNEL_ATTR_TX_TIMEOUT, RPMI_CHANNEL_ATTR_RX_TIMEOUT, RPMI_CHANNEL_ATTR_SERVICEGROUP_ID, diff --git a/lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c b/lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c index 2faf51e4..164ae14d 100644 --- a/lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c +++ b/lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c @@ -133,6 +133,7 @@ struct rpmi_shmem_mbox_controller { /* Driver specific members */ u32 slot_size; u32 queue_count; + u32 p2a_doorbell_sysmsi_index; struct rpmi_mb_regs *mb_regs; struct smq_queue_ctx queue_ctx_tbl[RPMI_QUEUE_IDX_MAX_COUNT]; /* Mailbox framework related members */ @@ -505,6 +506,9 @@ static int rpmi_shmem_mbox_get_attribute(struct mbox_chan *chan, case RPMI_CHANNEL_ATTR_MAX_DATA_LEN: *((u32 *)out_value) = RPMI_MSG_DATA_SIZE(mctl->slot_size); break; + case RPMI_CHANNEL_ATTR_P2A_DOORBELL_SYSMSI_INDEX: + *((u32 *)out_value) = mctl->p2a_doorbell_sysmsi_index; + break; case RPMI_CHANNEL_ATTR_TX_TIMEOUT: *((u32 *)out_value) = RPMI_DEF_TX_TIMEOUT; break; @@ -574,9 +578,9 @@ static int rpmi_shmem_transport_init(struct rpmi_shmem_mbox_controller *mctl, const void *fdt, int nodeoff) { const char *name; + const fdt32_t *prop; int count, len, ret, qid; uint64_t reg_addr, reg_size; - const fdt32_t *prop_slotsz; struct smq_queue_ctx *qctx; ret = fdt_node_check_compatible(fdt, nodeoff, @@ -585,17 +589,21 @@ static int rpmi_shmem_transport_init(struct rpmi_shmem_mbox_controller *mctl, return ret; /* get queue slot size in bytes */ - prop_slotsz = fdt_getprop(fdt, nodeoff, "riscv,slot-size", &len); - if (!prop_slotsz) + prop = fdt_getprop(fdt, nodeoff, "riscv,slot-size", &len); + if (!prop) return SBI_ENOENT; - mctl->slot_size = fdt32_to_cpu(*prop_slotsz); + mctl->slot_size = fdt32_to_cpu(*prop); if (mctl->slot_size < RPMI_SLOT_SIZE_MIN) { sbi_printf("%s: slot_size < mimnum required message size\n", __func__); mctl->slot_size = RPMI_SLOT_SIZE_MIN; } + /* get p2a doorbell system MSI index */ + prop = fdt_getprop(fdt, nodeoff, "riscv,p2a-doorbell-sysmsi-index", &len); + mctl->p2a_doorbell_sysmsi_index = prop ? fdt32_to_cpu(*prop) : -1U; + /* * queue names count is taken as the number of queues * supported which make it mandatory to provide the