* [PATCH 1/7] remoteproc: add rproc_va_to_pa function
2017-10-27 12:44 [PATCH 0/7] remoteproc: add fixed memory region support Loic Pallardy
@ 2017-10-27 12:44 ` Loic Pallardy
2017-10-27 12:44 ` [PATCH 2/7] remoteproc: add release ops in rproc_mem_entry struct Loic Pallardy
` (5 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-10-27 12:44 UTC (permalink / raw)
To: bjorn.andersson, ohad
Cc: linux-remoteproc, linux-kernel, arnaud.pouliquen,
benjamin.gaignard, Loic Pallardy
This new function translates CPU virtual address in
CPU physical one according to virtual address location.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/remoteproc/remoteproc_core.c | 13 ++++++++++++-
1 file changed, 12 insertions(+), 1 deletion(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index eab14b4..faa18a7 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -139,6 +139,17 @@ static void rproc_disable_iommu(struct rproc *rproc)
iommu_domain_free(domain);
}
+static phys_addr_t rproc_va_to_pa(void *cpu_addr)
+{
+ if (is_vmalloc_addr(cpu_addr)) {
+ return page_to_phys(vmalloc_to_page(cpu_addr)) +
+ offset_in_page(cpu_addr);
+ }
+
+ WARN_ON(!virt_addr_valid(cpu_addr));
+ return virt_to_phys(cpu_addr);
+}
+
/**
* rproc_da_to_va() - lookup the kernel virtual address for a remoteproc address
* @rproc: handle of a remote processor
@@ -700,7 +711,7 @@ static int rproc_handle_carveout(struct rproc *rproc,
* In this case, the device address and the physical address
* are the same.
*/
- rsc->pa = dma;
+ rsc->pa = (u32)rproc_va_to_pa(va);
carveout->va = va;
carveout->len = rsc->len;
--
1.9.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 2/7] remoteproc: add release ops in rproc_mem_entry struct
2017-10-27 12:44 [PATCH 0/7] remoteproc: add fixed memory region support Loic Pallardy
2017-10-27 12:44 ` [PATCH 1/7] remoteproc: add rproc_va_to_pa function Loic Pallardy
@ 2017-10-27 12:44 ` Loic Pallardy
2017-10-27 12:44 ` [PATCH 3/7] remoteproc: introduce rproc_add_carveout function Loic Pallardy
` (4 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-10-27 12:44 UTC (permalink / raw)
To: bjorn.andersson, ohad
Cc: linux-remoteproc, linux-kernel, arnaud.pouliquen,
benjamin.gaignard, Loic Pallardy
Memory entry could be allocated in different ways (ioremap,
dma_alloc_coherent, internal RAM allocator...).
This patch introduces a release ops in rproc_mem_entry structure
to associate dedicated release mechanism to each memory entry descriptor
in order to keep remoteproc core generic.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/remoteproc/remoteproc_core.c | 26 ++++++++++++++++++++++----
include/linux/remoteproc.h | 6 ++++--
2 files changed, 26 insertions(+), 6 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index faa18a7..f23daf9 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -592,6 +592,25 @@ static int rproc_handle_devmem(struct rproc *rproc, struct fw_rsc_devmem *rsc,
}
/**
+ * rproc_release_carveout() - release acquired carveout
+ * @rproc: rproc handle
+ * @mem: the memory entry to release
+ *
+ * This function releases specified memory entry @mem allocated via
+ * dma_alloc_coherent() function by @rproc.
+ */
+static int rproc_release_carveout(struct rproc *rproc, struct rproc_mem_entry *mem)
+{
+ struct device *dev = &rproc->dev;
+
+ /* clean up carveout allocations */
+ dma_free_coherent(dev->parent, mem->len, mem->va, mem->dma);
+ list_del(&mem->node);
+ kfree(mem);
+ return 0;
+}
+
+/**
* rproc_handle_carveout() - handle phys contig memory allocation requests
* @rproc: rproc handle
* @rsc: the resource entry
@@ -717,6 +736,7 @@ static int rproc_handle_carveout(struct rproc *rproc,
carveout->len = rsc->len;
carveout->dma = dma;
carveout->da = rsc->da;
+ carveout->release = rproc_release_carveout;
list_add_tail(&carveout->node, &rproc->carveouts);
@@ -847,10 +867,8 @@ static void rproc_resource_cleanup(struct rproc *rproc)
/* clean up carveout allocations */
list_for_each_entry_safe(entry, tmp, &rproc->carveouts, node) {
- dma_free_coherent(dev->parent, entry->len, entry->va,
- entry->dma);
- list_del(&entry->node);
- kfree(entry);
+ if (entry->release)
+ entry->release(rproc, entry);
}
/* clean up remote vdev entries */
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 44e630e..8780f2e 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -305,12 +305,15 @@ struct fw_rsc_vdev {
struct fw_rsc_vdev_vring vring[0];
} __packed;
+struct rproc;
+
/**
* struct rproc_mem_entry - memory entry descriptor
* @va: virtual address
* @dma: dma address
* @len: length, in bytes
* @da: device address
+ * @release: release associated memory
* @priv: associated data
* @node: list node
*/
@@ -319,12 +322,11 @@ struct rproc_mem_entry {
dma_addr_t dma;
int len;
u32 da;
+ int (*release)(struct rproc *rproc, struct rproc_mem_entry *mem);
void *priv;
struct list_head node;
};
-struct rproc;
-
/**
* struct rproc_ops - platform-specific device handlers
* @start: power on the device and boot it
--
1.9.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 3/7] remoteproc: introduce rproc_add_carveout function
2017-10-27 12:44 [PATCH 0/7] remoteproc: add fixed memory region support Loic Pallardy
2017-10-27 12:44 ` [PATCH 1/7] remoteproc: add rproc_va_to_pa function Loic Pallardy
2017-10-27 12:44 ` [PATCH 2/7] remoteproc: add release ops in rproc_mem_entry struct Loic Pallardy
@ 2017-10-27 12:44 ` Loic Pallardy
2017-10-27 12:44 ` [PATCH 4/7] remoteproc: introduce rproc_find_carveout_by_da Loic Pallardy
` (3 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-10-27 12:44 UTC (permalink / raw)
To: bjorn.andersson, ohad
Cc: linux-remoteproc, linux-kernel, arnaud.pouliquen,
benjamin.gaignard, Loic Pallardy
This patch introduces a new API to allow platform driver to register
platform specific carveout regions.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/remoteproc/remoteproc_core.c | 22 ++++++++++++++++++++++
drivers/remoteproc/remoteproc_internal.h | 7 +++++++
include/linux/remoteproc.h | 2 ++
3 files changed, 31 insertions(+)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index f23daf9..279320a 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -737,6 +737,7 @@ static int rproc_handle_carveout(struct rproc *rproc,
carveout->dma = dma;
carveout->da = rsc->da;
carveout->release = rproc_release_carveout;
+ carveout->priv = (void *)CARVEOUT_RSC_ALLOCATED;
list_add_tail(&carveout->node, &rproc->carveouts);
@@ -751,6 +752,27 @@ static int rproc_handle_carveout(struct rproc *rproc,
return ret;
}
+/**
+ * rproc_add_carveout() - register an allocated carveout region
+ * @rproc: rproc handle
+ * @mem: memory entry to register
+ *
+ * This function registers specified memory entry in @rproc carveouts list.
+ * Specified carveout should have been allocated before registering.
+ */
+int rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem)
+{
+ if (!rproc || !mem)
+ return -EINVAL;
+
+ mem->priv = (void *)CARVEOUT_EXTERNAL;
+
+ list_add_tail(&mem->node, &rproc->carveouts);
+
+ return 0;
+}
+EXPORT_SYMBOL(rproc_add_carveout);
+
/*
* A lookup table for resource handlers. The indices are defined in
* enum fw_resource_type.
diff --git a/drivers/remoteproc/remoteproc_internal.h b/drivers/remoteproc/remoteproc_internal.h
index c1077be..69b22ac 100644
--- a/drivers/remoteproc/remoteproc_internal.h
+++ b/drivers/remoteproc/remoteproc_internal.h
@@ -23,6 +23,13 @@
#include <linux/irqreturn.h>
#include <linux/firmware.h>
+/* Indicate carveout origin */
+enum carveout_src {
+ CARVEOUT_RSC = 0,
+ CARVEOUT_RSC_ALLOCATED = 1,
+ CARVEOUT_EXTERNAL = 2,
+};
+
struct rproc;
/**
diff --git a/include/linux/remoteproc.h b/include/linux/remoteproc.h
index 8780f2e..5bd5175 100644
--- a/include/linux/remoteproc.h
+++ b/include/linux/remoteproc.h
@@ -522,6 +522,8 @@ struct rproc *rproc_alloc(struct device *dev, const char *name,
int rproc_del(struct rproc *rproc);
void rproc_free(struct rproc *rproc);
+int rproc_add_carveout(struct rproc *rproc, struct rproc_mem_entry *mem);
+
int rproc_boot(struct rproc *rproc);
void rproc_shutdown(struct rproc *rproc);
void rproc_report_crash(struct rproc *rproc, enum rproc_crash_type type);
--
1.9.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 4/7] remoteproc: introduce rproc_find_carveout_by_da
2017-10-27 12:44 [PATCH 0/7] remoteproc: add fixed memory region support Loic Pallardy
` (2 preceding siblings ...)
2017-10-27 12:44 ` [PATCH 3/7] remoteproc: introduce rproc_add_carveout function Loic Pallardy
@ 2017-10-27 12:44 ` Loic Pallardy
2017-10-27 12:44 ` [PATCH 5/7] remoteproc: modify rproc_handle_carveout to support preallocated region Loic Pallardy
` (2 subsequent siblings)
6 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-10-27 12:44 UTC (permalink / raw)
To: bjorn.andersson, ohad
Cc: linux-remoteproc, linux-kernel, arnaud.pouliquen,
benjamin.gaignard, Loic Pallardy
This patch provides a new function to find a carveout according
to a device address (da).
If match found, this function returns CPU virtual address corresponding
to specified da.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/remoteproc/remoteproc_core.c | 42 ++++++++++++++++++++++++++++++++++++
1 file changed, 42 insertions(+)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 279320a..78525d1 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -211,6 +211,48 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len)
}
EXPORT_SYMBOL(rproc_da_to_va);
+/**
+ * rproc_find_carveout_by_da() - lookup the carveout region for a remoteproc address
+ * @rproc: handle of a remote processor
+ * @da: remoteproc device address to find
+ * @len: length of the memory region @da is pointing to
+ *
+ * Platform driver has the capability to register some pre-allacoted carveout
+ * (physically contiguous memory regions) before rproc firmware loading and
+ * associated resource table analysis. These regions may be dedicated memory
+ * regions internal to the coprocessor or specified DDR region with specific
+ * attributes
+ *
+ * This function is a helper function with which we can go over the
+ * allocated carveouts and translate specific device addresse to virtual
+ * addresse so we can fill firmware resource table.
+ *
+ * The function returns a valid virtual address on success or NULL on failure.
+ */
+void *rproc_find_carveout_by_da(struct rproc *rproc, u64 da, int len)
+{
+ struct rproc_mem_entry *carveout;
+ void *va = NULL;
+
+ list_for_each_entry(carveout, &rproc->carveouts, node) {
+ int offset = da - carveout->da;
+
+ /* try next carveout if da is too small */
+ if (offset < 0)
+ continue;
+
+ /* try next carveout if da is too large */
+ if (offset + len > carveout->len)
+ continue;
+
+ va = carveout->va + offset;
+
+ break;
+ }
+
+ return va;
+}
+
int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
{
struct rproc *rproc = rvdev->rproc;
--
1.9.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 5/7] remoteproc: modify rproc_handle_carveout to support preallocated region
2017-10-27 12:44 [PATCH 0/7] remoteproc: add fixed memory region support Loic Pallardy
` (3 preceding siblings ...)
2017-10-27 12:44 ` [PATCH 4/7] remoteproc: introduce rproc_find_carveout_by_da Loic Pallardy
@ 2017-10-27 12:44 ` Loic Pallardy
2017-10-27 12:44 ` [PATCH 6/7] remoteproc: modify vring allocation " Loic Pallardy
2017-10-27 12:44 ` [PATCH 7/7] remoteproc: st: add reserved memory support Loic Pallardy
6 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-10-27 12:44 UTC (permalink / raw)
To: bjorn.andersson, ohad
Cc: linux-remoteproc, linux-kernel, arnaud.pouliquen,
benjamin.gaignard, Loic Pallardy
In current version rproc_handle_carveout function support only dynamic
region allocation.
This patch extends rproc_handle_carveout function to support different carveout
configurations:
- fixed DA and fixed PA: check if already part of pre-registered carveouts
(platform driver). If no, return error.
- fixed DA and any PA: check if already part of pre-allocated carveouts
(platform driver). If not found and rproc supports iommu, continue with
dynamic allocation (DA will be used for iommu programming), else return
error as no way to force DA.
- any DA and any PA: use original dynamic allocation
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 78525d1..515a17a 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -184,6 +184,10 @@ void *rproc_da_to_va(struct rproc *rproc, u64 da, int len)
struct rproc_mem_entry *carveout;
void *ptr = NULL;
+ /*
+ * da_to_va platform driver is deprecated. Driver should register
+ * carveout thanks to rproc_add_carveout function
+ */
if (rproc->ops->da_to_va) {
ptr = rproc->ops->da_to_va(rproc, da, len);
if (ptr)
@@ -677,6 +681,7 @@ static int rproc_handle_carveout(struct rproc *rproc,
struct rproc_mem_entry *carveout, *mapping;
struct device *dev = &rproc->dev;
dma_addr_t dma;
+ phys_addr_t pa;
void *va;
int ret;
@@ -698,6 +703,41 @@ static int rproc_handle_carveout(struct rproc *rproc,
if (!carveout)
return -ENOMEM;
+ /* Check carveout rsc already part of a registered carveout */
+ if (rsc->da != FW_RSC_ADDR_ANY) {
+ va = rproc_find_carveout_by_da(rproc, rsc->da, rsc->len);
+
+ if (va) {
+ /* Registered region found */
+ pa = rproc_va_to_pa(va);
+ if (rsc->pa != FW_RSC_ADDR_ANY && rsc->pa != (u32)pa) {
+ /* Carveout doesn't match request */
+ dev_err(dev->parent,
+ "Failed to find carveout fitting da and pa\n");
+ return -ENOMEM;
+ }
+
+ /* Update rsc table with physical address */
+ rsc->pa = (u32)pa;
+
+ /* Update carveouts list */
+ carveout->va = va;
+ carveout->len = rsc->len;
+ carveout->da = rsc->da;
+ carveout->priv = (void *)CARVEOUT_RSC;
+
+ list_add_tail(&carveout->node, &rproc->carveouts);
+
+ return 0;
+ }
+
+ if (!rproc->domain) {
+ dev_err(dev->parent,
+ "Bad carveout rsc configuration\n");
+ return -ENOMEM;
+ }
+ }
+
va = dma_alloc_coherent(dev->parent, rsc->len, &dma, GFP_KERNEL);
if (!va) {
dev_err(dev->parent,
--
1.9.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 6/7] remoteproc: modify vring allocation to support preallocated region
2017-10-27 12:44 [PATCH 0/7] remoteproc: add fixed memory region support Loic Pallardy
` (4 preceding siblings ...)
2017-10-27 12:44 ` [PATCH 5/7] remoteproc: modify rproc_handle_carveout to support preallocated region Loic Pallardy
@ 2017-10-27 12:44 ` Loic Pallardy
2017-10-27 12:44 ` [PATCH 7/7] remoteproc: st: add reserved memory support Loic Pallardy
6 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-10-27 12:44 UTC (permalink / raw)
To: bjorn.andersson, ohad
Cc: linux-remoteproc, linux-kernel, arnaud.pouliquen,
benjamin.gaignard, Loic Pallardy
Current version of rproc_alloc_vring function supports only dynamic vring
allocation.
This patch extends rproc_alloc_vring to verify if requested vring DA is
already part or not of a registered carveout. If true, nothing to do, else
just allocate vring as before.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/remoteproc/remoteproc_core.c | 50 +++++++++++++++++++++++-------------
1 file changed, 32 insertions(+), 18 deletions(-)
diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 515a17a..e1dbe65 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -263,21 +263,41 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
struct device *dev = &rproc->dev;
struct rproc_vring *rvring = &rvdev->vring[i];
struct fw_rsc_vdev *rsc;
- dma_addr_t dma;
+ dma_addr_t dma = 0;
void *va;
int ret, size, notifyid;
/* actual size of vring (in bytes) */
size = PAGE_ALIGN(vring_size(rvring->len, rvring->align));
- /*
- * Allocate non-cacheable memory for the vring. In the future
- * this call will also configure the IOMMU for us
- */
- va = dma_alloc_coherent(dev->parent, size, &dma, GFP_KERNEL);
- if (!va) {
- dev_err(dev->parent, "dma_alloc_coherent failed\n");
- return -EINVAL;
+ /* get vring resource table pointer */
+ rsc = (void *)rproc->table_ptr + rvdev->rsc_offset;
+
+ if (rsc->vring[i].da != FW_RSC_ADDR_ANY) {
+ va = rproc_find_carveout_by_da(rproc, rsc->vring[i].da, size);
+
+ if (!va) {
+ /* No region not found */
+ dev_err(dev->parent, "Pre-allocated vring not found\n");
+ return -ENOMEM;
+ }
+ } else {
+ /*
+ * Allocate non-cacheable memory for the vring. In the future
+ * this call will also configure the IOMMU for us
+ */
+ va = dma_alloc_coherent(dev->parent, size, &dma, GFP_KERNEL);
+ if (!va) {
+ dev_err(dev->parent, "dma_alloc_coherent failed\n");
+ return -EINVAL;
+ }
+ /*
+ * Let the rproc know the da of this vring.
+ * Not all platforms use dma_alloc_coherent to automatically
+ * set up the iommu. In this case the device address (da) will
+ * hold the physical address and not the device address.
+ */
+ rsc->vring[i].da = dma;
}
/*
@@ -304,14 +324,7 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
rvring->dma = dma;
rvring->notifyid = notifyid;
- /*
- * Let the rproc know the notifyid and da of this vring.
- * Not all platforms use dma_alloc_coherent to automatically
- * set up the iommu. In this case the device address (da) will
- * hold the physical address and not the device address.
- */
- rsc = (void *)rproc->table_ptr + rvdev->rsc_offset;
- rsc->vring[i].da = dma;
+ /* Let the rproc know the notifyid of this vring. */
rsc->vring[i].notifyid = notifyid;
return 0;
}
@@ -348,7 +361,8 @@ void rproc_free_vring(struct rproc_vring *rvring)
int idx = rvring->rvdev->vring - rvring;
struct fw_rsc_vdev *rsc;
- dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma);
+ if (rvring->dma)
+ dma_free_coherent(rproc->dev.parent, size, rvring->va, rvring->dma);
idr_remove(&rproc->notifyids, rvring->notifyid);
/* reset resource entry info */
--
1.9.1
^ permalink raw reply [flat|nested] 8+ messages in thread* [PATCH 7/7] remoteproc: st: add reserved memory support
2017-10-27 12:44 [PATCH 0/7] remoteproc: add fixed memory region support Loic Pallardy
` (5 preceding siblings ...)
2017-10-27 12:44 ` [PATCH 6/7] remoteproc: modify vring allocation " Loic Pallardy
@ 2017-10-27 12:44 ` Loic Pallardy
6 siblings, 0 replies; 8+ messages in thread
From: Loic Pallardy @ 2017-10-27 12:44 UTC (permalink / raw)
To: bjorn.andersson, ohad
Cc: linux-remoteproc, linux-kernel, arnaud.pouliquen,
benjamin.gaignard, Loic Pallardy
ST remote processor needs some specified memory regions for firmware and IPC.
Memory regions are defined as reserved memory and should be registered in
remoteproc core thanks to rproc_add_carveout function.
Memory region release is handled by ST driver itself on remove operation.
Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/remoteproc/st_remoteproc.c | 43 +++++++++++++++++++++++++++++++-------
1 file changed, 35 insertions(+), 8 deletions(-)
diff --git a/drivers/remoteproc/st_remoteproc.c b/drivers/remoteproc/st_remoteproc.c
index aacef0e..1549ce8 100644
--- a/drivers/remoteproc/st_remoteproc.c
+++ b/drivers/remoteproc/st_remoteproc.c
@@ -19,6 +19,7 @@
#include <linux/mfd/syscon.h>
#include <linux/module.h>
#include <linux/of.h>
+#include <linux/of_address.h>
#include <linux/of_device.h>
#include <linux/of_reserved_mem.h>
#include <linux/platform_device.h>
@@ -208,8 +209,10 @@ 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;
- int err;
+ struct device_node *node, *np = dev->of_node;
+ struct resource res;
+ struct rproc_mem_entry *mem;
+ int err, count, i;
if (ddata->config->sw_reset) {
ddata->sw_reset = devm_reset_control_get_exclusive(dev,
@@ -254,10 +257,36 @@ 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");
- return err;
+ count = of_count_phandle_with_args(np, "memory-region", NULL);
+
+ for (i = 0; i < count; i++) {
+ node = of_parse_phandle(np, "memory-region", i);
+ if (!node) {
+ dev_err(dev, "No memory-region specified\n");
+ return -EINVAL;
+ }
+
+ err = of_address_to_resource(node, 0, &res);
+ if (err) {
+ dev_err(dev, "Bad memory-region definition\n");
+ return err;
+ }
+
+ mem = devm_kzalloc(dev, sizeof(*mem), GFP_KERNEL);
+ if (!mem)
+ return -ENOMEM;
+
+ mem->dma = res.start;
+ mem->da = res.start;
+ mem->len = resource_size(&res);
+ mem->va = devm_ioremap_wc(dev, mem->dma, mem->len);
+ if (!mem->va) {
+ dev_err(dev, "Unable to map memory region: %pa+%zx\n",
+ &res.start, mem->len);
+ return -EBUSY;
+ }
+
+ rproc_add_carveout(rproc, mem);
}
err = clk_prepare(ddata->clk);
@@ -387,8 +416,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 [flat|nested] 8+ messages in thread