diff options
author | Fabien Dessenne <fabien.dessenne@st.com> | 2019-11-15 13:03:08 +0300 |
---|---|---|
committer | Bjorn Andersson <bjorn.andersson@linaro.org> | 2019-11-19 07:35:16 +0300 |
commit | 4a56e423e0e19b616c2f2615674a7dffdb77afd6 (patch) | |
tree | f1f62222c2fe13ae05486b0463218eb187da3f2e /drivers/remoteproc/stm32_rproc.c | |
parent | 410119ee29b6c14b88bae8cfa87b202e3fbe0488 (diff) |
remoteproc: stm32: fix probe error case
If the rproc driver is probed before the mailbox driver and if the rproc
Device Tree node has some mailbox properties, the rproc driver probe
shall be deferred instead of being probed without mailbox support.
Tested-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Fabien Dessenne <fabien.dessenne@st.com>
Link: https://lore.kernel.org/r/1573812188-19842-1-git-send-email-fabien.dessenne@st.com
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Diffstat (limited to 'drivers/remoteproc/stm32_rproc.c')
-rw-r--r-- | drivers/remoteproc/stm32_rproc.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/drivers/remoteproc/stm32_rproc.c b/drivers/remoteproc/stm32_rproc.c index 4adc9cefb532..a18f88044111 100644 --- a/drivers/remoteproc/stm32_rproc.c +++ b/drivers/remoteproc/stm32_rproc.c @@ -326,11 +326,12 @@ static const struct stm32_mbox stm32_rproc_mbox[MBOX_NB_MBX] = { } }; -static void stm32_rproc_request_mbox(struct rproc *rproc) +static int stm32_rproc_request_mbox(struct rproc *rproc) { struct stm32_rproc *ddata = rproc->priv; struct device *dev = &rproc->dev; unsigned int i; + int j; const unsigned char *name; struct mbox_client *cl; @@ -345,6 +346,8 @@ static void stm32_rproc_request_mbox(struct rproc *rproc) ddata->mb[i].chan = mbox_request_channel_byname(cl, name); if (IS_ERR(ddata->mb[i].chan)) { + if (PTR_ERR(ddata->mb[i].chan) == -EPROBE_DEFER) + goto err_probe; dev_warn(dev, "cannot get %s mbox\n", name); ddata->mb[i].chan = NULL; } @@ -353,6 +356,14 @@ static void stm32_rproc_request_mbox(struct rproc *rproc) stm32_rproc_mb_vq_work); } } + + return 0; + +err_probe: + for (j = i - 1; j >= 0; j--) + if (ddata->mb[j].chan) + mbox_free_channel(ddata->mb[j].chan); + return -EPROBE_DEFER; } static int stm32_rproc_set_hold_boot(struct rproc *rproc, bool hold) @@ -629,7 +640,9 @@ static int stm32_rproc_probe(struct platform_device *pdev) if (ret) goto free_wkq; - stm32_rproc_request_mbox(rproc); + ret = stm32_rproc_request_mbox(rproc); + if (ret) + goto free_rproc; ret = rproc_add(rproc); if (ret) |