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

Roland Dreier (roland@topspin.com)
10 Jun 2002 09:03:22 -0700


>>>>> "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
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/