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

Roland Dreier
2002-06-09T06:16:43Z

>>>>> "David" == David S Miller <davem@redhat.com> writes:

Roland> Just to make sure I'm reading this correctly, you're
Roland> saying that as long as a buffer is OK for DMA, it should
Roland> be OK to use a sub-cache-line chunk as a DMA buffer via
Roland> pci_map_single(), and accessing the rest of the cache line
Roland> should be OK at any time before, during and after the DMA.

David> Yes.

Roland> What alternate implementation are you proposing?

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.

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

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

In any case if this is what pci_map is supposed to do then we have to
fix up several architectures at least...

Thanks,
Roland