diff mbox series

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

Message ID F19E93E071D95714+20240621101836.167600-1-wangyuli@uniontech.com (mailing list archive)
State New, archived
Headers show
Series net: stmmac: Add a barrier to make sure all access coherent | expand

Commit Message

WangYuli June 21, 2024, 10:18 a.m. UTC
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(-)

Comments

Sunil Kovvuri Goutham June 21, 2024, 10:53 a.m. UTC | #1
>Besides, increase the ring buffer size to avoid buffer overflow.
>
>  */
> #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))
>

If this is a fix, please add a fixes tag.

                /* Prefetch the next RX descriptor */
                rx_q->cur_rx = STMMAC_GET_ENTRY(rx_q->cur_rx,
                                                priv->dma_conf.dma_rx_size);

Also do please elaborate buffer overflow problem.
Is this ' DMA_DEFAULT_RX_SIZE ' descriptor size or size of full descriptor ring ?

Thanks,
Sunil.
Andrew Lunn June 21, 2024, 3:20 p.m. UTC | #2
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
diff mbox series

Patch

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);
 }