RE: [PATCH 03/11] remoteproc: stm32: Decouple rproc from DT parsing

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




> -----Original Message-----
> From: Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>
> Sent: mardi 24 mars 2020 23:03
> To: bjorn.andersson@xxxxxxxxxx
> Cc: ohad@xxxxxxxxxx; Loic PALLARDY <loic.pallardy@xxxxxx>; s-
> anna@xxxxxx; peng.fan@xxxxxxx; Arnaud POULIQUEN
> <arnaud.pouliquen@xxxxxx>; Fabien DESSENNE
> <fabien.dessenne@xxxxxx>; linux-remoteproc@xxxxxxxxxxxxxxx
> Subject: [PATCH 03/11] remoteproc: stm32: Decouple rproc from DT parsing
> 
> Remove the remote processor from the process of parsing the device tree
> since (1) there is no correlation between them and (2) to use the
> information that was gathered to make a decision on whether to
> synchronise with the MCU or not.
> 
> Signed-off-by: Mathieu Poirier <mathieu.poirier@xxxxxxxxxx>
Thanks Mathieu
 
Reviewed-by: Loic Pallardy <loic.pallardy@xxxxxx>  

> ---
>  drivers/remoteproc/stm32_rproc.c | 38 +++++++++++++++++++++-----------
>  1 file changed, 25 insertions(+), 13 deletions(-)
> 
> diff --git a/drivers/remoteproc/stm32_rproc.c
> b/drivers/remoteproc/stm32_rproc.c
> index 0c1f0b84e057..ca60c917e218 100644
> --- a/drivers/remoteproc/stm32_rproc.c
> +++ b/drivers/remoteproc/stm32_rproc.c
> @@ -538,12 +538,11 @@ static int stm32_rproc_get_syscon(struct
> device_node *np, const char *prop,
>  	return err;
>  }
> 
> -static int stm32_rproc_parse_dt(struct platform_device *pdev)
> +static int stm32_rproc_parse_dt(struct platform_device *pdev,
> +				struct stm32_rproc *ddata, bool *auto_boot)
>  {
>  	struct device *dev = &pdev->dev;
>  	struct device_node *np = dev->of_node;
> -	struct rproc *rproc = platform_get_drvdata(pdev);
> -	struct stm32_rproc *ddata = rproc->priv;
>  	struct stm32_syscon tz;
>  	unsigned int tzen;
>  	int err, irq;
> @@ -589,7 +588,7 @@ static int stm32_rproc_parse_dt(struct
> platform_device *pdev)
> 
>  	err = regmap_read(tz.map, tz.reg, &tzen);
>  	if (err) {
> -		dev_err(&rproc->dev, "failed to read tzen\n");
> +		dev_err(dev, "failed to read tzen\n");
>  		return err;
>  	}
>  	ddata->secured_soc = tzen & tz.mask;
> @@ -605,7 +604,7 @@ static int stm32_rproc_parse_dt(struct
> platform_device *pdev)
>  	if (err)
>  		dev_warn(dev, "failed to get pdds\n");
> 
> -	rproc->auto_boot = of_property_read_bool(np, "st,auto-boot");
> +	*auto_boot = of_property_read_bool(np, "st,auto-boot");
> 
>  	return stm32_rproc_of_memory_translations(pdev, ddata);
>  }
> @@ -616,18 +615,29 @@ static int stm32_rproc_probe(struct
> platform_device *pdev)
>  	struct stm32_rproc *ddata;
>  	struct device_node *np = dev->of_node;
>  	struct rproc *rproc;
> +	bool auto_boot = false;
>  	int ret;
> 
>  	ret = dma_coerce_mask_and_coherent(dev, DMA_BIT_MASK(32));
>  	if (ret)
>  		return ret;
> 
> -	rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL,
> sizeof(*ddata));
> -	if (!rproc)
> +	ddata = kzalloc(sizeof(*ddata), GFP_KERNEL);
> +	if (!ddata)
>  		return -ENOMEM;
> 
> +	ret = stm32_rproc_parse_dt(pdev, ddata, &auto_boot);
> +	if (ret)
> +		goto free_ddata;
> +
> +	rproc = rproc_alloc(dev, np->name, &st_rproc_ops, NULL,
> sizeof(*ddata));
> +	if (!rproc) {
> +		ret = -ENOMEM;
> +		goto free_ddata;
> +	}
> +
> +	rproc->auto_boot = auto_boot;
>  	rproc->has_iommu = false;
> -	ddata = rproc->priv;
>  	ddata->workqueue = create_workqueue(dev_name(dev));
>  	if (!ddata->workqueue) {
>  		dev_err(dev, "cannot create workqueue\n");
> @@ -635,20 +645,20 @@ static int stm32_rproc_probe(struct
> platform_device *pdev)
>  		goto free_rproc;
>  	}
> 
> -	platform_set_drvdata(pdev, rproc);
> +	memcpy(rproc->priv, ddata, sizeof(*ddata));
> 
> -	ret = stm32_rproc_parse_dt(pdev);
> -	if (ret)
> -		goto free_wkq;
> +	platform_set_drvdata(pdev, rproc);
> 
>  	ret = stm32_rproc_request_mbox(rproc);
>  	if (ret)
> -		goto free_rproc;
> +		goto free_wkq;
> 
>  	ret = rproc_add(rproc);
>  	if (ret)
>  		goto free_mb;
> 
> +	kfree(ddata);
> +
>  	return 0;
> 
>  free_mb:
> @@ -661,6 +671,8 @@ static int stm32_rproc_probe(struct platform_device
> *pdev)
>  		device_init_wakeup(dev, false);
>  	}
>  	rproc_free(rproc);
> +free_ddata:
> +	kfree(ddata);
>  	return ret;
>  }
> 
> --
> 2.20.1





[Index of Archives]     [Linux Sound]     [ALSA Users]     [ALSA Devel]     [Linux Audio Users]     [Linux Media]     [Kernel]     [Photo Sharing]     [Gimp]     [Yosemite News]     [Linux Media]

  Powered by Linux