[PATCH 02/11] lib: utils/mpxy: Setup group early in fdt_mpxy_rpmi_init()

Pawandeep Oza pawandeep.oza at oss.qualcomm.com
Tue Oct 13 12:45:45 PDT 2026


On Tue, Sep 22, 2026 at 8:24 PM Anup Patel <anup.patel at oss.qualcomm.com> wrote:
>
> Instead of setting group late in fdt_mpxy_rpmi_init(), it is better
> to do it as early as possible right after requesting mailbox channel
> so that we define new callback for channel attributes.
>
> Signed-off-by: Anup Patel <anup.patel at oss.qualcomm.com>
> ---
>  lib/utils/mpxy/fdt_mpxy_rpmi.c | 40 +++++++++++++++++-----------------
>  1 file changed, 20 insertions(+), 20 deletions(-)
>
> diff --git a/lib/utils/mpxy/fdt_mpxy_rpmi.c b/lib/utils/mpxy/fdt_mpxy_rpmi.c
> index 9a37fbdc..bbeb7a79 100644
> --- a/lib/utils/mpxy/fdt_mpxy_rpmi.c
> +++ b/lib/utils/mpxy/fdt_mpxy_rpmi.c
> @@ -235,47 +235,54 @@ int fdt_mpxy_rpmi_init(const void *fdt, int nodeoff, const struct fdt_match *mat
>                 goto fail_free_chan;
>         }
>
> +       /* Setup RPMI service group context */
> +       if (data->setup_group) {
> +               rc = data->setup_group(&rmb->group_context, chan, data);
> +               if (rc)
> +                       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;
> +               goto fail_cleanup_group;
>
>         /* 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;
> +               goto fail_cleanup_group;
>
>         /* Get channel Tx timeout */
>         rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_TX_TIMEOUT,
>                                      &tx_tout);
>         if (rc)
> -               goto fail_free_chan;
> +               goto fail_cleanup_group;
>
>         /* Get channel Rx timeout */
>         rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_RX_TIMEOUT,
>                                      &rx_tout);
>         if (rc)
> -               goto fail_free_chan;
> +               goto fail_cleanup_group;
>
>         /* Get channel service group version */
>         rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_SERVICEGROUP_VERSION,
>                                      &servicegrp_ver);
>         if (rc)
> -               goto fail_free_chan;
> +               goto fail_cleanup_group;
>
>         /* Get channel implementation id */
>         rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_IMPL_ID,
>                                      &impl_id);
>         if (rc)
> -               goto fail_free_chan;
> +               goto fail_cleanup_group;
>
>         /* Get channel implementation version */
>         rc = mbox_chan_get_attribute(chan, RPMI_CHANNEL_ATTR_IMPL_VERSION,
>                                      &impl_ver);
>         if (rc)
> -               goto fail_free_chan;
> +               goto fail_cleanup_group;
>
>         /*
>          * The "riscv,sbi-mpxy-channel-id" DT property is mandatory
> @@ -287,7 +294,7 @@ int fdt_mpxy_rpmi_init(const void *fdt, int nodeoff, const struct fdt_match *mat
>                 channel_id = fdt32_to_cpu(*val);
>         } else {
>                 rc = SBI_ENODEV;
> -               goto fail_free_chan;
> +               goto fail_cleanup_group;
>         }
>
>         /* Setup MPXY RPMI channel */
> @@ -329,23 +336,16 @@ int fdt_mpxy_rpmi_init(const void *fdt, int nodeoff, const struct fdt_match *mat
>         rmb->data = data;
>         rmb->chan = chan;
>
> -       /* Setup RPMI service group context */
> -       if (data->setup_group) {
> -               rc = data->setup_group(&rmb->group_context, chan, data);
> -               if (rc)
> -                       goto fail_free_chan;
> -       }
> -
>         /* Register RPMI service group */
>         rc = sbi_mpxy_register_channel(&rmb->channel);
> -       if (rc) {
> -               if (data->cleanup_group)
> -                       data->cleanup_group(rmb->group_context);
> -               goto fail_free_chan;
> -       }
> +       if (rc)
> +               goto fail_cleanup_group;
>
>         return SBI_OK;
>
> +fail_cleanup_group:
> +       if (data->cleanup_group)
> +               data->cleanup_group(rmb->group_context);
>  fail_free_chan:
>         mbox_controller_free_chan(chan);
>  fail_free_client:
> --
> 2.43.0
>
>
> --
> opensbi mailing list
> opensbi at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/opensbi

Reviewed-by: Pawandeep Oza <pawandeep.oza at oss.qualcomm.com>
Tested-by: Pawandeep Oza <pawandeep.oza at oss.qualcomm.com>



More information about the opensbi mailing list