xxxxx@gmail.com wrote:
The reason why we don’t want to do DMA from device is because we are doing some analysis for some cases in which host does the transfer and not the device.
Well, I think your analysis is complete. When the host does the
transfer, the TLP size will never be larger than 4.
Â
This is the actual Problem that we are facing:
Data copy is done in the DPC. During data copy from device to host, using StorPortMoveMemory, the DPC runs for a long time than its scheduled maximum of 100 microsecs. This causes the OS to hang. For this reason wanted to do a DMA from host so as to avoid stalling in the processor.
That has very little to do with TLP size and more to do with raw
bandwidth. Regardless of TLP size, 100us is only enough time to copy
100kB over a PCIe 3.0 x1 device. If you need to copy more, you either
need to defer it to a lower-priority thread, or do it with device DMA.
Approach 1 :
- Using StorportAllocateMDL to create MDL for Device buffer.
- Using StorPortBuildScatterGatherList to do DMA.
I assume you are just abbreviating here, and that you realize
StorPortBuildScatterGatherList doesn’t actually do DMA. It just gives
you the page numbers you need to create DMA descriptors for your
hardware’s DMA engine. You still have to set up and fire that operation
yourself.
Assuming the device is doing the DMA, you don’t need an MDL for the
device buffer. The device knows its own destination, and device memory
is always physically contiguous. The scatter/gather list is for the
system memory buffer.
Approach 2:
- Using IoGetDmaAdapter to get DmaAdapter from PDO
- Using InitializeDmaTransferContext to initialize the DMA Transfer
- Using AllocateAdapterChannelEx to allocate resources for DMA Transfer
- Using MapTransferEx to do the DMA
My same “abbreviation” comment applies to MapTransferEx. What you’ve
described here is essentially what StorPorBuildScatterGatherList does,
but without using kernel-specific APIs.
Is any of the approach correct? If yes, is any of the approaches feasible in StorPort Miniport Driver? If not, are there any more DMA API’s which can be used to do the same?
StorPortBuildScatterGatherList should be fine. You just need to build
your descriptors and fire the DMA.
–
Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.