DMA Adapter in filter driver

Dear Experts,

I have a secondary storage device. I would like to pre-allocate certain non-paged memory pool of 4KB in my disk lower filter driver. I need to get also the physical address of those pools to do DMA transaction. The purpose is to send additional information apart from IO buffer to the device in every IO. I have considered 3 options.

  1. Allocate memory in filter driver (Lookaside list) and get the physical address using DMA APIs (BuildScatterGatherList) during driver init. To do this, I need DMA adapter object. Can I create additional DMA adapter object in disk lower filter or storport upper filter driver. Ideally, storport would have created one for servicing miniport.

  2. Allocate memory in miniport driver and get the physical address using StorPortBuildScatterGatherList() in driver init. Pass these buffer list to the disk filter in an IOCTL. The problem here is, if the pool is exhausted, then I need to communicate miniport to create more on demand.

  3. Do not worry about DMA APIs. Just allocate 4KB aligned Non-Paged buffers with LookAsideList and use MmGetPhysicalAddress() to get physical address. Will this work in 32/64 bit systems VM and Non-VM case with my device capable to access entire DRAM for DMA.


If you have a disk lower filter driver why not just
use MmBuildMdlForNonPagedPool and create srb’s to send to your storport
device? See the ClassPnP storage driver code here:

Mark Roddy

Never do DMA using an address you get from MmGetPhysicalAddress. In Windows we don’t do DMA to physical addresses. What’s worse is if you try it, it may work on one system but not on another. Anytime and IOMMU is involved, using the Physical Address will fail.

Use the DMA apis… or do as Mr Roddy suggests. But do not use ththe physical address.



Actually, in my disk lower filter, I would prepare SRB with MDL for DataBuffer for R/W using MmBuildMdlForNonPagedPool. This data buffer is accessible in miniport with Srb->DataBuffer and I can get Scatter Gather List for this using StorPortGetScatterGatherList.

So, this method is not possible for additional information which is NOT sent to miniport as part of SRB->DataBuffer. I would have to use some private path from filter to miniport to share these buffers for DMA.

Yes, I do not want to use MmGetPhysicalAddress. Can I create one more DMA adapter object in upper filter driver for storport to use DMA APIs to build scatter gather list?