xxxxx@gmail.com wrote:
The buffer is allocated using ExAllocatePoolWithTag and filled with content read from a file.
mdl is created using IoAllocateMdl call with the above buffer
mdl is then passed to WDTI
A commonbuffer for write was allocated earlier in EvtDeviceAdd
I can’t do scatter/gather.
Then you should fire your hardware engineers.  No PCIe design in the
21st Century should ever be built without scatter/gather.
Now, my confusion, how is commonbuffer is used or connected with WdfDmaTransaction object? In EvtProgramDma, WdfDmaTransactionGetBytesTransferred returns 0 and the commonbuffer is empty.
There’s no connection between them. The common buffer is just another
way of allocating memory. It only gets used if you use it, and right
now you aren’t using it.
Here’s what happens now. You have your ExAllocatePoolWithTag (which, I
hope, is non-paged pool?) buffer, which is not physically contiguous.Â
When you pass that to WdfDmaTransactionInitialize, it’s going to call
your callback multiple times, once for each page in the transfer. Your
callback will set up and trigger the DMAs, one page at a time. As you
get the DMA completion interrupts, you call
WdfDmaTransactionDmaCompleted, and KMDF will call your callback again
for the next page. The common buffer is not involved.
As long as you have the common buffer, why don’t you just read the file
into the common buffer? Then you can do the entire thing as one
transfer. With a common buffer, there is really no need to use a
WdfDmaTransaction at all.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.