Skip to contentSkip to conversation

mailbox: Stop sending NULL mailbox messages

PATCH In review Douglas Anderson 4 participants 24 messages Feb 16 – Mar 11

Subsystems (12)
lore
Share & tools
lore
#0 lore raw

v3 cover mailbox: Stop sending NULL mailbox messages

As talked about in the first patch in this series, passing NULL as the 'mssg' argument to mbox_send_message() ends up causing confusion and quirky behavior inside the mailbox core. Despite this, there are a number of drivers that pass NULL.

It is plausible that some of the drivers passing NULL may have been taking advantage of the quirks of the mailbox core. Specifically, they may have been taking advantage that calling "tx_done" wasn't truly necessary for NULL messages (it was a noop) or that NULL messages were passed onto the mailbox controller right away without queuing.

This series introduces a new API call: mbox_ring_doorbell(). The new API call tries to mimic the specific quirks that were helpful in the old behavior and it's expected to be a nearly drop-in replacement.

There are some subtle differences between the new call and the old behavior, but it's expected that all of these differences are only for cases where the old behavior made little sense. The description of the first patch details these differences.

The series attempts to convert all in-tree users to stop passing NULL for mssg. As per above, there are some slight differences in behavior. If any of the patches are causing problems, they can safely be reverted while debugging the problems. Eventually, all code should be converted over to stop passing NULL mssg.

Changes in v3:
- Suggest mbox_ring_doorbell in the warning message
- Updated patch description based on Cristian's response.

Changes in v2:
- Instead of just documenting NULL, introduce a new function

Douglas Anderson (15):
mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()
ACPI: PCC: Use mbox_ring_doorbell() instead of NULL message
firmware: arm_scmi: Use mbox_ring_doorbell() instead of NULL message
firmware: imx-dsp: Use mbox_ring_doorbell() instead of NULL message
firmware: tegra: bpmp: Use mbox_ring_doorbell() instead of NULL
message
irqchip/qcom-mpm: Use mbox_ring_doorbell() instead of NULL message
remoteproc: xlnx: Use mbox_ring_doorbell() instead of NULL message
rpmsg: qcom_glink_rpm: Use mbox_ring_doorbell() instead of NULL
message
rpmsg: glink: smem: Use mbox_ring_doorbell() instead of NULL message
rpmsg: qcom_smd: Use mbox_ring_doorbell() instead of NULL message
soc: qcom: aoss: Use mbox_ring_doorbell() instead of NULL message
soc: qcom: smp2p: Use mbox_ring_doorbell() instead of NULL message
soc: qcom: smsm: Use mbox_ring_doorbell() instead of NULL message
soc: ti: wkup_m3_ipc: Use mbox_ring_doorbell() instead of NULL message
drivers: firmware: xilinx: Use mbox_ring_doorbell() instead of NULL
message

 drivers/acpi/acpi_pcc.c                       |  4 +-
 .../firmware/arm_scmi/transports/mailbox.c    |  8 +-
 drivers/firmware/imx/imx-dsp.c                |  2 +-
 drivers/firmware/tegra/bpmp-tegra186.c        |  4 +-
 drivers/irqchip/irq-qcom-mpm.c                |  2 +-
 drivers/mailbox/mailbox.c                     | 82 ++++++++++++++++++-
 drivers/remoteproc/xlnx_r5_remoteproc.c       |  2 +-
 drivers/rpmsg/qcom_glink_rpm.c                |  3 +-
 drivers/rpmsg/qcom_glink_smem.c               |  3 +-
 drivers/rpmsg/qcom_smd.c                      | 13 +--
 drivers/soc/qcom/qcom_aoss.c                  |  3 +-
 drivers/soc/qcom/smp2p.c                      |  8 +-
 drivers/soc/qcom/smsm.c                       |  8 +-
 drivers/soc/ti/wkup_m3_ipc.c                  | 10 +--
 drivers/soc/xilinx/zynqmp_power.c             |  2 +-
 include/linux/mailbox_client.h                |  1 +
 include/linux/mailbox_controller.h            |  4 +-
 17 files changed, 108 insertions(+), 51 deletions(-)
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#1 lore raw

PATCH v3 1/15 mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()

The way the mailbox core behaves when you pass a NULL mssg parameter to mbox_send_message() is a little questionable. Specifically, the mailbox core stores the currently active message directly in its active_req field. In at least two places it decides that if this field is NULL then there is no active request. That means if mssg is ever NULL it will cause the mailbox core to think is no active request. The two places where it does this are:

1. When a client calls mbox_send_message(), if active_req is NULL then it will call the mailbox controller to send the new message even if the mailbox controller hasn't yet called mbox_chan_txdone() on the previous (NULL) message.
2. The mailbox core will never call the client's tx_done() callback with a NULL message because tx_tick() returns early whenever the message is NULL.

Though the above doesn't look like it was a conscious design choice, it does have the benefit of providing a simple way to assert an edge-triggered interrupt to the remote processor on the other side of the mailbox. Specifically:

1. Like a normal edge-triggered interrupt, if multiple edges arrive before the interrupt is Acked they are coalesced.
2. Like a normal edge-triggered interrupt, as long as the receiver (the remote processor in this case) "Ack"s the interrupt _before_ checking for work and the sender (the mailbox client in this case) posts the interrupt _after_ adding new work then we can always be certain that new work will be noticed. This assumes that the mailbox client and remote processor have some out-of-band way to communicate work and the mailbox is just being used as an interrupt.

Doing a git grep -A1 mbox_send_message | grep NULL shows 14 hits in mainline today, but it's not 100% clear if all of those users are relying on the benefits/quirks of the existing behavior.

Since the current NULL mssg behavior is a bit questionable but has some benefits, let's:

1. Deprecate the NULL behavior and print a warning.
2. Add a new mbox_ring_doorbell() function that is very similar to the existing NULL mssg case but a tad bit cleaner.

The design of the new mbox_ring_doorbell() will be to maximize compatibility with the old NULL mssg behavior. Specifically:

* We'll still pass NULL to the mailbox controller to indicate a doorbell.
* Doorbells will not be queued and won't have txdone.
* We'll call immediately into the mailbox controller when a doorbell is posted.

With the above, any mailbox clients that don't mix doorbells and normal messages are intended to see no change in behavior when switching to the new API. Using the new API, which officiall documents that mbox_client_txdone() shouldn't be called for doorbells, does allow us to remove those calls.

There are two differences in behavior between the old sending a NULL message and the new mbox_ring_doorbell():

1. If the mailbox controller returned an error when trying to send a NULL message, the old NULL message could have ended up being queued up in the core's FIFO. Now we will just return the error.
2. If a client rings a doorbell while a non-doorbell message is in progress, previously NULL messages would have been "queued" in that case and now doorbells will be immediately posted.

I'm hoping that nobody was relying on either of the two differences. In general holding NULL messages in the mailbox core's queue has odd behavior and is hard to reason about. Hopefully it's reasonable to assume nobody was doing this.

As mentioned above, it should be noted that it's now documented that "txdone" shouldn't be called (by both mailbox drivers and clients) for doorbells. That being said, in most cases it won't hurt since the mailbox core will ignore the bogus "txdone". The only case where it's critical for a mailbox controller not to call "txdone" for a doorbell is when a mailbox channel mixes normal messages and doorbells and cares about the txdone callback. Specifically, when you ring a doorbell and immediately send a normal message, if the controller calls "txdone" for the doorbell it could look as if the normal message finished before it should have. This issue also would have happened with the old NULL mssg, though.

---

Changes in v3:
- Suggest mbox_ring_doorbell in the warning message

Changes in v2:
- Instead of just documenting NULL, introduce a new function

 drivers/mailbox/mailbox.c          | 82 +++++++++++++++++++++++++++++-
 include/linux/mailbox_client.h     |  1 +
 include/linux/mailbox_controller.h |  4 +-
 3 files changed, 85 insertions(+), 2 deletions(-)
drivers/mailbox/mailbox.c +81 -1
index 617ba505691d..fe3f2f75e734 100644
@@ -161,6 +161,9 @@ EXPORT_SYMBOL_GPL(mbox_chan_received_data);
  * The controller that has IRQ for TX ACK calls this atomic API
  * to tick the TX state machine. It works only if txdone_irq
  * is set by the controller.
+ *
+ * Should not be called for "doorbell" messages (any time the message
+ * sent was NULL).
  */
 void mbox_chan_txdone(struct mbox_chan *chan, int r)
 {
@@ -182,6 +185,9 @@ EXPORT_SYMBOL_GPL(mbox_chan_txdone);
  * The client/protocol had received some 'ACK' packet and it notifies
  * the API that the last packet was sent successfully. This only works
  * if the controller can't sense TX-Done.
+ *
+ * Should not be called for "doorbell" messages (any time the message
+ * sent was NULL).
  */
 void mbox_client_txdone(struct mbox_chan *chan, int r)
 {
@@ -222,7 +228,7 @@ EXPORT_SYMBOL_GPL(mbox_client_peek_data);
  * mbox_send_message -	For client to submit a message to be
  *				sent to the remote.
  * @chan: Mailbox channel assigned to this client.
- * @mssg: Client specific message typecasted.
+ * @mssg: Client specific message typecasted. Should not be NULL.
  *
  * For client to submit data to the controller destined for a remote
  * processor. If the client had set 'tx_block', the call will return
@@ -249,6 +255,28 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
 	if (!chan || !chan->cl)
 		return -EINVAL;
 
+	/*
+	 * The mailbox core gets confused when mbox_send_message() is called
+	 * with NULL messages since the code directly stores messages in
+	 * `active_req` and assumes that a NULL `active_req` means no request
+	 * is active. This causes the core to call the mailbox controller a
+	 * second time even if the previous message hasn't finished and also
+	 * means the client's tx_done() callback will never be called. However,
+	 * clients historically passed NULL anyway. Deprecate passing NULL
+	 * here by adding a warning.
+	 *
+	 * Clients who don't have a message should switch to using
+	 * mbox_ring_doorbell(), which explicitly documents the immediate
+	 * sending of doorbells, the lack of txdone, and what happens if you
+	 * mix doorbells and normal messages.
+	 *
+	 * TODO: when it's certain that all clients have transitioned, consider
+	 * changing this to return -EINVAL.
+	 */
+	if (!mssg)
+		dev_warn_once(chan->mbox->dev,
+			      "NULL mbox messages are deprecated; use mbox_ring_doorbell\n");
+
 	t = add_to_rbuf(chan, mssg);
 	if (t < 0) {
 		dev_err(chan->mbox->dev, "Try increasing MBOX_TX_QUEUE_LEN\n");
@@ -277,6 +305,58 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
 }
 EXPORT_SYMBOL_GPL(mbox_send_message);
 
+/**
+ * mbox_ring_doorbell - Client function to ring the doorbell with no message.
+ * @chan: Mailbox channel assigned to this client.
+ *
+ * Send a notification to the remote side of the mailbox but don't actually
+ * send any data. This is typically used when the client and the remote side
+ * of the mailbox have some other (non-mailbox) way to communicate and the
+ * mailbox is simply used as an "interrupt" to notify the remote side.
+ *
+ * This function has a few important differences from mbox_send_message():
+ * - There is no concept of "txdone" for mbox_ring_doorbell(), even if the
+ *   controller itself would be able to tell when the remote CPU saw or Acked
+ *   the doorbell.
+ * - Because there is no concept of "txdone", there is no need to wait for
+ *   previous doorbells to "finish" before notifying the controller of another
+ *   doorbell.
+ * - Because we never wait to notify a controller of a doorbell, there is no
+ *   queue for doorbells.
+ *
+ * The above properties mean that calling mbox_ring_doorbell() is the equivalent
+ * of re-asserting an edge triggered interrupt to the remote side. If the remote
+ * side hasn't yet "cleared" the interrupt this is a no-op. If the remote side
+ * has cleared the interrupt, it will be re-asserted. Expected usage:
+ *
+ * This CPU:
+ * - Update out-of-band (OOB) memory shared between this CPU and remote CPU.
+ * - Ring doorbell.
+ * Remote CPU:
+ * - Clear doorbell.
+ * - Read OOB shared memory and act on it.
+ *
+ * The remote CPU will always be guaranteed to notice changes, even if this CPU
+ * updates / rings multiple times before the remote CPU has a chance to run.
+ *
+ * Mixing calls of mbox_ring_doorbell() and mbox_send_message() on the same
+ * mailbox channel is allowed, assuming the mailbox controller correctly avoids
+ * calling mbox_chan_txdone() for doorbells.
+ *
+ * NOTE: For compatibility reasons, doorbells are sent to the mailbox
+ *	 controller driver by passing NULL to the mailbox controller's
+ *	 send_data() callback.
+ *
+ * Return: Negative error code upon failure.
+ */
+int mbox_ring_doorbell(struct mbox_chan *chan)
+{
+	guard(spinlock_irqsave)(&chan->lock);
+
+	return chan->mbox->ops->send_data(chan, NULL);
+}
+EXPORT_SYMBOL_GPL(mbox_ring_doorbell);
+
 /**
  * mbox_flush - flush a mailbox channel
  * @chan: mailbox channel to flush
include/linux/mailbox_client.h +1 -0
index c6eea9afb943..e3fc11e42c58 100644
@@ -42,6 +42,7 @@ struct mbox_chan *mbox_request_channel_byname(struct mbox_client *cl,
 					      const char *name);
 struct mbox_chan *mbox_request_channel(struct mbox_client *cl, int index);
 int mbox_send_message(struct mbox_chan *chan, void *mssg);
+int mbox_ring_doorbell(struct mbox_chan *chan);
 int mbox_flush(struct mbox_chan *chan, unsigned long timeout);
 void mbox_client_txdone(struct mbox_chan *chan, int r); /* atomic */
 bool mbox_client_peek_data(struct mbox_chan *chan); /* atomic */
include/linux/mailbox_controller.h +3 -1
index 80a427c7ca29..36648fa7b6f3 100644
@@ -19,7 +19,9 @@ struct mbox_chan;
  *		if the remote hasn't yet read the last data sent. Actual
  *		transmission of data is reported by the controller via
  *		mbox_chan_txdone (if it has some TX ACK irq). It must not
- *		sleep.
+ *		sleep. Will be passed NULL data for doorbell-only messages.
+ *		Note that doorbell messages are always sent immediately with
+ *		no queuing. mbox_chan_txdone() shouldn't be called on doorbells.
  * @flush:	Called when a client requests transmissions to be blocking but
  *		the context doesn't allow sleeping. Typically the controller
  *		will implement a busy loop waiting for the data to flush out.
Signature · 1 line
2.53.0.273.g2a3d683680-goog
maintainer
#2 lore raw

Re: [PATCH v3 01/15] mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()

Hi Doug,

Quoted 16 lines · Douglas Anderson
drivers/mailbox/mailbox.c +12 -0
@@ -249,6 +255,28 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
        if (!chan || !chan->cl)
                return -EINVAL;
 
+       /*
+        * The mailbox core gets confused when mbox_send_message() is called
+        * with NULL messages since the code directly stores messages in
+        * `active_req` and assumes that a NULL `active_req` means no request
+        * is active. This causes the core to call the mailbox controller a
+        * second time even if the previous message hasn't finished and also
+        * means the client's tx_done() callback will never be called. However,
+        * clients historically passed NULL anyway. Deprecate passing NULL
+        * here by adding a warning.
+        *
+        * Clients who don't have a message should switch to using
+        * mbox_ring_doorbell(), which explicitly documents the immediate

drivers/mailbox/mailbox.c int mbox_send_message(struct mbox_chan *chan, void *mssg) · line 279

Quoted 10 lines
drivers/mailbox/mailbox.c +10 -0
+        * sending of doorbells, the lack of txdone, and what happens if you
+        * mix doorbells and normal messages.
+        *
+        * TODO: when it's certain that all clients have transitioned, consider
+        * changing this to return -EINVAL.
+        */
+       if (!mssg)
+               dev_warn_once(chan->mbox->dev,
+                             "NULL mbox messages are deprecated; use mbox_ring_doorbell\n");
+

Does this patchset leave some such clients out? If not, should we drop this block and return -EINVAL already?

Thanks,
Jassi

#3 lore raw

Re: [PATCH v3 01/15] mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()

Hi,

Quoted 24 lines · Jassi Brar

Hi Doug,

Quoted 20 lines · Douglas Anderson
drivers/mailbox/mailbox.c +16 -0
@@ -249,6 +255,28 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg)
        if (!chan || !chan->cl)
                return -EINVAL;
 
+       /*
+        * The mailbox core gets confused when mbox_send_message() is called
+        * with NULL messages since the code directly stores messages in
+        * `active_req` and assumes that a NULL `active_req` means no request
+        * is active. This causes the core to call the mailbox controller a
+        * second time even if the previous message hasn't finished and also
+        * means the client's tx_done() callback will never be called. However,
+        * clients historically passed NULL anyway. Deprecate passing NULL
+        * here by adding a warning.
+        *
+        * Clients who don't have a message should switch to using
+        * mbox_ring_doorbell(), which explicitly documents the immediate
+        * sending of doorbells, the lack of txdone, and what happens if you
+        * mix doorbells and normal messages.
+        *
+        * TODO: when it's certain that all clients have transitioned, consider
Quoted 8 lines

drivers/mailbox/mailbox.c int mbox_send_message(struct mbox_chan *chan, void *mssg) · line 279

Quoted 6 lines
drivers/mailbox/mailbox.c +6 -0
+        * changing this to return -EINVAL.
+        */
+       if (!mssg)
+               dev_warn_once(chan->mbox->dev,
+                             "NULL mbox messages are deprecated; use mbox_ring_doorbell\n");
+

Does this patchset leave some such clients out? If not, should we drop this block and return -EINVAL already?

This patchset series got all the clients that were in mainline at the time I last checked. However, it was unclear to me if all the patches would all go through your tree or not, since they don't touch mailbox drivers but the somewhat widespread places that were clients of mailbox.

If all the patches aren't going through your tree, we'll need to keep it like this until we can confirm all of the clients have been updated. If all the patcheds are going through your tree, then we could make it return -EINVAL right away, but it we'd have to do that as a last patch in the series. I think it would still make sense for the first patch (which adds the mbox_ring_doorbell() call) to have a warning like this and then a final patch to switch to -EINVAL. That keeps things bisectable.

What do you think?

I'm happy to post a patch atop my series that switches it to -EINVAL and you can land it whenever you see fit. Would that work?

-Doug

#4 lore raw

PATCH v3 2/15 ACPI: PCC: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

From code inspection, it appears that this driver only ever sends NULL messages and thus the conversion is straightforward. The only change is to remove the call to mbox_chan_txdone(). The call wouldn't have done anything in the past anyway (since chan->active_req was NULL) but with doorbells it's officially documented to not be needed.

---
Something seemed a little fishy in this code. The code seems to be a _client_ of a mailbox, yet it was calling mbox_chan_txdone() which is something mailbox _controllers_ are supposed to call when their "txdone" interrupt goes off.

It appears that this client even reaches into the mailbox controller and confirms that txdone_irq is set, which should mean that the controller itself signals txdone.

If the mailbox controller is actually signaling "txdone" it should ideally be improved to not do so for doorbell (NULL) messages, but it won't matter much for this client since we only ever send doorbells and don't care about the txdone callback.

(no changes since v1)

 drivers/acpi/acpi_pcc.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/acpi/acpi_pcc.c +1 -3
index e3f302b9dee5..3d240ecd98f4 100644
@@ -106,7 +106,7 @@ acpi_pcc_address_space_handler(u32 function, acpi_physical_address addr,
 	/* Write to Shared Memory */
 	memcpy_toio(data->pcc_chan->shmem, (void *)value, data->ctx.length);
 
-	ret = mbox_send_message(data->pcc_chan->mchan, NULL);
+	ret = mbox_ring_doorbell(data->pcc_chan->mchan);
 	if (ret < 0)
 		return AE_ERROR;
 
@@ -123,8 +123,6 @@ acpi_pcc_address_space_handler(u32 function, acpi_physical_address addr,
 		return AE_TIME;
 	}
 
-	mbox_chan_txdone(data->pcc_chan->mchan, ret);
-
 	memcpy_fromio(value, data->pcc_chan->shmem, data->ctx.length);
 
 	return AE_OK;
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#5 lore raw

PATCH v3 3/15 firmware: arm_scmi: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

The mbox_ring_doorbell() explicitly documents not to call mbox_client_txdone() for doorbells, so remove the call.

NOTE: upon first glance, this mailbox client appears to send doorbells and regular messages on the same mailbox channel (smbox->chan), so it needs some extra attention. Specifically, the new API behaves differently if you ring a doorbell while a non-doorbell message is in progress. I don't believe that this is something we have to worry about with this mailbox client, though, because the code was calling mbox_client_txdone() after sending the NULL message. Had a non-mailbox message been in progress, that would have marked the in-progress message as done instead of marking the NULL message as done.

In discussion [1], it was further clarified that the driver shouldn't ever be sending doorbell and non-doorbell messages on the same channel.

---

Changes in v3:
- Updated patch description based on Cristian's response.

 drivers/firmware/arm_scmi/transports/mailbox.c | 8 +-------
 1 file changed, 1 insertion(+), 7 deletions(-)
drivers/firmware/arm_scmi/transports/mailbox.c +1 -7
index ae0f67e6cc45..c4561441ac2e 100644
@@ -324,7 +324,6 @@ static void mailbox_clear_channel(struct scmi_chan_info *cinfo)
 {
 	struct scmi_mailbox *smbox = cinfo->transport_info;
 	struct mbox_chan *intr_chan;
-	int ret;
 
 	core->shmem->clear_channel(smbox->shmem);
 
@@ -338,12 +337,7 @@ static void mailbox_clear_channel(struct scmi_chan_info *cinfo)
 	else
 		return;
 
-	ret = mbox_send_message(intr_chan, NULL);
-	/* mbox_send_message returns non-negative value on success, so reset */
-	if (ret > 0)
-		ret = 0;
-
-	mbox_client_txdone(intr_chan, ret);
+	mbox_ring_doorbell(intr_chan);
 }
 
 static bool
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#6 lore raw

PATCH v3 4/15 firmware: imx-dsp: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward.

---

(no changes since v1)

 drivers/firmware/imx/imx-dsp.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/imx/imx-dsp.c +1 -1
index ed79e823157a..231e9f841226 100644
@@ -30,7 +30,7 @@ int imx_dsp_ring_doorbell(struct imx_dsp_ipc *ipc, unsigned int idx)
 		return -EINVAL;
 
 	dsp_chan = &ipc->chans[idx];
-	ret = mbox_send_message(dsp_chan->ch, NULL);
+	ret = mbox_ring_doorbell(dsp_chan->ch);
 	if (ret < 0)
 		return ret;
 
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#7 lore raw

PATCH v3 5/15 firmware: tegra: bpmp: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

---

(no changes since v1)

 drivers/firmware/tegra/bpmp-tegra186.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/firmware/tegra/bpmp-tegra186.c +1 -3
index 64863db7a715..c45ea66aabfb 100644
@@ -84,12 +84,10 @@ static int tegra186_bpmp_ring_doorbell(struct tegra_bpmp *bpmp)
 	struct tegra186_bpmp *priv = bpmp->priv;
 	int err;
 
-	err = mbox_send_message(priv->mbox.channel, NULL);
+	err = mbox_ring_doorbell(priv->mbox.channel);
 	if (err < 0)
 		return err;
 
-	mbox_client_txdone(priv->mbox.channel, 0);
-
 	return 0;
 }
 
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#8 lore raw

PATCH v3 6/15 irqchip/qcom-mpm: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward.

This client didn't previously call mbox_client_txdone() and it appears that the mailboxes it hooks up with (qcom-apcs-ipc-mailbox.c or qcom-ipcc.c) have both txdone_irq and txdone_poll as false. Presumably this means the client was relying the mailbox core's quirky behavior when sending NULL messages.

---

(no changes since v1)

 drivers/irqchip/irq-qcom-mpm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/irqchip/irq-qcom-mpm.c +1 -1
index 83f31ea657b7..5b79d95bf1fb 100644
@@ -302,7 +302,7 @@ static int mpm_pd_power_off(struct generic_pm_domain *genpd)
 		qcom_mpm_write(priv, MPM_REG_STATUS, i, 0);
 
 	/* Notify RPM to write vMPM into HW */
-	ret = mbox_send_message(priv->mbox_chan, NULL);
+	ret = mbox_ring_doorbell(priv->mbox_chan);
 	if (ret < 0)
 		return ret;
 
Signature · 1 line
2.53.0.273.g2a3d683680-goog
maintainer Acked-by on v3 6/15
#9 lore raw

Re: [PATCH v3 06/15] irqchip/qcom-mpm: Use mbox_ring_doorbell() instead of NULL message

Quoted 7 lines · Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward.

Quoted 7 lines

This client didn't previously call mbox_client_txdone() and it appears that the mailboxes it hooks up with (qcom-apcs-ipc-mailbox.c or qcom-ipcc.c) have both txdone_irq and txdone_poll as false. Presumably this means the client was relying the mailbox core's quirky behavior when sending NULL messages.

#10 lore raw

PATCH v3 7/15 remoteproc: xlnx: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL message on the rx channel, so the transition is straightforward.

---

(no changes since v1)

 drivers/remoteproc/xlnx_r5_remoteproc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/remoteproc/xlnx_r5_remoteproc.c +1 -1
index bd619a6c42aa..2acdc536d6b6 100644
@@ -245,7 +245,7 @@ static void zynqmp_r5_mb_rx_cb(struct mbox_client *cl, void *msg)
 	memcpy(buf_msg->data, ipi_msg->data, len);
 
 	/* received and processed interrupt ack */
-	if (mbox_send_message(ipi->rx_chan, NULL) < 0)
+	if (mbox_ring_doorbell(ipi->rx_chan) < 0)
 		dev_err(cl->dev, "ack failed to mbox rx_chan\n");
 
 	schedule_work(&ipi->mbox_work);
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#11 lore raw

PATCH v3 8/15 rpmsg: qcom_glink_rpm: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

---

(no changes since v1)

 drivers/rpmsg/qcom_glink_rpm.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rpmsg/qcom_glink_rpm.c +1 -2
index e3ba2c63a5fc..4cb9c36adcd4 100644
@@ -197,8 +197,7 @@ static void glink_rpm_tx_kick(struct qcom_glink_pipe *glink_pipe)
 	struct glink_rpm_pipe *pipe = to_rpm_pipe(glink_pipe);
 	struct glink_rpm *rpm = container_of(pipe, struct glink_rpm, tx_pipe);
 
-	mbox_send_message(rpm->mbox_chan, NULL);
-	mbox_client_txdone(rpm->mbox_chan, 0);
+	mbox_ring_doorbell(rpm->mbox_chan);
 }
 
 static irqreturn_t qcom_glink_rpm_intr(int irq, void *data)
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#12 lore raw

PATCH v3 9/15 rpmsg: glink: smem: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

---
This driver is used on my sc7180-trogdor Chromebook. While I haven't stress tested with it, I can confirm that the system boots normally to UI and can suspend/resume with this patch in place.

(no changes since v1)

 drivers/rpmsg/qcom_glink_smem.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/rpmsg/qcom_glink_smem.c +1 -2
index 7a982c60a8dd..f2a6d94e72ea 100644
@@ -197,8 +197,7 @@ static void glink_smem_tx_kick(struct qcom_glink_pipe *glink_pipe)
 	struct glink_smem_pipe *pipe = to_smem_pipe(glink_pipe);
 	struct qcom_glink_smem *smem = pipe->smem;
 
-	mbox_send_message(smem->mbox_chan, NULL);
-	mbox_client_txdone(smem->mbox_chan, 0);
+	mbox_ring_doorbell(smem->mbox_chan);
 }
 
 static irqreturn_t qcom_glink_smem_intr(int irq, void *data)
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#13 lore raw

PATCH v3 10/15 rpmsg: qcom_smd: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

Also remove the comment about the only cause of errors for mbox_send_message() being if the framework's FIFO was full since we don't queue doorbells.

---

(no changes since v1)

 drivers/rpmsg/qcom_smd.c | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)
drivers/rpmsg/qcom_smd.c +3 -10
index 42594f5ee438..afe1177d092e 100644
@@ -371,17 +371,10 @@ static void qcom_smd_signal_channel(struct qcom_smd_channel *channel)
 {
 	struct qcom_smd_edge *edge = channel->edge;
 
-	if (edge->mbox_chan) {
-		/*
-		 * We can ignore a failing mbox_send_message() as the only
-		 * possible cause is that the FIFO in the framework is full of
-		 * other writes to the same bit.
-		 */
-		mbox_send_message(edge->mbox_chan, NULL);
-		mbox_client_txdone(edge->mbox_chan, 0);
-	} else {
+	if (edge->mbox_chan)
+		mbox_ring_doorbell(edge->mbox_chan);
+	else
 		regmap_write(edge->ipc_regmap, edge->ipc_offset, BIT(edge->ipc_bit));
-	}
 }
 
 /*
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#14 lore raw

PATCH v3 11/15 soc: qcom: aoss: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

---
This driver is used on my sc7180-trogdor Chromebook. While I haven't stress tested with it, I can confirm that the system boots normally to UI and can suspend/resume with this patch in place.

(no changes since v1)

 drivers/soc/qcom/qcom_aoss.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/qcom_aoss.c +1 -2
index a543ab9bee6c..2ecab93239d2 100644
@@ -97,8 +97,7 @@ struct qmp {
 
 static void qmp_kick(struct qmp *qmp)
 {
-	mbox_send_message(qmp->mbox_chan, NULL);
-	mbox_client_txdone(qmp->mbox_chan, 0);
+	mbox_ring_doorbell(qmp->mbox_chan);
 }
 
 static bool qmp_magic_valid(struct qmp *qmp)
Signature · 1 line
2.53.0.273.g2a3d683680-goog
maintainer Acked-by on v3 11/15
#15 lore raw

Re: [PATCH v3 11/15] soc: qcom: aoss: Use mbox_ring_doorbell() instead of NULL message

Quoted 9 lines · Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

Regards,
Bjorn

Quoted 28 lines

---
This driver is used on my sc7180-trogdor Chromebook. While I haven't stress tested with it, I can confirm that the system boots normally to UI and can suspend/resume with this patch in place.

(no changes since v1)

 drivers/soc/qcom/qcom_aoss.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/soc/qcom/qcom_aoss.c +1 -2
index a543ab9bee6c..2ecab93239d2 100644
@@ -97,8 +97,7 @@ struct qmp {
 
 static void qmp_kick(struct qmp *qmp)
 {
-	mbox_send_message(qmp->mbox_chan, NULL);
-	mbox_client_txdone(qmp->mbox_chan, 0);
+	mbox_ring_doorbell(qmp->mbox_chan);
 }
 
 static bool qmp_magic_valid(struct qmp *qmp)
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#16 lore raw

PATCH v3 12/15 soc: qcom: smp2p: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

---
This driver is used on my sc7180-trogdor Chromebook. While I haven't stress tested with it, I can confirm that the system boots normally to UI and can suspend/resume with this patch in place.

(no changes since v1)

 drivers/soc/qcom/smp2p.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/soc/qcom/smp2p.c +3 -5
index cb515c2340c1..139307b66a47 100644
@@ -169,12 +169,10 @@ static void qcom_smp2p_kick(struct qcom_smp2p *smp2p)
 	/* Make sure any updated data is written before the kick */
 	wmb();
 
-	if (smp2p->mbox_chan) {
-		mbox_send_message(smp2p->mbox_chan, NULL);
-		mbox_client_txdone(smp2p->mbox_chan, 0);
-	} else {
+	if (smp2p->mbox_chan)
+		mbox_ring_doorbell(smp2p->mbox_chan);
+	else
 		regmap_write(smp2p->ipc_regmap, smp2p->ipc_offset, BIT(smp2p->ipc_bit));
-	}
 }
 
 static bool qcom_smp2p_check_ssr(struct qcom_smp2p *smp2p)
Signature · 1 line
2.53.0.273.g2a3d683680-goog
maintainer Acked-by on v3 12/15
#17 lore raw

Re: [PATCH v3 12/15] soc: qcom: smp2p: Use mbox_ring_doorbell() instead of NULL message

Quoted 9 lines · Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

Regards,
Bjorn

Quoted 34 lines

---
This driver is used on my sc7180-trogdor Chromebook. While I haven't stress tested with it, I can confirm that the system boots normally to UI and can suspend/resume with this patch in place.

(no changes since v1)

 drivers/soc/qcom/smp2p.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/soc/qcom/smp2p.c +3 -5
index cb515c2340c1..139307b66a47 100644
@@ -169,12 +169,10 @@ static void qcom_smp2p_kick(struct qcom_smp2p *smp2p)
 	/* Make sure any updated data is written before the kick */
 	wmb();
 
-	if (smp2p->mbox_chan) {
-		mbox_send_message(smp2p->mbox_chan, NULL);
-		mbox_client_txdone(smp2p->mbox_chan, 0);
-	} else {
+	if (smp2p->mbox_chan)
+		mbox_ring_doorbell(smp2p->mbox_chan);
+	else
 		regmap_write(smp2p->ipc_regmap, smp2p->ipc_offset, BIT(smp2p->ipc_bit));
-	}
 }
 
 static bool qcom_smp2p_check_ssr(struct qcom_smp2p *smp2p)
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#18 lore raw

PATCH v3 13/15 soc: qcom: smsm: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

---

(no changes since v1)

 drivers/soc/qcom/smsm.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/soc/qcom/smsm.c +3 -5
index 021e9d1f61dc..1e127678fd9c 100644
@@ -182,14 +182,12 @@ static int smsm_update_bits(void *data, u32 mask, u32 value)
 		if (!(val & changes))
 			continue;
 
-		if (hostp->mbox_chan) {
-			mbox_send_message(hostp->mbox_chan, NULL);
-			mbox_client_txdone(hostp->mbox_chan, 0);
-		} else if (hostp->ipc_regmap) {
+		if (hostp->mbox_chan)
+			mbox_ring_doorbell(hostp->mbox_chan);
+		else if (hostp->ipc_regmap)
 			regmap_write(hostp->ipc_regmap,
 				     hostp->ipc_offset,
 				     BIT(hostp->ipc_bit));
-		}
 	}
 
 done:
Signature · 1 line
2.53.0.273.g2a3d683680-goog
maintainer Acked-by on v3 13/15
#19 lore raw

Re: [PATCH v3 13/15] soc: qcom: smsm: Use mbox_ring_doorbell() instead of NULL message

Quoted 9 lines · Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

Regards,
Bjorn

Quoted 33 lines

---

(no changes since v1)

 drivers/soc/qcom/smsm.c | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)
drivers/soc/qcom/smsm.c +3 -5
index 021e9d1f61dc..1e127678fd9c 100644
@@ -182,14 +182,12 @@ static int smsm_update_bits(void *data, u32 mask, u32 value)
 		if (!(val & changes))
 			continue;
 
-		if (hostp->mbox_chan) {
-			mbox_send_message(hostp->mbox_chan, NULL);
-			mbox_client_txdone(hostp->mbox_chan, 0);
-		} else if (hostp->ipc_regmap) {
+		if (hostp->mbox_chan)
+			mbox_ring_doorbell(hostp->mbox_chan);
+		else if (hostp->ipc_regmap)
 			regmap_write(hostp->ipc_regmap,
 				     hostp->ipc_offset,
 				     BIT(hostp->ipc_bit));
-		}
 	}
 
 done:
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#20 lore raw

PATCH v3 14/15 soc: ti: wkup_m3_ipc: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

---

(no changes since v1)

 drivers/soc/ti/wkup_m3_ipc.c | 10 ++++------
 1 file changed, 4 insertions(+), 6 deletions(-)
drivers/soc/ti/wkup_m3_ipc.c +4 -6
index 5845fc652adc..9f74f2dfc217 100644
@@ -328,9 +328,9 @@ static int wkup_m3_ping(struct wkup_m3_ipc *m3_ipc)
 	 * the RX callback to avoid multiple interrupts being received
 	 * by the CM3.
 	 */
-	ret = mbox_send_message(m3_ipc->mbox, NULL);
+	ret = mbox_ring_doorbell(m3_ipc->mbox);
 	if (ret < 0) {
-		dev_err(dev, "%s: mbox_send_message() failed: %d\n",
+		dev_err(dev, "%s: mbox_ring_doorbell() failed: %d\n",
 			__func__, ret);
 		return ret;
 	}
@@ -343,7 +343,6 @@ static int wkup_m3_ping(struct wkup_m3_ipc *m3_ipc)
 		return -EIO;
 	}
 
-	mbox_client_txdone(m3_ipc->mbox, 0);
 	return 0;
 }
 
@@ -358,14 +357,13 @@ static int wkup_m3_ping_noirq(struct wkup_m3_ipc *m3_ipc)
 		return -EIO;
 	}
 
-	ret = mbox_send_message(m3_ipc->mbox, NULL);
+	ret = mbox_ring_doorbell(m3_ipc->mbox);
 	if (ret < 0) {
-		dev_err(dev, "%s: mbox_send_message() failed: %d\n",
+		dev_err(dev, "%s: mbox_ring_doorbell() failed: %d\n",
 			__func__, ret);
 		return ret;
 	}
 
-	mbox_client_txdone(m3_ipc->mbox, 0);
 	return 0;
 }
 
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#21 lore raw

PATCH v3 15/15 drivers: firmware: xilinx: Use mbox_ring_doorbell() instead of NULL message

In reply to Douglas Anderson

As per the patch ("mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()"), we want to switch all users of NULL mailbox messages to use mbox_ring_doorbell().

This client only ever sent NULL messages, so the transition is straightforward. We can remove the call to mbox_client_txdone(). The call didn't do anything for NULL messages and it's now officially documented not to be called for doorbells.

---

(no changes since v1)

 drivers/soc/xilinx/zynqmp_power.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/soc/xilinx/zynqmp_power.c +1 -1
index 9085db1b480a..b4e751247a35 100644
@@ -144,7 +144,7 @@ static void ipi_receive_callback(struct mbox_client *cl, void *data)
 			   &zynqmp_pm_init_suspend_work->callback_work);
 
 		/* Send NULL message to mbox controller to ack the message */
-		ret = mbox_send_message(rx_chan, NULL);
+		ret = mbox_ring_doorbell(rx_chan);
 		if (ret)
 			pr_err("IPI ack failed. Error %d\n", ret);
 	}
Signature · 1 line
2.53.0.273.g2a3d683680-goog
#22 lore raw
In reply to Douglas Anderson

Hi Jassi,

Quoted 45 lines · Douglas Anderson

As talked about in the first patch in this series, passing NULL as the 'mssg' argument to mbox_send_message() ends up causing confusion and quirky behavior inside the mailbox core. Despite this, there are a number of drivers that pass NULL.

It is plausible that some of the drivers passing NULL may have been taking advantage of the quirks of the mailbox core. Specifically, they may have been taking advantage that calling "tx_done" wasn't truly necessary for NULL messages (it was a noop) or that NULL messages were passed onto the mailbox controller right away without queuing.

This series introduces a new API call: mbox_ring_doorbell(). The new API call tries to mimic the specific quirks that were helpful in the old behavior and it's expected to be a nearly drop-in replacement.

There are some subtle differences between the new call and the old behavior, but it's expected that all of these differences are only for cases where the old behavior made little sense. The description of the first patch details these differences.

The series attempts to convert all in-tree users to stop passing NULL for mssg. As per above, there are some slight differences in behavior. If any of the patches are causing problems, they can safely be reverted while debugging the problems. Eventually, all code should be converted over to stop passing NULL mssg.

Changes in v3:
- Suggest mbox_ring_doorbell in the warning message
- Updated patch description based on Cristian's response.

Changes in v2:
- Instead of just documenting NULL, introduce a new function

Douglas Anderson (15):
mailbox: Deprecate NULL mbox messages; Introduce mbox_ring_doorbell()
ACPI: PCC: Use mbox_ring_doorbell() instead of NULL message
firmware: arm_scmi: Use mbox_ring_doorbell() instead of NULL message
firmware: imx-dsp: Use mbox_ring_doorbell() instead of NULL message
firmware: tegra: bpmp: Use mbox_ring_doorbell() instead of NULL
message
irqchip/qcom-mpm: Use mbox_ring_doorbell() instead of NULL message
remoteproc: xlnx: Use mbox_ring_doorbell() instead of NULL message
rpmsg: qcom_glink_rpm: Use mbox_ring_doorbell() instead of NULL
message

Quoted 8 lines

rpmsg: glink: smem: Use mbox_ring_doorbell() instead of NULL message
rpmsg: qcom_smd: Use mbox_ring_doorbell() instead of NULL message
soc: qcom: aoss: Use mbox_ring_doorbell() instead of NULL message
soc: qcom: smp2p: Use mbox_ring_doorbell() instead of NULL message
soc: qcom: smsm: Use mbox_ring_doorbell() instead of NULL message
soc: ti: wkup_m3_ipc: Use mbox_ring_doorbell() instead of NULL message
drivers: firmware: xilinx: Use mbox_ring_doorbell() instead of NULL
message

Just checking to see if there is any addional changes you need from me on this series. It looks like it's -rc3 which is maybe an ideal time for this series to get some linux-next bake time? A good number of the patches in this series have Acks from maintainers so they could all go in your tree, I think. For those that don't, I guess worst case they just don't land right now and I can re-post them later. ...or if you think they would be OK to pickup that would be cool too.

Thanks!

-Doug

#23 lore raw
In reply to Douglas Anderson

Hi,

Quoted 27 lines · Douglas Anderson

As talked about in the first patch in this series, passing NULL as the 'mssg' argument to mbox_send_message() ends up causing confusion and quirky behavior inside the mailbox core. Despite this, there are a number of drivers that pass NULL.

It is plausible that some of the drivers passing NULL may have been taking advantage of the quirks of the mailbox core. Specifically, they may have been taking advantage that calling "tx_done" wasn't truly necessary for NULL messages (it was a noop) or that NULL messages were passed onto the mailbox controller right away without queuing.

This series introduces a new API call: mbox_ring_doorbell(). The new API call tries to mimic the specific quirks that were helpful in the old behavior and it's expected to be a nearly drop-in replacement.

There are some subtle differences between the new call and the old behavior, but it's expected that all of these differences are only for cases where the old behavior made little sense. The description of the first patch details these differences.

The series attempts to convert all in-tree users to stop passing NULL for mssg. As per above, there are some slight differences in behavior. If any of the patches are causing problems, they can safely be reverted while debugging the problems. Eventually, all code should be converted over to stop passing NULL mssg.

Quoted 6 lines

Changes in v3:
- Suggest mbox_ring_doorbell in the warning message
- Updated patch description based on Cristian's response.

Changes in v2:
- Instead of just documenting NULL, introduce a new function

In case any mailbox client API users want to comment, Jassi has proposed an alternative to this series:

https://lore.kernel.org/r/[email protected]/

Feel free to join the conversation over there. :-)

-Doug