Skip to content

Commit 6070203

Browse files
mathieupoirierandersson
authored andcommitted
remoteproc: Introduce function __rproc_detach()
Introduce function __rproc_detach() to perform the same kind of operation as rproc_stop(), but instead of switching off the remote processor using rproc->ops->stop(), it uses rproc->ops->detach(). That way it is possible for the core to release the resources associated with a remote processor while the latter is kept operating. Signed-off-by: Mathieu Poirier <[email protected]> Reviewed-by: Peng Fan <[email protected]> Reviewed-by: Arnaud Pouliquen <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Bjorn Andersson <[email protected]>
1 parent 7f3bd0c commit 6070203

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

drivers/remoteproc/remoteproc_core.c

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1712,6 +1712,36 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
17121712
return 0;
17131713
}
17141714

1715+
/*
1716+
* __rproc_detach(): Does the opposite of __rproc_attach()
1717+
*/
1718+
static int __maybe_unused __rproc_detach(struct rproc *rproc)
1719+
{
1720+
struct device *dev = &rproc->dev;
1721+
int ret;
1722+
1723+
/* No need to continue if a detach() operation has not been provided */
1724+
if (!rproc->ops->detach)
1725+
return -EINVAL;
1726+
1727+
/* Stop any subdevices for the remote processor */
1728+
rproc_stop_subdevices(rproc, false);
1729+
1730+
/* Tell the remote processor the core isn't available anymore */
1731+
ret = rproc->ops->detach(rproc);
1732+
if (ret) {
1733+
dev_err(dev, "can't detach from rproc: %d\n", ret);
1734+
return ret;
1735+
}
1736+
1737+
rproc_unprepare_subdevices(rproc);
1738+
1739+
rproc->state = RPROC_DETACHED;
1740+
1741+
dev_info(dev, "detached remote processor %s\n", rproc->name);
1742+
1743+
return 0;
1744+
}
17151745

17161746
/**
17171747
* rproc_trigger_recovery() - recover a remoteproc

0 commit comments

Comments
 (0)