diff options
author | Beleswar Padhi <b-padhi@ti.com> | 2025-05-13 11:14:55 +0530 |
---|---|---|
committer | Mathieu Poirier <mathieu.poirier@linaro.org> | 2025-05-20 11:19:11 -0600 |
commit | 67de5d0e6d65ef2016650e2e5c05153a3376fb61 (patch) | |
tree | 4470434e865bc2479a269d9a3504808fe04e520b | |
parent | 23e16e210befaf2ce48feec25c11ce5b89f16039 (diff) |
remoteproc: k3-m4: Ping the mbox while acquiring the channel
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-padhi@ti.com>
Tested-by: Judith Mendez <jm@ti.com>
Reviewed-by: Andrew Davis <afd@ti.com>
Link: https://lore.kernel.org/r/20250513054510.3439842-22-b-padhi@ti.com
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
-rw-r--r-- | drivers/remoteproc/ti_k3_m4_remoteproc.c | 44 |
1 files changed, 19 insertions, 25 deletions
diff --git a/drivers/remoteproc/ti_k3_m4_remoteproc.c b/drivers/remoteproc/ti_k3_m4_remoteproc.c index 3a21ff95046f..182ac71e22da 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) |