linux-remoteproc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: ohad@wizery.com, bjorn.andersson@linaro.org
Cc: linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: [PATCH v6 6/9] remoteproc: Refactor function rproc_boot()
Date: Tue, 14 Jul 2020 13:50:32 -0600	[thread overview]
Message-ID: <20200714195035.1426873-7-mathieu.poirier@linaro.org> (raw)
In-Reply-To: <20200714195035.1426873-1-mathieu.poirier@linaro.org>

Refactor function rproc_boot() to properly deal with scenarios
where the remoteproc core needs to attach with a remote
processor that has already been booted by an external entity.

Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: Bjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
---
 drivers/remoteproc/remoteproc_core.c | 28 +++++++++++++++++-----------
 1 file changed, 17 insertions(+), 11 deletions(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index ad500c291d5f..caea920ce4b8 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -1494,7 +1494,7 @@ static int rproc_fw_boot(struct rproc *rproc, const struct firmware *fw)
  * Attach to remote processor - similar to rproc_fw_boot() but without
  * the steps that deal with the firmware image.
  */
-static int __maybe_unused rproc_actuate(struct rproc *rproc)
+static int rproc_actuate(struct rproc *rproc)
 {
 	struct device *dev = &rproc->dev;
 	int ret;
@@ -1905,24 +1905,30 @@ int rproc_boot(struct rproc *rproc)
 		goto unlock_mutex;
 	}
 
-	/* skip the boot process if rproc is already powered up */
+	/* skip the boot or attach process if rproc is already powered up */
 	if (atomic_inc_return(&rproc->power) > 1) {
 		ret = 0;
 		goto unlock_mutex;
 	}
 
-	dev_info(dev, "powering up %s\n", rproc->name);
+	if (rproc->state == RPROC_DETACHED) {
+		dev_info(dev, "attaching to %s\n", 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;
-	}
+		ret = rproc_actuate(rproc);
+	} else {
+		dev_info(dev, "powering up %s\n", rproc->name);
 
-	ret = rproc_fw_boot(rproc, firmware_p);
+		/* 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;
+		}
 
-	release_firmware(firmware_p);
+		ret = rproc_fw_boot(rproc, firmware_p);
+
+		release_firmware(firmware_p);
+	}
 
 downref_rproc:
 	if (ret)
-- 
2.25.1


  parent reply	other threads:[~2020-07-14 19:51 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-07-14 19:50 [PATCH v6 0/9] remoteproc: Add support for attaching with rproc Mathieu Poirier
2020-07-14 19:50 ` [PATCH v6 1/9] remoteproc: Add new RPROC_DETACHED state Mathieu Poirier
2020-07-14 19:50 ` [PATCH v6 2/9] remoteproc: Add new attach() remoteproc operation Mathieu Poirier
2020-07-14 19:50 ` [PATCH v6 3/9] remoteproc: Introducing function rproc_attach() Mathieu Poirier
2020-07-14 19:50 ` [PATCH v6 4/9] remoteproc: Introducing function rproc_actuate() Mathieu Poirier
2020-07-14 19:50 ` [PATCH v6 5/9] remoteproc: Introducing function rproc_validate() Mathieu Poirier
2020-07-14 19:50 ` Mathieu Poirier [this message]
2020-07-14 19:50 ` [PATCH v6 7/9] remoteproc: Refactor function rproc_trigger_auto_boot() Mathieu Poirier
2020-07-14 19:50 ` [PATCH v6 8/9] remoteproc: Refactor function rproc_free_vring() Mathieu Poirier
2020-07-14 19:50 ` [PATCH v6 9/9] remoteproc: Properly handle firmware name when attaching Mathieu Poirier
2020-07-17  5:55   ` Bjorn Andersson
2020-07-18  0:20 ` [PATCH v6 0/9] remoteproc: Add support for attaching with rproc patchwork-bot+linux-remoteproc
2020-07-24  7:29 ` Peng Fan

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200714195035.1426873-7-mathieu.poirier@linaro.org \
    --to=mathieu.poirier@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=ohad@wizery.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).