net: ethernet: ftgmac100: Fix DMA coherency issue with SW checksum
authorBenjamin Herrenschmidt <benh@kernel.crashing.org>
Fri, 25 Oct 2019 02:47:24 +0000 (13:47 +1100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sun, 10 Nov 2019 10:27:40 +0000 (11:27 +0100)
commit189982d111c077922b0811372e7bf4dc36c51e46
tree5cb9aa8c57bed371c3e379e41045778194953d7d
parent5536fc891221464bc2900d1d108eb87da14614ff
net: ethernet: ftgmac100: Fix DMA coherency issue with SW checksum

[ Upstream commit 88824e3bf29a2fcacfd9ebbfe03063649f0f3254 ]

We are calling the checksum helper after the dma_map_single()
call to map the packet. This is incorrect as the checksumming
code will touch the packet from the CPU. This means the cache
won't be properly flushes (or the bounce buffering will leave
us with the unmodified packet to DMA).

This moves the calculation of the checksum & vlan tags to
before the DMA mapping.

This also has the side effect of fixing another bug: If the
checksum helper fails, we goto "drop" to drop the packet, which
will not unmap the DMA mapping.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Fixes: 05690d633f30 ("ftgmac100: Upgrade to NETIF_F_HW_CSUM")
Reviewed-by: Vijay Khemka <vijaykhemka@fb.com>
Tested-by: Vijay Khemka <vijaykhemka@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/net/ethernet/faraday/ftgmac100.c