Allow remote to specify shared memory
cover Allow remote to specify shared memory
This patch enables the remoteproc to specify the shared memory. Remoteproc declared this memory as DMA memory.
It can be used for virtio, or shared buffers.
Wendy Liang (3):
remoteproc: add rproc mem resource entry
remoteproc: add rproc_mem resource entry handler
remoteproc: Release DMA declare mem when cleanup rsc
drivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++++++++++++ include/linux/remoteproc.h | 23 ++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)
Signature · 1 line
1.9.1
RFC PATCH 1/3 remoteproc: add rproc mem resource entry
From: Wendy Liang <[email protected]>
Add a resource entry to the resource table to tells the host the remote processor's memory which can be used as shared memory.
--- include/linux/remoteproc.h | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-)
include/linux/remoteproc.h +22 -1
@@ -115,7 +115,8 @@ enum fw_resource_type {RSC_DEVMEM =1 ,RSC_TRACE =2 ,RSC_VDEV =3 , - RSC_LAST = 4, +RSC_RPROC_MEM =4 , + RSC_LAST = 5, };#define FW_RSC_ADDR_ANY (-1)
@@ -306,6 +307,26 @@ struct fw_rsc_vdev { } __packed;/** +* struct fw_rsc_rproc_mem - remote processor memory +* @da: device address +* @pa: physical address +* @len: length (in bytes) +* @reserved: reserved (must be zero) +* +* This resource entry tells the host to the remote processor +* memory that the host can be used as shared memory. +* +* These request entries should precede other shared resource entries +* such as vdevs, vrings. +*/ +struct fw_rsc_rproc_mem { +u32 da; +u32 pa; +u32 len; +u32 reserved; +} __packed; + +/** * struct rproc_mem_entry - memory entry descriptor * @va: virtual address * @dma: dma address
Signature · 1 line
1.9.1
RFC PATCH 2/3 remoteproc: add rproc_mem resource entry handler
In reply to Wendy LiangFrom: Wendy Liang <[email protected]>
Add resource table handler to handle fw_rsc_rproc_mem entry.
--- drivers/remoteproc/remoteproc_core.c | 37 ++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+)
drivers/remoteproc/remoteproc_core.c +37 -0
@@ -720,6 +720,42 @@ static int rproc_handle_carveout(struct rproc *rproc,return ret; } +/** +* rproc_handle_rproc_mem() - handle remote processor memory +* @rproc: rproc handle +* @rsc: the resource entry +* @avail: size of available data (for image validation) +* +* This function will handle declare the remote procesor's memory +* as DMA memory of the remoteproc, and then, the host can use it +* as shared memory, e.g. vrings ahre shared buffers. +*/ +static int rproc_handle_rproc_mem (struct rproc *rproc, +struct fw_rsc_rproc_mem *rsc, +int offset,int avail) +{ +struct device *dev = &rproc->dev; +int ret; + +if (sizeof (*rsc) > avail) { +dev_err (dev,"rproc_mem rsc is truncated\n" ); +return -EINVAL ; + } + +if (rsc->pa ==FW_RSC_ADDR_ANY ) { +dev_err (dev,"not able to declare rproc mem, pa is 0x%x\n" , + rsc->pa); +return -EINVAL ; + } + ret =dma_declare_coherent_memory (dev->parent, rsc->pa, + rsc->pa, rsc->len,DMA_MEMORY_MAP ); +if (!ret) { +dev_err (dev,"failed to declare rproc mem as DMA mem.\n" ); +return -ENOMEM ; + } +return 0 ; +} +/* * A lookup table for resource handlers. The indices are defined in * enum fw_resource_type.
@@ -729,6 +765,7 @@ static int rproc_handle_carveout(struct rproc *rproc, [RSC_DEVMEM] = (rproc_handle_resource_t)rproc_handle_devmem, [RSC_TRACE] = (rproc_handle_resource_t)rproc_handle_trace, [RSC_VDEV] = (rproc_handle_resource_t)rproc_handle_vdev, + [RSC_RPROC_MEM] = (rproc_handle_resource_t)rproc_handle_rproc_mem, };/* handle firmware resource entries before booting the remote processor */
Signature · 1 line
1.9.1
RFC PATCH 3/3 remoteproc: Release DMA declare mem when cleanup rsc
In reply to Wendy LiangFrom: Wendy Liang <[email protected]>
Release the declared DMA memory in the end of resource cleanup.
--- drivers/remoteproc/remoteproc_core.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/remoteproc/remoteproc_core.c +3 -0
@@ -882,6 +882,9 @@ static void rproc_resource_cleanup(struct rproc *rproc)/* clean up remote vdev entries */ list_for_each_entry_safe (rvdev, rvtmp, &rproc->rvdevs, node)kref_put (&rvdev->refcount, rproc_vdev_release); + +/* Release declared DMA memory */ +dma_release_declared_memory (dev->parent); }/*
Signature · 1 line
1.9.1
Hi Wendy,
Quoted 3 lines · Wendy Liang
This patch enables the remoteproc to specify the shared memory. Remoteproc declared this memory as DMA memory.
It can be used for virtio, or shared buffers.
You should be able to achieve this without any remoteproc core changes. You can do this by defining a reserved-memory node in your DTS file (can be a CMA pool or a DMA pool), assigning the node using memory-region in your remoteproc DT node and using the function, of_reserved_mem_device_init() in your remoteproc driver.
regards
Suman
Quoted 10 lines
Wendy Liang (3):
remoteproc: add rproc mem resource entry
remoteproc: addrproc_memresource entry handler
remoteproc: Release DMA declare mem when cleanup rscdrivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++++++++++++ include/linux/remoteproc.h | 23 ++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)
Thanks Suman for your comments.
Quoted 7 lines · Suman Anna
Hi Wendy,
Quoted 3 lines · Wendy Liang
This patch enables the remoteproc to specify the shared memory. Remoteproc declared this memory as DMA memory.
It can be used for virtio, or shared buffers.
Quoted 5 lines
You should be able to achieve this without any remoteproc core changes. You can do this by defining a reserved-memory node in your DTS file (can be a CMA pool or a DMA pool), assigning the node using memory-region in your remoteproc DT node and using the function,
of_reserved_mem_device_init()in your remoteproc driver.
The idea to introduce the rproc_mem is to let the remote to specify the shared memory.
I am trying to see if there is a way to specify this software attribute without touching the device tree as it doesn't look like it is hardware related. And try to see if there is a way that when I change the firmware, i don't need to change the device tree.
Thanks,
Wendy
Quoted 19 lines
regards
SumanQuoted 10 lines
Wendy Liang (3):
remoteproc: add rproc mem resource entry
remoteproc: addrproc_memresource entry handler
remoteproc: Release DMA declare mem when cleanup rscdrivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++++++++++++ include/linux/remoteproc.h | 23 ++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Wendy,
Quoted 16 lines · Wendy Liang
Thanks Suman for your comments.
Quoted 7 lines · Suman Anna
Hi Wendy,
Quoted 3 lines · Wendy Liang
This patch enables the remoteproc to specify the shared memory. Remoteproc declared this memory as DMA memory.
It can be used for virtio, or shared buffers.Quoted 5 lines
You should be able to achieve this without any remoteproc core changes. You can do this by defining a reserved-memory node in your DTS file (can be a CMA pool or a DMA pool), assigning the node using memory-region in your remoteproc DT node and using the function,
of_reserved_mem_device_init()in your remoteproc driver.
Quoted 6 lines
The idea to introduce the
rproc_memis to let the remote to specify the shared memory.
I am trying to see if there is a way to specify this software attribute without touching the device tree as it doesn't look like it is hardware related. And try to see if there is a way that when I change the firmware, i don't need to change the device tree.
So is this shared memory going to be accessed through an MMU by the remote processor? If not, don't you need a specific carveout, which would then in turn mean boot-time memory reservation?
regards
Suman
Quoted 23 lines
Thanks,
WendyQuoted 19 lines
regards
SumanQuoted 10 lines
Wendy Liang (3):
remoteproc: add rproc mem resource entry
remoteproc: addrproc_memresource entry handler
remoteproc: Release DMA declare mem when cleanup rscdrivers/remoteproc/remoteproc_core.c | 40 ++++++++++++++++++++++++++++++++++++ include/linux/remoteproc.h | 23 ++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Suman,
Quoted 31 lines
-----Original Message-----
From: Suman Anna [mailto:[email protected]]
Sent: Tuesday, March 28, 2017 4:24 PM
To: Wendy Liang
Cc: Jiaying Liang; Bjorn Andersson; [email protected]; linux- [email protected]; Jiaying Liang
Subject: Re: [RFC LINUX PATCH 0/3] Allow remote to specify shared memoryHi Wendy,
Quoted 16 lines · Wendy Liang
Thanks Suman for your comments.
Quoted 7 lines · Suman Anna
Hi Wendy,
Quoted 3 lines · Wendy Liang
This patch enables the remoteproc to specify the shared memory. Remoteproc declared this memory as DMA memory.
It can be used for virtio, or shared buffers.Quoted 5 lines
You should be able to achieve this without any remoteproc core changes. You can do this by defining a reserved-memory node in your DTS file (can be a CMA pool or a DMA pool), assigning the node using memory-region in your remoteproc DT node and using the function,
of_reserved_mem_device_init()in your remoteproc driver.Quoted 4 lines
The idea to introduce the
rproc_memis to let the remote to specify the shared memory.
I am trying to see if there is a way to specify this software attribute without touching the device tree as it doesn't look like it is
Quoted 7 lines
hardware related.
Quoted 2 lines
And try to see if there is a way that when I change the firmware, i don't need to change the device tree.
So is this shared memory going to be accessed through an MMU by the remote processor? If not, don't you need a specific carveout, which would then in turn mean boot-time memory reservation?
[Wendy] This memory is not accessed through MMU by remote.
Here is the usecase, the number of remotes can be changed at run time, Also the firmware running on the remotes can be changed. And the remote will Need to memory map those memory before it can use it.
From what you have suggested, we reserved memory from the device node, and then remoteproc driver linked to that reserved memory with "memory-region", I suppose different remoteproc drivers can share one "memory-region". However, now the question is how the remote knows the shared memory. Let say I use rpmsg for the communication between the two. But how can remote knows about the shared buffers before it can used it.
I saw Loic has a patch to add virtio config to specify this buffer, however, it is not in the latest linux kernel master. And thus, trying to see if there is another way to solve this issue. Use existing carveout to specify this memory?
Thanks,
Wendy
Quoted 24 lines
regards
SumanQuoted 15 lines
Thanks,
WendyQuoted 11 lines
regards
SumanQuoted 7 lines
Wendy Liang (3):
remoteproc: add rproc mem resource entry
remoteproc: addrproc_memresource entry handler
remoteproc: Release DMA declare mem when cleanup rscdrivers/remoteproc/remoteproc_core.c | 40++++++++++++++++++++++++++++++++++++
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
include/linux/remoteproc.h | 23 ++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)
Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in the body of a message to [email protected] More majordomo info at
This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
Quoted 67 lines
-----Original Message-----
From: [email protected] [mailto:linux-remoteproc- [email protected]] On Behalf Of Jiaying Liang
Sent: Wednesday, March 29, 2017 6:41 PM
To: Suman Anna <[email protected]>; Wendy Liang <[email protected]>
Cc: Bjorn Andersson <[email protected]>; linux- [email protected]; [email protected]
Subject: RE: [RFC LINUX PATCH 0/3] Allow remote to specify shared memoryHi Suman,
Quoted 9 lines
-----Original Message-----
From: Suman Anna [mailto:[email protected]]
Sent: Tuesday, March 28, 2017 4:24 PM
To: Wendy Liang
Cc: Jiaying Liang; Bjorn Andersson; [email protected]; linux- [email protected]; Jiaying Liang
Subject: Re: [RFC LINUX PATCH 0/3] Allow remote to specify shared memoryQuoted 14 lines
Hi Wendy,
Quoted 11 lines · Wendy Liang
Thanks Suman for your comments.
Quoted 8 lines · Suman Anna
Hi Wendy,
Quoted 3 lines · Wendy Liang
This patch enables the remoteproc to specify the shared memory. Remoteproc declared this memory as DMA memory.
It can be used for virtio, or shared buffers.You should be able to achieve this without any remoteproc core
changes.
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
You can do this by defining a reserved-memory node in your DTS file (can be a CMA pool or a DMA pool), assigning the node using memory-region in your remoteproc DT node and using the function,
of_reserved_mem_device_init()in your remoteproc driver.The idea to introduce the
rproc_memis to let the remote to specify the shared memory.
I am trying to see if there is a way to specify this software attribute without touching the device tree as it doesn't look like it isQuoted 7 lines
hardware related.
Quoted 2 lines
And try to see if there is a way that when I change the firmware, i don't need to change the device tree.
So is this shared memory going to be accessed through an MMU by the remote processor? If not, don't you need a specific carveout, which would then in turn mean boot-time memory reservation?
[Wendy] This memory is not accessed through MMU by remote.
Here is the usecase, the number of remotes can be changed at run time, Also the firmware running on the remotes can be changed. And the remote will Need to memory map those memory before it can use it.From what you have suggested, we reserved memory from the device node, and then remoteproc driver linked to that reserved memory with "memory- region", I suppose different remoteproc drivers can share one "memory- region". However, now the question is how the remote knows the shared memory.
Let say I use rpmsg for the communication between the two. But how can remote knows about the shared buffers before it can used it.
Quoted 4 lines
I saw Loic has a patch to add virtio config to specify this buffer, however, it is not in the latest linux kernel master. And thus, trying to see if there is another way to solve this issue. Use existing carveout to specify this memory?
Hi Wendy,
Potential issue with this proposal if the order resource table is proceed. This memory region should be assigned to device driver first before starting any allocation. Moreover you can assign only one region to a device. But you need different memory regions with different attributes: one for firmware and one for vring for example. That's why we propose sub-dev mechanism some months ago.
I think we need to find a central mechanism to manage "fixed" memory region for firmware (carveout) vring as both are handled by rproc. For rpmsg buffer, one proposal will be to assigned a dedicated region to vring device as mentioned in
"[PATCH v4 0/5] virtio_rpmsg: make rpmsg channel configurable" cover letter.
It will be rproc responsibility to provide this specific memory region based either on DT or an firmware resource table information to virtio device.
Regards,
Loic
Quoted 44 lines
Thanks,
WendyQuoted 24 lines
regards
SumanQuoted 15 lines
Thanks,
WendyQuoted 11 lines
regards
SumanQuoted 7 lines
Wendy Liang (3):
remoteproc: add rproc mem resource entry
remoteproc: addrproc_memresource entry handler
remoteproc: Release DMA declare mem when cleanup rscdrivers/remoteproc/remoteproc_core.c | 40++++++++++++++++++++++++++++++++++++
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
include/linux/remoteproc.h | 23 ++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in the body of a message to [email protected] More majordomo info atThis email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.
N r y b X ǧv ^ ){.n + { 騵 k ȧ ܨ} Ơz &j:+v zZ+ +zf h ~ i z w ?
& )ߢf
HI Loic,
Quoted 82 lines
-----Original Message-----
From: Loic PALLARDY [mailto:[email protected]]
Sent: Wednesday, March 29, 2017 11:57 AM
To: Jiaying Liang; Suman Anna; Wendy Liang
Cc: Bjorn Andersson; [email protected]; linux- [email protected]
Subject: RE: [RFC LINUX PATCH 0/3] Allow remote to specify shared memoryQuoted 28 lines
-----Original Message-----
From: [email protected] [mailto:linux-remoteproc- [email protected]] On Behalf Of Jiaying Liang
Sent: Wednesday, March 29, 2017 6:41 PM
To: Suman Anna <[email protected]>; Wendy Liang <[email protected]>
Cc: Bjorn Andersson <[email protected]>; linux- [email protected]; [email protected]
Subject: RE: [RFC LINUX PATCH 0/3] Allow remote to specify shared memoryHi Suman,
Quoted 16 lines
-----Original Message-----
From: Suman Anna [mailto:[email protected]]
Sent: Tuesday, March 28, 2017 4:24 PM
To: Wendy Liang
Cc: Jiaying Liang; Bjorn Andersson; [email protected];
linux- [email protected]; Jiaying Liang
Subject: Re: [RFC LINUX PATCH 0/3] Allow remote to specify shared memoryHi Wendy,
Quoted 3 lines · Wendy Liang
Thanks Suman for your comments.
On Mon, Mar 27, 2017 at 8:54 AM, Suman Anna <[email protected]>
Quoted 39 lines · wrote:
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Hi Wendy,
Quoted 3 lines · Wendy Liang
This patch enables the remoteproc to specify the shared memory. Remoteproc declared this memory as DMA memory.
It can be used for virtio, or shared buffers.You should be able to achieve this without any remoteproc core
changes.
Quoted 10 lines
Quoted 10 lines
Quoted 4 lines
You can do this by defining a reserved-memory node in your DTS file (can be a CMA pool or a DMA pool), assigning the node using memory-region in your remoteproc DT node and using the function,
of_reserved_mem_device_init()in your remoteproc driver.The idea to introduce the
rproc_memis to let the remote to specify the shared memory.
I am trying to see if there is a way to specify this software attribute without touching the device tree as it doesn't look like it isQuoted 7 lines
hardware related.
Quoted 2 lines
And try to see if there is a way that when I change the firmware, i don't need to change the device tree.
So is this shared memory going to be accessed through an MMU by the remote processor? If not, don't you need a specific carveout, which would then in turn mean boot-time memory reservation?
[Wendy] This memory is not accessed through MMU by remote. Here is the usecase, the number of remotes can be changed at run time, Also the firmware running on the remotes can be changed. And the remote will Need to memory map those memory before it can use it.
From what you have suggested, we reserved memory from the device node, and then remoteproc driver linked to that reserved memory with "memory- region", I suppose different remoteproc drivers can share one "memory- region". However, now the question is how the remote knows the shared memory.
Let say I use rpmsg for the communication between the two. But how can remote knows about the shared buffers before it can used it.Quoted 4 lines
I saw Loic has a patch to add virtio config to specify this buffer, however, it is not in the latest linux kernel master. And thus, trying to see if there is another way to solve this issue. Use existing carveout to specify this memory?
Quoted 5 lines
Hi Wendy,
Potential issue with this proposal if the order resource table is proceed. This memory region should be assigned to device driver first before starting any allocation.
[Wendy] User will need to put it to the first entry in the resource table. So that It can be declared first before device driver to allocate memory.
Quoted 4 lines
Moreover you can assign only one region to a device. But you need different memory regions with different attributes: one for firmware and one for vring for example.
That's why we propose sub-dev mechanism some months ago.
[Wendy] Just in our case, we only use virtio devices. But I agree, there can be Limitations if you have other sub-devices.
Quoted 8 lines
I think we need to find a central mechanism to manage "fixed" memory region for firmware (carveout) vring as both are handled by rproc. For rpmsg buffer, one proposal will be to assigned a dedicated region to vring device as mentioned in "[PATCH v4 0/5]
virtio_rpmsg: make rpmsg channel configurable" cover letter.
It will be rproc responsibility to provide this specific memory region based either on DT or an firmware resource table information to virtio device.
[Wendy] Just the virtio_rpmsg is not in the latest Linux kernel master. Is there Any plan to apply the patch?
I agree we need to find a central mechanism to manage "fixed" memory.
Here are some questions:
* Shall we reuse carveout resource for "fixed" memory?
* Although "fixed" memory doesn't sound like the same as "carveout" memory to me.
We may consider "fixed" memory as carveout resource with pre-defined addresses. Is this ok?
* How to linked the fixed memory to the target device (e.g. virtio device)?, Can we use "name" of the memory resource?
* how to "formalize" the name? "virtio_<id>"?
Maybe Bjorn can provide some suggestions on the "fixed" memory solution.
Thanks,
Wendy
Quoted 45 lines
Regards,
LoicQuoted 36 lines
Thanks,
WendyQuoted 24 lines
regards
SumanQuoted 15 lines
Thanks,
WendyQuoted 11 lines
regards
SumanQuoted 7 lines
Wendy Liang (3):
remoteproc: add rproc mem resource entry
remoteproc: addrproc_memresource entry handler
remoteproc: Release DMA declare mem when cleanup rscdrivers/remoteproc/remoteproc_core.c | 40++++++++++++++++++++++++++++++++++++
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
include/linux/remoteproc.h | 23 ++++++++++++++++++++- 2 files changed, 62 insertions(+), 1 deletion(-)Quoted 5 lines
Quoted 4 lines
Quoted 4 lines
--
To unsubscribe from this list: send the line "unsubscribe linux-remoteproc" in the body of a message to [email protected] More majordomo info atQuoted 6 lines
This email and any attachments are intended for the sole use of the named
recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any
Quoted 5 lines
attachments immediately.
Quoted 2 lines
N r y b X ǧv ^ ){.n + { 騵 k ȧ ܨ} Ơz &j:+v zZ+ +zf h ~ i
z w ?
Quoted 1 line
& )ߢf
This email and any attachments are intended for the sole use of the named recipient(s) and contain(s) confidential information that may be proprietary, privileged or copyrighted under applicable law. If you are not the intended recipient, do not read, copy, or forward this email message or any attachments. Delete this email message and any attachments immediately.