From: Mathieu Poirier Date: Tue, 14 Jul 2020 19:50:29 +0000 (-0600) Subject: remoteproc: Introducing function rproc_attach() X-Git-Tag: v5.15~3127^2~41 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=d848a4819d858973952de181314de6d05512fb98;p=platform%2Fkernel%2Flinux-starfive.git remoteproc: Introducing function rproc_attach() Introducing function rproc_attach() to enact the same actions as rproc_start(), but without the steps related to the handling of a firmware image. That way we can properly deal with scenarios where the remoteproc core needs to attach with a remote processsor that has been booted by another entity. Signed-off-by: Mathieu Poirier Reviewed-by: Bjorn Andersson Tested-by: Arnaud Pouliquen Link: https://lore.kernel.org/r/20200714195035.1426873-4-mathieu.poirier@linaro.org Signed-off-by: Bjorn Andersson --- diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index e00dff4..90842c5 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1372,6 +1372,48 @@ reset_table_ptr: return ret; } +static int __maybe_unused rproc_attach(struct rproc *rproc) +{ + struct device *dev = &rproc->dev; + int ret; + + ret = rproc_prepare_subdevices(rproc); + if (ret) { + dev_err(dev, "failed to prepare subdevices for %s: %d\n", + rproc->name, ret); + goto out; + } + + /* Attach to the remote processor */ + ret = rproc_attach_device(rproc); + if (ret) { + dev_err(dev, "can't attach to rproc %s: %d\n", + rproc->name, ret); + goto unprepare_subdevices; + } + + /* Start any subdevices for the remote processor */ + ret = rproc_start_subdevices(rproc); + if (ret) { + dev_err(dev, "failed to probe subdevices for %s: %d\n", + rproc->name, ret); + goto stop_rproc; + } + + rproc->state = RPROC_RUNNING; + + dev_info(dev, "remote processor %s is now attached\n", rproc->name); + + return 0; + +stop_rproc: + rproc->ops->stop(rproc); +unprepare_subdevices: + rproc_unprepare_subdevices(rproc); +out: + return ret; +} + /* * take a firmware and boot a remote processor with it. */