Re: [PATCH 7/7] mailbox: goog-mba: Introduce the goog-mba mailbox driver

From: Doug Anderson

Date: Sat Oct 10 2026 - 05:17:00 EST


Hi,

On Fri, Oct 9, 2026 at 8:43 AM Jassi Brar <jassisinghbrar@xxxxxxxxx> wrote:
>
> Hi Doug,
>
> On Fri, Oct 9, 2026 at 3:42 AM Doug Anderson <dianders@xxxxxxxxxxxx> wrote:
> > > >
> > > > for (i = 0; i < mbox->num_chans; i++) {
> > > > if (!mbox->chans[i].cl)
> > > > return &mbox->chans[i];
> > > > }
> > > >
> > > > return ERR_PTR(-EBUSY);
> > > > }
> > > > ```
> > > >
> > > > Then the client loops around and requests the same channel over and
> > > > over again until it gets -EBUSY? Like:
> > > >
> > > > ```C
> > > > for (i = 0; i < FIFO_MAX; i++) {
> > > > client
> > > > chan[i] = mbox_request_channel(client[i], TX_CHAN);
> > > > if (IS_ERR(chan[i]) && PTR_ERR(chan[i]) == -EBUSY)
> > > > break;
> > > > }
> > > > fifo_depth = i;
> > > > ```
> > > >
> > > > I _guess_ that works, but it still feels like a bit of a hack to me.
> > > > You said you were worried about people abusing the "has_queue" API.
> > > > The above feels like it's abusing the "fw_xlate" API, turning it from
> > > > something that is normally a "lookup" into an allocator function.
> > > >
> > > > +Rob, Saravana, and devicetree@xxxxxxxxxxxxxxx. DT folks: is the above
> > > > something that looks right to you?
> > >
> > > There is no allocation in your xlate code above, so this is not that
> > > terrible as we talked on LPC.
> > >
> > > >
> > > >
> > > > I researched whether other upstream drivers use of_xlate() /
> > > > fw_xlate() as an "allocator" like this. I did find "exynos-mailbox,"
> > > > which appears to be doing something similar. However, upon deeper
> > > > digging it seems like "exynos-mailbox" isn't using this dynamic
> > > > allocation for any compelling reason. It looks like, really,
> > > > "exynos-mailbox" should just be returning one channel. The client
> > > > (exynos-acpm) could just use the same channel for everything since:
> > > > * It actually gets the _real_ channel ID out of the data.
> > > > * It doesn't care about txdone.
> > > > * All it does is ring a doorbell and there's no queueing.
> > > >
> > > >
> > > > In any case, if using fw_xlate() as an allocator is truly the only way
> > > > to proceed, I'll finish my prototype and send a v2, but I'm still
> > >
> > > Why fw_xlate() would be an allocator? Can you extend your code to show that?
> > >
> > > I think doing any allocation in xlate() is calls is fundamentally wrong.
> > > These should not modify the state of the device, so no allocations, no
> > > device_link_add() etc.
> >
> > It's not _calling_ an allocator, it _is_ an allocator. It is walking
> > through the array of channels and returning the first free one. Then
> > that free channel is "allocated" to the client.
> >
> You mean _assigned_.
> Allocation means when there are some resources reserved that must be
> released at some point later .... which is what the mailbox controller
> driver does in probe() and remove().
> In xlate() the platform just decides which channel to assign to the
> incoming request -- some platforms take the hint from device-tree,
> your platform has flexibility and can simply assign the first free
> found.

In this case, mbox_request_channel() plus the fw_xlate() seem to me to
act like an allocator. There is a pool of channels and each call
allocates one. mbox_release_channel() releases the channel. This is in
contrast to normal cases where fw_xlate() always returns the same
channel. Sure, I guess in that case it still "allocates" that one
slot, but that feels more like someone requesting/reserving a channel
rather than allocating the next free channel.

...but I guess the root of the problem is that it just seems
unexpected to me that fw_xlate() is taking the same input "fw_node"
and then is returning different mailboxes.

If this is what everyone wants then I agree that it can work. I just
want to confirm since it doesn't feel very clean to me.


> I will try to explain in detail your questions in your last post, but
> I am still not convinced you need to modify the api.

Sure, anything you can do to clarify is appreciated! I'd love to be
able to send a v2 and move forward, but I don't want to do so while
things are still unresolved.

-Doug