Refactoring function rproc_boot() in order to properly handle cases where the core needs to synchronise with a remote processor rather than booting it. Signed-off-by: Mathieu Poirier <mathieu.poirier@xxxxxxxxxx> --- drivers/remoteproc/remoteproc_core.c | 25 ++++++++++++++++-------- drivers/remoteproc/remoteproc_internal.h | 5 +++++ 2 files changed, 22 insertions(+), 8 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 1b4756909584..a02593b75bec 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1762,7 +1762,9 @@ static void rproc_crash_handler_work(struct work_struct *work) * rproc_boot() - boot a remote processor * @rproc: handle of a remote processor * - * Boot a remote processor (i.e. load its firmware, power it on, ...). + * Boot or synchronise with a remote processor. In the former case the + * firmware is loaded and the remote processor powered on, in the latter + * those steps are simply skipped. * * If the remote processor is already powered on, this function immediately * returns (successfully). @@ -1771,8 +1773,9 @@ static void rproc_crash_handler_work(struct work_struct *work) */ int rproc_boot(struct rproc *rproc) { - const struct firmware *firmware_p; + const struct firmware *firmware_p = NULL; struct device *dev; + bool syncing; int ret; if (!rproc) { @@ -1788,6 +1791,8 @@ int rproc_boot(struct rproc *rproc) return ret; } + syncing = rproc_needs_syncing(rproc); + if (rproc->state == RPROC_DELETED) { ret = -ENODEV; dev_err(dev, "can't boot deleted rproc %s\n", rproc->name); @@ -1800,13 +1805,17 @@ int rproc_boot(struct rproc *rproc) goto unlock_mutex; } - dev_info(dev, "powering up %s\n", rproc->name); + dev_info(dev, "%s %s\n", + !syncing ? "powering up" : "syncing with", rproc->name); - /* load firmware */ - ret = request_firmware(&firmware_p, rproc->firmware, dev); - if (ret < 0) { - dev_err(dev, "request_firmware failed: %d\n", ret); - goto downref_rproc; + + /* load firmware if not syncing with remote processor */ + if (!syncing) { + ret = request_firmware(&firmware_p, rproc->firmware, dev); + if (ret < 0) { + dev_err(dev, "request_firmware failed: %d\n", ret); + goto downref_rproc; + } } ret = rproc_fw_boot(rproc, firmware_p); diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h index 59fc871743c7..47b500e40dd9 100644 --- a/drivers/remoteproc/remoteproc_internal.h +++ b/drivers/remoteproc/remoteproc_internal.h @@ -64,6 +64,11 @@ struct resource_table *rproc_elf_find_loaded_rsc_table(struct rproc *rproc, struct rproc_mem_entry * rproc_find_carveout_by_name(struct rproc *rproc, const char *name, ...); +static inline bool rproc_needs_syncing(struct rproc *rproc) +{ + return rproc->sync_with_rproc; +} + static inline int rproc_fw_sanity_check(struct rproc *rproc, const struct firmware *fw) { -- 2.20.1