On Fri, Apr 21, 2017 at 8:07 AM, Alexander Duyck <alexander.du...@gmail.com> wrote: > On Fri, Apr 21, 2017 at 7:20 AM, Jakub Kicinski > <jakub.kicin...@netronome.com> wrote: >> DMA unmap may destroy changes CPU made to the buffer. To make XDP >> run correctly on non-x86 platforms we should use the >> DMA_ATTR_SKIP_CPU_SYNC attribute. >> >> Thanks to using the attribute we can now push the sync operation to >> the common code path from XDP handler. >> >> A little bit of variable name reshuffling is required to bring the >> code back to readable state. >> >> Signed-off-by: Jakub Kicinski <jakub.kicin...@netronome.com> > > So I see where you added the sync_single_for_cpu, but what about the > sync_single_for_device? It needs to be called for the buffer before > you assign it for Rx. On x86 it won't really matter but for proper > utilization of the DMA API you need to sync the buffer even for Rx > just to make certain that the cache lines are evicted prior to the > device attempting to write to the buffer.
Ah, indeed, thanks for catching this. We need to invalidate the caches in case they are dirty and could get written back between the device DMA and sync_for_cpu, correct?