Recently, I am writing dma driver for xilinx A7 Pcie core. But I encounter a problem, I have to initiate two dma transactions functioning simultaneously to deal with read dma and wirte dma each other, the partial code is here:
in EvtDeviceAdd:
WDF_DMA_ENABLER_CONFIG_INIT( &dmaConfig,
WdfDmaProfileScatterGather,
MAXNLEN );
status = WdfDmaEnablerCreate( Device,
&dmaConfig,
WDF_NO_OBJECT_ATTRIBUTES,
&pDeviceContext->DmaEnabler );
status = WdfDmaTransactionCreate( pDeviceContext->DmaEnabler,
WDF_NO_OBJECT_ATTRIBUTES,
&pDeviceContext->DmaWriteTransaction );
status = WdfDmaTransactionCreate( pDeviceContext->DmaEnabler,
WDF_NO_OBJECT_ATTRIBUTES,
&pDeviceContext->DmaReadTransaction );
in EvtIoCtrl:
status = WdfDmaTransactionInitializeUsingRequest(
pDeviceContext->DmaWriteTransaction,
Request,
xc7a_EvtProgramDma,
WdfDmaDirectionWriteToDevice);
status = WdfDmaTransactionInitializeUsingRequest(
pDeviceContext->DmaReadTransaction,
Request,
xc7a_EvtProgramDma,
WdfDmaDirectionReadFromDevice);
status = WdfDmaTransactionExecute(pDeviceContext->DmaWriteTransaction, WDF_NO_CONTEXT);
status = WdfDmaTransactionExecute(pDeviceContext->DmaReadTransaction, WDF_NO_CONTEXT);
The hardware recieves the data_alpha from write dma and after its own computing with the data, it returns the data_beta to driver from read dma channel. When the read dma finishs, it triggers read dma completion interrupt. Then the driver clear the interrupt and releases two dma transaction and the other aftermath…
But what when EvtIoCtrl executes, the os BSOD. OS: win 7 64bit, kernal develop tool: wdk 7600.
In MSDN, “If the device performs scatter/gather transfers, the operating system can execute multiple DMA transactions simultaneously. In this case, the driver can call WdfDmaTransactionExecute while another transaction is executing.”
Any advises are welcome!