0
votes

I'm currently writing a PCIe kernel driver for linux kernel 4.19.
A FPGA (Arria 10) running an Intel DMA IP is connected to the Linux CPU (i7-6700TE) via PCIe Gen 2.
I want to run an upstream DMA transfer from FPGA to CPU RAM.
First the PCIe driver is initialized. I'm using the following instructions in order:

  1. pci_enable_device
  2. pci_set_master
  3. pci_set_mwi
  4. pci_set_dma_mask DMA_BIT_MASK(64)
  5. pci_alloc_consistent

After allocation I push the physical address into the DMA configuration and start the transfer. After finishing I post a MSI, which is received and handeled.
The problem I have is that when reading the DMA data using the virtual address I only read zeros, while not writing any zeros via DMA.
I also tested the memory region by first writing a ramp to memory via CPU, then starting the DMA, then reading again and the ramp remained unchanged, thus I'm quite convinced, that no memory accesses to the specified region happened.
Why does the MSI transfer work (address space CPU), but the RAM access doesn't?
Do you have an idea what to do next?
Thanks in advance for your help.

1

1 Answers

0
votes

Welcome to Unix & Linux StackExchange!

Your question is about Linux kernel programming, and so might be better suited to Stack Overflow instead. But anyway...

Have you read the kernel DMA API HOWTO?

You said you pushed the physical address into the DMA configuration. But a DMA-capable device on the bus needs a different kind of address, since its view of the bus may be different: a "bus address". It may or may not be identical to a physical address, depending on system architecture.