Skip to contentSkip to conversation

net: stmmac: dwmac4: Fixes bugs in dwmac4

PATCH In review Ley Foon Tan 2 participants 6 messages Oct 16, 2024 – Oct 17, 2024

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

v2 cover net: stmmac: dwmac4: Fixes bugs in dwmac4

This patch series fix the bugs in dwmac4 drivers.

Changes since v1:
- Removed empty line between Fixes and Signoff
- Rebased to https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
- Updated git commit description for patch 4/4

History:
v1: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

Ley Foon Tan (4):
net: stmmac: dwmac4: Fix MTL_OP_MODE_RTC mask and shift macros
net: stmmac: dwmac4: Fix the MTL_OP_MODE_*_MASK operation
net: stmmac: dwmac4: Receive Watchdog Timeout is not in abnormal
interrupt summary
net: stmmac: dwmac4: Fix high address display by updating reg_space[]
from register values

 drivers/net/ethernet/stmicro/stmmac/dwmac4.h     |  4 ++--
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 12 ++++++++++--
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h |  2 ++
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c |  6 ++++--
 4 files changed, 18 insertions(+), 6 deletions(-)
Signature · 1 line
2.34.1
#1 lore raw

PATCH v2 1/4 net: stmmac: dwmac4: Fix MTL_OP_MODE_RTC mask and shift macros

RTC fields are located in bits [1:0]. Correct the _MASK and _SHIFT macros to use the appropriate mask and shift.

Fixes 35f74c0c5dce ("stmmac: add GMAC4 DMA/CORE Header File")
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4.h +2 -2
index 93a78fd0737b..acbe5a027c85 100644
@@ -389,8 +389,8 @@ static inline u32 mtl_chanx_base_addr(const struct dwmac4_addrs *addrs,
 
 #define MTL_OP_MODE_EHFC		BIT(7)
 
-#define MTL_OP_MODE_RTC_MASK		0x18
-#define MTL_OP_MODE_RTC_SHIFT		3
+#define MTL_OP_MODE_RTC_MASK		GENMASK(1, 0)
+#define MTL_OP_MODE_RTC_SHIFT		0
 
 #define MTL_OP_MODE_RTC_32		(1 << MTL_OP_MODE_RTC_SHIFT)
 #define MTL_OP_MODE_RTC_64		0
Signature · 1 line
2.34.1
#2 lore raw

PATCH v2 2/4 net: stmmac: dwmac4: Fix the MTL_OP_MODE_*_MASK operation

In reply to Ley Foon Tan

In order to mask off the bits, we need to use the '~' operator to invert all the bits of _MASK and clear them.

Fixes 48863ce5940f ("stmmac: add DMA support for GMAC 4.xx")
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +2 -2
index e0165358c4ac..4e1b1bd98f68 100644
@@ -266,7 +266,7 @@ static void dwmac4_dma_rx_chan_op_mode(struct stmmac_priv *priv,
 	} else {
 		pr_debug("GMAC: disable RX SF mode (threshold %d)\n", mode);
 		mtl_rx_op &= ~MTL_OP_MODE_RSF;
-		mtl_rx_op &= MTL_OP_MODE_RTC_MASK;
+		mtl_rx_op &= ~MTL_OP_MODE_RTC_MASK;
 		if (mode <= 32)
 			mtl_rx_op |= MTL_OP_MODE_RTC_32;
 		else if (mode <= 64)
@@ -335,7 +335,7 @@ static void dwmac4_dma_tx_chan_op_mode(struct stmmac_priv *priv,
 	} else {
 		pr_debug("GMAC: disabling TX SF (threshold %d)\n", mode);
 		mtl_tx_op &= ~MTL_OP_MODE_TSF;
-		mtl_tx_op &= MTL_OP_MODE_TTC_MASK;
+		mtl_tx_op &= ~MTL_OP_MODE_TTC_MASK;
 		/* Set the transmit threshold */
 		if (mode <= 32)
 			mtl_tx_op |= MTL_OP_MODE_TTC_32;
Signature · 1 line
2.34.1
#3 lore raw

PATCH v2 3/4 net: stmmac: dwmac4: Receive Watchdog Timeout is not in abnormal interrupt summary

In reply to Ley Foon Tan

The Receive Watchdog Timeout (RWT, bit[9]) is not part of Abnormal Interrupt Summary (AIS). Move the RWT handling out of the AIS condition statement.

From databook, the AIS is the logical OR of the following interrupt bits:

- Bit 1: Transmit Process Stopped
- Bit 7: Receive Buffer Unavailable
- Bit 8: Receive Process Stopped
- Bit 10: Early Transmit Interrupt
- Bit 12: Fatal Bus Error
- Bit 13: Context Descriptor Error

Fixes 48863ce5940f ("stmmac: add DMA support for GMAC 4.xx")
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c +4 -2
index 0d185e54eb7e..57c03d491774 100644
@@ -185,8 +185,6 @@ int dwmac4_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
 			x->rx_buf_unav_irq++;
 		if (unlikely(intr_status & DMA_CHAN_STATUS_RPS))
 			x->rx_process_stopped_irq++;
-		if (unlikely(intr_status & DMA_CHAN_STATUS_RWT))
-			x->rx_watchdog_irq++;
 		if (unlikely(intr_status & DMA_CHAN_STATUS_ETI))
 			x->tx_early_irq++;
 		if (unlikely(intr_status & DMA_CHAN_STATUS_TPS)) {
@@ -198,6 +196,10 @@ int dwmac4_dma_interrupt(struct stmmac_priv *priv, void __iomem *ioaddr,
 			ret = tx_hard_error;
 		}
 	}
+
+	if (unlikely(intr_status & DMA_CHAN_STATUS_RWT))
+		x->rx_watchdog_irq++;
+
 	/* TX/RX NORMAL interrupts */
 	if (likely(intr_status & DMA_CHAN_STATUS_RI)) {
 		u64_stats_update_begin(&stats->syncp);
Signature · 1 line
2.34.1
#4 lore raw

PATCH v2 4/4 net: stmmac: dwmac4: Fix high address display by updating reg_space[] from register values

In reply to Ley Foon Tan

The high address will display as 0 if the driver does not set the reg_space[]. To fix this, read the high address registers and update the reg_space[] accordingly.

Fixes fbf68229ffe7 ("net: stmmac: unify registers dumps methods")
---
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 8 ++++++++
 drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h | 2 ++
 2 files changed, 10 insertions(+)
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +8 -0
index 4e1b1bd98f68..60cee7a06ba2 100644
@@ -203,8 +203,12 @@ static void _dwmac4_dump_dma_regs(struct stmmac_priv *priv,
 		readl(ioaddr + DMA_CHAN_TX_CONTROL(dwmac4_addrs, channel));
 	reg_space[DMA_CHAN_RX_CONTROL(default_addrs, channel) / 4] =
 		readl(ioaddr + DMA_CHAN_RX_CONTROL(dwmac4_addrs, channel));
+	reg_space[DMA_CHAN_TX_BASE_ADDR_HI(default_addrs, channel) / 4] =
+		readl(ioaddr + DMA_CHAN_TX_BASE_ADDR_HI(dwmac4_addrs, channel));
 	reg_space[DMA_CHAN_TX_BASE_ADDR(default_addrs, channel) / 4] =
 		readl(ioaddr + DMA_CHAN_TX_BASE_ADDR(dwmac4_addrs, channel));
+	reg_space[DMA_CHAN_RX_BASE_ADDR_HI(default_addrs, channel) / 4] =
+		readl(ioaddr + DMA_CHAN_RX_BASE_ADDR_HI(dwmac4_addrs, channel));
 	reg_space[DMA_CHAN_RX_BASE_ADDR(default_addrs, channel) / 4] =
 		readl(ioaddr + DMA_CHAN_RX_BASE_ADDR(dwmac4_addrs, channel));
 	reg_space[DMA_CHAN_TX_END_ADDR(default_addrs, channel) / 4] =
@@ -225,8 +229,12 @@ static void _dwmac4_dump_dma_regs(struct stmmac_priv *priv,
 		readl(ioaddr + DMA_CHAN_CUR_TX_DESC(dwmac4_addrs, channel));
 	reg_space[DMA_CHAN_CUR_RX_DESC(default_addrs, channel) / 4] =
 		readl(ioaddr + DMA_CHAN_CUR_RX_DESC(dwmac4_addrs, channel));
+	reg_space[DMA_CHAN_CUR_TX_BUF_ADDR_HI(default_addrs, channel) / 4] =
+		readl(ioaddr + DMA_CHAN_CUR_TX_BUF_ADDR_HI(dwmac4_addrs, channel));
 	reg_space[DMA_CHAN_CUR_TX_BUF_ADDR(default_addrs, channel) / 4] =
 		readl(ioaddr + DMA_CHAN_CUR_TX_BUF_ADDR(dwmac4_addrs, channel));
+	reg_space[DMA_CHAN_CUR_RX_BUF_ADDR_HI(default_addrs, channel) / 4] =
+		readl(ioaddr + DMA_CHAN_CUR_RX_BUF_ADDR_HI(dwmac4_addrs, channel));
 	reg_space[DMA_CHAN_CUR_RX_BUF_ADDR(default_addrs, channel) / 4] =
 		readl(ioaddr + DMA_CHAN_CUR_RX_BUF_ADDR(dwmac4_addrs, channel));
 	reg_space[DMA_CHAN_STATUS(default_addrs, channel) / 4] =
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +2 -0
index 17d9120db5fe..4f980dcd3958 100644
@@ -127,7 +127,9 @@ static inline u32 dma_chanx_base_addr(const struct dwmac4_addrs *addrs,
 #define DMA_CHAN_SLOT_CTRL_STATUS(addrs, x)	(dma_chanx_base_addr(addrs, x) + 0x3c)
 #define DMA_CHAN_CUR_TX_DESC(addrs, x)	(dma_chanx_base_addr(addrs, x) + 0x44)
 #define DMA_CHAN_CUR_RX_DESC(addrs, x)	(dma_chanx_base_addr(addrs, x) + 0x4c)
+#define DMA_CHAN_CUR_TX_BUF_ADDR_HI(addrs, x)	(dma_chanx_base_addr(addrs, x) + 0x50)
 #define DMA_CHAN_CUR_TX_BUF_ADDR(addrs, x)	(dma_chanx_base_addr(addrs, x) + 0x54)
+#define DMA_CHAN_CUR_RX_BUF_ADDR_HI(addrs, x)	(dma_chanx_base_addr(addrs, x) + 0x58)
 #define DMA_CHAN_CUR_RX_BUF_ADDR(addrs, x)	(dma_chanx_base_addr(addrs, x) + 0x5c)
 #define DMA_CHAN_STATUS(addrs, x)	(dma_chanx_base_addr(addrs, x) + 0x60)
 
Signature · 1 line
2.34.1
reviewer
#5 lore raw
In reply to Ley Foon Tan
Quoted 9 lines · Ley Foon Tan

This patch series fix the bugs in dwmac4 drivers.

Changes since v1:
- Removed empty line between Fixes and Signoff
- Rebased to https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git
- Updated git commit description for patch 4/4

History:
v1: https://patchwork.kernel.org/project/netdevbpf/cover/[email protected]/

Hi,

Thanks for the update and sorry for not providing more timely feedback.

I think that the code changes themselves look fine. However, as a rule of thumb, fixes for net should resolve user-visible problems. I see that is the case for patch 4/4, but it is less clear to me for the other 3 patches. If it is indeed then I think it would be good to explain that more clearly in their patch descriptions.

If not, perhaps they should be submitted to net-next without Fixes tags while patch 4 and any others that are still fixes resubmitted as a smaller v3 patch-set for net.

...