From: Paul Cercueil <paul@crapouillou.net>
To: Arnaud POULIQUEN <arnaud.pouliquen@st.com>
Cc: Ohad Ben-Cohen <ohad@wizery.com>,
Bjorn Andersson <bjorn.andersson@linaro.org>,
Rob Herring <robh+dt@kernel.org>,
Mark Rutland <mark.rutland@arm.com>,
od@zcrc.me, linux-remoteproc@vger.kernel.org,
devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v5 3/5] remoteproc: Add prepare/unprepare callbacks
Date: Mon, 24 Feb 2020 12:25:14 -0300 [thread overview]
Message-ID: <1582557914.3.1@crapouillou.net> (raw)
In-Reply-To: <daf58c35-c240-e50a-da50-48b14c0e097c@st.com>
Hi Arnaud,
Le mar., févr. 18, 2020 at 17:31, Arnaud POULIQUEN
<arnaud.pouliquen@st.com> a écrit :
> Hi Paul,
>
> I still wonder about the use of pm_runtime mechanism as a more
> generic alternative...
The use of pm_runtime is perfect if CONFIG_PM is enabled, but otherwise
it's a bit cumbersome, as the clocks must be enabled in the probe.
-Paul
> Else just a minor remark inline.
>
> On 2/11/20 3:26 PM, Paul Cercueil wrote:
>> The .prepare() callback is called before the firmware is loaded to
>> memory. This is useful for instance in the case where some setup is
>> required for the memory to be accessible.
>>
>> Signed-off-by: Paul Cercueil <paul@crapouillou.net>
>> ---
>>
>> Notes:
>> v2-v4: No change
>> v5: Move calls to prepare/unprepare to
>> rproc_fw_boot/rproc_shutdown
>>
>> drivers/remoteproc/remoteproc_core.c | 16 +++++++++++++++-
>> include/linux/remoteproc.h | 4 ++++
>> 2 files changed, 19 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/remoteproc/remoteproc_core.c
>> b/drivers/remoteproc/remoteproc_core.c
>> index fe5c7a2f9767..022b927e176b 100644
>> --- a/drivers/remoteproc/remoteproc_core.c
>> +++ b/drivers/remoteproc/remoteproc_core.c
>> @@ -1373,6 +1373,14 @@ static int rproc_fw_boot(struct rproc
>> *rproc, const struct firmware *fw)
>>
>> dev_info(dev, "Booting fw image %s, size %zd\n", name, fw->size);
>>
>> + if (rproc->ops->prepare) {
>> + ret = rproc->ops->prepare(rproc);
>> + if (ret) {
>> + dev_err(dev, "Failed to prepare rproc: %d\n", ret);
>> + return ret;
>> + }
>> + }
>> +
>> /*
>> * if enabling an IOMMU isn't relevant for this rproc, this is
>> * just a nop
>> @@ -1380,7 +1388,7 @@ static int rproc_fw_boot(struct rproc *rproc,
>> const struct firmware *fw)
>> ret = rproc_enable_iommu(rproc);
>> if (ret) {
>> dev_err(dev, "can't enable iommu: %d\n", ret);
>> - return ret;
>> + goto unprepare_rproc;
>> }
>>
>> rproc->bootaddr = rproc_get_boot_addr(rproc, fw);
>> @@ -1424,6 +1432,9 @@ static int rproc_fw_boot(struct rproc *rproc,
>> const struct firmware *fw)
>> rproc->table_ptr = NULL;
>> disable_iommu:
>> rproc_disable_iommu(rproc);
>> +unprepare_rproc:
>> + if (rproc->ops->unprepare)
>> + rproc->ops->unprepare(rproc);
>> return ret;
>> }
>>
>> @@ -1823,6 +1834,9 @@ void rproc_shutdown(struct rproc *rproc)
>>
>> rproc_disable_iommu(rproc);
>>
>> + if (rproc->ops->unprepare)
>> + rproc->ops->unprepare(rproc);
>> +
>> /* Free the copy of the resource table */
>> kfree(rproc->cached_table);
>> rproc->cached_table = NULL;
>> diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
>> index 5f201f0c86c3..a6272d1ba384 100644
>> --- a/include/linux/remoteproc.h
>> +++ b/include/linux/remoteproc.h
>> @@ -355,6 +355,8 @@ enum rsc_handling_status {
>>
>> /**
>> * struct rproc_ops - platform-specific device handlers
>> + * @prepare: prepare the device for power up (before the firmware
>> is loaded)
>> + * @unprepare: unprepare the device after it is stopped
>
> Would be nice here to precise that these functions are optional
> you can look at rproc_ops struct for example.
>
> Regards,
> Arnaud
>
>> * @start: power on the device and boot it
>> * @stop: power off the device
>> * @kick: kick a virtqueue (virtqueue id given as a parameter)
>> @@ -371,6 +373,8 @@ enum rsc_handling_status {
>> * @get_boot_addr: get boot address to entry point specified in
>> firmware
>> */
>> struct rproc_ops {
>> + int (*prepare)(struct rproc *rproc);
>> + void (*unprepare)(struct rproc *rproc);
>> int (*start)(struct rproc *rproc);
>> int (*stop)(struct rproc *rproc);
>> void (*kick)(struct rproc *rproc, int vqid);
>>
next prev parent reply other threads:[~2020-02-24 15:25 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-11 14:26 [PATCH v5 1/5] dt-bindings: Document JZ47xx VPU auxiliary processor Paul Cercueil
2020-02-11 14:26 ` [PATCH v5 2/5] remoteproc: Add device-managed variants of rproc_alloc/rproc_add Paul Cercueil
2020-02-11 14:26 ` [PATCH v5 3/5] remoteproc: Add prepare/unprepare callbacks Paul Cercueil
2020-02-18 16:31 ` Arnaud POULIQUEN
2020-02-18 16:31 ` Arnaud POULIQUEN
2020-02-24 15:25 ` Paul Cercueil [this message]
2020-02-11 14:26 ` [PATCH v5 4/5] remoteproc: ingenic: Added remoteproc driver Paul Cercueil
2020-02-11 14:26 ` [PATCH v5 5/5] MAINTAINERS: Add myself as reviewer for Ingenic rproc driver Paul Cercueil
2020-02-12 2:05 ` [PATCH v5 1/5] dt-bindings: Document JZ47xx VPU auxiliary processor Rob Herring
2020-02-12 2:07 ` Rob Herring
2020-02-12 2:07 ` Rob Herring
2020-02-12 2:08 ` Rob Herring
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=1582557914.3.1@crapouillou.net \
--to=paul@crapouillou.net \
--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=mark.rutland@arm.com \
--cc=od@zcrc.me \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.