public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Tanmay Shah <tanmay.shah@amd.com>
To: "Rob Herring (Arm)" <robh@kernel.org>,
	Saravana Kannan <saravanak@google.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Bjorn Andersson <andersson@kernel.org>,
	Mathieu Poirier <mathieu.poirier@linaro.org>,
	Shawn Guo <shawnguo@kernel.org>,
	Sascha Hauer <s.hauer@pengutronix.de>,
	Pengutronix Kernel Team <kernel@pengutronix.de>,
	Fabio Estevam <festevam@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>,
	Chen-Yu Tsai <wens@kernel.org>
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-remoteproc@vger.kernel.org, imx@lists.linux.dev,
	linux-arm-kernel@lists.infradead.org,
	linux-arm-msm@vger.kernel.org,
	linux-stm32@st-md-mailman.stormreply.com
Subject: Re: [PATCH v2 4/4] remoteproc: Use of_reserved_mem_region_* functions for "memory-region"
Date: Fri, 2 May 2025 10:40:36 -0500	[thread overview]
Message-ID: <938c4876-d284-4f11-a4ac-9f3831d3c14d@amd.com> (raw)
In-Reply-To: <20250423-dt-memory-region-v2-v2-4-2fbd6ebd3c88@kernel.org>


Hello Rob,

Thanks for the patch. Please find my comments below.


On 4/23/25 2:42 PM, 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.
> 
> The error handling is a bit different in some cases. Often
> "memory-region" is optional, so failed lookup is not an error. But then
> an error in of_reserved_mem_lookup() is treated as an error. However,
> that distinction is not really important. Either the region is available
> and usable or it is not. So now, it is just
> of_reserved_mem_region_to_resource() which is checked for an error.
> 
> Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
> ---
> v2:
>   - Use strstarts instead of strcmp for resource names as they include
>     the unit-address.
>   - Drop the unit-address from resource name for imx and st drivers
> ---
>   drivers/remoteproc/imx_dsp_rproc.c        | 45 ++++++++------------
>   drivers/remoteproc/imx_rproc.c            | 68 ++++++++++++------------------
>   drivers/remoteproc/qcom_q6v5_adsp.c       | 24 ++++-------
>   drivers/remoteproc/qcom_q6v5_mss.c        | 60 +++++++++------------------
>   drivers/remoteproc/qcom_q6v5_pas.c        | 69 +++++++++++--------------------
>   drivers/remoteproc/qcom_q6v5_wcss.c       | 25 +++++------
>   drivers/remoteproc/qcom_wcnss.c           | 23 ++++-------
>   drivers/remoteproc/rcar_rproc.c           | 36 +++++++---------
>   drivers/remoteproc/st_remoteproc.c        | 41 +++++++++---------
>   drivers/remoteproc/stm32_rproc.c          | 44 +++++++++-----------
>   drivers/remoteproc/ti_k3_dsp_remoteproc.c | 28 +++++--------
>   drivers/remoteproc/ti_k3_m4_remoteproc.c  | 28 +++++--------
>   drivers/remoteproc/ti_k3_r5_remoteproc.c  | 28 +++++--------
>   drivers/remoteproc/xlnx_r5_remoteproc.c   | 51 +++++++++--------------
>   14 files changed, 221 insertions(+), 349 deletions(-)
> 
> diff --git a/drivers/remoteproc/imx_dsp_rproc.c b/drivers/remoteproc/imx_dsp_rproc.c
> index 90cb1fc13e71..fffae6ff4a5c 100644

[ ... ]

> diff --git a/drivers/remoteproc/xlnx_r5_remoteproc.c b/drivers/remoteproc/xlnx_r5_remoteproc.c
> index 5aeedeaf3c41..b73e97074c01 100644
> --- a/drivers/remoteproc/xlnx_r5_remoteproc.c
> +++ b/drivers/remoteproc/xlnx_r5_remoteproc.c
> @@ -460,49 +460,44 @@ static int add_mem_regions_carveout(struct rproc *rproc)
>   {
>   	struct rproc_mem_entry *rproc_mem;
>   	struct zynqmp_r5_core *r5_core;
> -	struct of_phandle_iterator it;
> -	struct reserved_mem *rmem;
>   	int i = 0;
>   
>   	r5_core = rproc->priv;
>   
>   	/* Register associated reserved memory regions */
> -	of_phandle_iterator_init(&it, r5_core->np, "memory-region", NULL, 0);
> +	while (1) {
> +		int err;
> +		struct resource res;
>   
> -	while (of_phandle_iterator_next(&it) == 0) {
> -		rmem = of_reserved_mem_lookup(it.node);
> -		if (!rmem) {
> -			of_node_put(it.node);
> -			dev_err(&rproc->dev, "unable to acquire memory-region\n");
> -			return -EINVAL;
> -		}
> +		err = of_reserved_mem_region_to_resource(r5_core->np, i++, &res);

Here i++ is not needed as it's done at the end of the loop.
This bug breaks RPMsg communication on zynqmp platform.

Thanks,
Tanmay

> +		if (err)
> +			return 0;
>   
> -		if (!strcmp(it.node->name, "vdev0buffer")) {
> +		if (strstarts(res.name, "vdev0buffer")) {
>   			/* Init reserved memory for vdev buffer */
>   			rproc_mem = rproc_of_resm_mem_entry_init(&rproc->dev, i,
> -								 rmem->size,
> -								 rmem->base,
> -								 it.node->name);
> +								 resource_size(&res),
> +								 res.start,
> +								 "vdev0buffer");
>   		} else {
>   			/* Register associated reserved memory regions */
>   			rproc_mem = rproc_mem_entry_init(&rproc->dev, NULL,
> -							 (dma_addr_t)rmem->base,
> -							 rmem->size, rmem->base,
> +							 (dma_addr_t)res.start,
> +							 resource_size(&res), res.start,
>   							 zynqmp_r5_mem_region_map,
>   							 zynqmp_r5_mem_region_unmap,
> -							 it.node->name);
> +							 "%.*s",
> +							 strchrnul(res.name, '@') - res.name,
> +							 res.name);
>   		}
>   
> -		if (!rproc_mem) {
> -			of_node_put(it.node);
> +		if (!rproc_mem)
>   			return -ENOMEM;
> -		}
>   
>   		rproc_add_carveout(rproc, rproc_mem);
> -		rproc_coredump_add_segment(rproc, rmem->base, rmem->size);
> +		rproc_coredump_add_segment(rproc, res.start, resource_size(&res));
>   
> -		dev_dbg(&rproc->dev, "reserved mem carveout %s addr=%llx, size=0x%llx",
> -			it.node->name, rmem->base, rmem->size);
> +		dev_dbg(&rproc->dev, "reserved mem carveout %pR\n", &res);
>   		i++;
>   	}
>   
> @@ -776,7 +771,6 @@ static int zynqmp_r5_get_rsc_table_va(struct zynqmp_r5_core *r5_core)
>   	struct device *dev = r5_core->dev;
>   	struct rsc_tbl_data *rsc_data_va;
>   	struct resource res_mem;
> -	struct device_node *np;
>   	int ret;
>   
>   	/*
> @@ -786,14 +780,7 @@ static int zynqmp_r5_get_rsc_table_va(struct zynqmp_r5_core *r5_core)
>   	 * contains that data structure which holds resource table address, size
>   	 * and some magic number to validate correct resource table entry.
>   	 */
> -	np = of_parse_phandle(r5_core->np, "memory-region", 0);
> -	if (!np) {
> -		dev_err(dev, "failed to get memory region dev node\n");
> -		return -EINVAL;
> -	}
> -
> -	ret = of_address_to_resource(np, 0, &res_mem);
> -	of_node_put(np);
> +	ret = of_reserved_mem_region_to_resource(r5_core->np, 0, &res_mem);
>   	if (ret) {
>   		dev_err(dev, "failed to get memory-region resource addr\n");
>   		return -EINVAL;
> 


  reply	other threads:[~2025-05-02 15:40 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-23 19:42 [PATCH v2 0/4] of: Common "memory-region" parsing Rob Herring (Arm)
2025-04-23 19:42 ` [PATCH v2 1/4] of: reserved_mem: Add functions to parse "memory-region" Rob Herring (Arm)
2025-04-28  8:07   ` Arnaud POULIQUEN
2025-04-23 19:42 ` [PATCH v2 2/4] of: Simplify of_dma_set_restricted_buffer() to use of_for_each_phandle() Rob Herring (Arm)
2025-04-23 19:42 ` [PATCH v2 3/4] devres: Export devm_ioremap_resource_wc() Rob Herring (Arm)
2025-04-23 19:42 ` [PATCH v2 4/4] remoteproc: Use of_reserved_mem_region_* functions for "memory-region" Rob Herring (Arm)
2025-05-02 15:40   ` Tanmay Shah [this message]
2025-05-02 20:33     ` Rob Herring
2025-04-24 14:14 ` [PATCH v2 0/4] of: Common "memory-region" parsing Mathieu Poirier
2025-04-25 23:34   ` Iuliana Prodan
2025-04-28 12:23     ` Rob Herring
2025-04-28 21:40       ` Iuliana Prodan
2025-05-01 15:44   ` Tanmay Shah
2025-05-01 23:56     ` Tanmay Shah
2025-04-28  8:16 ` Arnaud POULIQUEN
2025-05-07  4:42 ` Peng Fan

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=938c4876-d284-4f11-a4ac-9f3831d3c14d@amd.com \
    --to=tanmay.shah@amd.com \
    --cc=akpm@linux-foundation.org \
    --cc=alexandre.torgue@foss.st.com \
    --cc=andersson@kernel.org \
    --cc=arnaud.pouliquen@foss.st.com \
    --cc=devicetree@vger.kernel.org \
    --cc=festevam@gmail.com \
    --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-stm32@st-md-mailman.stormreply.com \
    --cc=mathieu.poirier@linaro.org \
    --cc=mcoquelin.stm32@gmail.com \
    --cc=patrice.chotard@foss.st.com \
    --cc=robh@kernel.org \
    --cc=s.hauer@pengutronix.de \
    --cc=saravanak@google.com \
    --cc=shawnguo@kernel.org \
    --cc=wens@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