diff mbox

[v2,11/16] remoteproc: introduce rproc_find_carveout_by_name function

Message ID 1512060411-729-12-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
This patch provides a new function to find a carveout according
to a name.
If match found, this function returns a point on the corresponding
carveout.

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

Comments

Bjorn Andersson Dec. 14, 2017, 1:32 a.m. UTC | #1
On Thu 30 Nov 08:46 PST 2017, Loic Pallardy wrote:
> +struct rproc_mem_entry *
> +rproc_find_carveout_by_name(struct rproc *rproc, char *name)

In almost all cases after this patch you have to do a snprintf(), so it
would be better to make this function format the name based on a format
string and variable arguments.

> +{
> +	struct rproc_mem_entry *carveout, *mem = NULL;
> +
> +	if (!name)
> +		return NULL;
> +
> +	list_for_each_entry(carveout, &rproc->carveouts, node) {
> +		/* Compare carveout and requested names */
> +		if (!strcmp(carveout->name, name)) {
> +			mem = carveout;
> +			break;
> +		}
> +	}
> +
> +	return mem;
> +}
> +

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, 9:10 a.m. UTC | #2
> -----Original Message-----
> From: Bjorn Andersson [mailto:bjorn.andersson@linaro.org]
> Sent: Thursday, December 14, 2017 2:33 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 11/16] remoteproc: introduce
> rproc_find_carveout_by_name function
> 
> On Thu 30 Nov 08:46 PST 2017, Loic Pallardy wrote:
> > +struct rproc_mem_entry *
> > +rproc_find_carveout_by_name(struct rproc *rproc, char *name)
> 
> In almost all cases after this patch you have to do a snprintf(), so it
> would be better to make this function format the name based on a format
> string and variable arguments.

Good point
/Loic
> 
> > +{
> > +	struct rproc_mem_entry *carveout, *mem = NULL;
> > +
> > +	if (!name)
> > +		return NULL;
> > +
> > +	list_for_each_entry(carveout, &rproc->carveouts, node) {
> > +		/* Compare carveout and requested names */
> > +		if (!strcmp(carveout->name, name)) {
> > +			mem = carveout;
> > +			break;
> > +		}
> > +	}
> > +
> > +	return mem;
> > +}
> > +
> 
> 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 2b7effb..8d990b1 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -367,6 +367,42 @@  void *rproc_find_carveout_by_da(struct rproc *rproc, u64 da, int len)
 	return va;
 }
 
+/**
+ * rproc_find_carveout_by_name() - lookup the carveout region by a name
+ * @rproc: handle of a remote processor
+ * @name: carveout name to find
+ *
+ * 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 return associated region characteristics like
+ * coprocessor address, length or processor virtual address.
+ *
+ * The function returns a valid pointer on carveout entry on success or NULL on failure.
+ */
+struct rproc_mem_entry *
+rproc_find_carveout_by_name(struct rproc *rproc, char *name)
+{
+	struct rproc_mem_entry *carveout, *mem = NULL;
+
+	if (!name)
+		return NULL;
+
+	list_for_each_entry(carveout, &rproc->carveouts, node) {
+		/* Compare carveout and requested names */
+		if (!strcmp(carveout->name, name)) {
+			mem = carveout;
+			break;
+		}
+	}
+
+	return mem;
+}
+
 int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
 {
 	struct rproc *rproc = rvdev->rproc;