* [PATCH net v2 1/4] net: stmmac: dwmac4: Fix MTL_OP_MODE_RTC mask and shift macros
2024-10-16 3:18 [PATCH net v2 0/4] net: stmmac: dwmac4: Fixes bugs in dwmac4 Ley Foon Tan
@ 2024-10-16 3:18 ` Ley Foon Tan
2024-10-16 3:18 ` [PATCH net v2 2/4] net: stmmac: dwmac4: Fix the MTL_OP_MODE_*_MASK operation Ley Foon Tan
` (3 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Ley Foon Tan @ 2024-10-16 3:18 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-kernel, lftan.linux
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")
Signed-off-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
index 93a78fd0737b..acbe5a027c85 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h
@@ -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
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v2 2/4] net: stmmac: dwmac4: Fix the MTL_OP_MODE_*_MASK operation
2024-10-16 3:18 [PATCH net v2 0/4] net: stmmac: dwmac4: Fixes bugs in dwmac4 Ley Foon Tan
2024-10-16 3:18 ` [PATCH net v2 1/4] net: stmmac: dwmac4: Fix MTL_OP_MODE_RTC mask and shift macros Ley Foon Tan
@ 2024-10-16 3:18 ` Ley Foon Tan
2024-10-16 3:18 ` [PATCH net v2 3/4] net: stmmac: dwmac4: Receive Watchdog Timeout is not in abnormal interrupt summary Ley Foon Tan
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Ley Foon Tan @ 2024-10-16 3:18 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-kernel, lftan.linux
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")
Signed-off-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
index e0165358c4ac..4e1b1bd98f68 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
@@ -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;
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v2 3/4] net: stmmac: dwmac4: Receive Watchdog Timeout is not in abnormal interrupt summary
2024-10-16 3:18 [PATCH net v2 0/4] net: stmmac: dwmac4: Fixes bugs in dwmac4 Ley Foon Tan
2024-10-16 3:18 ` [PATCH net v2 1/4] net: stmmac: dwmac4: Fix MTL_OP_MODE_RTC mask and shift macros Ley Foon Tan
2024-10-16 3:18 ` [PATCH net v2 2/4] net: stmmac: dwmac4: Fix the MTL_OP_MODE_*_MASK operation Ley Foon Tan
@ 2024-10-16 3:18 ` Ley Foon Tan
2024-10-16 3:18 ` [PATCH net v2 4/4] net: stmmac: dwmac4: Fix high address display by updating reg_space[] from register values Ley Foon Tan
2024-10-17 14:09 ` [PATCH net v2 0/4] net: stmmac: dwmac4: Fixes bugs in dwmac4 Simon Horman
4 siblings, 0 replies; 7+ messages in thread
From: Ley Foon Tan @ 2024-10-16 3:18 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-kernel, lftan.linux
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")
Signed-off-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
index 0d185e54eb7e..57c03d491774 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_lib.c
@@ -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);
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* [PATCH net v2 4/4] net: stmmac: dwmac4: Fix high address display by updating reg_space[] from register values
2024-10-16 3:18 [PATCH net v2 0/4] net: stmmac: dwmac4: Fixes bugs in dwmac4 Ley Foon Tan
` (2 preceding siblings ...)
2024-10-16 3:18 ` [PATCH net v2 3/4] net: stmmac: dwmac4: Receive Watchdog Timeout is not in abnormal interrupt summary Ley Foon Tan
@ 2024-10-16 3:18 ` Ley Foon Tan
2024-10-17 14:09 ` [PATCH net v2 0/4] net: stmmac: dwmac4: Fixes bugs in dwmac4 Simon Horman
4 siblings, 0 replies; 7+ messages in thread
From: Ley Foon Tan @ 2024-10-16 3:18 UTC (permalink / raw)
To: Alexandre Torgue, Jose Abreu
Cc: David S . Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
netdev, linux-kernel, lftan.linux
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")
Signed-off-by: Ley Foon Tan <leyfoon.tan@starfivetech.com>
---
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 8 ++++++++
drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h | 2 ++
2 files changed, 10 insertions(+)
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
index 4e1b1bd98f68..60cee7a06ba2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c
@@ -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] =
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h
index 17d9120db5fe..4f980dcd3958 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h
@@ -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)
--
2.34.1
^ permalink raw reply related [flat|nested] 7+ messages in thread* Re: [PATCH net v2 0/4] net: stmmac: dwmac4: Fixes bugs in dwmac4
2024-10-16 3:18 [PATCH net v2 0/4] net: stmmac: dwmac4: Fixes bugs in dwmac4 Ley Foon Tan
` (3 preceding siblings ...)
2024-10-16 3:18 ` [PATCH net v2 4/4] net: stmmac: dwmac4: Fix high address display by updating reg_space[] from register values Ley Foon Tan
@ 2024-10-17 14:09 ` Simon Horman
4 siblings, 0 replies; 7+ messages in thread
From: Simon Horman @ 2024-10-17 14:09 UTC (permalink / raw)
To: Ley Foon Tan
Cc: Alexandre Torgue, Jose Abreu, David S . Miller, Eric Dumazet,
Jakub Kicinski, Paolo Abeni, netdev, linux-kernel, lftan.linux
On Wed, Oct 16, 2024 at 11:18:28AM +0800, Ley Foon Tan wrote:
> 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/20241015065708.3465151-1-leyfoon.tan@starfivetech.com/
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.
...
^ permalink raw reply [flat|nested] 7+ messages in thread