From: Mathieu Poirier <mathieu.poirier@linaro.org> To: Peng Fan <peng.fan@nxp.com> Cc: "bjorn.andersson@linaro.org" <bjorn.andersson@linaro.org>, "ohad@wizery.com" <ohad@wizery.com>, "linux-remoteproc@vger.kernel.org" <linux-remoteproc@vger.kernel.org>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org> Subject: Re: [PATCH 07/13] remoteproc: Introduce function rproc_detach() Date: Thu, 22 Oct 2020 15:55:42 -0600 Message-ID: <20201022215542.GB729430@xps15> (raw) In-Reply-To: <DB6PR0402MB2760F33EF3C3BF69D737899688020@DB6PR0402MB2760.eurprd04.prod.outlook.com> On Thu, Oct 15, 2020 at 01:52:16AM +0000, Peng Fan wrote: > > Subject: [PATCH 07/13] remoteproc: Introduce function rproc_detach() > > > > 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> > > --- > > drivers/remoteproc/remoteproc_core.c | 65 > > +++++++++++++++++++++++++++- > > include/linux/remoteproc.h | 1 + > > 2 files changed, 65 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/remoteproc/remoteproc_core.c > > b/drivers/remoteproc/remoteproc_core.c > > index 7a1fc7e0620f..f3943a1e2754 100644 > > --- a/drivers/remoteproc/remoteproc_core.c > > +++ b/drivers/remoteproc/remoteproc_core.c > > @@ -1644,7 +1644,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; > > @@ -1887,6 +1887,69 @@ 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()). > > + * > > + * 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); > > + > > + /* > > + * Set the remote processor's table pointer to NULL. Since mapping > > + * of the resource table to a virtual address is done in the platform > > + * driver, unmapping should also be done there. > > + */ > > + 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 > > 1a57e165da2c..6250491ee851 100644 > > --- a/include/linux/remoteproc.h > > +++ b/include/linux/remoteproc.h > > @@ -656,6 +656,7 @@ 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); > > 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, > > -- > > > Reviewed-by: Peng Fan <peng.fan@nxp.com> > > Not relevant to your patch, just see unregister_virtio_device not set device > status when reading code, should that add device status setting in > unregister_virtio_device? I must admit that I don't understand the question - would you mind rephrasing or expanding? Thanks, Mathieu > >
next prev parent reply index Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-08-26 16:45 [PATCH 00/13] remoteproc: Add support for detaching from rproc Mathieu Poirier 2020-08-26 16:45 ` [PATCH 01/13] remoteproc: Re-check state in rproc_shutdown() Mathieu Poirier 2020-10-15 1:28 ` Peng Fan 2020-08-26 16:45 ` [PATCH 02/13] remoteproc: Remove useless check in rproc_del() Mathieu Poirier 2020-10-15 1:29 ` Peng Fan 2020-08-26 16:45 ` [PATCH 03/13] remoteproc: Add new RPROC_ATTACHED state Mathieu Poirier 2020-10-15 1:31 ` Peng Fan 2020-08-26 16:45 ` [PATCH 04/13] remoteproc: Properly represent the attached state Mathieu Poirier 2020-10-15 1:33 ` Peng Fan 2020-08-26 16:45 ` [PATCH 05/13] remoteproc: Add new detach() remoteproc operation Mathieu Poirier 2020-10-15 1:37 ` Peng Fan 2020-10-22 21:51 ` Mathieu Poirier 2020-08-26 16:45 ` [PATCH 06/13] remoteproc: Introduce function __rproc_detach() Mathieu Poirier 2020-10-15 1:39 ` Peng Fan 2020-08-26 16:45 ` [PATCH 07/13] remoteproc: Introduce function rproc_detach() Mathieu Poirier 2020-10-15 1:52 ` Peng Fan 2020-10-22 21:55 ` Mathieu Poirier [this message] 2020-08-26 16:45 ` [PATCH 08/13] remoteproc: Rename function rproc_actuate() Mathieu Poirier 2020-10-15 2:15 ` Peng Fan 2020-08-26 16:45 ` [PATCH 09/13] remoteproc: Add return value to function rproc_shutdown() Mathieu Poirier 2020-10-15 2:21 ` Peng Fan 2020-08-26 16:45 ` [PATCH 10/13] remoteproc: Properly deal with a stop request when attached Mathieu Poirier 2020-10-15 2:29 ` Peng Fan 2020-08-26 16:45 ` [PATCH 11/13] remoteproc: Properly deal with detach request Mathieu Poirier 2020-10-15 2:30 ` Peng Fan 2020-08-26 16:45 ` [PATCH 12/13] remoteproc: Refactor rproc delete and cdev release path Mathieu Poirier 2020-10-15 2:31 ` Peng Fan 2020-08-26 16:45 ` [PATCH 13/13] remoteproc: Properly deal with a kernel panic when attached Mathieu Poirier 2020-10-15 2:28 ` Peng Fan 2020-09-01 16:55 ` [PATCH 00/13] remoteproc: Add support for detaching from rproc Arnaud POULIQUEN 2020-09-01 18:02 ` 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=20201022215542.GB729430@xps15 \ --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 \ --cc=peng.fan@nxp.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
Linux-remoteproc Archive on lore.kernel.org Archives are clonable: git clone --mirror https://lore.kernel.org/linux-remoteproc/0 linux-remoteproc/git/0.git # If you have public-inbox 1.1+ installed, you may # initialize and index your mirror using the following commands: public-inbox-init -V2 linux-remoteproc linux-remoteproc/ https://lore.kernel.org/linux-remoteproc \ linux-remoteproc@vger.kernel.org public-inbox-index linux-remoteproc Example config snippet for mirrors Newsgroup available over NNTP: nntp://nntp.lore.kernel.org/org.kernel.vger.linux-remoteproc AGPL code for this site: git clone https://public-inbox.org/public-inbox.git