From: Joonwon Kang <joonwonkang@google.com>
To: dianders@chromium.org
Cc: andersson@kernel.org, arnd@arndb.de, jassisinghbrar@gmail.com,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] RFC: mailbox: Fix NULL message support in mbox_send_message()
Date: Fri, 13 Mar 2026 08:44:48 +0000 [thread overview]
Message-ID: <20260313084450.2995354-1-joonwonkang@google.com> (raw)
In-Reply-To: <CAD=FV=X=eLrWZC7p7xfF97=m6+Ewu9T6fya9nNCoGCFjgp0-uw@mail.gmail.com>
> Hi,
>
> On Tue, Mar 10, 2026 at 8:42 PM Jassi Brar <jassisinghbrar@gmail.com> wrote:
> >
> > > > > In my case, I have a mailbox driver that's currently downstream
> > > > > (though I hope to change that). My mailbox controller has an interrupt
> > > > > for txdone, so mailbox clients _shouldn't_ call mbox_client_txdone().
> > > > > Some clients of this mailbox client want the txdone interrupt, but
> > > > > some clients of it just care about sending doorbells.
> > > > >
> > > > So imx-dsp.c like? Please let me know what is lacking in the core to
> > > > fully support that. Happy to look into it.
> > >
> > > I know that with my downstream mailbox client, if I let NULL messages
> > > queue up I end up with a queue of a dozen or so NULL messages. The
> > > downstream client is really taking advantage (AKA abusing) the core's
> > > current NULL behavior. It truly does want the "mbox_ring_doorbell"
> > > concept of just making sure the doorbell is asserted and returning
> > > immediately. If the core changes to start queuing NULL messages, we'll
> > > have to figure out some sort of workaround...
> > >
> > You said your controller has an irq raised for the doorbell sent (?).
>
> It has an interrupt for when the remote side receives the doorbell
> (when it clears the IRQ on its side).
>
> > If so, your clients should want to wait for that confirmation (the
> > controller driver would tick via mbox_chan_txdone).
>
> Ah, I think I see what you're saying. Functionally, I think it should
> work. Pseudocode for the client:
>
> def ring_doorbell():
> if not previous_doorbell_acked:
> another_doorbell_pending = true
> else:
> previous_doorbell_acked = false;
> mbox_send_message(NULL)
>
> def tx_done():
> if another_doorbell_pending:
> another_doorbell_pending = false
> mbox_send_message(NULL)
> else:
> previous_doorbell_acked = true;
>
> I think that will ensure the other side always gets at least one
> future interrupt when the doorbell is rung.
>
> I guess another option would be for the mailbox controller to issue
> "tx_done" immediately for NULL messages. With no data to transmit, I
> guess one could say that as soon as the interrupt is raised that the
> data is "transmitted", so maybe this would be OK too?
One thing to note is that if the mailbox controller issues "tx_done"
immediately in the same thread that is executing
mbox_controller->send_data(), you will encounter deadlock(refer to
chan->lock on the code). Thus, it should be issued after ->send_data() or
in another thread. Either way, it is unavoidable to have window to queue
up the NULL messages in the multi-threads situation anyway. So, the key in
that case will be how quickly the queue is dequeued or how to recover from
the tx failure due to the overflow, I think.
next prev parent reply other threads:[~2026-03-13 8:44 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-10 23:46 jassisinghbrar
2026-03-10 23:52 ` Doug Anderson
2026-03-10 23:58 ` Jassi Brar
2026-03-11 0:15 ` Doug Anderson
2026-03-11 0:45 ` Jassi Brar
2026-03-11 1:59 ` Doug Anderson
2026-03-11 3:41 ` Jassi Brar
2026-03-12 20:59 ` Doug Anderson
2026-03-13 8:44 ` Joonwon Kang [this message]
2026-03-13 16:19 ` Doug Anderson
2026-03-17 2:21 ` Jassi Brar
2026-03-12 10:19 ` [PATCH] RFC: mailbox: Fix NULL message support in Joonwon Kang
2026-03-12 7:34 ` Joonwon Kang
2026-03-13 10:12 ` [PATCH] RFC: mailbox: Fix NULL message support in mbox_send_message() Joonwon Kang
2026-03-13 16:23 ` Doug Anderson
2026-03-17 3:12 ` Jassi Brar
2026-03-17 5:03 ` Joonwon Kang
2026-03-20 21:03 ` Doug Anderson
2026-03-21 16:11 ` Jassi Brar
2026-03-26 7:31 ` Joonwon Kang
2026-03-27 18:29 ` Jassi Brar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260313084450.2995354-1-joonwonkang@google.com \
--to=joonwonkang@google.com \
--cc=andersson@kernel.org \
--cc=arnd@arndb.de \
--cc=dianders@chromium.org \
--cc=jassisinghbrar@gmail.com \
--cc=linux-kernel@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®