Commit 0f9dc562 authored by Mathieu Poirier's avatar Mathieu Poirier Committed by Bjorn Andersson
Browse files

remoteproc: Refactor function rproc_boot()



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: default avatarMathieu Poirier <mathieu.poirier@linaro.org>
Reviewed-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
Tested-by: default avatarArnaud Pouliquen <arnaud.pouliquen@st.com>
Link: https://lore.kernel.org/r/20200714195035.1426873-7-mathieu.poirier@linaro.org


Signed-off-by: default avatarBjorn Andersson <bjorn.andersson@linaro.org>
parent 88d3a136
Loading
Loading
Loading
Loading
+17 −11
Original line number Diff line number Diff line
@@ -1497,7 +1497,7 @@ disable_iommu:
 * 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;
@@ -1908,12 +1908,17 @@ 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;
	}

	if (rproc->state == RPROC_DETACHED) {
		dev_info(dev, "attaching to %s\n", rproc->name);

		ret = rproc_actuate(rproc);
	} else {
		dev_info(dev, "powering up %s\n", rproc->name);

		/* load firmware */
@@ -1926,6 +1931,7 @@ int rproc_boot(struct rproc *rproc)
		ret = rproc_fw_boot(rproc, firmware_p);

		release_firmware(firmware_p);
	}

downref_rproc:
	if (ret)