diff mbox

[v2,14/16] remoteproc: look-up pre-registered carveout by name for carveout allocation

Message ID 1512060411-729-15-git-send-email-loic.pallardy@st.com (mailing list archive)
State Superseded
Headers show

Commit Message

Loic PALLARDY Nov. 30, 2017, 4:46 p.m. UTC
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(-)

Comments

Bjorn Andersson Dec. 14, 2017, 5:34 a.m. UTC | #1
On Thu 30 Nov 08:46 PST 2017, Loic Pallardy wrote:
> +	/* By name */
> +	mem = rproc_find_carveout_by_name(rproc, rsc->name);
> +	if (mem) {
> +		/*
> +		 * Update resource table with registered carevout information
> +		 */
> +		rsc->len = mem->len;

You should validate that len, da and pa are compatible.

> +		rsc->da = mem->da;
> +		rsc->pa = rproc_va_to_pa(mem->va);
> +		/* no need to register as already match one for one */
> +		return 0;
> +	}

Regards,
Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Loic PALLARDY Jan. 15, 2018, 8:59 p.m. UTC | #2
> -----Original Message-----
> From: Bjorn Andersson [mailto:bjorn.andersson@linaro.org]
> Sent: Thursday, December 14, 2017 6:35 AM
> To: Loic PALLARDY <loic.pallardy@st.com>
> Cc: ohad@wizery.com; linux-remoteproc@vger.kernel.org; linux-
> kernel@vger.kernel.org; Arnaud POULIQUEN <arnaud.pouliquen@st.com>;
> benjamin.gaignard@linaro.org
> Subject: Re: [PATCH v2 14/16] remoteproc: look-up pre-registered carveout
> by name for carveout allocation
> 
> On Thu 30 Nov 08:46 PST 2017, Loic Pallardy wrote:
> > +	/* By name */
> > +	mem = rproc_find_carveout_by_name(rproc, rsc->name);
> > +	if (mem) {
> > +		/*
> > +		 * Update resource table with registered carevout
> information
> > +		 */
> > +		rsc->len = mem->len;
> 
> You should validate that len, da and pa are compatible.
Yes you're right, complete definition must be checked

Regards,
Loic
> 
> > +		rsc->da = mem->da;
> > +		rsc->pa = rproc_va_to_pa(mem->va);
> > +		/* no need to register as already match one for one */
> > +		return 0;
> > +	}
> 
> Regards,
> Bjorn
--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

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,