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 Changes Requested
Delegated to: Netdev Maintainers
Headers show
Series net: stmmac: Add a barrier to make sure all access coherent | expand

Checks

Context Check Description
netdev/series_format warning Single patches do not need cover letters; Target tree name not specified in the subject
netdev/tree_selection success Guessed tree name to be net-next
netdev/ynl success Generated files up to date; no warnings/errors; no diff in generated;
netdev/fixes_present success Fixes tag not required for -next series
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 842 this patch: 842
netdev/build_tools success No tools touched, skip
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 849 this patch: 849
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/deprecated_api success None detected
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success No Fixes tag
netdev/build_allmodconfig_warn success Errors and warnings before: 861 this patch: 861
netdev/checkpatch warning WARNING: line length of 83 exceeds 80 columns
netdev/build_clang_rust success No Rust files in patch. Skipping build
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0
netdev/contest fail net-next-2024-06-21--15-00 (tests: 658)

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