Re: [PATCH v2 1/5] RISC-V: Move common MPXY helper routines to arch/riscv
From: Anup Patel
Date: Fri Dec 04 2026 - 05:58:48 EST
On Mon, Nov 30, 2026 at 5:17 AM Amirreza Zarrabi
<amirreza.zarrabi@xxxxxxxxxxxxxxxx> wrote:
>
> 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()?
I agree. Since, both sbi_mpxy_send_message_with_resp() and
sbi_mpxy_send_message_without_resp() are copying Tx data to
MPXY shared memory, we should check tx_lex against the MPXY
shared memory size.
I will update in the next revision.
Regards,
Anup