Skip to contentSkip to conversation

net: macb: Fix Ethernet malfunction on AMD Versal board after suspend

PATCH Applied Kevin Hao 3 participants 5 messages Mar 12 – Mar 14

Subsystems (4)
lore
Share & tools
lore

Kevin Hao

author
#0 lore raw

cover net: macb: Fix Ethernet malfunction on AMD Versal board after suspend

Hi,

On Versal boards, the tx/rx queue pointer registers are cleared after suspend, which causes Ethernet malfunction. This patch series addresses this issue by reinitializing the tx/rx queue pointer registers and the rx ring.

---
Cc: Nicolas Ferre <[email protected]>
Cc: Claudiu Beznea <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Paolo Abeni <[email protected]>

---
Kevin Hao (2):
net: macb: Introduce gem_init_rx_ring()
net: macb: Reinitialize tx/rx queue pointer registers and rx ring during resume

 drivers/net/ethernet/cadence/macb_main.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

---
base-commit: f90aadf1c67c8b4969d1e5e6d4fd7227adb6e4d7
change-id: 20260311-macb-versal-e5493bbac09f

Best regards,

Signature · 1 line
Kevin Hao <[email protected]>
author
#1 lore raw

PATCH 1/2 net: macb: Introduce gem_init_rx_ring()

Extract the initialization code for the GEM RX ring into a new function. This change will be utilized in a subsequent patch. No functional changes are introduced.

---
 drivers/net/ethernet/cadence/macb_main.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)
drivers/net/ethernet/cadence/macb_main.c +9 -4
index 952aaf84757c20e94f3bbc98162a18330aa4cf73..67f7ecb05a7d6b8a5f49da588faafe1aa70d0d2b 100644
@@ -2805,6 +2805,14 @@ static void macb_init_tieoff(struct macb *bp)
 	desc->ctrl = 0;
 }
 
+static void gem_init_rx_ring(struct macb_queue *queue)
+{
+	queue->rx_tail = 0;
+	queue->rx_prepared_head = 0;
+
+	gem_rx_refill(queue);
+}
+
 static void gem_init_rings(struct macb *bp)
 {
 	struct macb_queue *queue;
@@ -2822,10 +2830,7 @@ static void gem_init_rings(struct macb *bp)
 		queue->tx_head = 0;
 		queue->tx_tail = 0;
 
-		queue->rx_tail = 0;
-		queue->rx_prepared_head = 0;
-
-		gem_rx_refill(queue);
+		gem_init_rx_ring(queue);
 	}
 
 	macb_init_tieoff(bp);
Signature · 1 line
2.53.0
author
#2 lore raw

PATCH 2/2 net: macb: Reinitialize tx/rx queue pointer registers and rx ring during resume

In reply to Kevin Hao

On certain platforms, such as AMD Versal boards, the tx/rx queue pointer registers are cleared after suspend, and the rx queue pointer register is also disabled during suspend if WOL is enabled. Previously, we assumed that these registers would be restored by macb_mac_link_up(). However, in commit bf9cf80cab81, macb_init_buffers() was moved from macb_mac_link_up() to macb_open(). Therefore, we should call macb_init_buffers() to reinitialize the tx/rx queue pointer registers during resume.

Due to the reset of these two registers, we also need to adjust the tx/rx rings accordingly. The tx ring will be handled by gem_shuffle_tx_rings() in macb_mac_link_up(), so we only need to initialize the rx ring here.

Fixes bf9cf80cab81 ("net: macb: Fix tx/rx malfunction after phy link down and up")
---
 drivers/net/ethernet/cadence/macb_main.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
drivers/net/ethernet/cadence/macb_main.c +10 -0
index 67f7ecb05a7d6b8a5f49da588faafe1aa70d0d2b..100f478c0d30e4a91021a7da83f8f08606eca66e 100644
@@ -6106,8 +6106,18 @@ static int __maybe_unused macb_resume(struct device *dev)
 		rtnl_unlock();
 	}
 
+	if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC))
+		macb_init_buffers(bp);
+
 	for (q = 0, queue = bp->queues; q < bp->num_queues;
 	     ++q, ++queue) {
+		if (!(bp->caps & MACB_CAPS_MACB_IS_EMAC)) {
+			if (macb_is_gem(bp))
+				gem_init_rx_ring(queue);
+			else
+				macb_init_rx_ring(queue);
+		}
+
 		napi_enable(&queue->napi_rx);
 		napi_enable(&queue->napi_tx);
 	}
Signature · 1 line
2.53.0
reviewer Reviewed-by on the v1 series
#3 lore raw
In reply to Kevin Hao
Quoted 15 lines · Kevin Hao

Hi,

On Versal boards, the tx/rx queue pointer registers are cleared after suspend, which causes Ethernet malfunction. This patch series addresses this issue by reinitializing the tx/rx queue pointer registers and the rx ring.

---
Cc: Nicolas Ferre <[email protected]>
Cc: Claudiu Beznea <[email protected]>
Cc: Andrew Lunn <[email protected]>
Cc: "David S. Miller" <[email protected]>
Cc: Eric Dumazet <[email protected]>
Cc: Jakub Kicinski <[email protected]>
Cc: Paolo Abeni <[email protected]>

Quoted 7 lines

---
Kevin Hao (2):
net: macb: Introduce gem_init_rx_ring()
net: macb: Reinitialize tx/rx queue pointer registers and rx ring during resume

 drivers/net/ethernet/cadence/macb_main.c | 23 +++++++++++++++++++----
 1 file changed, 19 insertions(+), 4 deletions(-)

For the series,

#4 lore raw
In reply to Kevin Hao
This series was applied to netdev/net.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This series was applied to netdev/net.git (main)
by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Thu, 12 Mar 2026 16:13:57 +0800 you wrote:

Hi,

On Versal boards, the tx/rx queue pointer registers are cleared after suspend, which causes Ethernet malfunction. This patch series addresses this issue by reinitializing the tx/rx queue pointer registers and the rx ring.

[...]

Here is the summary with links:
- [net,1/2] net: macb: Introduce gem_init_rx_ring()

    https://git.kernel.org/netdev/net/c/1a7124ecd655
  - [net,2/2] net: macb: Reinitialize tx/rx queue pointer registers and rx ring during resume
    https://git.kernel.org/netdev/net/c/718d0766ce4c

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html