Tech Support > Microsoft Windows > Drivers > Unexpected data during DMA
Unexpected data during DMA
Posted by Jake Haddock on November 24th, 2004



I have an XP driver that calls the following function:

RtlCopyMemory(((PCHAR)Open->TxBufferVirtualAddress[C_FIRSTMAPPING] +
Open->OldHead), UserData, BufLen);

This function copies data from a user data buffer into a TX buffer. Once
this copy is complete, I notify my HW, on a PCI bus, that data is ready for
the HW to read. The HW then becomes the PCI master and DMAs (reads) data from
the TX buffer on the host to its local memory.

The problem: Often the data that's copied into the TX buffer isn't the data
that's transfered during the DMA. I've doubled checked my pointers for DMA
and I'm positive they are correct. After the call to RtlCopyMemory(), I read
back the first few location of the updated TX buffer memory and they are
correct, but when I look at the DMA data, via a PCI anaylzer, it is
incorrect. Below is the ouput shown from my PCI anaylzer:

MemRL 05F2BC40 ;The first 16 lwords are old/incorrect data
DATA 4A494847
DATA 4E4D4C4B
DATA 4B51504F
DATA CDCDCDCD
DATA 00000000
DATA 00002000
DATA 0000000E
DATA 81218600
DATA 00000000
DATA 00000000
DATA 00000040
DATA 00000000
DATA 0000000E
DATA 81230CA0
DATA 00000000
DATA 00000000
WAIT
WAIT
WAIT ;starting here the data is
correct.
DATA 00002D00
DATA 11010040
DATA 010AB47B
DATA 090A0101
DATA 020001E9
DATA 19000200
DATA 42410000
DATA 46454443

After the first 16 words (1 cache line??) are transferered, the following
data is correct. I've done testing with several PCs and this problem seems to
only occur on one of my PCs.

Any insight or thoughts on this problem would be greatly appreciated!

Posted by Mark Roddy on November 24th, 2004


Jake Haddock wrote:

Exactly what kind of memory object is a
TxBufferVirtualAddress[C_FIRSTMAPPING]?

Assuming that you have followed the rules, the platform memory subsystem
is supposed to guarantee memory/cache coherency, including access from
external devices. If those memory locations are dirty/cached, the DMA
access attempt ought to (at least logically) force the cache lines out
to physical memory before the read is satisfied.

The fact that it occurs on only one PC is highly suspect. You might want
to make sure that the virtual memory you are using for DMA is marked as
non-cached, at least as a test to see if that makes your bad PC behave.


--

=====================
Mark Roddy DDK MVP
Windows 2003/XP/2000 Consulting
Hollis Technology Solutions 603-321-1032


Similar Posts