Re: [PATCH 7/7] mailbox: goog-mba: Introduce the goog-mba mailbox driver
From: Doug Anderson
Date: Mon Sep 28 2026 - 17:35:06 EST
Hi,
On Tue, Sep 22, 2026 at 5:23 PM Jassi Brar <jassisinghbrar@xxxxxxxxx> wrote:
>
> So I think clk_mailbox can acquire all 8 channels during probe and
> maintain a list of idle channels from which it picks one and uses it
> for an incoming clk_prepare(). If all channels are busy, the
> clk_prepare() will sleep/block on a wait-queue which is nudged by
> tx_done of a transfer after the channel is added back to the idle
> list.
Sorry for the delay in responding. I wanted to prototype the change
and needed time to look at it.
So I think the crux of your current suggestion is that we have a
non-idempotent "fw_xlate" function, right? We call it multiple times
with the same arguments and it returns a different channel each time?
In my prototype, it looked like this:
```C
static struct mbox_chan *goog_mba_fw_xlate(struct mbox_controller *mbox,
const struct fwnode_reference_args *sp)
{
int i;
if (sp->nargs)
return ERR_PTR(-EINVAL);
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?
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
skeptical that this is better than just adding queuing into the core.
Speaking of which, I actually want to go back to something you said
earlier. I asked a bit about this but I don't think I saw a response
(sorry if I missed it!):
> It is not the diff stat but about inserting a flag in the api to
> introduce special case behavior. It is like adding one person to the
> party introduces N-1 handshakes - the has_queue flag doesn't play well
> with other configurations and may allow future platforms to abuse
> has_queue to implement hacks.
Can you elaborate more on this?
1. How does "has_queue" not play well with other configurations?
Everything should behave the same if "has_queue" isn't set, right? Are
you saying that it will make the code too hard to understand, or
something?
2. How does this allow future programs to abuse "has_queue"? Won't
they need to submit mailbox controllers to the mailbox subsystem,
meaning they'll have to go through you? If someone is using
"has_queue" to do a hack, can't you just NAK them?
One other thing that my prototype turned up: If I do the "fw_xlate()
as an allocator" solution, I believe I need to change the DT bindings
by adding a "tx-payload-size" attribute, or I need to jump through a
pile of awkward hoops. The reason is that I suddenly need to know the
number of FIFO entries much earlier. The v1 of my patch simply figured
out the "tx-payload-size" based on the first message sent, but now we
need it earlier.
While that's maybe not the end of the world, it's always unfortunate
when we have to change the DT bindings to accommodate the software
design.
-Doug