IoAllocateMdl() vs MmAllocatePagesForMdl()

>Too bad MS have not explicitly provide this function with Offset/Length, not
nonsensial VirtualAddress

Tape.sys stack sends SRBs with the buffer VA within the original MDL they pass down. Unlike disk stack, they don’t build partial MDLs. Using offsets would not be right, because the transfer will start on non-zero offset.

Hi guys,
a few days ago I solved this problem with allocation. For other people this is working sequence. I use this sequence for allocation/deallocation of both buffer. Only data buffer is mapped to user space.
I tested it many times in cycle on 32/64 bit computer.

thanks,Ondrej

allocation

  1. IoGetDmaAdapter
  2. MmAllocatePagesForMdl
  3. MmGetSystemAddressForMdlSafe
  4. GetScatterGatherList
  5. MmMapLockedPagesSpecifyCache(…,UserMode,…) - only for data buffer

…scatter/gather dma transfer…

deallocation

  1. PutScatterGatherList
  2. MmUnmapLockedPages - only for data buffer
  3. MmFreePagesFromMdl
  4. IoFreeMdl
  5. PutDmaAdapter

> 3) MmGetSystemAddressForMdlSafe

No need in this at all in DMA scenarios, you’re wasting performance and kernel resources.


Maxim S. Shatskih
Microsoft MVP on File System And Storage
xxxxx@storagecraft.com
http://www.storagecraft.com

Hi Maxim,
you are right.

Thanks , Ondrej