2021-04-24 00:19:22 +00:00
|
|
|
From 816ac3e6e67bdd78d86226c6eb53619780750e92 Mon Sep 17 00:00:00 2001
|
2020-10-24 19:14:16 +00:00
|
|
|
From: Felix Fietkau <nbd@nbd.name>
|
2021-04-24 00:19:22 +00:00
|
|
|
Date: Thu, 22 Apr 2021 22:21:04 -0700
|
|
|
|
Subject: [PATCH] net: ethernet: mtk_eth_soc: only read the full RX descriptor
|
|
|
|
if DMA is done
|
2020-10-24 19:14:16 +00:00
|
|
|
|
|
|
|
Uncached memory access is expensive, and there is no need to access all
|
|
|
|
descriptor words if we can't process them anyway
|
|
|
|
|
|
|
|
Signed-off-by: Felix Fietkau <nbd@nbd.name>
|
2021-04-24 00:19:22 +00:00
|
|
|
Signed-off-by: Ilya Lipnitskiy <ilya.lipnitskiy@gmail.com>
|
|
|
|
Signed-off-by: David S. Miller <davem@davemloft.net>
|
2020-10-24 19:14:16 +00:00
|
|
|
---
|
2021-04-24 00:19:22 +00:00
|
|
|
drivers/net/ethernet/mediatek/mtk_eth_soc.c | 12 ++++++++----
|
|
|
|
1 file changed, 8 insertions(+), 4 deletions(-)
|
2020-10-24 19:14:16 +00:00
|
|
|
|
|
|
|
--- a/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
|
|
|
+++ b/drivers/net/ethernet/mediatek/mtk_eth_soc.c
|
2023-03-18 19:05:11 +00:00
|
|
|
@@ -799,13 +799,18 @@ static inline int mtk_max_buf_size(int f
|
2020-10-24 19:14:16 +00:00
|
|
|
return buf_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static inline void mtk_rx_get_desc(struct mtk_rx_dma *rxd,
|
|
|
|
+static inline bool mtk_rx_get_desc(struct mtk_rx_dma *rxd,
|
|
|
|
struct mtk_rx_dma *dma_rxd)
|
|
|
|
{
|
|
|
|
- rxd->rxd1 = READ_ONCE(dma_rxd->rxd1);
|
|
|
|
rxd->rxd2 = READ_ONCE(dma_rxd->rxd2);
|
|
|
|
+ if (!(rxd->rxd2 & RX_DMA_DONE))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ rxd->rxd1 = READ_ONCE(dma_rxd->rxd1);
|
|
|
|
rxd->rxd3 = READ_ONCE(dma_rxd->rxd3);
|
|
|
|
rxd->rxd4 = READ_ONCE(dma_rxd->rxd4);
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
}
|
|
|
|
|
2022-06-22 15:58:33 +00:00
|
|
|
static void *mtk_max_lro_buf_alloc(gfp_t gfp_mask)
|
2023-03-18 19:05:11 +00:00
|
|
|
@@ -1288,8 +1293,7 @@ static int mtk_poll_rx(struct napi_struc
|
2020-10-24 19:14:16 +00:00
|
|
|
rxd = &ring->dma[idx];
|
|
|
|
data = ring->data[idx];
|
|
|
|
|
|
|
|
- mtk_rx_get_desc(&trxd, rxd);
|
|
|
|
- if (!(trxd.rxd2 & RX_DMA_DONE))
|
|
|
|
+ if (!mtk_rx_get_desc(&trxd, rxd))
|
|
|
|
break;
|
|
|
|
|
|
|
|
/* find out which mac the packet come from. values start at 1 */
|