Re: PCI DMA to small buffers on cache-incoherent arch

Roland Dreier
2002-06-10T16:03:27Z

>>>>> "Roland" == Roland Dreier <roland@topspin.com> writes:

David> For non-cacheline aligned chunks in the range "start" to
David> "end" you must perform a cache writeback and invalidate. To
David> preserve the data outside of the DMA range.

Roland> Doesn't this still have a problem if you touch data in the
Roland> same cache line as the DMA buffer after the pci_map but
Roland> before the DMA takes place? The CPU will pull the cache
Roland> line back in and it might not see the data the DMA brought
Roland> in.

Roland> It seems to me that to be totally safe, pci_unmap would
Roland> have to save the non-aligned part outside the buffer to
Roland> temporary storage, do an invalidate, and then copy back
Roland> the non-aligned part.

Replying to myself.... Anyway, I realized that even my idea above is
wrong. I don't see _any_ safe way to share a cache line between a DMA
buffer and other data. Access to the cache line might pull the cache
line back in and write it back at any time, which could corrupt the
DMA'ed data. I don't see a way to hide the existence of cache lines
etc. from the driver.

Best,
Roland