Hi All,
So I’m slowly eeking my way towards getting scatter/gather DMA working on my bus/master PCIe device. I’m trying to use GetScatterGatherListEx() with the DMA_SYNCHRONOUS_CALLBACK flag enabled. I’d prefer to use it without the callback (parameter ExecutionRoutine == NULL, parameter ScatterGatherList != NULL), but using it with the callback (parameter ExecutionRoutine != NULL, parameter ScatterGatherList == NULL) is OK too. I’ve got it working both with and without the callback and I’ve verified that the SCATTER_GATHER_LIST returned makes sense for the MDL I’m passing in for both cases. The problem I’m having is that after using this function, my driver blue screens the system when it is unloaded (when I call PutDmaAdapter() to deallocate the adapter I created with IoGetDmaAdapter()). I presume that means I am leaking some resource. That’s not terribly surprising as I’m finding the documentation for GetScatterGatherListEx() really confusing in terms of what I have to deallocate and what is and isn’t a singleton per DMA_ADAPTER object. So does anybody know (for the case of no callback, with callback or both):
- Do you need to call PutScatterGatherList()?
- Do you need to call FreeAdapterObject(), and if so, with what value for the AllocationAction parameter?
- Does using FreeAdapterObject() absolve you of the responsibility of calling PutDmaAdapter()? Or must you still call PutDmaAdapter()?
- Does using FreeAdapterObject() reset the DMA_ADAPTER object such that it’s in the same usable state as right after calling IoGetDmaAdapter()?
- Must you call InitializeDmaTransferContext() after each DMA transaction before you reuse the DMA transfer context buffer again or just once to initialize it?
- If you are using multiple DMA channels simultaneously (for example, I have 4 H2C and 4 C2H channels on my device), is it ok to call GetScatterGatherListEx() multiple times on the same DMA_ADAPTER before completing a previous DMA transaction started with GetScatterGatherListEx() (ie calling PutScatterGatherList() and/or FreeAdapterObject() to complete the transaction)?
- If not, can you call IoGetDmaAdapter() multiple times and have a DMA_ADAPTER for each DMA channel (8 in my case) and use these separate DMA_ADAPTER objects simultaneously for multiple concurrent DMA transfers.
Thanks,
Omri