Skip to content

Commit 976d8ab

Browse files
haokexinpelwell
authored andcommitted
net: macb: Fix tx/rx malfunction after phy link down and up
In commit 99537d5 ("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/rx 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: 99537d5 ("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
1 parent d94afb6 commit 976d8ab

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -722,14 +722,12 @@ static void macb_mac_link_up(struct phylink_config *config,
722722
if (rx_pause)
723723
ctrl |= MACB_BIT(PAE);
724724

725-
/* Initialize rings & buffers as clearing MACB_BIT(TE) in link down
726-
* cleared the pipeline and control registers.
727-
*/
728-
macb_init_buffers(bp);
729-
730-
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue)
725+
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
726+
queue->tx_head = 0;
727+
queue->tx_tail = 0;
731728
queue_writel(queue, IER,
732729
bp->rx_intr_mask | MACB_TX_INT_FLAGS | MACB_BIT(HRESP));
730+
}
733731
}
734732

735733
macb_or_gem_writel(bp, NCFGR, ctrl);
@@ -3019,6 +3017,7 @@ static int macb_open(struct net_device *dev)
30193017
}
30203018

30213019
bp->macbgem_ops.mog_init_rings(bp);
3020+
macb_init_buffers(bp);
30223021

30233022
for (q = 0, queue = bp->queues; q < bp->num_queues; ++q, ++queue) {
30243023
napi_enable(&queue->napi_rx);

0 commit comments

Comments
 (0)