[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1512060411-729-15-git-send-email-loic.pallardy@st.com>
Date: Thu, 30 Nov 2017 17:46:49 +0100
From: Loic Pallardy <loic.pallardy@...com>
To: <bjorn.andersson@...aro.org>, <ohad@...ery.com>
CC: <linux-remoteproc@...r.kernel.org>, <linux-kernel@...r.kernel.org>,
<arnaud.pouliquen@...com>, <benjamin.gaignard@...aro.org>,
Loic Pallardy <loic.pallardy@...com>
Subject: [PATCH v2 14/16] remoteproc: look-up pre-registered carveout by name for carveout allocation
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@...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
Powered by blists - more mailing lists