[PATCH] net: stmmac: Add a barrier to make sure all access coherent

WangYuli wangyuli at uniontech.com
Fri Jun 21 03:18:36 PDT 2024


Add a memory barrier to sync TX descriptor to avoid data error.
Besides, increase the ring buffer size to avoid buffer overflow.

Signed-off-by: Wang Zhimin <wangzhimin1179 at phytium.com.cn>
Signed-off-by: Li Wencheng <liwencheng at phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi at phytium.com.cn>
Signed-off-by: Wang Yinfeng <wangyinfeng at phytium.com.cn>
Signed-off-by: WangYuli <wangyuli at uniontech.com>
---
 drivers/net/ethernet/stmicro/stmmac/common.h    | 4 ++--
 drivers/net/ethernet/stmicro/stmmac/norm_desc.c | 4 ++++
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h
index 9cd62b2110a1..7cc2fecbaf18 100644
--- a/drivers/net/ethernet/stmicro/stmmac/common.h
+++ b/drivers/net/ethernet/stmicro/stmmac/common.h
@@ -50,10 +50,10 @@
  */
 #define DMA_MIN_TX_SIZE		64
 #define DMA_MAX_TX_SIZE		1024
-#define DMA_DEFAULT_TX_SIZE	512
+#define DMA_DEFAULT_TX_SIZE	1024
 #define DMA_MIN_RX_SIZE		64
 #define DMA_MAX_RX_SIZE		1024
-#define DMA_DEFAULT_RX_SIZE	512
+#define DMA_DEFAULT_RX_SIZE	1024
 #define STMMAC_GET_ENTRY(x, size)	((x + 1) & (size - 1))
 
 #undef FRAME_FILTER_DEBUG
diff --git a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
index 68a7cfcb1d8f..40088a390f7b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
+++ b/drivers/net/ethernet/stmicro/stmmac/norm_desc.c
@@ -200,6 +200,10 @@ static void ndesc_prepare_tx_desc(struct dma_desc *p, int is_fs, int len,
 	else
 		norm_set_tx_desc_len_on_ring(p, len);
 
+	/* The own bit must be the latest setting done when prepare the
+	 * descriptor and then barrier is needed to make sure that all is coherent.
+	 */
+	wmb();
 	if (tx_own)
 		p->des0 |= cpu_to_le32(TDES0_OWN);
 }
-- 
2.43.4




More information about the linux-arm-kernel mailing list