diff mbox series

[1/1] remoteproc: mediatek: Support multiple reserved memory regions

Message ID 20240703115308.17436-2-shun-yi.wang@mediatek.com (mailing list archive)
State New
Headers show
Series Support multiple reserved memory regions | expand

Commit Message

Shun-Yi Wang (王順億) July 3, 2024, 11:53 a.m. UTC
From: "shun-yi.wang" <shun-yi.wang@mediatek.com>

SCP supports multiple reserved memory regions, intended for
specific hardwards.

Signed-off-by: shun-yi.wang <shun-yi.wang@mediatek.com>
---
 drivers/remoteproc/mtk_scp.c | 25 +++++++++++++++++--------
 1 file changed, 17 insertions(+), 8 deletions(-)

Comments

Mathieu Poirier July 10, 2024, 3:56 p.m. UTC | #1
On Wed, Jul 03, 2024 at 07:53:08PM +0800, Shun-yi Wang wrote:
> From: "shun-yi.wang" <shun-yi.wang@mediatek.com>
> 
> SCP supports multiple reserved memory regions, intended for
> specific hardwards.
>
> Signed-off-by: shun-yi.wang <shun-yi.wang@mediatek.com>
> ---
>  drivers/remoteproc/mtk_scp.c | 25 +++++++++++++++++--------
>  1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index 9ecd5ea04b5f3..1902826cea0af 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -1006,22 +1006,31 @@ EXPORT_SYMBOL_GPL(scp_mapping_dm_addr);
>  
>  static int scp_map_memory_region(struct mtk_scp *scp)
>  {
> -	int ret;
> +	int ret, i, err;
>  	const struct mtk_scp_sizes_data *scp_sizes;
> +	struct device_node *node = scp->dev->of_node;
> +	struct of_phandle_iterator it;
> +
> +	i = 0;
> +	of_for_each_phandle(&it, err, node, "memory-region", NULL, 0) {
> +		ret = of_reserved_mem_device_init_by_idx(scp->dev, node, i);
> +
> +		if (ret) {
> +			dev_err(scp->dev, "failed to assign memory-region: %s\n",
> +				it.node->name);
> +			of_node_put(it.node);
> +			return -ENOMEM;
> +		}

With this patch the code is out of sync with the bindings which are still
specifying a maxItems of 1 - please address.

Thanks,
Mathieu

>  
> -	ret = of_reserved_mem_device_init(scp->dev);
> +		i++;
> +	}
>  
>  	/* reserved memory is optional. */
> -	if (ret == -ENODEV) {
> +	if (!i) {
>  		dev_info(scp->dev, "skipping reserved memory initialization.");
>  		return 0;
>  	}
>  
> -	if (ret) {
> -		dev_err(scp->dev, "failed to assign memory-region: %d\n", ret);
> -		return -ENOMEM;
> -	}
> -
>  	/* Reserved SCP code size */
>  	scp_sizes = scp->data->scp_sizes;
>  	scp->cpu_addr = dma_alloc_coherent(scp->dev, scp_sizes->max_dram_size,
> -- 
> 2.18.0
>
AngeloGioacchino Del Regno July 12, 2024, 8:21 a.m. UTC | #2
Il 03/07/24 13:53, Shun-yi Wang ha scritto:
> From: "shun-yi.wang" <shun-yi.wang@mediatek.com>
> 
> SCP supports multiple reserved memory regions, intended for
> specific hardwards.
> 
> Signed-off-by: shun-yi.wang <shun-yi.wang@mediatek.com>
> ---
>   drivers/remoteproc/mtk_scp.c | 25 +++++++++++++++++--------
>   1 file changed, 17 insertions(+), 8 deletions(-)
> 
> diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
> index 9ecd5ea04b5f3..1902826cea0af 100644
> --- a/drivers/remoteproc/mtk_scp.c
> +++ b/drivers/remoteproc/mtk_scp.c
> @@ -1006,22 +1006,31 @@ EXPORT_SYMBOL_GPL(scp_mapping_dm_addr);
>   
>   static int scp_map_memory_region(struct mtk_scp *scp)
>   {
> -	int ret;
> +	int ret, i, err;
>   	const struct mtk_scp_sizes_data *scp_sizes;
> +	struct device_node *node = scp->dev->of_node;
> +	struct of_phandle_iterator it;


	struct device_node *node = scp->dev->of_node;
  	const struct mtk_scp_sizes_data *scp_sizes;
	struct of_phandle_iterator it;
	int i = 0;
	int ret;

	of_for_each_phandle(&it, ret, node, "memory-region", NULL, 0) {
		ret = ...
		if (ret) .....
		i++;
	}

> +
> +	i = 0;
> +	of_for_each_phandle(&it, err, node, "memory-region", NULL, 0) {
> +		ret = of_reserved_mem_device_init_by_idx(scp->dev, node, i);
> +
> +		if (ret) {
> +			dev_err(scp->dev, "failed to assign memory-region: %s\n",
> +				it.node->name);
> +			of_node_put(it.node);
> +			return -ENOMEM;
> +		}
>   
> -	ret = of_reserved_mem_device_init(scp->dev);
> +		i++;
> +	}
>   
>   	/* reserved memory is optional. */
> -	if (ret == -ENODEV) {
> +	if (!i) {

	if (i == 0) {
		dev_dbg(scp->dev, "skipping reserved memory initialization\n");
		return 0;
	}


Regards,
Angelo
diff mbox series

Patch

diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c
index 9ecd5ea04b5f3..1902826cea0af 100644
--- a/drivers/remoteproc/mtk_scp.c
+++ b/drivers/remoteproc/mtk_scp.c
@@ -1006,22 +1006,31 @@  EXPORT_SYMBOL_GPL(scp_mapping_dm_addr);
 
 static int scp_map_memory_region(struct mtk_scp *scp)
 {
-	int ret;
+	int ret, i, err;
 	const struct mtk_scp_sizes_data *scp_sizes;
+	struct device_node *node = scp->dev->of_node;
+	struct of_phandle_iterator it;
+
+	i = 0;
+	of_for_each_phandle(&it, err, node, "memory-region", NULL, 0) {
+		ret = of_reserved_mem_device_init_by_idx(scp->dev, node, i);
+
+		if (ret) {
+			dev_err(scp->dev, "failed to assign memory-region: %s\n",
+				it.node->name);
+			of_node_put(it.node);
+			return -ENOMEM;
+		}
 
-	ret = of_reserved_mem_device_init(scp->dev);
+		i++;
+	}
 
 	/* reserved memory is optional. */
-	if (ret == -ENODEV) {
+	if (!i) {
 		dev_info(scp->dev, "skipping reserved memory initialization.");
 		return 0;
 	}
 
-	if (ret) {
-		dev_err(scp->dev, "failed to assign memory-region: %d\n", ret);
-		return -ENOMEM;
-	}
-
 	/* Reserved SCP code size */
 	scp_sizes = scp->data->scp_sizes;
 	scp->cpu_addr = dma_alloc_coherent(scp->dev, scp_sizes->max_dram_size,