e99302ecdaac03e9cf245005b330d9de5c1c87bc
[openwrt/staging/stintel.git] /
1 From 5196c417854942e218a59ec87bf7d414b3bd581e Mon Sep 17 00:00:00 2001
2 From: Felix Fietkau <nbd@nbd.name>
3 Date: Thu, 22 Apr 2021 22:20:55 -0700
4 Subject: [PATCH] net: ethernet: mtk_eth_soc: unmap RX data before calling
5 build_skb
6
7 Since build_skb accesses the data area (for initializing shinfo), dma unmap
8 needs to happen before that call
9
10 Signed-off-by: Felix Fietkau <nbd@nbd.name>
11 [Ilya: split build_skb cleanup fix into a separate commit]
12 Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
13 Signed-off-by: David S. Miller <davem@davemloft.net>
14 ---
15 drivers/net/ethernet/mediatek/mtk_eth_soc.c | 5 +++--
16 1 file changed, 3 insertions(+), 2 deletions(-)
17
18 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
19 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
20 @@ -1319,6 +1319,9 @@ static int mtk_poll_rx(struct napi_struc
21 goto release_desc;
22 }
23
24 + dma_unmap_single(eth->dev, trxd.rxd1,
25 + ring->buf_size, DMA_FROM_DEVICE);
26 +
27 /* receive data */
28 skb = build_skb(data, ring->frag_size);
29 if (unlikely(!skb)) {
30 @@ -1328,8 +1331,6 @@ static int mtk_poll_rx(struct napi_struc
31 }
32 skb_reserve(skb, NET_SKB_PAD + NET_IP_ALIGN);
33
34 - dma_unmap_single(eth->dev, trxd.rxd1,
35 - ring->buf_size, DMA_FROM_DEVICE);
36 pktlen = RX_DMA_GET_PLEN0(trxd.rxd2);
37 skb->dev = netdev;
38 skb_put(skb, pktlen);