[PATCH 3/3] lib: utils: Add MPXY RPMI mailbox driver for performance

Anup Patel anup at brainfault.org
Mon Nov 3 21:12:47 PST 2025


On Mon, Oct 13, 2025 at 9:02 PM Joshua Yeong
<joshua.yeong at starfivetech.com> wrote:
>
> Add MPXY RPMI mailbox driver for performance.
>
> Signed-off-by: Joshua Yeong <joshua.yeong at starfivetech.com>

I have marked the driver as experimental until the DT compatible
string is accepted on LKML.

Applied this patch to the riscv/opensbi repo.

Thanks,
Anup

> ---
>  include/sbi_utils/mailbox/rpmi_msgprot.h   | 118 +++++++++++++++++++++
>  lib/utils/mpxy/Kconfig                     |   4 +
>  lib/utils/mpxy/fdt_mpxy_rpmi_performance.c |  90 ++++++++++++++++
>  lib/utils/mpxy/objects.mk                  |   3 +
>  platform/generic/configs/defconfig         |   1 +
>  5 files changed, 216 insertions(+)
>  create mode 100644 lib/utils/mpxy/fdt_mpxy_rpmi_performance.c
>
> diff --git a/include/sbi_utils/mailbox/rpmi_msgprot.h b/include/sbi_utils/mailbox/rpmi_msgprot.h
> index 4e915a08..f8b16753 100644
> --- a/include/sbi_utils/mailbox/rpmi_msgprot.h
> +++ b/include/sbi_utils/mailbox/rpmi_msgprot.h
> @@ -219,6 +219,7 @@ enum rpmi_servicegroup_id {
>         RPMI_SRVGRP_VOLTAGE = 0x00007,
>         RPMI_SRVGRP_CLOCK = 0x0008,
>         RPMI_SRVGRP_DEVICE_POWER = 0x0009,
> +       RPMI_SRVGRP_PERFORMANCE = 0x0000A,
>         RPMI_SRVGRP_ID_MAX_COUNT,
>
>         /* Reserved range for service groups */
> @@ -829,4 +830,121 @@ struct rpmi_dpwr_get_state_resp {
>         u32 state;
>  };
>
> +/** RPMI Performance ServiceGroup Service IDs */
> +enum rpmi_performance_service_id {
> +       RPMI_PERF_SRV_ENABLE_NOTIFICATION = 0x01,
> +       RPMI_PERF_SRV_GET_NUM_DOMAINS = 0x02,
> +       RPMI_PERF_SRV_GET_ATTRIBUTES = 0x03,
> +       RPMI_PERF_SRV_GET_SUPPORTED_LEVELS = 0x04,
> +       RPMI_PERF_SRV_GET_LEVEL = 0x05,
> +       RPMI_PERF_SRV_SET_LEVEL = 0x06,
> +       RPMI_PERF_SRV_GET_LIMIT = 0x07,
> +       RPMI_PERF_SRV_SET_LIMIT = 0x08,
> +       RPMI_PERF_SRV_GET_FAST_CHANNEL_REGION = 0x09,
> +       RPMI_PERF_SRV_GET_FAST_CHANNEL_ATTRIBUTES = 0x0A,
> +       RPMI_PERF_SRV_MAX_COUNT,
> +};
> +
> +struct rpmi_perf_get_num_domain_resp {
> +       s32 status;
> +       u32 num_domains;
> +};
> +
> +struct rpmi_perf_get_attrs_req {
> +       u32 domain_id;
> +};
> +
> +struct rpmi_perf_get_attrs_resp {
> +       s32 status;
> +       u32 flags;
> +       u32 num_level;
> +       u32 latency;
> +       u8 name[16];
> +};
> +
> +struct rpmi_perf_get_supported_level_req {
> +       u32 domain_id;
> +       u32 perf_level_index;
> +};
> +
> +struct rpmi_perf_domain_level {
> +       u32 level_index;
> +       u32 opp_level;
> +       u32 power_cost_uw;
> +       u32 transition_latency_us;
> +};
> +
> +struct rpmi_perf_get_supported_level_resp {
> +       s32 status;
> +       u32 reserve;
> +       u32 remaining;
> +       u32 returned;
> +       struct rpmi_perf_domain_level level[0];
> +};
> +
> +struct rpmi_perf_get_level_req {
> +       u32 domain_id;
> +};
> +
> +struct rpmi_perf_get_level_resp {
> +       s32 status;
> +       u32 level_index;
> +};
> +
> +struct rpmi_perf_set_level_req {
> +       u32 domain_id;
> +       u32 level_index;
> +};
> +
> +struct rpmi_perf_set_level_resp {
> +       s32 status;
> +};
> +
> +struct rpmi_perf_get_limit_req {
> +       u32 domain_id;
> +};
> +
> +struct rpmi_perf_get_limit_resp {
> +       s32 status;
> +       u32 level_index_max;
> +       u32 level_index_min;
> +};
> +
> +struct rpmi_perf_set_limit_req {
> +       u32 domain_id;
> +       u32 level_index_max;
> +       u32 level_index_min;
> +};
> +
> +struct rpmi_perf_set_limit_resp {
> +       s32 status;
> +};
> +
> +struct rpmi_perf_get_fast_chn_region_resp {
> +       s32 status;
> +       u32 region_phy_addr_low;
> +       u32 region_phy_addr_high;
> +       u32 region_size_low;
> +       u32 region_size_high;
> +};
> +
> +struct rpmi_perf_get_fast_chn_attr_req {
> +       u32 domain_id;
> +       u32 service_id;
> +};
> +
> +struct rpmi_perf_get_fast_chn_attr_resp {
> +       s32 status;
> +       u32 flags;
> +       u32 region_offset_low;
> +       u32 region_offset_high;
> +       u32 region_size;
> +       u32 db_addr_low;
> +       u32 db_addr_high;
> +       u32 db_id_low;
> +       u32 db_id_high;
> +       u32 db_perserved_low;
> +       u32 db_perserved_high;
> +};
> +
>  #endif /* !__RPMI_MSGPROT_H__ */
> diff --git a/lib/utils/mpxy/Kconfig b/lib/utils/mpxy/Kconfig
> index 25288671..507b8371 100644
> --- a/lib/utils/mpxy/Kconfig
> +++ b/lib/utils/mpxy/Kconfig
> @@ -30,6 +30,10 @@ config FDT_MPXY_RPMI_DEVICE_POWER
>         bool "MPXY driver for RPMI device power service group"
>         default n
>
> +config FDT_MPXY_RPMI_PERFORMANCE
> +       bool "MPXY driver for RPMI performance service group"
> +       default n
> +
>  endif
>
>  endmenu
> diff --git a/lib/utils/mpxy/fdt_mpxy_rpmi_performance.c b/lib/utils/mpxy/fdt_mpxy_rpmi_performance.c
> new file mode 100644
> index 00000000..f4f18831
> --- /dev/null
> +++ b/lib/utils/mpxy/fdt_mpxy_rpmi_performance.c
> @@ -0,0 +1,90 @@
> +#include <sbi_utils/mpxy/fdt_mpxy_rpmi_mbox.h>
> +
> +static struct mpxy_rpmi_service_data performance_services[] = {
> +{
> +       .id = RPMI_PERF_SRV_ENABLE_NOTIFICATION,
> +       .min_tx_len = sizeof(struct rpmi_enable_notification_req),
> +       .max_tx_len = sizeof(struct rpmi_enable_notification_req),
> +       .min_rx_len = sizeof(struct rpmi_enable_notification_resp),
> +       .max_rx_len = sizeof(struct rpmi_enable_notification_resp),
> +},
> +{
> +       .id = RPMI_PERF_SRV_GET_NUM_DOMAINS,
> +       .min_tx_len = 0,
> +       .max_tx_len = 0,
> +       .min_rx_len = sizeof(struct rpmi_perf_get_num_domain_resp),
> +       .max_rx_len = sizeof(struct rpmi_perf_get_num_domain_resp),
> +},
> +{
> +       .id = RPMI_PERF_SRV_GET_ATTRIBUTES,
> +       .min_tx_len = sizeof(struct rpmi_perf_get_attrs_req),
> +       .max_tx_len = sizeof(struct rpmi_perf_get_attrs_req),
> +       .min_rx_len = sizeof(struct rpmi_perf_get_attrs_resp),
> +       .max_rx_len = sizeof(struct rpmi_perf_get_attrs_resp),
> +},
> +{
> +       .id = RPMI_PERF_SRV_GET_SUPPORTED_LEVELS,
> +       .min_tx_len = sizeof(struct rpmi_perf_get_supported_level_req),
> +       .max_tx_len = sizeof(struct rpmi_perf_get_supported_level_req),
> +       .min_rx_len = sizeof(struct rpmi_perf_get_supported_level_resp),
> +       .max_rx_len = -1U,
> +},
> +{
> +       .id = RPMI_PERF_SRV_GET_LEVEL,
> +       .min_tx_len = sizeof(struct rpmi_perf_get_level_req),
> +       .max_tx_len = sizeof(struct rpmi_perf_get_level_req),
> +       .min_rx_len = sizeof(struct rpmi_perf_get_level_resp),
> +       .max_rx_len = sizeof(struct rpmi_perf_get_level_resp),
> +},
> +{
> +       .id = RPMI_PERF_SRV_SET_LEVEL,
> +       .min_tx_len = sizeof(struct rpmi_perf_set_level_req),
> +       .max_tx_len = sizeof(struct rpmi_perf_set_level_req),
> +       .min_rx_len = sizeof(struct rpmi_perf_set_level_resp),
> +       .max_rx_len = sizeof(struct rpmi_perf_set_level_resp),
> +},
> +{
> +       .id = RPMI_PERF_SRV_GET_LIMIT,
> +       .min_tx_len = sizeof(struct rpmi_perf_get_limit_req),
> +       .max_tx_len = sizeof(struct rpmi_perf_get_limit_req),
> +       .min_rx_len = sizeof(struct rpmi_perf_get_limit_resp),
> +       .max_rx_len = sizeof(struct rpmi_perf_get_limit_resp),
> +},
> +{
> +       .id = RPMI_PERF_SRV_SET_LIMIT,
> +       .min_tx_len = sizeof(struct rpmi_perf_set_limit_req),
> +       .max_tx_len = sizeof(struct rpmi_perf_set_limit_req),
> +       .min_rx_len = sizeof(struct rpmi_perf_set_limit_resp),
> +       .max_rx_len = sizeof(struct rpmi_perf_set_limit_resp),
> +},
> +{
> +       .id = RPMI_PERF_SRV_GET_FAST_CHANNEL_REGION,
> +       .min_tx_len = 0,
> +       .max_tx_len = 0,
> +       .min_rx_len = sizeof(struct rpmi_perf_get_fast_chn_region_resp),
> +       .max_rx_len = sizeof(struct rpmi_perf_get_fast_chn_region_resp),
> +},
> +{
> +       .id = RPMI_PERF_SRV_GET_FAST_CHANNEL_ATTRIBUTES,
> +       .min_tx_len = sizeof(struct rpmi_perf_get_fast_chn_attr_req),
> +       .max_tx_len = sizeof(struct rpmi_perf_get_fast_chn_attr_req),
> +       .min_rx_len = sizeof(struct rpmi_perf_get_fast_chn_attr_resp),
> +       .max_rx_len = sizeof(struct rpmi_perf_get_fast_chn_attr_resp),
> +},
> +};
> +
> +static const struct mpxy_rpmi_mbox_data performance_data = {
> +       .servicegrp_id = RPMI_SRVGRP_PERFORMANCE ,
> +       .num_services = RPMI_PERF_SRV_MAX_COUNT,
> +       .service_data = performance_services,
> +};
> +
> +static const struct fdt_match performance_match[] = {
> +       { .compatible = "riscv,rpmi-mpxy-performance", .data = &performance_data },
> +       { },
> +};
> +
> +const struct fdt_driver fdt_mpxy_rpmi_performance = {
> +       .match_table = performance_match,
> +       .init = mpxy_rpmi_mbox_init,
> +};
> diff --git a/lib/utils/mpxy/objects.mk b/lib/utils/mpxy/objects.mk
> index 45b3281b..bbc998af 100644
> --- a/lib/utils/mpxy/objects.mk
> +++ b/lib/utils/mpxy/objects.mk
> @@ -15,6 +15,9 @@ libsbiutils-objs-$(CONFIG_FDT_MPXY_RPMI_MBOX) += mpxy/fdt_mpxy_rpmi_mbox.o
>  carray-fdt_mpxy_drivers-$(CONFIG_FDT_MPXY_RPMI_CLOCK) += fdt_mpxy_rpmi_clock
>  libsbiutils-objs-$(CONFIG_FDT_MPXY_RPMI_CLOCK) += mpxy/fdt_mpxy_rpmi_clock.o
>
> +carray-fdt_mpxy_drivers-$(CONFIG_FDT_MPXY_RPMI_PERFORMANCE) += fdt_mpxy_rpmi_performance
> +libsbiutils-objs-$(CONFIG_FDT_MPXY_RPMI_PERFORMANCE) += mpxy/fdt_mpxy_rpmi_performance.o
> +
>  carray-fdt_mpxy_drivers-$(CONFIG_FDT_MPXY_RPMI_SYSMSI) += fdt_mpxy_rpmi_sysmsi
>  libsbiutils-objs-$(CONFIG_FDT_MPXY_RPMI_SYSMSI) += mpxy/fdt_mpxy_rpmi_sysmsi.o
>
> diff --git a/platform/generic/configs/defconfig b/platform/generic/configs/defconfig
> index 5e819b3b..387ce833 100644
> --- a/platform/generic/configs/defconfig
> +++ b/platform/generic/configs/defconfig
> @@ -61,4 +61,5 @@ CONFIG_FDT_MPXY_RPMI_MBOX=y
>  CONFIG_FDT_MPXY_RPMI_CLOCK=y
>  CONFIG_FDT_MPXY_RPMI_VOLTAGE=y
>  CONFIG_FDT_MPXY_RPMI_DEVICE_POWER=y
> +CONFIG_FDT_MPXY_RPMI_PERFORMANCE=y
>  CONFIG_FDT_MPXY_RPMI_SYSMSI=y
> --
> 2.43.0
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi



More information about the opensbi mailing list