From: Rob Herring <robh@kernel.org>
To: Mathieu Poirier <mathieu.poirier@linaro.org>
Cc: Bjorn Andersson <andersson@kernel.org>,
Shawn Guo <shawnguo@kernel.org>,
Sascha Hauer <s.hauer@pengutronix.de>,
Pengutronix Kernel Team <kernel@pengutronix.de>,
Fabio Estevam <festevam@gmail.com>,
Geert Uytterhoeven <geert+renesas@glider.be>,
Magnus Damm <magnus.damm@gmail.com>,
Patrice Chotard <patrice.chotard@foss.st.com>,
Maxime Coquelin <mcoquelin.stm32@gmail.com>,
Alexandre Torgue <alexandre.torgue@foss.st.com>,
Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>,
Peng Fan <peng.fan@nxp.com>,
linux-remoteproc@vger.kernel.org, imx@lists.linux.dev,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org,
linux-renesas-soc@vger.kernel.org,
linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v6] remoteproc: Use of_reserved_mem_region_* functions for "memory-region"
Date: Wed, 12 Nov 2025 10:59:42 -0600 [thread overview]
Message-ID: <CAL_JsqL7HcDkPgJjcqJSagdN=gH2rv6noVS57QMGNRp0YCxUBw@mail.gmail.com> (raw)
In-Reply-To: <CANLsYkwcbrTaKASdr5fj0m9ARS4xUgzVH8iWQKwTCvEsoZDDsQ@mail.gmail.com>
On Wed, Nov 12, 2025 at 9:43 AM Mathieu Poirier
<mathieu.poirier@linaro.org> wrote:
>
> On Tue, 11 Nov 2025 at 12:59, Rob Herring <robh@kernel.org> wrote:
> >
> > On Tue, Nov 11, 2025 at 10:38:05AM -0700, Mathieu Poirier wrote:
> > > Hi Rob,
> > >
> > > Please see may comment for st_remoteproc.c
> > >
> > > On Fri, Oct 31, 2025 at 12:59:22PM -0500, Rob Herring (Arm) wrote:
> > > > Use the newly added of_reserved_mem_region_to_resource() and
> > > > of_reserved_mem_region_count() functions to handle "memory-region"
> > > > properties.
[...]
> > > > diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c
> > > > index e6566a9839dc..043348366926 100644
> > > > --- a/drivers/remoteproc/st_remoteproc.c
> > > > +++ b/drivers/remoteproc/st_remoteproc.c
> > > > @@ -120,40 +120,37 @@ static int st_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
> > > > struct device *dev = rproc->dev.parent;
> > > > struct device_node *np = dev->of_node;
> > > > struct rproc_mem_entry *mem;
> > > > - struct reserved_mem *rmem;
> > > > - struct of_phandle_iterator it;
> > > > - int index = 0;
> > > > -
> > > > - of_phandle_iterator_init(&it, np, "memory-region", NULL, 0);
> > > > - while (of_phandle_iterator_next(&it) == 0) {
> > > > - rmem = of_reserved_mem_lookup(it.node);
> > > > - if (!rmem) {
> > > > - of_node_put(it.node);
> > > > - dev_err(dev, "unable to acquire memory-region\n");
> > > > - return -EINVAL;
> > > > - }
> > > > + int index = 0, mr = 0;
> > > > +
> > > > + while (1) {
> > > > + struct resource res;
> > > > + int ret;
> > > > +
> > > > + ret = of_reserved_mem_region_to_resource(np, mr++, &res);
> > > > + if (ret)
> > > > + return 0;
> > >
> > > The original code calls rproc_elf_load_rsc_table() [1] after iterating through
> > > the memory region, something that won't happen with the above.
> >
> > Indeed. it needs the following incremental change. It is slightly
> > different in that rproc_elf_load_rsc_table() is not called if
> > 'memory-region' is missing, but the binding says that's required.
> >
> > 8<--------------------------------------------------
> >
> > diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c
> > index 043348366926..cb09c244fdb5 100644
> > --- a/drivers/remoteproc/st_remoteproc.c
> > +++ b/drivers/remoteproc/st_remoteproc.c
> > @@ -120,15 +120,19 @@ static int st_rproc_parse_fw(struct rproc *rproc, const struct firmware *fw)
> > struct device *dev = rproc->dev.parent;
> > struct device_node *np = dev->of_node;
> > struct rproc_mem_entry *mem;
> > - int index = 0, mr = 0;
> > + int index = 0;
> >
> > while (1) {
> > struct resource res;
> > int ret;
> >
> > - ret = of_reserved_mem_region_to_resource(np, mr++, &res);
> > - if (ret)
> > - return 0;
> > + ret = of_reserved_mem_region_to_resource(np, index, &res);
> > + if (ret) {
> > + if (index)
> > + break;
> > + else
> > + return ret;
> > + }
>
> This looks brittle and I'm not sure it would work.
>
> Going back to the original implementation, the only time we want to
> "break" is when @index is equal to the amount of memory regions _and_
> ret is -EINVAL. Any other condition should return.
@index equal to number of entries returns -ENODEV, so that condition
is impossible. We can simply it to this:
if (ret == -ENODEV && index)
break;
else
return ret;
If you want to keep the prior behavior when 'memory-region' is
missing, then '&& index' can be removed, but I think that was wrong
behavior.
Rob
next prev parent reply other threads:[~2025-11-12 17:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-31 17:59 [PATCH v6] remoteproc: Use of_reserved_mem_region_* functions for "memory-region" Rob Herring (Arm)
2025-11-11 17:38 ` Mathieu Poirier
2025-11-11 19:59 ` Rob Herring
2025-11-12 15:43 ` Mathieu Poirier
2025-11-12 16:59 ` Rob Herring [this message]
2025-11-13 15:32 ` Mathieu Poirier
2025-11-19 8:02 ` Beleswar Prasad Padhi
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='CAL_JsqL7HcDkPgJjcqJSagdN=gH2rv6noVS57QMGNRp0YCxUBw@mail.gmail.com' \
--to=robh@kernel.org \
--cc=alexandre.torgue@foss.st.com \
--cc=andersson@kernel.org \
--cc=arnaud.pouliquen@foss.st.com \
--cc=festevam@gmail.com \
--cc=geert+renesas@glider.be \
--cc=imx@lists.linux.dev \
--cc=kernel@pengutronix.de \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-remoteproc@vger.kernel.org \
--cc=linux-renesas-soc@vger.kernel.org \
--cc=linux-stm32@st-md-mailman.stormreply.com \
--cc=magnus.damm@gmail.com \
--cc=mathieu.poirier@linaro.org \
--cc=mcoquelin.stm32@gmail.com \
--cc=patrice.chotard@foss.st.com \
--cc=peng.fan@nxp.com \
--cc=s.hauer@pengutronix.de \
--cc=shawnguo@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).