From: Mathieu Poirier <mathieu.poirier@linaro.org>
To: Arnaud POULIQUEN <arnaud.pouliquen@st.com>
Cc: "ohad@wizery.com" <ohad@wizery.com>,
"bjorn.andersson@linaro.org" <bjorn.andersson@linaro.org>,
"robh+dt@kernel.org" <robh+dt@kernel.org>,
"linux-remoteproc@vger.kernel.org"
<linux-remoteproc@vger.kernel.org>,
"devicetree@vger.kernel.org" <devicetree@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH v4 12/17] remoteproc: Introduce function rproc_detach()
Date: Fri, 29 Jan 2021 15:31:35 -0700 [thread overview]
Message-ID: <20210129223135.GC1319650@xps15> (raw)
In-Reply-To: <406cd7ad-060e-a611-be20-5c1869f17e73@st.com>
On Wed, Jan 27, 2021 at 09:50:31AM +0100, Arnaud POULIQUEN wrote:
>
>
> On 12/18/20 6:32 PM, Mathieu Poirier wrote:
> > Introduce function rproc_detach() to enable the remoteproc
> > core to release the resources associated with a remote processor
> > without stopping its operation.
> >
> > Signed-off-by: Mathieu Poirier <mathieu.poirier@linaro.org>
> > Reviewed-by: Peng Fan <peng.fan@nxp.com>
> > ---
> > drivers/remoteproc/remoteproc_core.c | 71 +++++++++++++++++++++++++++-
> > include/linux/remoteproc.h | 2 +
> > 2 files changed, 72 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
> > index e665ed4776c3..ece3f15070b9 100644
> > --- a/drivers/remoteproc/remoteproc_core.c
> > +++ b/drivers/remoteproc/remoteproc_core.c
> > @@ -1673,7 +1673,7 @@ static int rproc_stop(struct rproc *rproc, bool crashed)
> > /*
> > * __rproc_detach(): Does the opposite of rproc_attach()
> > */
> > -static int __maybe_unused __rproc_detach(struct rproc *rproc)
> > +static int __rproc_detach(struct rproc *rproc)
> > {
> > struct device *dev = &rproc->dev;
> > int ret;
> > @@ -1927,6 +1927,75 @@ void rproc_shutdown(struct rproc *rproc)
> > }
> > EXPORT_SYMBOL(rproc_shutdown);
> >
> > +/**
> > + * rproc_detach() - Detach the remote processor from the
> > + * remoteproc core
> > + *
> > + * @rproc: the remote processor
> > + *
> > + * Detach a remote processor (previously attached to with rproc_actuate()).
>
> You rename the function to rproc_attach in you patch 04/17.
>
Yes, good catch.
> Then Reviewed-by: Arnaud Pouliquen <arnaud.pouliquen@st.com>
>
> Thanks,
> Arnaud
>
> > + *
> > + * In case @rproc is still being used by an additional user(s), then
> > + * this function will just decrement the power refcount and exit,
> > + * without disconnecting the device.
> > + *
> > + * Function rproc_detach() calls __rproc_detach() in order to let a remote
> > + * processor know that services provided by the application processor are
> > + * no longer available. From there it should be possible to remove the
> > + * platform driver and even power cycle the application processor (if the HW
> > + * supports it) without needing to switch off the remote processor.
> > + */
> > +int rproc_detach(struct rproc *rproc)
> > +{
> > + struct device *dev = &rproc->dev;
> > + int ret;
> > +
> > + ret = mutex_lock_interruptible(&rproc->lock);
> > + if (ret) {
> > + dev_err(dev, "can't lock rproc %s: %d\n", rproc->name, ret);
> > + return ret;
> > + }
> > +
> > + if (rproc->state != RPROC_RUNNING && rproc->state != RPROC_ATTACHED) {
> > + ret = -EPERM;
> > + goto out;
> > + }
> > +
> > + /* if the remote proc is still needed, bail out */
> > + if (!atomic_dec_and_test(&rproc->power)) {
> > + ret = -EBUSY;
> > + goto out;
> > + }
> > +
> > + ret = __rproc_detach(rproc);
> > + if (ret) {
> > + atomic_inc(&rproc->power);
> > + goto out;
> > + }
> > +
> > + /* clean up all acquired resources */
> > + rproc_resource_cleanup(rproc);
> > +
> > + rproc_disable_iommu(rproc);
> > +
> > + /*
> > + * If the remote processor was booted by the core the cached table needs
> > + * to be freed and ->table_ptr set to NULL because it will be
> > + * invalidated by rproc_resource_cleanup(). If the remote processor was
> > + * attached to ->cached_table is NULL and kfree() returns right away.
> > + *
> > + * In either case ->table_ptr has to be set to NULL. It will be set
> > + * again when the remote processor is re-attached to.
> > + */
> > + kfree(rproc->cached_table);
> > + rproc->cached_table = NULL;
> > + rproc->table_ptr = NULL;
> > +out:
> > + mutex_unlock(&rproc->lock);
> > + return ret;
> > +}
> > +EXPORT_SYMBOL(rproc_detach);
> > +
> > /**
> > * rproc_get_by_phandle() - find a remote processor by phandle
> > * @phandle: phandle to the rproc
> > diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
> > index 9bb34c3eb847..65ece6f177b7 100644
> > --- a/include/linux/remoteproc.h
> > +++ b/include/linux/remoteproc.h
> > @@ -659,6 +659,8 @@ rproc_of_resm_mem_entry_init(struct device *dev, u32 of_resm_idx, size_t len,
> >
> > int rproc_boot(struct rproc *rproc);
> > void rproc_shutdown(struct rproc *rproc);
> > +int rproc_detach(struct rproc *rproc);
> > +int rproc_set_firmware(struct rproc *rproc, const char *fw_name);
> > void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);
> > int rproc_coredump_add_segment(struct rproc *rproc, dma_addr_t da, size_t size);
> > int rproc_coredump_add_custom_segment(struct rproc *rproc,
> >
next prev parent reply other threads:[~2021-01-29 22:32 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-18 17:32 [PATCH v4 00/17] remoteproc: Add support for detaching a rproc Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 01/17] dt-bindings: remoteproc: Add bindind to support autonomous processors Mathieu Poirier
2021-01-20 15:53 ` Rob Herring
2020-12-18 17:32 ` [PATCH v4 02/17] remoteproc: Re-check state in rproc_shutdown() Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 03/17] remoteproc: Remove useless check in rproc_del() Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 04/17] remoteproc: Rename function rproc_actuate() Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 05/17] remoteproc: Add new get_loaded_rsc_table() remoteproc operation Mathieu Poirier
2021-01-27 8:44 ` Arnaud POULIQUEN
2021-01-29 21:37 ` Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 06/17] remoteproc: stm32: Move resource table setup to rproc_ops Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 07/17] remoteproc: Add new RPROC_ATTACHED state Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 08/17] remoteproc: Properly represent the attached state Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 09/17] remoteproc: Properly deal with a kernel panic when attached Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 10/17] remoteproc: Add new detach() remoteproc operation Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 11/17] remoteproc: Introduce function __rproc_detach() Mathieu Poirier
2021-01-27 8:46 ` Arnaud POULIQUEN
2021-01-29 22:17 ` Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 12/17] remoteproc: Introduce function rproc_detach() Mathieu Poirier
2021-01-27 8:50 ` Arnaud POULIQUEN
2021-01-29 22:31 ` Mathieu Poirier [this message]
2020-12-18 17:32 ` [PATCH v4 13/17] remoteproc: Add return value to function rproc_shutdown() Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 14/17] remoteproc: Properly deal with a stop request when attached Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 15/17] remoteproc: Properly deal with a start " Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 16/17] remoteproc: Properly deal with detach request Mathieu Poirier
2020-12-18 17:32 ` [PATCH v4 17/17] remoteproc: Refactor rproc delete and cdev release path Mathieu Poirier
2021-01-27 8:56 ` Arnaud POULIQUEN
2021-01-27 9:21 ` [PATCH v4 00/17] remoteproc: Add support for detaching a rproc Arnaud POULIQUEN
2021-02-02 0:49 ` Mathieu Poirier
2021-02-02 8:54 ` Arnaud POULIQUEN
2021-02-02 22:42 ` Mathieu Poirier
2021-02-03 7:58 ` Arnaud POULIQUEN
2021-02-08 23:43 ` Mathieu Poirier
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=20210129223135.GC1319650@xps15 \
--to=mathieu.poirier@linaro.org \
--cc=arnaud.pouliquen@st.com \
--cc=bjorn.andersson@linaro.org \
--cc=devicetree@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=ohad@wizery.com \
--cc=robh+dt@kernel.org \
/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).