How to deal with two dmatransaction?

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!

PCIe devices use bus master, they don’t rely on system controller. Whether your read DMA and write DMA run serially or in parallel, is completely under your control. If you want your device to receive data first, process it, and send data back to the host, you just program your device in such sequence.

When you say BSOD, you need to post your “!analyze -v” output, or, at least, bugcheck codes.

xxxxx@live.com wrote:

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,

This doesn’t make sense. Can you describe in more detail what exactly
should happen here?

As it is, you are initializing two DMA transactions from the same
request. Are you expecting that your device will read the buffer,
modify it, and then write it back out? If so, then this is not actually
two simultaneous transactions. The write-back cannot happen until the
read and the processing are complete.

Are there two DMA engines in your hardware? Or is it just one engine
that switches directions? If your hardware does need to intermix reads
and writes from the buffer, you still don’t need two DMA transactions.
Remember, as long as you do 64-bit addressing and scatter/gather, all
that the DMA transaction is doing for you is locking and mapping the
memory. It doesn’t matter whether you declare it as ReadFrom or
WriteTo, your device can dance on the physical addresses as much as it
wants.


Tim Roberts, xxxxx@probo.com
Providenza & Boekelheide, Inc.

Use WdfDmaProfileScatterGatherDuplex

A simplex enabler will only let you execute one transaction at a time.

Alternately create a second enabler.

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:xxxxx@lists.osr.com] On Behalf Of xxxxx@live.com
Sent: Thursday, April 9, 2015 6:26 AM
To: Windows System Software Devs Interest List
Subject: [ntdev] How to deal with two dmatransaction?

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!


NTDEV is sponsored by OSR

Visit the list at: http://www.osronline.com/showlists.cfm?list=ntdev

OSR is HIRING!! See http://www.osr.com/careers

For our schedule of WDF, WDM, debugging and other seminars visit:
http://www.osr.com/seminars

To unsubscribe, visit the List Server section of OSR Online at http://www.osronline.com/page.cfm?name=ListServer

Thank you all! I have tried WdfDmaProfileScatterGetherDuplex, and BSOD dissapeared. Can’t reply more specifically by using cellphone.
Thanks again.