All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 0/2] remoteproc: st: add virtio_rpmsg support
@ 2017-02-15 20:18 ` Loic Pallardy
  0 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-02-15 20:18 UTC (permalink / raw)
  To: bjorn.andersson, ohad, lee.jones
  Cc: loic.pallardy, linux-remoteproc, linux-kernel, kernel,
	patrice.chotard, hugues.fruchet, peter.griffin

Goal of this series is:
- to add vring based communication link (virtio_rpmsg)
- to add rproc_da_to_va translation function to allow firmware loading in
  pre-reserved carveout memory region

V2:
Only changes in patch 1 to:
- fix typos
- fix mailbox allocation per coprocessor

V3:
- Integrate Bjorn's comments about mailbox support simplification
- Add missing Signed-of-by
- Move st_rproc_probe error management correction in a dedicated patch
- Fix warnings reported by checkpatch --strict

V4:
- Rebase on maintainer rproc-next branch on which patches 1 & 2 are present
- Remove check on device address (da) from patch 4
- Add Acked-by and Tested-by

Loic Pallardy (2):
  remoteproc: st: add da to va support
  remoteproc: core: don't allocate carveout if pa is defined

 drivers/remoteproc/remoteproc_core.c |  5 +++++
 drivers/remoteproc/st_remoteproc.c   | 43 +++++++++++++++++++++++++++++++-----
 2 files changed, 42 insertions(+), 6 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 0/2] remoteproc: st: add virtio_rpmsg support
@ 2017-02-15 20:18 ` Loic Pallardy
  0 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-02-15 20:18 UTC (permalink / raw)
  To: bjorn.andersson, ohad, lee.jones
  Cc: loic.pallardy, linux-remoteproc, linux-kernel, kernel,
	patrice.chotard, hugues.fruchet, peter.griffin

Goal of this series is:
- to add vring based communication link (virtio_rpmsg)
- to add rproc_da_to_va translation function to allow firmware loading in
  pre-reserved carveout memory region

V2:
Only changes in patch 1 to:
- fix typos
- fix mailbox allocation per coprocessor

V3:
- Integrate Bjorn's comments about mailbox support simplification
- Add missing Signed-of-by
- Move st_rproc_probe error management correction in a dedicated patch
- Fix warnings reported by checkpatch --strict

V4:
- Rebase on maintainer rproc-next branch on which patches 1 & 2 are present
- Remove check on device address (da) from patch 4
- Add Acked-by and Tested-by

Loic Pallardy (2):
  remoteproc: st: add da to va support
  remoteproc: core: don't allocate carveout if pa is defined

 drivers/remoteproc/remoteproc_core.c |  5 +++++
 drivers/remoteproc/st_remoteproc.c   | 43 +++++++++++++++++++++++++++++++-----
 2 files changed, 42 insertions(+), 6 deletions(-)

-- 
1.9.1

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [PATCH v4 1/2] remoteproc: st: add da to va support
  2017-02-15 20:18 ` Loic Pallardy
@ 2017-02-15 20:18   ` Loic Pallardy
  -1 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-02-15 20:18 UTC (permalink / raw)
  To: bjorn.andersson, ohad, lee.jones
  Cc: loic.pallardy, linux-remoteproc, linux-kernel, kernel,
	patrice.chotard, hugues.fruchet, peter.griffin

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@st.com>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
Tested-by: Hugues Fruchet <hugues.fruchet@st.com>
---
Changes since V2:
- fix checkpatch --strict warning

Changes since V3:
- Rebase on rproc-next branch
---
 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 d534bf2..5a2cf59 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 const 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]);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 1/2] remoteproc: st: add da to va support
@ 2017-02-15 20:18   ` Loic Pallardy
  0 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-02-15 20:18 UTC (permalink / raw)
  To: bjorn.andersson, ohad, lee.jones
  Cc: loic.pallardy, linux-remoteproc, linux-kernel, kernel,
	patrice.chotard, hugues.fruchet, peter.griffin

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@st.com>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
Tested-by: Hugues Fruchet <hugues.fruchet@st.com>
---
Changes since V2:
- fix checkpatch --strict warning

Changes since V3:
- Rebase on rproc-next branch
---
 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 d534bf2..5a2cf59 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 const 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]);
 
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 2/2] remoteproc: core: don't allocate carveout if pa is defined
  2017-02-15 20:18 ` Loic Pallardy
@ 2017-02-15 20:18   ` Loic Pallardy
  -1 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-02-15 20:18 UTC (permalink / raw)
  To: bjorn.andersson, ohad, lee.jones
  Cc: loic.pallardy, linux-remoteproc, linux-kernel, kernel,
	patrice.chotard, hugues.fruchet, peter.griffin

Remoteproc doesn't check if firmware requests fixed
addresses for carveout regions.
Current assumption is that platform specific driver is in
charge of coprocessor specific memory region allocation and
remoteproc core doesn't have to handle them.
If a pa is specified in firmware resource table, remoteproc
core doesn't have to perform any allocation.
Access to carveout will be done thanks to rproc_da_to_pa function,
which will provide virtual address on carveout region allocated
by platform specific driver.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
Tested-by: Hugues Fruchet <hugues.fruchet@st.com>
---
Changes from V3:
- Fix Bjorn's remark: Don't check if da is already specified in resource table.
  Because this doesn't mean buffer has been allocated, but that a specific da
  is requested for IOMMU configuration.
- Rebase on rproc-next branch
---
 drivers/remoteproc/remoteproc_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 3dabb20..74ad2d0 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -622,6 +622,11 @@ static int rproc_handle_carveout(struct rproc *rproc,
 	dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n",
 		rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags);
 
+	if (rsc->pa != FW_RSC_ADDR_ANY) {
+		dev_dbg(dev, "carveout already allocated by low level driver\n");
+		return 0;
+	}
+
 	carveout = kzalloc(sizeof(*carveout), GFP_KERNEL);
 	if (!carveout)
 		return -ENOMEM;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [PATCH v4 2/2] remoteproc: core: don't allocate carveout if pa is defined
@ 2017-02-15 20:18   ` Loic Pallardy
  0 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-02-15 20:18 UTC (permalink / raw)
  To: bjorn.andersson, ohad, lee.jones
  Cc: loic.pallardy, linux-remoteproc, linux-kernel, kernel,
	patrice.chotard, hugues.fruchet, peter.griffin

Remoteproc doesn't check if firmware requests fixed
addresses for carveout regions.
Current assumption is that platform specific driver is in
charge of coprocessor specific memory region allocation and
remoteproc core doesn't have to handle them.
If a pa is specified in firmware resource table, remoteproc
core doesn't have to perform any allocation.
Access to carveout will be done thanks to rproc_da_to_pa function,
which will provide virtual address on carveout region allocated
by platform specific driver.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
Acked-by: Hugues Fruchet <hugues.fruchet@st.com>
Tested-by: Hugues Fruchet <hugues.fruchet@st.com>
---
Changes from V3:
- Fix Bjorn's remark: Don't check if da is already specified in resource table.
  Because this doesn't mean buffer has been allocated, but that a specific da
  is requested for IOMMU configuration.
- Rebase on rproc-next branch
---
 drivers/remoteproc/remoteproc_core.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 3dabb20..74ad2d0 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -622,6 +622,11 @@ static int rproc_handle_carveout(struct rproc *rproc,
 	dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n",
 		rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags);
 
+	if (rsc->pa != FW_RSC_ADDR_ANY) {
+		dev_dbg(dev, "carveout already allocated by low level driver\n");
+		return 0;
+	}
+
 	carveout = kzalloc(sizeof(*carveout), GFP_KERNEL);
 	if (!carveout)
 		return -ENOMEM;
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 0/2] remoteproc: st: add virtio_rpmsg support
  2017-02-15 20:18 ` Loic Pallardy
@ 2017-05-03 15:29   ` Loic Pallardy
  -1 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-05-03 15:29 UTC (permalink / raw)
  To: bjorn.andersson, ohad, lee.jones
  Cc: linux-remoteproc, linux-kernel, patrice.chotard, hugues.fruchet,
	peter.griffin



On 02/15/2017 09:18 PM, Loic Pallardy wrote:
> Goal of this series is:
> - to add vring based communication link (virtio_rpmsg)
> - to add rproc_da_to_va translation function to allow firmware loading in
>   pre-reserved carveout memory region
>
> V2:
> Only changes in patch 1 to:
> - fix typos
> - fix mailbox allocation per coprocessor
>
> V3:
> - Integrate Bjorn's comments about mailbox support simplification
> - Add missing Signed-of-by
> - Move st_rproc_probe error management correction in a dedicated patch
> - Fix warnings reported by checkpatch --strict
>
> V4:
> - Rebase on maintainer rproc-next branch on which patches 1 & 2 are present
> - Remove check on device address (da) from patch 4
> - Add Acked-by and Tested-by
>
Hi Bjorn,

As discussed during Linaro connect, could you review/accept these 2 
patches providing da to pa translation mechanism for firmware loading?
I agree a central solution will better, but today all drivers are based 
on this mechanism.
Could we move on this solution to complete remoteproc support for B2260 
96board?

Regards,
Loic

> Loic Pallardy (2):
>   remoteproc: st: add da to va support
>   remoteproc: core: don't allocate carveout if pa is defined
>
>  drivers/remoteproc/remoteproc_core.c |  5 +++++
>  drivers/remoteproc/st_remoteproc.c   | 43 +++++++++++++++++++++++++++++++-----
>  2 files changed, 42 insertions(+), 6 deletions(-)
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH v4 0/2] remoteproc: st: add virtio_rpmsg support
@ 2017-05-03 15:29   ` Loic Pallardy
  0 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-05-03 15:29 UTC (permalink / raw)
  To: bjorn.andersson, ohad, lee.jones
  Cc: linux-remoteproc, linux-kernel, patrice.chotard, hugues.fruchet,
	peter.griffin



On 02/15/2017 09:18 PM, Loic Pallardy wrote:
> Goal of this series is:
> - to add vring based communication link (virtio_rpmsg)
> - to add rproc_da_to_va translation function to allow firmware loading in
>   pre-reserved carveout memory region
>
> V2:
> Only changes in patch 1 to:
> - fix typos
> - fix mailbox allocation per coprocessor
>
> V3:
> - Integrate Bjorn's comments about mailbox support simplification
> - Add missing Signed-of-by
> - Move st_rproc_probe error management correction in a dedicated patch
> - Fix warnings reported by checkpatch --strict
>
> V4:
> - Rebase on maintainer rproc-next branch on which patches 1 & 2 are present
> - Remove check on device address (da) from patch 4
> - Add Acked-by and Tested-by
>
Hi Bjorn,

As discussed during Linaro connect, could you review/accept these 2 
patches providing da to pa translation mechanism for firmware loading?
I agree a central solution will better, but today all drivers are based 
on this mechanism.
Could we move on this solution to complete remoteproc support for B2260 
96board?

Regards,
Loic

> Loic Pallardy (2):
>   remoteproc: st: add da to va support
>   remoteproc: core: don't allocate carveout if pa is defined
>
>  drivers/remoteproc/remoteproc_core.c |  5 +++++
>  drivers/remoteproc/st_remoteproc.c   | 43 +++++++++++++++++++++++++++++++-----
>  2 files changed, 42 insertions(+), 6 deletions(-)
>

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2017-05-03 15:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-02-15 20:18 [PATCH v4 0/2] remoteproc: st: add virtio_rpmsg support Loic Pallardy
2017-02-15 20:18 ` Loic Pallardy
2017-02-15 20:18 ` [PATCH v4 1/2] remoteproc: st: add da to va support Loic Pallardy
2017-02-15 20:18   ` Loic Pallardy
2017-02-15 20:18 ` [PATCH v4 2/2] remoteproc: core: don't allocate carveout if pa is defined Loic Pallardy
2017-02-15 20:18   ` Loic Pallardy
2017-05-03 15:29 ` [PATCH v4 0/2] remoteproc: st: add virtio_rpmsg support Loic Pallardy
2017-05-03 15:29   ` Loic Pallardy

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.