Driver updates to match frozen RPMI specification
cover Driver updates to match frozen RPMI specification
The RPMI v1.0 specification is frozen and in public review so update RPMI drivers to match last minute specification changes which were based on ARC feedback.
These patches can also be found in the rpmi_fixes_v1 branch at:
https://github.com/avpatel/opensbi.git
To test these patches, use the dev-upstream branch of the following repos:
* https://github.com/ventanamicro/qemu.git
* https://github.com/ventanamicro/linux.git
To enable QEMU RPMI emulation (using librpmi) for virt machine, use "virt,rpmi=on,aia=aplic-imsic" as the QEMU machine name.
Anup Patel (4):
lib: utils/mailbox: Update DT register name of A2P doorbell
lib: utils/mailbox: Parse P2A doorbell system MSI index from DT
lib: utils/mailbox: Parse A2P doorbell value from DT
lib: utils/mpxy: Remove p2a_db_index from RPMI system MSI attributes
include/sbi_utils/mailbox/rpmi_msgprot.h | 2 +- lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c | 34 +++++++++++++++------- lib/utils/mpxy/fdt_mpxy_rpmi_sysmsi.c | 13 ++++++--- 3 files changed, 34 insertions(+), 15 deletions(-)
Signature · 7 lines
2.43.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 1/4 lib: utils/mailbox: Update DT register name of A2P doorbell
The latest device tree bindings define A2P doorbell register name as "a2p-doorbell" so update rpmi_shmem_transport_init() accordingly.
--- lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c +2 -2
@@ -651,7 +651,7 @@ static int rpmi_shmem_transport_init(struct rpmi_shmem_mbox_controller *mctl,SPIN_LOCK_INIT (qctx->queue_lock); } -/* get the db-reg property name */ +/* get the a2p-doorbell property name */ name =fdt_stringlist_get (fdt, nodeoff,"reg-names" , qid, &len);if (!name || (name && len <0 ))return len;
@@ -659,7 +659,7 @@ static int rpmi_shmem_transport_init(struct rpmi_shmem_mbox_controller *mctl,/* fetch doorbell register address*/ ret =fdt_get_node_addr_size (fdt, nodeoff, qid, ®_addr, ®_size); -if (!ret && !(strncmp (name,"db-reg" ,strlen ("db-reg" )))) { +if (!ret && !(strncmp (name,"a2p-doorbell" ,strlen ("a2p-doorbell" )))) { mctl->mb_regs = (void *)(unsigned long )reg_addr; ret = sbi_domain_root_add_memrange(reg_addr, reg_size, reg_size, (SBI_DOMAIN_MEMREGION_MMIO |
Signature · 7 lines
2.43.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 2/4 lib: utils/mailbox: Parse P2A doorbell system MSI index from DT
In reply to Anup PatelThe 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.
--- include/sbi_utils/mailbox/rpmi_msgprot.h | 1 + lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 4 deletions(-)
include/sbi_utils/mailbox/rpmi_msgprot.h +1 -0
@@ -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 ,
lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c +12 -4
@@ -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
Signature · 7 lines
2.43.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 3/4 lib: utils/mailbox: Parse A2P doorbell value from DT
In reply to Anup PatelThe A2P doorbell value written to the 32-bit A2P doorbell value must be discoverd from device tree instead of always using the default value 1.
--- lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-)
lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c +10 -4
@@ -134,6 +134,7 @@ struct rpmi_shmem_mbox_controller {u32 slot_size;u32 queue_count;u32 p2a_doorbell_sysmsi_index; +u32 a2p_doorbell_value;struct rpmi_mb_regs *mb_regs;struct smq_queue_ctx queue_ctx_tbl[RPMI_QUEUE_IDX_MAX_COUNT ];/* Mailbox framework related members */
@@ -248,7 +249,8 @@ static int __smq_rx(struct smq_queue_ctx *qctx, u32 slot_size, }static int __smq_tx (struct smq_queue_ctx *qctx,struct rpmi_mb_regs *mb_regs, -u32 slot_size,u32 service_group_id,struct mbox_xfer *xfer) +u32 a2p_doorbell_value,u32 slot_size,u32 service_group_id, +struct mbox_xfer *xfer) {u32 i, tailidx;void *dst, *src;
@@ -300,7 +302,7 @@ static int __smq_tx(struct smq_queue_ctx *qctx, struct rpmi_mb_regs *mb_regs,/* Ring the RPMI doorbell if present */ if (mb_regs) -writel (cpu_to_le32 (1 ), &mb_regs->db_reg); +writel (a2p_doorbell_value, &mb_regs->db_reg);return SBI_OK ; }
@@ -364,8 +366,8 @@ static int smq_tx(struct rpmi_shmem_mbox_controller *mctl,*/ do { spin_lock(&qctx->queue_lock); - ret = __smq_tx(qctx, mctl->mb_regs, mctl->slot_size, - service_group_id, xfer); + ret = __smq_tx(qctx, mctl->mb_regs, mctl->a2p_doorbell_value, + mctl->slot_size, service_group_id, xfer); spin_unlock(&qctx->queue_lock); if (!ret) return 0;
@@ -604,6 +606,10 @@ static int rpmi_shmem_transport_init(struct rpmi_shmem_mbox_controller *mctl, prop =fdt_getprop (fdt, nodeoff,"riscv,p2a-doorbell-sysmsi-index" , &len); mctl->p2a_doorbell_sysmsi_index = prop ?fdt32_to_cpu (*prop) :-1U ; +/* get a2p doorbell value */ + prop =fdt_getprop (fdt, nodeoff,"riscv,a2p-doorbell-value" , &len); + mctl->a2p_doorbell_value = prop ?fdt32_to_cpu (*prop) :1 ; +/* * queue names count is taken as the number of queues * supported which make it mandatory to provide the
Signature · 7 lines
2.43.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
PATCH 4/4 lib: utils/mpxy: Remove p2a_db_index from RPMI system MSI attributes
In reply to Anup PatelThe discovery of P2A doorbell system MSI index is now through RPMI shared memory DT node so remove p2a_db_index from RPMI system MSI attributes and access it as a mailbox channel attribute.
--- include/sbi_utils/mailbox/rpmi_msgprot.h | 1 - lib/utils/mpxy/fdt_mpxy_rpmi_sysmsi.c | 13 +++++++++---- 2 files changed, 9 insertions(+), 5 deletions(-)
include/sbi_utils/mailbox/rpmi_msgprot.h +0 -1
@@ -285,7 +285,6 @@ enum rpmi_sysmsi_service_id {struct rpmi_sysmsi_get_attributes_resp {s32 status;u32 sys_num_msi; -u32 p2a_db_index;u32 flag0;u32 flag1; };
lib/utils/mpxy/fdt_mpxy_rpmi_sysmsi.c +9 -4
@@ -32,10 +32,9 @@ static int mpxy_rpmi_sysmis_xfer(void *context, struct mbox_chan *chan,case RPMI_SYSMSI_SRV_GET_ATTRIBUTES : ((u32 *)xfer->rx)[0 ] =cpu_to_le32 (RPMI_SUCCESS ); ((u32 *)xfer->rx)[1 ] =cpu_to_le32 (smg->sys_num_msi); - ((u32 *)xfer->rx)[2 ] =-1U ; + ((u32 *)xfer->rx)[2 ] =0 ; ((u32 *)xfer->rx)[3 ] =0 ; - ((u32 *)xfer->rx)[4 ] =0 ; - args->rx_data_len =5 *sizeof (u32); + args->rx_data_len =4 *sizeof (u32);break ;case RPMI_SYSMSI_SRV_GET_MSI_ATTRIBUTES :case RPMI_SYSMSI_SRV_SET_MSI_STATE :
@@ -90,8 +89,14 @@ static int mpxy_rpmi_sysmsi_setup(void **context, struct mbox_chan *chan,struct rpmi_sysmsi_get_msi_attributes_req gmareq;struct rpmi_sysmsi_get_attributes_resp garesp;struct mpxy_rpmi_sysmsi *smg; +u32 p2a_db_index;int rc, i; + rc =mbox_chan_get_attribute (chan,RPMI_CHANNEL_ATTR_P2A_DOORBELL_SYSMSI_INDEX , + &p2a_db_index); +if (rc) +return rc; + rc =rpmi_normal_request_with_status (chan,RPMI_SYSMSI_SRV_GET_ATTRIBUTES ,NULL ,0 ,0 , &garesp,rpmi_u32_count (garesp),rpmi_u32_count (garesp));
@@ -122,7 +127,7 @@ static int mpxy_rpmi_sysmsi_setup(void **context, struct mbox_chan *chan,return rc; } -if (garesp.p2a_db_index == i || +if (p2a_db_index == i || (gmaresp.flag0 &RPMI_SYSMSI_MSI_ATTRIBUTES_FLAG0_PREF_PRIV ))bitmap_set (smg->sys_msi_denied_bmap, i,1 ); }
Signature · 7 lines
2.43.0 -- opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi
Anup Patel
AppliedQuoted 12 lines · Anup Patel
The RPMI v1.0 specification is frozen and in public review so update RPMI drivers to match last minute specification changes which were based on ARC feedback.
These patches can also be found in the
rpmi_fixes_v1branch at:
https://github.com/avpatel/opensbi.gitTo test these patches, use the dev-upstream branch of the following repos:
* https://github.com/ventanamicro/qemu.git
* https://github.com/ventanamicro/linux.git
Quoted 8 lines
To enable QEMU RPMI emulation (using librpmi) for virt machine, use "virt,rpmi=on,aia=aplic-imsic" as the QEMU machine name.
Anup Patel (4):
lib: utils/mailbox: Update DT register name of A2P doorbell
lib: utils/mailbox: Parse P2A doorbell system MSI index from DT
lib: utils/mailbox: Parse A2P doorbell value from DT
lib: utils/mpxy: Removep2a_db_indexfrom RPMI system MSI attributes
Applied this series to the riscv/opensbi repo.
Regards,
Anup
Quoted 9 lines
include/sbi_utils/mailbox/rpmi_msgprot.h | 2 +- lib/utils/mailbox/fdt_mailbox_rpmi_shmem.c | 34 +++++++++++++++------- lib/utils/mpxy/fdt_mpxy_rpmi_sysmsi.c | 13 ++++++--- 3 files changed, 34 insertions(+), 15 deletions(-)--
2.43.0
Signature · 3 lines
opensbi mailing list [email protected] http://lists.infradead.org/mailman/listinfo/opensbi