I am porting a PCIe driver to the new IODMACommand API (my previous post).
I currently am able to perform DMA accesses, but I cannot seem to release the DART IO mapped addresses properly. After a few thousand requests, the address range is exhausted leading to
- Subsequent mapping requests fail
(mapper-apciec0-3-0-0) IODARTVMAllocatorGeneric::vmAlloc: VM exhausted
(mapper-apciec0-3-0-0) IODARTMapper::iovmMapMemory: Map request failed (0xe00002bd) ...
setMemoryDescriptor() returned kIOReturnNoMemory
- The whole computer usually crashes a few seconds / minutes later with
panic(cpu 1 caller 0xfffffe00283155d8): "pmap_mark_page_as_ppl_page_internal: page is not free, " "pa=0x80fb0c000"
I do not understand what I'm doing wrong. I carefully call prepare and complete on my IODMACommand around DMA accesses.
I check the return code of every call.
I have tried
- creating and releasing a new IODMACommand for each request
- creating and releasing a new IOBufferMemoryDescriptor for each request
- unloading and reloading my kext between each request
Whatever I do, the addresses returned by genIOVMSegments
are increasing and never seem to be reused.
Thanks for your help!