diff mbox series

[v3,4/4] remoteproc: core: don't allocate carveout if pa or da are defined

Message ID 1485866156-6364-5-git-send-email-loic.pallardy@st.com
State Superseded
Headers show
Series remoteproc: st: add virtio_rpmsg support | expand

Commit Message

Loic Pallardy Jan. 31, 2017, 12:35 p.m. UTC
Remoteproc doesn't check if firmware requests fixed
addresses for carveout regions.
Current assumption is that platform specific driver is in
charge of coprocessor specific memory region allocation and
remoteproc core doesn't have to handle them.
If a da or a pa is specified in firmware resource table, remoteproc
core doesn't have to perform any allocation.
Access to carveout will be done thanks to rproc_da_to_pa function,
which will provide virtual address on carveout region allocated
by platform specific driver.

Signed-off-by: Loic Pallardy <loic.pallardy@st.com>

---
No change since V1

 drivers/remoteproc/remoteproc_core.c | 5 +++++
 1 file changed, 5 insertions(+)

-- 
1.9.1

Comments

Hugues FRUCHET Feb. 8, 2017, 9 a.m. UTC | #1
On 01/31/2017 01:35 PM, Loic PALLARDY wrote:
> Remoteproc doesn't check if firmware requests fixed

> addresses for carveout regions.

> Current assumption is that platform specific driver is in

> charge of coprocessor specific memory region allocation and

> remoteproc core doesn't have to handle them.

> If a da or a pa is specified in firmware resource table, remoteproc

> core doesn't have to perform any allocation.

> Access to carveout will be done thanks to rproc_da_to_pa function,

> which will provide virtual address on carveout region allocated

> by platform specific driver.

>

> Signed-off-by: Loic Pallardy <loic.pallardy@st.com>


Acked-and-tested-by: Hugues Fruchet <hugues.fruchet@st.com>

Tested on B2260 ST Platform with st-delta video decoder V4L2 kernel 
driver 
(http://www.mail-archive.com/linux-media@vger.kernel.org/msg107644.html).

> ---

> No change since V1

>

>  drivers/remoteproc/remoteproc_core.c | 5 +++++

>  1 file changed, 5 insertions(+)

>

> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c

> index 90b05c7..dd63ceed 100644

> --- a/drivers/remoteproc/remoteproc_core.c

> +++ b/drivers/remoteproc/remoteproc_core.c

> @@ -622,6 +622,11 @@ static int rproc_handle_carveout(struct rproc *rproc,

>  	dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n",

>  		rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags);

>

> +	if (rsc->pa != FW_RSC_ADDR_ANY || rsc->da != FW_RSC_ADDR_ANY) {

> +		dev_dbg(dev, "carveout already allocated by low level driver\n");

> +		return 0;

> +	}

> +

>  	carveout = kzalloc(sizeof(*carveout), GFP_KERNEL);

>  	if (!carveout)

>  		return -ENOMEM;

>

>
Bjorn Andersson Feb. 9, 2017, 1:55 a.m. UTC | #2
On Tue 31 Jan 04:35 PST 2017, Loic Pallardy wrote:

> Remoteproc doesn't check if firmware requests fixed

> addresses for carveout regions.

> Current assumption is that platform specific driver is in

> charge of coprocessor specific memory region allocation and

> remoteproc core doesn't have to handle them.

> If a da or a pa is specified in firmware resource table, remoteproc

> core doesn't have to perform any allocation.

> Access to carveout will be done thanks to rproc_da_to_pa function,

> which will provide virtual address on carveout region allocated

> by platform specific driver.

> 

> Signed-off-by: Loic Pallardy <loic.pallardy@st.com>

> ---

> No change since V1

> 

>  drivers/remoteproc/remoteproc_core.c | 5 +++++

>  1 file changed, 5 insertions(+)

> 

> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c

> index 90b05c7..dd63ceed 100644

> --- a/drivers/remoteproc/remoteproc_core.c

> +++ b/drivers/remoteproc/remoteproc_core.c

> @@ -622,6 +622,11 @@ static int rproc_handle_carveout(struct rproc *rproc,

>  	dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n",

>  		rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags);

>  

> +	if (rsc->pa != FW_RSC_ADDR_ANY || rsc->da != FW_RSC_ADDR_ANY) {


For devices with an IOMMU it's valid to specify "da" and have the
allocated region mapped there. So this is not correct.

Regards,
Bjorn
Loic Pallardy Feb. 9, 2017, 9:34 p.m. UTC | #3
> -----Original Message-----

> From: Bjorn Andersson [mailto:bjorn.andersson@linaro.org]

> Sent: Thursday, February 09, 2017 2:55 AM

> To: Loic PALLARDY <loic.pallardy@st.com>

> Cc: ohad@wizery.com; lee.jones@linaro.org; linux-

> remoteproc@vger.kernel.org; linux-kernel@vger.kernel.org;

> kernel@stlinux.com; Patrice CHOTARD <patrice.chotard@st.com>; Hugues

> FRUCHET <hugues.fruchet@st.com>; peter.griffin@linaro.org

> Subject: Re: [PATCH v3 4/4] remoteproc: core: don't allocate carveout if pa or

> da are defined

> 

> On Tue 31 Jan 04:35 PST 2017, Loic Pallardy wrote:

> 

> > Remoteproc doesn't check if firmware requests fixed

> > addresses for carveout regions.

> > Current assumption is that platform specific driver is in

> > charge of coprocessor specific memory region allocation and

> > remoteproc core doesn't have to handle them.

> > If a da or a pa is specified in firmware resource table, remoteproc

> > core doesn't have to perform any allocation.

> > Access to carveout will be done thanks to rproc_da_to_pa function,

> > which will provide virtual address on carveout region allocated

> > by platform specific driver.

> >

> > Signed-off-by: Loic Pallardy <loic.pallardy@st.com>

> > ---

> > No change since V1

> >

> >  drivers/remoteproc/remoteproc_core.c | 5 +++++

> >  1 file changed, 5 insertions(+)

> >

> > diff --git a/drivers/remoteproc/remoteproc_core.c

> b/drivers/remoteproc/remoteproc_core.c

> > index 90b05c7..dd63ceed 100644

> > --- a/drivers/remoteproc/remoteproc_core.c

> > +++ b/drivers/remoteproc/remoteproc_core.c

> > @@ -622,6 +622,11 @@ static int rproc_handle_carveout(struct rproc

> *rproc,

> >  	dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x,

> flags 0x%x\n",

> >  		rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags);

> >

> > +	if (rsc->pa != FW_RSC_ADDR_ANY || rsc->da !=

> FW_RSC_ADDR_ANY) {

> 

> For devices with an IOMMU it's valid to specify "da" and have the

> allocated region mapped there. So this is not correct.


You're right, moreover patch series touch only to pa, so even if da behavior should be changed, should be done in a dedicated patch.
I'll send a V4.

Regards,
Loic
> 

> Regards,

> Bjorn
diff mbox series

Patch

diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
index 90b05c7..dd63ceed 100644
--- a/drivers/remoteproc/remoteproc_core.c
+++ b/drivers/remoteproc/remoteproc_core.c
@@ -622,6 +622,11 @@  static int rproc_handle_carveout(struct rproc *rproc,
 	dev_dbg(dev, "carveout rsc: name: %s, da 0x%x, pa 0x%x, len 0x%x, flags 0x%x\n",
 		rsc->name, rsc->da, rsc->pa, rsc->len, rsc->flags);
 
+	if (rsc->pa != FW_RSC_ADDR_ANY || rsc->da != FW_RSC_ADDR_ANY) {
+		dev_dbg(dev, "carveout already allocated by low level driver\n");
+		return 0;
+	}
+
 	carveout = kzalloc(sizeof(*carveout), GFP_KERNEL);
 	if (!carveout)
 		return -ENOMEM;