1 From: Felix Fietkau <nbd@nbd.name>
2 Date: Thu, 27 Aug 2020 09:24:25 +0200
3 Subject: [PATCH] net: ethernet: mtk_eth_soc: only read the full rx
4 descriptor if DMA is done
6 Uncached memory access is expensive, and there is no need to access all
7 descriptor words if we can't process them anyway
9 Signed-off-by: Felix Fietkau <nbd@nbd.name>
12 --- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
13 +++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
14 @@ -776,13 +776,18 @@ static inline int mtk_max_buf_size(int f
18 -static inline void mtk_rx_get_desc(struct mtk_rx_dma *rxd,
19 +static inline bool mtk_rx_get_desc(struct mtk_rx_dma *rxd,
20 struct mtk_rx_dma *dma_rxd)
22 - rxd->rxd1 = READ_ONCE(dma_rxd->rxd1);
23 rxd->rxd2 = READ_ONCE(dma_rxd->rxd2);
24 + if (!(rxd->rxd2 & RX_DMA_DONE))
27 + rxd->rxd1 = READ_ONCE(dma_rxd->rxd1);
28 rxd->rxd3 = READ_ONCE(dma_rxd->rxd3);
29 rxd->rxd4 = READ_ONCE(dma_rxd->rxd4);
34 /* the qdma core needs scratch memory to be setup */
35 @@ -1254,8 +1259,7 @@ static int mtk_poll_rx(struct napi_struc
36 rxd = &ring->dma[idx];
37 data = ring->data[idx];
39 - mtk_rx_get_desc(&trxd, rxd);
40 - if (!(trxd.rxd2 & RX_DMA_DONE))
41 + if (!mtk_rx_get_desc(&trxd, rxd))
44 /* find out which mac the packet come from. values start at 1 */