* [PATCH net] net: macb: Fix tx/rx malfunction after phy link down and up
@ 2026-02-08 8:45 Kevin Hao
2026-02-11 12:20 ` patchwork-bot+netdevbpf
2026-02-19 15:33 ` Alexander Dahl
0 siblings, 2 replies; 3+ messages in thread
From: Kevin Hao @ 2026-02-08 8:45 UTC (permalink / raw)
To: netdev
Cc: Kevin Hao, stable, Nicolas Ferre, Claudiu Beznea, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Xiaolei Wang
In commit 99537d5c476c ("net: macb: Relocate mog_init_rings() callback
from macb_mac_link_up() to macb_open()"), the mog_init_rings() callback
was moved from macb_mac_link_up() to macb_open() to resolve a deadlock
issue. However, this change introduced a tx/rx malfunction following
phy link down and up events. The issue arises from a mismatch between
the software queue->tx_head, queue->tx_tail, queue->rx_prepared_head,
and queue->rx_tail values and the hardware's internal tx/rx queue
pointers.
According to the Zynq UltraScale TRM [1], when tx/rx is disabled, the
internal tx queue pointer resets to the value in the tx queue base
address register, while the internal rx queue pointer remains unchanged.
The following is quoted from the Zynq UltraScale TRM:
When transmit is disabled, with bit [3] of the network control register
set low, the transmit-buffer queue pointer resets to point to the address
indicated by the transmit-buffer queue base address register. Disabling
receive does not have the same effect on the receive-buffer queue
pointer.
Additionally, there is no need to reset the RBQP and TBQP registers in a
phy event callback. Therefore, move macb_init_buffers() to macb_open().
In a phy link up event, the only required action is to reset the tx
software head and tail pointers to align with the hardware's behavior.
[1] https://docs.amd.com/v/u/en-US/ug1085-zynq-ultrascale-trm
Fixes: 99537d5c476c ("net: macb: Relocate mog_init_rings() callback from macb_mac_link_up() to macb_open()")
Signed-off-by: Kevin Hao <haokexin@gmail.com>
Cc: stable@vger.kernel.org
---
Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>
Cc: "David S. Miller" <davem@davemloft.net>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Xiaolei Wang <xiaolei.wang@windriver.com>
---
drivers/net/ethernet/cadence/macb_main.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
index effef67d80731e5cc795fcef5adc280ad931eda9..43cd013bb70e6bd08a31a0826364e4f34c0e0b89 100644
--- a/drivers/net/ethernet/cadence/macb_main.c
+++ b/drivers/net/ethernet/cadence/macb_main.c
@@ -705,14 +705,12 @@ static void macb_mac_link_up(struct phylink_config *config,
if (rx_pause)
ctrl |= MACB_BIT(PAE);
- /* Initialize rings & buffers as clearing MACB_BIT(TE) in link down
- * cleared the pipeline and control registers.
- */
- macb_init_buffers(bp);
-
- for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
+ for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
+ queue->tx_head = 0;
+ queue->tx_tail = 0;
queue_writel(queue, IER,
bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));
+ }
}
macb_or_gem_writel(bp, NCFGR, ctrl);
@@ -2954,6 +2952,7 @@ static int macb_open(struct net_device *dev)
}
bp->macbgem_ops.mog_init_rings(bp);
+ macb_init_buffers(bp);
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
napi_enable(&queue->napi_rx);
---
base-commit: 9845cf73f7db6094c0d8419d6adb848028f4a921
change-id: 20260207-macb-init-ring-b0e37b3a3755
Best regards,
--
Kevin Hao <haokexin@gmail.com>
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: macb: Fix tx/rx malfunction after phy link down and up
2026-02-08 8:45 [PATCH net] net: macb: Fix tx/rx malfunction after phy link down and up Kevin Hao
@ 2026-02-11 12:20 ` patchwork-bot+netdevbpf
2026-02-19 15:33 ` Alexander Dahl
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-02-11 12:20 UTC (permalink / raw)
To: Kevin Hao
Cc: netdev, stable, nicolas.ferre, claudiu.beznea, andrew+netdev,
davem, edumazet, kuba, pabeni, xiaolei.wang
Hello:
This patch was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:
On Sun, 08 Feb 2026 16:45:52 +0800 you wrote:
> In commit 99537d5c476c ("net: macb: Relocate mog_init_rings() callback
> from macb_mac_link_up() to macb_open()"), the mog_init_rings() callback
> was moved from macb_mac_link_up() to macb_open() to resolve a deadlock
> issue. However, this change introduced a tx/rx malfunction following
> phy link down and up events. The issue arises from a mismatch between
> the software queue->tx_head, queue->tx_tail, queue->rx_prepared_head,
> and queue->rx_tail values and the hardware's internal tx/rx queue
> pointers.
>
> [...]
Here is the summary with links:
- [net] net: macb: Fix tx/rx malfunction after phy link down and up
https://git.kernel.org/netdev/net/c/bf9cf80cab81
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net] net: macb: Fix tx/rx malfunction after phy link down and up
2026-02-08 8:45 [PATCH net] net: macb: Fix tx/rx malfunction after phy link down and up Kevin Hao
2026-02-11 12:20 ` patchwork-bot+netdevbpf
@ 2026-02-19 15:33 ` Alexander Dahl
1 sibling, 0 replies; 3+ messages in thread
From: Alexander Dahl @ 2026-02-19 15:33 UTC (permalink / raw)
To: Kevin Hao
Cc: netdev, stable, Nicolas Ferre, Claudiu Beznea, Andrew Lunn,
David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
Xiaolei Wang
Hello Kevin,
Am Sun, Feb 08, 2026 at 04:45:52PM +0800 schrieb Kevin Hao:
> In commit 99537d5c476c ("net: macb: Relocate mog_init_rings() callback
> from macb_mac_link_up() to macb_open()"), the mog_init_rings() callback
> was moved from macb_mac_link_up() to macb_open() to resolve a deadlock
> issue. However, this change introduced a tx/rx malfunction following
> phy link down and up events. The issue arises from a mismatch between
> the software queue->tx_head, queue->tx_tail, queue->rx_prepared_head,
> and queue->rx_tail values and the hardware's internal tx/rx queue
> pointers.
>
> According to the Zynq UltraScale TRM [1], when tx/rx is disabled, the
> internal tx queue pointer resets to the value in the tx queue base
> address register, while the internal rx queue pointer remains unchanged.
> The following is quoted from the Zynq UltraScale TRM:
> When transmit is disabled, with bit [3] of the network control register
> set low, the transmit-buffer queue pointer resets to point to the address
> indicated by the transmit-buffer queue base address register. Disabling
> receive does not have the same effect on the receive-buffer queue
> pointer.
>
> Additionally, there is no need to reset the RBQP and TBQP registers in a
> phy event callback. Therefore, move macb_init_buffers() to macb_open().
> In a phy link up event, the only required action is to reset the tx
> software head and tail pointers to align with the hardware's behavior.
>
> [1] https://docs.amd.com/v/u/en-US/ug1085-zynq-ultrascale-trm
>
> Fixes: 99537d5c476c ("net: macb: Relocate mog_init_rings() callback from macb_mac_link_up() to macb_open()")
> Signed-off-by: Kevin Hao <haokexin@gmail.com>
> Cc: stable@vger.kernel.org
After backporting this to my 6.12.66-rt15 based tree I can confirm
this solved our system lockup issue we had on at91 sam9x60, and which
was caused by the above mentioned commit 99537d5c476c (which made it
to the v6.12.64 release as f5c055c284156).
So for the stable tree:
Tested-by: Alexander Dahl <ada@thorsis.com>
Thanks and greetings
Alex
> ---
> Cc: Nicolas Ferre <nicolas.ferre@microchip.com>
> Cc: Claudiu Beznea <claudiu.beznea@tuxon.dev>
> Cc: Andrew Lunn <andrew+netdev@lunn.ch>
> Cc: "David S. Miller" <davem@davemloft.net>
> Cc: Eric Dumazet <edumazet@google.com>
> Cc: Jakub Kicinski <kuba@kernel.org>
> Cc: Paolo Abeni <pabeni@redhat.com>
> Cc: Xiaolei Wang <xiaolei.wang@windriver.com>
> ---
> drivers/net/ethernet/cadence/macb_main.c | 11 +++++------
> 1 file changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index effef67d80731e5cc795fcef5adc280ad931eda9..43cd013bb70e6bd08a31a0826364e4f34c0e0b89 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -705,14 +705,12 @@ static void macb_mac_link_up(struct phylink_config *config,
> if (rx_pause)
> ctrl |= MACB_BIT(PAE);
>
> - /* Initialize rings & buffers as clearing MACB_BIT(TE) in link down
> - * cleared the pipeline and control registers.
> - */
> - macb_init_buffers(bp);
> -
> - for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
> + for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
> + queue->tx_head = 0;
> + queue->tx_tail = 0;
> queue_writel(queue, IER,
> bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));
> + }
> }
>
> macb_or_gem_writel(bp, NCFGR, ctrl);
> @@ -2954,6 +2952,7 @@ static int macb_open(struct net_device *dev)
> }
>
> bp->macbgem_ops.mog_init_rings(bp);
> + macb_init_buffers(bp);
>
> for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
> napi_enable(&queue->napi_rx);
>
> ---
> base-commit: 9845cf73f7db6094c0d8419d6adb848028f4a921
> change-id: 20260207-macb-init-ring-b0e37b3a3755
>
> Best regards,
> --
> Kevin Hao <haokexin@gmail.com>
>
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-02-19 15:33 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-08 8:45 [PATCH net] net: macb: Fix tx/rx malfunction after phy link down and up Kevin Hao
2026-02-11 12:20 ` patchwork-bot+netdevbpf
2026-02-19 15:33 ` Alexander Dahl
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox