32 bit PCI DMA
On my Linux system with over 16 GB of RAM, I would like to allocate about 100 MB of space, which:
- is physically contiguous. Ideally, all the 100MB would be physically contiguous, but I'm also OK with using HUGEPAGEs so that each 2MB is physically contiguous. - can be used as a DMA target, with the 32 bit PCI space, not the 64 bit.This will allow us to use the shorter header for the PCIe transactions which saves a bit of bandwidth. - is accessible from userspace programs (not just from kernel drivers). I think the use of HUGEPAGEs and mmap can achieve the 1st (partial contiguity up to 2 MB at a time) and 3rd constraints (user space access through mmap), but I'm not sure how to ensure that the 2nd constraint (32 bit DMA) is guaranteed. Thanks in advance for your help. |
If you are running a 64 bit kernel then just use 64 bit dma. Otherwise plan on some late nights and hair loss.
|
Thanks. I don't have much hair left, so it's good advice to keep in mind.
All the same, I would have thought that pci_set_dma_mask(gDev, DMA_BIT_MASK(32)) would allow me to use only 32-bit DMA. What am I missing? |
I don't argue with people on the internet, so let me just ask a question. If the device doing the DMA handles 64 bit addresses, what are you planning on putting in the top 32?
|
The upper 32 bits will contain 0. The device (an FPGA) will pick the appropriate addressing cycle, based on the value of the upper 32 bits.
|
When I try using pci_set_dma_mask(32), and then pci_map_sg() on a page, it returns a failure, even for small sizes. So, it doesn't sound like this scheme will work, although I can't explain why.
|
All times are GMT -5. The time now is 10:10 PM. |