Re: [PATCH v2 1/5] RISC-V: Move common MPXY helper routines to arch/riscv
From: Amirreza Zarrabi
Date: Sun Nov 29 2026 - 18:48:00 EST
Hi Anup,
On 11/16/2026 3:00 PM, Anup Patel wrote:
> +int sbi_mpxy_send_message_with_resp(u32 channel_id, u32 msg_id,
> + void *tx, unsigned long tx_len,
> + void *rx, unsigned long max_rx_len,
> + unsigned long *rx_len)
> +{
> + struct mpxy_local *mpxy = this_cpu_ptr(&mpxy_local);
> + unsigned long rx_bytes;
> + struct sbiret sret;
> +
> + if (!mpxy->shmem_active)
> + return -ENODEV;
> + if (!tx && tx_len)
> + return -EINVAL;
> +
> + get_cpu();
> +
> + /* Message protocols allowed to have no data in messages */
> + if (tx_len)
> + memcpy(mpxy->shmem, tx, tx_len);
Before this patch, both send helpers were private to the mailbox driver.
Their caller, mpxy_mbox_send_rpmi_data(), checks request_len against
mchan->max_xfer_len. That limit is the smaller of the MPXY shared-memory
size and the channel's maximum message length.
Now that callers can use these helpers directly, should not both helpers
check tx_len against mpxy_shmem_size before the memcpy()?
Regards,
Amir
> +
> + sret = sbi_ecall(SBI_EXT_MPXY, SBI_EXT_MPXY_SEND_MSG_WITH_RESP,
> + channel_id, msg_id, tx_len, 0, 0, 0);
> + if (rx && !sret.error) {
> + rx_bytes = sret.value;
> + if (rx_bytes > max_rx_len) {
> + put_cpu();
> + return -ENOSPC;
> + }
> +
> + memcpy(rx, mpxy->shmem, rx_bytes);
> + if (rx_len)
> + *rx_len = rx_bytes;
> + }
> +
> + put_cpu();
> + return sbi_err_map_linux_errno(sret.error);
> +}
> +EXPORT_SYMBOL_GPL(sbi_mpxy_send_message_with_resp);