UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Adventurer
Adventurer
1,596 Views
Registered: ‎11-05-2014

AMP and DMA

I'm running an AMP system, with Linux on cpu0 and a bare-metal application on cpu1.  They are using OpenAMP to communicate, as well as two data buffers in DDR RAM that are marked as uncached and shareable in the MMU.  The DMA ping-pongs between the two buffers when doing DMA transfers and when a transfer is complete, the bare-metal cpu1 application sends a notification via rpmsg to Linux on cpu0.  On this notification, Linux accesses the DMA buffer (via the dmem-uio driver) and when it has completed processing the data buffer, an rpmsg is sent back to cpu1 to release the buffer for the next DMA transfer.

 

The issue I'm having is when DMA is used by the bare-metal application, the rpmsg data in OpenAMP will sometimes get corrupted.  When DMA is not used (dummy data is produced by cpu1), the system apparently works fine.

 

I've taken pains to ensure the DMA is not writing outside of the two ping pong buffers.  Only cpu0-to-cpu1 rpmsg data seems to be affected and the nature of the corruption is also specific.  The rpmsg data for different cpu0-to-cpu1 messages seems to get combined.  This would seem to point to a concurrency issue on Linux writing to the rpmsg device, but I have also verified that only one process and one thread is writing to the rpmsg device from Linux.  Plus we don’t see this issue unless DMA is being used.

 

Any help or suggestions for further debugging appreciated.

0 Kudos
3 Replies
Contributor
Contributor
1,551 Views
Registered: ‎03-03-2017

Re: AMP and DMA

First of all, I want to apologize for writing here without being able to help you. The reason for adding noise in your thread is because I'm just developing the same application (but still far from getting to where you are) and I only wanted to kindly ask you to share the configuration used in "system-user.dtsi"  to define the uncached shareable portion of DDR RAM. I'm quite newbe with Linux and the only site I've found a suitable description of the device tree is here, although I still have many doubts. Thank you very much.

0 Kudos
Adventurer
Adventurer
1,453 Views
Registered: ‎11-05-2014

Re: AMP and DMA

I have these nodes in my device tree:

 

cpu1app: cpu1app@0 {
    compatible = "xlnx,zynq_remoteproc";
    reg = < 0x1E000000 0x2000000 >;
    interrupt-parent = <&ps7_scugic_0>;
    interrupts = < 0 27 4   0 29 4   0 30 4   0 31 4   0 32 4   0 37 4   0 38 4   0 39 4 >;
    firmware = "cpu1app.elf";
    vring0 = <15>;
    vring1 = <14>;
} ;

dmabuf1 {
    compatible = "dmem-uio";
    reg = < 0x1E700000 0x800000>;
}

dmabuf2 {
    compatible = "dmem-uio";
    reg = < 0x1F200000 0x800000>;
}

 

I'm using the dmem-uio driver to read the DMA buffers in DDR RAM.  Now, I'm not sure where/if Linux marks the memory as noncacheable/shareable.  When I mentioned the buffers are marked as noncacheable/shareable in my original post, it was being done by cpu1 in boot.S file in the BSP.  But the DMA data is coming across fine.  The corruption I'm seeing occurs in the rpmsg area for cpu0-to-cpu1 messages.

 

 

Visitor garfy123
Visitor
965 Views
Registered: ‎01-31-2018

Re: AMP and DMA

Hi, just wondering if you have resolved this problem? If so, could you kindly share? Thanks.
0 Kudos