Skip to content

Commit c92d608

Browse files
Mathieu Othacehekuba-moo
authored andcommitted
net: cadence: macb: Fix a possible deadlock in macb_halt_tx.
There is a situation where after THALT is set high, TGO stays high as well. Because jiffies are never updated, as we are in a context with interrupts disabled, we never exit that loop and have a deadlock. That deadlock was noticed on a sama5d4 device that stayed locked for days. Use retries instead of jiffies so that the timeout really works and we do not have a deadlock anymore. Fixes: e86cd53 ("net/macb: better manage tx errors") Signed-off-by: Mathieu Othacehe <othacehe@gnu.org> Reviewed-by: Simon Horman <horms@kernel.org> Link: https://patch.msgid.link/20250509121935.16282-1-othacehe@gnu.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent 4d64321 commit c92d608

File tree

1 file changed

+6
-13
lines changed

1 file changed

+6
-13
lines changed

drivers/net/ethernet/cadence/macb_main.c

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -997,22 +997,15 @@ static void macb_update_stats(struct macb *bp)
997997

998998
static int macb_halt_tx(struct macb *bp)
999999
{
1000-
unsigned long halt_time, timeout;
1001-
u32 status;
1000+
u32 status;
10021001

10031002
macb_writel(bp, NCR, macb_readl(bp, NCR) | MACB_BIT(THALT));
10041003

1005-
timeout = jiffies + usecs_to_jiffies(MACB_HALT_TIMEOUT);
1006-
do {
1007-
halt_time = jiffies;
1008-
status = macb_readl(bp, TSR);
1009-
if (!(status & MACB_BIT(TGO)))
1010-
return 0;
1011-
1012-
udelay(250);
1013-
} while (time_before(halt_time, timeout));
1014-
1015-
return -ETIMEDOUT;
1004+
/* Poll TSR until TGO is cleared or timeout. */
1005+
return read_poll_timeout_atomic(macb_readl, status,
1006+
!(status & MACB_BIT(TGO)),
1007+
250, MACB_HALT_TIMEOUT, false,
1008+
bp, TSR);
10161009
}
10171010

10181011
static void macb_tx_unmap(struct macb *bp, struct macb_tx_skb *tx_skb, int budget)

0 commit comments

Comments
 (0)