The TI K3 M4 remoteproc driver acquires the mailbox channel in probe but sends a message through the acquired channel later in .attach()/.start() callbacks.
Put both the things together in the form of 'k3_m4_rproc_request_mbox()' function and invoke that in the probe routine. This is done to align the rproc_request_mbox() implementation with R5 and DSP drivers which can be factored out at a later stage. Signed-off-by: Beleswar Padhi <b-pa...@ti.com> Tested-by: Judith Mendez <j...@ti.com> Reviewed-by: Andrew Davis <a...@ti.com> --- v12: Changelog: 1. Carried R/B tag. Link to v11: https://lore.kernel.org/all/20250425104135.830255-21-b-pa...@ti.com/ v11: Changelog: 1. Carried T/B tag. Link to v10: https://lore.kernel.org/all/20250417182001.3903905-19-b-pa...@ti.com/ v10: Changelog: 1. Split [v9 14/26] into [v10 18/33] and [v10 19/33] patches. Link to v9: https://lore.kernel.org/all/20250317120622.1746415-15-b-pa...@ti.com/ drivers/remoteproc/ti_k3_m4_remoteproc.c | 44 ++++++++++-------------- 1 file changed, 19 insertions(+), 25 deletions(-) diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 3a21ff95046fd..182ac71e22da3 100644 --- a/drivers/remoteproc/ti_k3_m4_remoteproc.c +++ b/drivers/remoteproc/ti_k3_m4_remoteproc.c @@ -21,11 +21,24 @@ #include "ti_sci_proc.h" #include "ti_k3_common.h" -static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc) +static int k3_m4_rproc_request_mbox(struct rproc *rproc) { + struct k3_rproc *kproc = rproc->priv; + struct mbox_client *client = &kproc->client; struct device *dev = kproc->dev; int ret; + client->dev = dev; + client->tx_done = NULL; + client->rx_callback = k3_rproc_mbox_callback; + client->tx_block = false; + client->knows_txdone = false; + + kproc->mbox = mbox_request_channel(client, 0); + if (IS_ERR(kproc->mbox)) + return dev_err_probe(dev, PTR_ERR(kproc->mbox), + "mbox_request_channel failed\n"); + /* * Ping the remote processor, this is only for sanity-sake for now; * there is no functional effect whatsoever. @@ -36,6 +49,7 @@ static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc) ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST); if (ret < 0) { dev_err(dev, "mbox_send_message failed: %d\n", ret); + mbox_free_channel(kproc->mbox); return ret; } @@ -347,15 +361,8 @@ static void k3_m4_release_tsp(void *data) static int k3_m4_rproc_start(struct rproc *rproc) { struct k3_rproc *kproc = rproc->priv; - int ret; - - ret = k3_m4_rproc_ping_mbox(kproc); - if (ret) - return ret; - - ret = k3_rproc_release(kproc); - return ret; + return k3_rproc_release(kproc); } /* @@ -380,13 +387,6 @@ static int k3_m4_rproc_stop(struct rproc *rproc) */ static int k3_m4_rproc_attach(struct rproc *rproc) { - struct k3_rproc *kproc = rproc->priv; - int ret; - - ret = k3_m4_rproc_ping_mbox(kproc); - if (ret) - return ret; - return 0; } @@ -493,15 +493,9 @@ static int k3_m4_rproc_probe(struct platform_device *pdev) dev_info(dev, "configured M4F for remoteproc mode\n"); } - kproc->client.dev = dev; - kproc->client.tx_done = NULL; - kproc->client.rx_callback = k3_rproc_mbox_callback; - kproc->client.tx_block = false; - kproc->client.knows_txdone = false; - kproc->mbox = mbox_request_channel(&kproc->client, 0); - if (IS_ERR(kproc->mbox)) - return dev_err_probe(dev, PTR_ERR(kproc->mbox), - "mbox_request_channel failed\n"); + ret = k3_m4_rproc_request_mbox(rproc); + if (ret) + return ret; ret = devm_rproc_add(dev, rproc); if (ret) -- 2.34.1