Re: [PATCH] mailbox: Document the behavior of mbox_send_message() w/ NULL mssg

From: Doug Anderson

Date: Tue Jan 06 2026 - 12:42:46 EST


Hi,

On Mon, Jan 5, 2026 at 5:57 PM Jassi Brar <jassisinghbrar@xxxxxxxxx> wrote:
>
> > Right (well, "NULL" instead of "0"). It's actually quite common. Using
> > `git grep -A2 mbox_send_message.*NULL`, I see:
> >
> > * drivers/acpi/acpi_pcc.c
> > * drivers/firmware/arm_scmi/transports/mailbox.c
> > * drivers/firmware/imx/imx-dsp.c
> > * drivers/firmware/tegra/bpmp-tegra186.c
> > * drivers/irqchip/irq-qcom-mpm.c
> > * drivers/remoteproc/xlnx_r5_remoteproc.c
> > * drivers/rpmsg/qcom_glink_rpm.c
> > * drivers/rpmsg/qcom_glink_smem.c
> > * drivers/rpmsg/qcom_smd.c
> > * drivers/soc/qcom/qcom_aoss.c
> > * drivers/soc/qcom/smp2p.c
> > * drivers/soc/qcom/smsm.c
> > * drivers/soc/ti/wkup_m3_ipc.c
> > * drivers/soc/xilinx/zynqmp_power.c
> >
> > ...or did you mean something different when you said drivers are
> > passing "0" as an argument?
> >
> Actually I meant to say some 'constant' value, but yes 0 and NULL
> don't make a difference.
> The core needs to track the in-flight request in the 'active_req'
> pointer which is also checked
> to be non-null as a marker of busyness. That _can be_ a problem when
> the client sends NULL
> as the message, depending upon the submission pattern and speed.
> Clients that call with NULL are likely simple one-message-at-a-time
> users, but I haven't checked.

I guess my worry is that some of them are _not_ one-message-at-a-time
and are relying on the current behavior of the core when `mssg` is
NULL. At least one downstream user I've studied was relying on this...


> > Anyway, I'm not 100% set on any one solution, I just see that the NULL
> > case is (unexpectedly) different and either want it documented or to
> > fix it so it's not different (ideally without angry people with
> > pitchforks coming after me because I changed behavior). :-)
> >
> Yes, I too think we should leave the existing api alone to be safe.
> For new pure-doorbell clients, how about something like
> #define MBOX_NODATA ERR_PTR(-ENOMEM)
> mailbox_ring_doorbell(chan)
> {
> mailbox_send_message(chan, MBOX_NODATA)
> }
> because the underlying controller driver anyway ignores the submitted
> 'mssg' pointer.
>
> And of course add the clarification comment in this patch.

OK, how about this for a plan:

1. A patch to introduce the new mbox_ring_doorbell() API, which will
behave nearly the same as the existing mailbox_send_message(chan,
NULL) case.

2. A series of patches transitioning all existing upstream users that
are passing NULL to use mbox_ring_doorbell().

3. A patch making it an error to pass NULL as the `mmsg`.

Does that work for you?

-Doug