Skip to content

Commit 67de5d0

Browse files
3V3RYONEmathieupoirier
authored andcommitted
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 <[email protected]> Tested-by: Judith Mendez <[email protected]> Reviewed-by: Andrew Davis <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Mathieu Poirier <[email protected]>
1 parent 23e16e2 commit 67de5d0

File tree

1 file changed

+19
-25
lines changed

1 file changed

+19
-25
lines changed

drivers/remoteproc/ti_k3_m4_remoteproc.c

Lines changed: 19 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,24 @@
2121
#include "ti_sci_proc.h"
2222
#include "ti_k3_common.h"
2323

24-
static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc)
24+
static int k3_m4_rproc_request_mbox(struct rproc *rproc)
2525
{
26+
struct k3_rproc *kproc = rproc->priv;
27+
struct mbox_client *client = &kproc->client;
2628
struct device *dev = kproc->dev;
2729
int ret;
2830

31+
client->dev = dev;
32+
client->tx_done = NULL;
33+
client->rx_callback = k3_rproc_mbox_callback;
34+
client->tx_block = false;
35+
client->knows_txdone = false;
36+
37+
kproc->mbox = mbox_request_channel(client, 0);
38+
if (IS_ERR(kproc->mbox))
39+
return dev_err_probe(dev, PTR_ERR(kproc->mbox),
40+
"mbox_request_channel failed\n");
41+
2942
/*
3043
* Ping the remote processor, this is only for sanity-sake for now;
3144
* there is no functional effect whatsoever.
@@ -36,6 +49,7 @@ static int k3_m4_rproc_ping_mbox(struct k3_rproc *kproc)
3649
ret = mbox_send_message(kproc->mbox, (void *)RP_MBOX_ECHO_REQUEST);
3750
if (ret < 0) {
3851
dev_err(dev, "mbox_send_message failed: %d\n", ret);
52+
mbox_free_channel(kproc->mbox);
3953
return ret;
4054
}
4155

@@ -347,15 +361,8 @@ static void k3_m4_release_tsp(void *data)
347361
static int k3_m4_rproc_start(struct rproc *rproc)
348362
{
349363
struct k3_rproc *kproc = rproc->priv;
350-
int ret;
351-
352-
ret = k3_m4_rproc_ping_mbox(kproc);
353-
if (ret)
354-
return ret;
355-
356-
ret = k3_rproc_release(kproc);
357364

358-
return ret;
365+
return k3_rproc_release(kproc);
359366
}
360367

361368
/*
@@ -380,13 +387,6 @@ static int k3_m4_rproc_stop(struct rproc *rproc)
380387
*/
381388
static int k3_m4_rproc_attach(struct rproc *rproc)
382389
{
383-
struct k3_rproc *kproc = rproc->priv;
384-
int ret;
385-
386-
ret = k3_m4_rproc_ping_mbox(kproc);
387-
if (ret)
388-
return ret;
389-
390390
return 0;
391391
}
392392

@@ -493,15 +493,9 @@ static int k3_m4_rproc_probe(struct platform_device *pdev)
493493
dev_info(dev, "configured M4F for remoteproc mode\n");
494494
}
495495

496-
kproc->client.dev = dev;
497-
kproc->client.tx_done = NULL;
498-
kproc->client.rx_callback = k3_rproc_mbox_callback;
499-
kproc->client.tx_block = false;
500-
kproc->client.knows_txdone = false;
501-
kproc->mbox = mbox_request_channel(&kproc->client, 0);
502-
if (IS_ERR(kproc->mbox))
503-
return dev_err_probe(dev, PTR_ERR(kproc->mbox),
504-
"mbox_request_channel failed\n");
496+
ret = k3_m4_rproc_request_mbox(rproc);
497+
if (ret)
498+
return ret;
505499

506500
ret = devm_rproc_add(dev, rproc);
507501
if (ret)

0 commit comments

Comments
 (0)