How to use DMA from PCIe Device to Jetson Tx2 local DDR

hi,
Recently ,I work with a FPGA + TX2 platform.
I’d like to use FPGA input data with DMA mode.
I specify a physical memory and give its staring address to FPGA register which was used for save data from FPGA.Then I mmap this address to my program and use it to get data.
This work normally in TX1 but when I move to TX2 it does’t work.

What is the release you are using? It is most likely because SMMU is enabled for PCIe in TX2 releases. So, if you are giving physical address to FPGA’s DMA, it wouldn’t work. Either
a) Use dma_alloc_cohere / dma_map_single kind of APIs to reserve memory and give IOVA/bus address to FPGA’s DMA.
b) Disable SMMU for PCIe thereby making IOVA equivalent to physical address

Hi vidyas,
I reflash my board with Jetpack 3.1 and its release is R28.1.
I would appreciate it if you can describe these two methods in detail.

Hi vidyas,
I adopted your advise of b)Disable SMMU for PCIe thereby making IOVA equivalent to physical address .
I removed the following two lines:

  1. #stream-id-cells = <1>;” from “tegra_pcie” node
  2. “<&{/pcie-controller@10003000} TEGRA_SID_AFI>,” from “smmu” node

But how can I get a safe and effective physical address which will give to FPGA directly.

For the first method a) Use dma_alloc_cohere / dma_map_single kind of APIs to reserve memory and give IOVA/bus address to FPGA’s DMA.
Do you mean I need to write code for driver? Unfortunately,I am not familier with driver programming.So I would prefer if you can give me futher instructions.

Hi vidyas,
@vidyas will you give me further more instructions?

Need for safe physical address arises if FPGA has issues of accessing system memory regions which it shouldn’t.
Anyway, a better thing to do is to enable SMMU for PCIe and refactor your driver to use DMA APIs so that IOVA is available to be given to FPGA.
Please refer to https://www.kernel.org/doc/Documentation/DMA-API.txt on how to use DMA APIs or any PCIe device driver in kernel should give you a hands on of how they are used