about WDF_DMA_DIRECTION

As we know, there are only two members of this enum type.
Now, I am puzzled.
Can I use it as follows:

WdfDmaTransactionInitialize(
…,
…,
(WdfDmaDirectionReadFromDevice | WdfDmaDirectionWriteToDevice)
);

thanks!!

No, a DMA transaction has to be EITHER read or write. If for example your
device only supports 32-bit DMA physical addresses and you are running on a
64-bit OS with lots of memory, the OS may have to copy your I/O buffers to
memory that can be addresses by the hardware. For read, it would have to
copy from your buffer to temporary memory, and for write copy from temporary
memory to you buffer. There is no way it can know that some of your buffer
would be copied before and some copied after the DMA operation. If you
enable driver verifier DMA validation, this will force this DMA buffer
copying on every operation, even if your hardware can access the buffer, and
it will also check the memory on the ends for corruption.

Generally, if you want to have some cache coherent memory that you can read
and write to from hardware at arbitrary times, you allocate some common
memory. You might also create two DMA transactions, a read one and a write
one.

A few years ago there was some discussion of enhancing the Windows DMA
model, although I have not heard anything about that recently. The argument
was that most modern hardware was cache coherent, so the hardware could
actually work on combined read/write DMA operations. For things like RDMA,
initiated directly from user mode, on hardware like Infiniband, you didn’t
want to take the performance hit from making a round trip to kernel mode
just to setup the DMA operation. On uses like scientific clusters, which
make many small transfers between processes on different computers, and need
the lowest possible latency (often near a microsecond), a round trip to
kernel mode and any kind of touching the page tables is a vast amount of
overhead. These applications generally had a pool of inter-process
communications buffers, which are page locked and mapped to physical
addresses once (actually the scatter gather list is mapped to a virtual
address translated by the Infinband hardware), and then I/O requests consist
of putting an entry into a hardware queue, which is mapped into the process
address space. These queue entries use a virtual handle (referencing a set
of mapped pages) and offset. I/O happens with initial setup of the buffers
and no kernel transitions for each request. A processor polls another queue
for completions, the polling overhead can be less than the time to process
any kind of kernel I/O completion, assuming requests happen pretty quickly.
Officially, the Windows DMA model can’t do this, and the choices come down
to violating the Windows DMA model, even though the hardware can do it, or
reverting to techniques like having the applications copy the I/O requests
from process memory to chunks of common memory mapped into the process, and
then initiating the I/O on the common memory, which is defined to allow
arbitrary read/write. Copying the requests degrades performance some. I
suspect what happened was VM’s came along, and everybody was busy
implementing them, so hardware direct I/O was not at the top of the priority
list.

As soon as the VM hoopla dies down, perhaps we can get back to actually
improving computer architectures.

As of right now, DMA transactions on arbitrary memory still need to be read
OR write.

Jan

-----Original Message-----
From: xxxxx@lists.osr.com [mailto:bounce-415723-
xxxxx@lists.osr.com] On Behalf Of xxxxx@hotmail.com
Sent: Thursday, June 24, 2010 6:56 PM
To: Windows System Software Devs Interest List
Subject: [ntdev] about WDF_DMA_DIRECTION

As we know, there are only two members of this enum type.
Now, I am puzzled.
Can I use it as follows:

WdfDmaTransactionInitialize(
…,
…,
(WdfDmaDirectionReadFromDevice | WdfDmaDirectionWriteToDevice)
);

thanks!!


NTDEV is sponsored by OSR

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

xxxxx@hotmail.com wrote:

As we know, there are only two members of this enum type.
Now, I am puzzled.
Can I use it as follows:

WdfDmaTransactionInitialize(
…,
…,
(WdfDmaDirectionReadFromDevice | WdfDmaDirectionWriteToDevice)
);

No. A 10-second search would have shown you that one of these is FALSE
(0), and one of them is TRUE (1), so or-ing them together produces 1.

A single transaction is either one or the other. If you need to go in
both directions, then you have two transactions.


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

>As we know, there are only two members of this enum type.

Now, I am puzzled.
Can I use it as follows:
WdfDmaTransactionInitialize( …, …, (WdfDmaDirectionReadFromDevice | >WdfDmaDirectionWriteToDevice) );
thanks!!
Even if this would be possible you can not combine Read/Write in DMA engine. Despite on very interesting information, which Jan gave to us, the current DMA engines provide DMA transaction in one direction. At least this must be done for one entry of SGL.

Igor Sharovar

I see, thanks everyone.