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

WangYuli posted 1 patch 1 year, 5 months ago
drivers/net/ethernet/stmicro/stmmac/common.h    | 4 ++--
drivers/net/ethernet/stmicro/stmmac/norm_desc.c | 4 ++++
2 files changed, 6 insertions(+), 2 deletions(-)
[PATCH] net: stmmac: Add a barrier to make sure all access coherent
Posted by WangYuli 1 year, 5 months ago
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@phytium.com.cn>
Signed-off-by: Li Wencheng <liwencheng@phytium.com.cn>
Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
Signed-off-by: WangYuli <wangyuli@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
Re: [PATCH] net: stmmac: Add a barrier to make sure all access coherent
Posted by Andrew Lunn 1 year, 5 months ago
On Fri, Jun 21, 2024 at 06:18:36PM +0800, WangYuli wrote:
> Add a memory barrier to sync TX descriptor to avoid data error.
> Besides, increase the ring buffer size to avoid buffer overflow.

This sounds to do two things. Two patches please, each with a good
commit message.

> Signed-off-by: Wang Zhimin <wangzhimin1179@phytium.com.cn>
> Signed-off-by: Li Wencheng <liwencheng@phytium.com.cn>
> Signed-off-by: Chen Baozi <chenbaozi@phytium.com.cn>
> Signed-off-by: Wang Yinfeng <wangyinfeng@phytium.com.cn>
> Signed-off-by: WangYuli <wangyuli@uniontech.com>

Five developers for a 25 line patch? Should some of these be
Suggested-by:, Tested-by: Reported-by:?

    Andrew

---
pw-bot: cr