All of lore.kernel.org
 help / color / mirror / Atom feed
From: loic pallardy <loic.pallardy@st.com>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: ohad@wizery.com, lee.jones@linaro.org,
	linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org,
	kernel@stlinux.com, Suman Anna <s-anna@ti.com>
Subject: Re: [PATCH v2 3/3] remoteproc: core: add rproc ops for memory allocation
Date: Fri, 16 Sep 2016 09:47:29 +0200	[thread overview]
Message-ID: <10b33f31-8e6f-2ea8-87bd-e9725aeacaea@st.com> (raw)
In-Reply-To: <20160915172743.GE21438@tuxbot>



On 09/15/2016 07:27 PM, Bjorn Andersson wrote:
> On Tue 06 Sep 00:39 PDT 2016, Loic Pallardy wrote:
>
>> Remoteproc core is currently using dma_alloc_coherent for
>> carveout and vring allocation.
>> It doesn't allow to support specific use cases like fixed memory
>> region or internal RAM support.
>>
>> Two new rproc ops (alloc and free) is added to provide flexibility
>> to platform implementation to provide specific memory allocator
>> taking into account coprocessor characteristics.
>> rproc_handle_carveout and rproc_alloc_vring functions are modified
>> to invoke these ops if present, and fallback to regular processing
>> if platform specific allocation failed and if resquested memory is
>> not fixed (physical address == FW_RSC_ADDR_ANY)
>>
>> Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
>> ---
>>  drivers/remoteproc/remoteproc_core.c | 67 ++++++++++++++++++++++++++++++------
>>  include/linux/remoteproc.h           |  4 +++
>>  2 files changed, 60 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
>> index 0d3c191..7493b08 100644
>> --- a/drivers/remoteproc/remoteproc_core.c
>> +++ b/drivers/remoteproc/remoteproc_core.c
>> @@ -207,19 +207,29 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
>>  	struct rproc_vring *rvring = &rvdev->vring[i];
>>  	struct fw_rsc_vdev *rsc;
>>  	dma_addr_t dma;
>> -	void *va;
>> +	void *va = NULL;
>>  	int ret, size, notifyid;
>>
>>  	/* actual size of vring (in bytes) */
>>  	size = PAGE_ALIGN(vring_size(rvring->len, rvring->align));
>>
>> +	rsc = (void *)rproc->table_ptr + rvdev->rsc_offset;
>> +
>>  	/*
>>  	 * Allocate non-cacheable memory for the vring. In the future
>>  	 * this call will also configure the IOMMU for us
>>  	 */
>> -	va = dma_alloc_coherent(dev->parent, size, &dma, GFP_KERNEL);
>> +
>> +	dma = rsc->vring[i].pa;
>> +
>> +	if (rproc->ops->alloc)
>> +		va = rproc->ops->alloc(rproc, size, &dma);
>
> I believe this will be awkward for the remoteproc drivers to implement.
>
> Imagine a driver that programmatically register some fixed positioned
> carveouts and ioremapped vring buffers, it would then need internal book
> keeping to figure out which type of allocation each call is related to.

Yes true like any allocator does. And it is needed to manage region overlap.
>
>
> Rather then deferring the allocation until this point I think we should
> tie a rproc_mem_entry to each vring and once we reach
> rproc_alloc_vring() we simply use "va" and "dma" from that.
>
> We would get this from rproc_parse_vring() checking to find an existing
> mem_entry matching the vring requirements (da, then pa) and falling back
> to allocating a new carveout mem_entry.
>
This doesn't answer to use case described by Suman. What if no specific 
address are requested in firmware resource table, but buffers need to be 
allocated in internal RAM for example. Only rproc driver will know on 
which allocator to rely.

By memremaping a complete memory area and offering va to dma (pa) 
conversion, you don't verify possible overlap between requested regions. 
This is done today by allocator.

The idea from ST pov, was to rely on memory region, to declare subdev 
associated to rproc driver and to rely on dma_alloc_coherent.
I think TI wants to rely on its internal RAM memory allocator.

Regards,
Loic

>
> By then making the current "carveouts" list heterogeneous we would allow
> for arbitrary memory types to be used for backing vrings, as well as
> trace devices, code and data segments.
>
> Regards,
> Bjorn
>

WARNING: multiple messages have this Message-ID (diff)
From: loic pallardy <loic.pallardy@st.com>
To: Bjorn Andersson <bjorn.andersson@linaro.org>
Cc: <ohad@wizery.com>, <lee.jones@linaro.org>,
	<linux-remoteproc@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <kernel@stlinux.com>,
	Suman Anna <s-anna@ti.com>
Subject: Re: [PATCH v2 3/3] remoteproc: core: add rproc ops for memory allocation
Date: Fri, 16 Sep 2016 09:47:29 +0200	[thread overview]
Message-ID: <10b33f31-8e6f-2ea8-87bd-e9725aeacaea@st.com> (raw)
In-Reply-To: <20160915172743.GE21438@tuxbot>



On 09/15/2016 07:27 PM, Bjorn Andersson wrote:
> On Tue 06 Sep 00:39 PDT 2016, Loic Pallardy wrote:
>
>> Remoteproc core is currently using dma_alloc_coherent for
>> carveout and vring allocation.
>> It doesn't allow to support specific use cases like fixed memory
>> region or internal RAM support.
>>
>> Two new rproc ops (alloc and free) is added to provide flexibility
>> to platform implementation to provide specific memory allocator
>> taking into account coprocessor characteristics.
>> rproc_handle_carveout and rproc_alloc_vring functions are modified
>> to invoke these ops if present, and fallback to regular processing
>> if platform specific allocation failed and if resquested memory is
>> not fixed (physical address == FW_RSC_ADDR_ANY)
>>
>> Signed-off-by: Loic Pallardy <loic.pallardy@st.com>
>> ---
>>  drivers/remoteproc/remoteproc_core.c | 67 ++++++++++++++++++++++++++++++------
>>  include/linux/remoteproc.h           |  4 +++
>>  2 files changed, 60 insertions(+), 11 deletions(-)
>>
>> diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c
>> index 0d3c191..7493b08 100644
>> --- a/drivers/remoteproc/remoteproc_core.c
>> +++ b/drivers/remoteproc/remoteproc_core.c
>> @@ -207,19 +207,29 @@ int rproc_alloc_vring(struct rproc_vdev *rvdev, int i)
>>  	struct rproc_vring *rvring = &rvdev->vring[i];
>>  	struct fw_rsc_vdev *rsc;
>>  	dma_addr_t dma;
>> -	void *va;
>> +	void *va = NULL;
>>  	int ret, size, notifyid;
>>
>>  	/* actual size of vring (in bytes) */
>>  	size = PAGE_ALIGN(vring_size(rvring->len, rvring->align));
>>
>> +	rsc = (void *)rproc->table_ptr + rvdev->rsc_offset;
>> +
>>  	/*
>>  	 * Allocate non-cacheable memory for the vring. In the future
>>  	 * this call will also configure the IOMMU for us
>>  	 */
>> -	va = dma_alloc_coherent(dev->parent, size, &dma, GFP_KERNEL);
>> +
>> +	dma = rsc->vring[i].pa;
>> +
>> +	if (rproc->ops->alloc)
>> +		va = rproc->ops->alloc(rproc, size, &dma);
>
> I believe this will be awkward for the remoteproc drivers to implement.
>
> Imagine a driver that programmatically register some fixed positioned
> carveouts and ioremapped vring buffers, it would then need internal book
> keeping to figure out which type of allocation each call is related to.

Yes true like any allocator does. And it is needed to manage region overlap.
>
>
> Rather then deferring the allocation until this point I think we should
> tie a rproc_mem_entry to each vring and once we reach
> rproc_alloc_vring() we simply use "va" and "dma" from that.
>
> We would get this from rproc_parse_vring() checking to find an existing
> mem_entry matching the vring requirements (da, then pa) and falling back
> to allocating a new carveout mem_entry.
>
This doesn't answer to use case described by Suman. What if no specific 
address are requested in firmware resource table, but buffers need to be 
allocated in internal RAM for example. Only rproc driver will know on 
which allocator to rely.

By memremaping a complete memory area and offering va to dma (pa) 
conversion, you don't verify possible overlap between requested regions. 
This is done today by allocator.

The idea from ST pov, was to rely on memory region, to declare subdev 
associated to rproc driver and to rely on dma_alloc_coherent.
I think TI wants to rely on its internal RAM memory allocator.

Regards,
Loic

>
> By then making the current "carveouts" list heterogeneous we would allow
> for arbitrary memory types to be used for backing vrings, as well as
> trace devices, code and data segments.
>
> Regards,
> Bjorn
>

  reply	other threads:[~2016-09-16  7:47 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-06  7:39 [PATCH v2 0/3] Remoteproc: Add predefined coprocessor memory mapping support Loic Pallardy
2016-09-06  7:39 ` Loic Pallardy
2016-09-06  7:39 ` [PATCH v2 1/3] remoteproc: Modify FW_RSC_ADDR_ANY definition Loic Pallardy
2016-09-06  7:39   ` Loic Pallardy
2016-09-06 18:10   ` Bjorn Andersson
2016-09-06  7:39 ` [PATCH v2 2/3] remoteproc: core: transform struct fw_rsc_vdev_vring reserved field in pa Loic Pallardy
2016-09-06  7:39   ` Loic Pallardy
2016-09-06 18:10   ` Bjorn Andersson
2016-09-06  7:39 ` [PATCH v2 3/3] remoteproc: core: add rproc ops for memory allocation Loic Pallardy
2016-09-06  7:39   ` Loic Pallardy
2016-09-08 14:06   ` Lee Jones
2016-09-15 17:27   ` Bjorn Andersson
2016-09-16  7:47     ` loic pallardy [this message]
2016-09-16  7:47       ` loic pallardy
2016-09-16 18:12       ` Bjorn Andersson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=10b33f31-8e6f-2ea8-87bd-e9725aeacaea@st.com \
    --to=loic.pallardy@st.com \
    --cc=bjorn.andersson@linaro.org \
    --cc=kernel@stlinux.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-remoteproc@vger.kernel.org \
    --cc=ohad@wizery.com \
    --cc=s-anna@ti.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.