Public bug reported:
FastRPC: IOVA allocation fails for buffers larger than 2 GiB within a
32-bit DMA aperture
Environment
* Hardware: Arduino Ventuno Q
* SoC: Qualcomm QCS8275
* Accelerator: Hexagon HTP V75
* Operating system: Ubuntu 24.04.5 LTS, ARM64
* Original kernel: 6.8.0-1089-qcom
* Kernel source package: linux-qcom, version 6.8.0-1089.94
* QAIRT SDK: 2.49.0.260730
* Workload: DiffRhythm FP16 transformer inference
* Model size: approximately 2.22 GB
Problem description
Large neural network models executed through the Qualcomm QNN HTP
backend may fail during graph execution when the runtime attempts to map
a persistent weights buffer larger than 2 GiB.
Graph composition and finalization complete successfully, but execution
fails with the following errors:
fastrpc memory map for fd: 30 with length: 2225078272 failed with error: 0x1
Mapping buffer fd 30 to FastRpc failed on domain 3
Failed to map weights buffer on host, err 3
Could not allocate persistent weights buffer!
Failed to initialize graph memory
The failure occurs despite sufficient available physical system memory.
The issue was reproduced using both the official qnn-net-run utility and
an independent QNN API-based model runner.
Root cause investigation
System call tracing identified the failing operation:
FASTRPC_IOCTL_MEM_MAP = -1 ENOMEM
Kernel tracing using kprobes subsequently identified the failing
allocation path:
fastrpc_request: fd=30 length=2225078272
iova_request: size=2225078272 dma_limit=0xffffffff
alloc_request: pages=543232 limit_pfn=0xfffff
alloc_result: result=0x0
iova_result: result=0x0
fastrpc_result: result=-12
The failure occurs in the host-side IOMMU allocation path, before the
FastRPC memory mapping request is sent to the DSP.
The relevant allocation path is:
fastrpc_req_mem_map()
-> fastrpc_map_create()
-> fastrpc_map_attach()
-> dma_buf_map_attachment_unlocked()
-> IOMMU DMA mapping
-> iommu_dma_alloc_iova()
-> alloc_iova_fast()
-> alloc_iova()
The FastRPC compute context bank uses a 32-bit DMA mask.
The existing IOVA allocation implementation requests natural size-based
alignment through:
alloc_iova(iovad, size, limit_pfn, true);
For the requested allocation of 543232 pages with a 4096-byte page size,
the resulting alignment requirement is 4 GiB.
This alignment cannot be satisfied within a 32-bit IOVA aperture with a
nonzero starting PFN, even when sufficient contiguous IOVA space is
otherwise available.
Proposed experimental workaround
A narrowly scoped modification was implemented in:
drivers/iommu/dma-iommu.c
The modification bypasses natural size-based alignment only when:
* The allocation size exceeds 2 GiB.
* The effective DMA address limit is exactly 0xffffffff.
* The device is compatible with qcom,fastrpc-compute-cb.
For these allocations, the implementation uses:
range = alloc_iova(iovad, iova_len,
dma_limit >> shift, false);
The original 32-bit DMA addressing restriction is preserved.
All other devices and allocation sizes continue to use the existing
allocation path.
The complete experimental patch is attached for review.
Validation results
A custom kernel was built from the corresponding Ubuntu Qualcomm kernel
source and installed on the same hardware.
The same QNN model, backend, and input files were used without
modification.
Test Original kernel Patched kernel
Graph composition Successful Successful
Graph finalization Successful Successful
Graph execution Failed Successful
The experimental kernel also booted successfully with working Ethernet,
NVMe storage, SSH connectivity and FastRPC device initialization.
Potential impact
This issue may affect other large neural network workloads that require
individual contiguous IOVA mappings exceeding 2 GiB on Qualcomm
platforms with 32-bit FastRPC DMA apertures.
The workaround does not increase the DMA address width or remove other
hardware memory constraints.
Request for maintainer review
We would appreciate feedback on:
1. Whether natural size-based IOVA alignment is required for these large
FastRPC allocations.
2. Whether the proposed device-specific workaround is appropriate.
3. Whether a generic fallback allocation strategy would be preferable.
4. Whether an official fix could be incorporated into future Ubuntu Qualcomm
kernel releases.
The proposed patch is experimental. Broader regression testing and
review of allocator behavior are required before considering it suitable
for production or upstream inclusion.
** Affects: linux-qcom (Ubuntu)
Importance: Undecided
Status: New
** Patch added: "fastrpc-large-iova.patch"
https://bugs.launchpad.net/bugs/2190839/+attachment/6025176/+files/fastrpc-large-iova.patch
--
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/2190839
Title:
FastRPC: IOVA allocation fails for buffers larger than 2 GiB within a
32-bit DMA aperture
To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/linux-qcom/+bug/2190839/+subscriptions
--
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs