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

Benjamin Herrenschmidt
2002-06-09T10:54:09Z

>
>Now at this point the driver calls pci_unmap_single or whatever. What
>is pci_unmap_single to do? If it does nothing, or does a writeback,
>we lose the DMA data. If it does an invalidate we lose the value
>written to X. Clearly, neither is correct.
>
>The bottom line is that we can only have one writer to any given cache
>line at a time. If a buffer is being used for DMA from a device to
>memory, the cpu MUST NOT write to any cache line that overlaps the
>buffer.

Note that this typically happen with network drivers, some infos in
the skbuf getting lost when they happen to share a cache line with
the data portion of the skbuf. When writing a driver specific to a
non-coherent CPU, it can be worked around by reserving enough space,
but "generic" PCI drivers are still affected.

On those architectures, the core skbuf alloc routines should probably
make sure the data portion don't share a cache line with other
informations.

Ben.