On an X86, the caches are coherent, but you still must worry about:
- reads being reordered WRT writes
- writes by different CPUs being in a different order than you expect.
On the X86, KeFlushIoBuffers() is a no-op (it wasn’t on the alpha). If I believe the W2K (not XP)
DDK, on IA64 this is now a function (and therefore could do something).
Section 16.5 in the design guide:
"In some platforms, the processor and system DMA controller (or busmaster DMA adapters) exhibit cache coherency anomalies. To maintain data integrity during DMA operations, lowest-level drivers must follow these guidelines:
1… Call KeFlushIoBuffers before beginning a transfer operation to maintain consistency between data that might be cached in the processor and the data in memory.
If a driver calls AllocateCommonBuffer with the CacheEnabled parameter set to TRUE, the driver must call KeFlushIoBuffers before beginning a transfer operation to/from its buffer.
2… Call FlushAdapterBuffers at the end of each device transfer operation to be sure any remainder bytes in the system DMA controller’s buffers have been written into memory or to the slave device.
Or, call FlushAdapterBuffers at the end of each transfer operation for a given IRP to be sure all data has been read into system memory or written out to a busmaster DMA device. "
I suspect that FlushAdapterBuffers issues the serializing instruction needed to prevent read-aheads in the CPU pipeline.
I’m unable to come up with an example where the write order across CPUs is a problem. (Each CPU issues its own writes in order.) Read the gory Intel documentation if you want to go further.
----- Original Message -----
From: hesham
To: NT Developers Interest List
Sent: Thursday, July 19, 2001 10:40 AM
Subject: [ntdev] Re: Cached and non cached common buffer
please give me more details
where can I find this macro, and why it is NOP?
are you mean that there is no precaution to use cached memory with DMA?
thanks in advance
Hesham
----- Original Message -----
From: Dave Harvey
To: NT Developers Interest List
Sent: Wednesday, July 18, 2001 7:31 PM
Subject: [ntdev] Re: Cached and non cached common buffer
The cache coherence should work as defined by the Intel specs if its a PCI device. If you look up the x86 version of the macro the DDK defines for forcing the cache coherant, you’ll find its a no-op.
You should read all of the Intel documentation on write ordering, serializing instructions, out of order reads, etc., carefully.
When I tried this, I got a measurable performance improvement, and no stability problems.
-DH
----- Original Message -----
From: hesham
To: NT Developers Interest List
Sent: Wednesday, July 18, 2001 7:33 PM
Subject: [ntdev] Cached and non cached common buffer
Hi all
I want to ask what is the difference between the cahced and noncached Commonbuffers
and if they are cached is there any coherence problem which require flushing the cache.
any help will be appreciated
thanks in advance
Hesham
You are currently subscribed to ntdev as: xxxxx@syssoftsol.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@yahoo.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: xxxxx@syssoftsol.com
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com
You are currently subscribed to ntdev as: $subst(‘Recip.EmailAddr’)
To unsubscribe send a blank email to leave-ntdev-$subst(‘Recip.MemberIDChar’)@lists.osr.com