net: lan966x: Fix unmapping of received frames using FDMA
authorHoratiu Vultur <horatiu.vultur@microchip.com>
Mon, 31 Oct 2022 13:34:21 +0000 (14:34 +0100)
committerJakub Kicinski <kuba@kernel.org>
Wed, 2 Nov 2022 04:20:30 +0000 (21:20 -0700)
commitfc57062f98b0b0ae52bc584d8fd5ac77c50df607
tree619a2ab4c1e58bbe6c327e77bacda5f4915a4ae8
parent70644f722f0d297ca3c7664939f0bd3595eec14b
net: lan966x: Fix unmapping of received frames using FDMA

When lan966x was receiving a frame, then it was building the skb and
after that it was calling dma_unmap_single with frame size as the
length. This actually has 2 issues:
1. It is using a length to map and a different length to unmap.
2. When the unmap was happening, the data was sync for cpu but it could
   be that this will overwrite what build_skb was initializing.

The fix for these two problems is to change the order of operations.
First to sync the frame for cpu, then to build the skb and in the end to
unmap using the correct size but without sync the frame again for cpu.

Fixes: c8349639324a ("net: lan966x: Add FDMA functionality")
Signed-off-by: Horatiu Vultur <horatiu.vultur@microchip.com>
Link: https://lore.kernel.org/r/20221031133421.1283196-1-horatiu.vultur@microchip.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/microchip/lan966x/lan966x_fdma.c