remoteproc: stm32: Move memory parsing to rproc_ops

Some actions such as memory resources reallocation are needed when
trying to reattach a co-processor. Use the prepare() operation for
these actions.

Co-developed-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Signed-off-by: Arnaud POULIQUEN <arnaud.pouliquen@foss.st.com>
Link: https://lore.kernel.org/r/20210312162453.1234145-8-mathieu.poirier@linaro.org
Signed-off-by: Bjorn Andersson <bjorn.andersson@linaro.org>
This commit is contained in:
Arnaud POULIQUEN 2021-03-12 09:24:43 -07:00 committed by Bjorn Andersson
parent 8a471396d2
commit 6e20a05104
2 changed files with 18 additions and 23 deletions

View File

@ -1588,10 +1588,17 @@ static int rproc_attach(struct rproc *rproc)
return ret;
}
/* Do anything that is needed to boot the remote processor */
ret = rproc_prepare_device(rproc);
if (ret) {
dev_err(dev, "can't prepare rproc %s: %d\n", rproc->name, ret);
goto disable_iommu;
}
ret = rproc_set_rsc_table(rproc);
if (ret) {
dev_err(dev, "can't load resource table: %d\n", ret);
goto disable_iommu;
goto unprepare_device;
}
/* reset max_notifyid */
@ -1608,7 +1615,7 @@ static int rproc_attach(struct rproc *rproc)
ret = rproc_handle_resources(rproc, rproc_loading_handlers);
if (ret) {
dev_err(dev, "Failed to process resources: %d\n", ret);
goto disable_iommu;
goto unprepare_device;
}
/* Allocate carveout resources associated to rproc */
@ -1627,6 +1634,9 @@ static int rproc_attach(struct rproc *rproc)
clean_up_resources:
rproc_resource_cleanup(rproc);
unprepare_device:
/* release HW resources if needed */
rproc_unprepare_device(rproc);
disable_iommu:
rproc_disable_iommu(rproc);
return ret;

View File

@ -207,16 +207,7 @@ static int stm32_rproc_mbox_idx(struct rproc *rproc, const unsigned char *name)
return -EINVAL;
}
static int stm32_rproc_elf_load_rsc_table(struct rproc *rproc,
const struct firmware *fw)
{
if (rproc_elf_load_rsc_table(rproc, fw))
dev_warn(&rproc->dev, "no resource table found for this firmware\n");
return 0;
}
static int stm32_rproc_parse_memory_regions(struct rproc *rproc)
static int stm32_rproc_prepare(struct rproc *rproc)
{
struct device *dev = rproc->dev.parent;
struct device_node *np = dev->of_node;
@ -274,12 +265,10 @@ static int stm32_rproc_parse_memory_regions(struct rproc *rproc)
static int stm32_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
{
int ret = stm32_rproc_parse_memory_regions(rproc);
if (rproc_elf_load_rsc_table(rproc, fw))
dev_warn(&rproc->dev, "no resource table found for this firmware\n");
if (ret)
return ret;
return stm32_rproc_elf_load_rsc_table(rproc, fw);
return 0;
}
static irqreturn_t stm32_rproc_wdg(int irq, void *data)
@ -614,6 +603,7 @@ done:
}
static const struct rproc_ops st_rproc_ops = {
.prepare = stm32_rproc_prepare,
.start = stm32_rproc_start,
.stop = stm32_rproc_stop,
.attach = stm32_rproc_attach,
@ -796,14 +786,9 @@ static int stm32_rproc_probe(struct platform_device *pdev)
if (ret)
goto free_rproc;
if (state == M4_STATE_CRUN) {
if (state == M4_STATE_CRUN)
rproc->state = RPROC_DETACHED;
ret = stm32_rproc_parse_memory_regions(rproc);
if (ret)
goto free_resources;
}
rproc->has_iommu = false;
ddata->workqueue = create_workqueue(dev_name(dev));
if (!ddata->workqueue) {