Fix hugepage DMA mapping with IOMMU enabled #191
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Commit
92d8a6b9("Fix memory mapping of user (DMA) buffers") introduceddma_map_single()for obtaining FPGA-accessible DMA addresses, which is necessary for IOMMU support. However, the hugepage path maps only the first 4KB page of each hugepage and then calculates the remaining sub-page IOVAs by addingPAGE_SIZEoffsets. With an IOMMU enabled, IOVA space is not guaranteed to be contiguous, so these calculated addresses can point to unmapped or incorrect regions, causing DMA transfers to hang.This fix maps each 4KB page individually via
dma_map_single()regardless of hugepage backing, and updates all cleanup paths accordingly.Type of change
Tests & Results
Tested with example
09_perf_rdmaon Xilinx U280 with IOMMU enabled. Before the fix, RDMA transfers hang at 256 bytes and above when using hugepage-backed buffers. After the fix, all transfer sizes (64B–4MB) complete successfully.Checklist