lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <a39432b7-8194-f4d5-31a3-ba3abe742cbc@st.com>
Date:   Wed, 8 Feb 2017 09:00:35 +0000
From:   Hugues FRUCHET <hugues.fruchet@...com>
To:     Loic PALLARDY <loic.pallardy@...com>,
        "bjorn.andersson@...aro.org" <bjorn.andersson@...aro.org>,
        "ohad@...ery.com" <ohad@...ery.com>,
        "lee.jones@...aro.org" <lee.jones@...aro.org>
CC:     "linux-remoteproc@...r.kernel.org" <linux-remoteproc@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        "kernel@...inux.com" <kernel@...inux.com>,
        Patrice CHOTARD <patrice.chotard@...com>,
        "peter.griffin@...aro.org" <peter.griffin@...aro.org>
Subject: Re: [v3,3/4] remoteproc: st: add da to va support

On 01/31/2017 01:35 PM, Loic PALLARDY wrote:
> ST remoteproc driver needs to provide information about
> carveout memory region to allow remoteproc core to load
> firmware and access trace buffer.
>
> Signed-off-by: Loic Pallardy <loic.pallardy@...com>

Acked-and-tested-by: Hugues Fruchet <hugues.fruchet@...com>

Tested on B2260 ST Platform with st-delta video decoder V4L2 kernel 
driver 
(http://www.mail-archive.com/linux-media@vger.kernel.org/msg107644.html).

> ---
> Changes since V2:
> - fix checkpatch --strict warning
> ---
>  drivers/remoteproc/st_remoteproc.c | 43 ++++++++++++++++++++++++++++++++------
>  1 file changed, 37 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c
> index f1e9339..80f8118 100644
> --- a/drivers/remoteproc/st_remoteproc.c
> +++ b/drivers/remoteproc/st_remoteproc.c
> @@ -21,6 +21,7 @@
>  #include <linux/of.h>
>  #include <linux/of_device.h>
>  #include <linux/of_reserved_mem.h>
> +#include <linux/of_address.h>
>  #include <linux/platform_device.h>
>  #include <linux/regmap.h>
>  #include <linux/remoteproc.h>
> @@ -53,6 +54,10 @@ struct st_rproc {
>  	struct mbox_chan	*mbox_chan[ST_RPROC_MAX_VRING * MBOX_MAX];
>  	struct mbox_client mbox_client_vq0;
>  	struct mbox_client mbox_client_vq1;
> +	phys_addr_t mem_phys;
> +	phys_addr_t mem_reloc;
> +	void *mem_region;
> +	size_t mem_size;
>  };
>
>  static void st_rproc_mbox_callback(struct device *dev, u32 msg)
> @@ -157,10 +162,23 @@ static int st_rproc_stop(struct rproc *rproc)
>  	return sw_err ?: pwr_err;
>  }
>
> +static void *st_proc_da_to_va(struct rproc *rproc, u64 da, int len)
> +{
> +	struct st_rproc *ddata = rproc->priv;
> +	int offset;
> +
> +	offset = da - ddata->mem_reloc;
> +	if (offset < 0 || offset + len > ddata->mem_size)
> +		return NULL;
> +
> +	return ddata->mem_region + offset;
> +}
> +
>  static struct rproc_ops st_rproc_ops = {
>  	.kick		= st_rproc_kick,
>  	.start		= st_rproc_start,
>  	.stop		= st_rproc_stop,
> +	.da_to_va	= st_proc_da_to_va,
>  };
>
>  /*
> @@ -208,7 +226,8 @@ static int st_rproc_parse_dt(struct platform_device *pdev)
>  	struct device *dev = &pdev->dev;
>  	struct rproc *rproc = platform_get_drvdata(pdev);
>  	struct st_rproc *ddata = rproc->priv;
> -	struct device_node *np = dev->of_node;
> +	struct device_node *np = dev->of_node, *node;
> +	struct resource res;
>  	int err;
>
>  	if (ddata->config->sw_reset) {
> @@ -252,10 +271,24 @@ static int st_rproc_parse_dt(struct platform_device *pdev)
>  		return -EINVAL;
>  	}
>
> -	err = of_reserved_mem_device_init(dev);
> -	if (err) {
> -		dev_err(dev, "Failed to obtain shared memory\n");
> +	node = of_parse_phandle(np, "memory-region", 0);
> +	if (!node) {
> +		dev_err(dev, "No memory-region specified\n");
> +		return -EINVAL;
> +	}
> +
> +	err = of_address_to_resource(node, 0, &res);
> +	if (err)
>  		return err;
> +
> +	ddata->mem_phys = res.start;
> +	ddata->mem_reloc = res.start;
> +	ddata->mem_size = resource_size(&res);
> +	ddata->mem_region = devm_ioremap_wc(dev, ddata->mem_phys, ddata->mem_size);
> +	if (!ddata->mem_region) {
> +		dev_err(dev, "Unable to map memory region: %pa+%zx\n",
> +			&res.start, ddata->mem_size);
> +		return -EBUSY;
>  	}
>
>  	err = clk_prepare(ddata->clk);
> @@ -385,8 +418,6 @@ static int st_rproc_remove(struct platform_device *pdev)
>
>  	clk_disable_unprepare(ddata->clk);
>
> -	of_reserved_mem_device_release(&pdev->dev);
> -
>  	for (i = 0; i < ST_RPROC_MAX_VRING * MBOX_MAX; i++)
>  		mbox_free_channel(ddata->mbox_chan[i]);
>
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ