lkml.org 
[lkml]   [2017]   [Nov]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH v2 14/16] remoteproc: look-up pre-registered carveout by name for carveout allocation
Date
Look-up for a pre-registred carveout having the same
name as requested one.
If match found, pre-registed carevout is used and resource
table updated.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
---
drivers/remoteproc/remoteproc_core.c | 17 ++++++++++++++++-
1 file changed, 16 insertions(+), 1 deletion(-)

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 9c12319..8436185 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -873,7 +873,7 @@ static int rproc_handle_carveout(struct rproc *rproc,
struct fw_rsc_carveout *rsc,
int offset, int avail)
{
- struct rproc_mem_entry *carveout, *mapping;
+ struct rproc_mem_entry *carveout, *mapping, *mem;
struct device *dev = &rproc->dev;
dma_addr_t dma;
phys_addr_t pa;
@@ -899,6 +899,7 @@ static int rproc_handle_carveout(struct rproc *rproc,
return -ENOMEM;

/* Check carveout rsc already part of a registered carveout */
+ /* By device address if any */
if (rsc->da != FW_RSC_ADDR_ANY) {
va = rproc_find_carveout_by_da(rproc, rsc->da, rsc->len);

@@ -933,6 +934,20 @@ static int rproc_handle_carveout(struct rproc *rproc,
}
}

+ /* By name */
+ mem = rproc_find_carveout_by_name(rproc, rsc->name);
+ if (mem) {
+ /*
+ * Update resource table with registered carevout information
+ */
+ rsc->len = mem->len;
+ rsc->da = mem->da;
+ rsc->pa = rproc_va_to_pa(mem->va);
+ /* no need to register as already match one for one */
+ return 0;
+ }
+
+ /* No registered carveout found, allocate a new one */
va = dma_alloc_coherent(dev->parent, rsc->len, &dma, GFP_KERNEL);
if (!va) {
dev_err(dev->parent,
--
1.9.1
\
 
 \ /
  Last update: 2017-11-30 17:49    [W:0.263 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site