Skip to content

Commit

Permalink
net: cadence: macb: Fix a possible deadlock in macb_halt_tx.
Browse files Browse the repository at this point in the history
[ Upstream commit c92d608 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
  • Loading branch information
Mathieu Othacehe authored and Greg Kroah-Hartman committed May 22, 2025
1 parent 1cb9a89 commit aace6b6
Showing 1 changed file with 6 additions and 13 deletions.
19 changes: 6 additions & 13 deletions drivers/net/ethernet/cadence/macb_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -962,22 +962,15 @@ static void macb_update_stats(struct macb *bp)

static int macb_halt_tx(struct macb *bp)
{
unsigned long halt_time, timeout;
u32 status;
u32 status;

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

timeout = jiffies + usecs_to_jiffies(MACB_HALT_TIMEOUT);
do {
halt_time = jiffies;
status = macb_readl(bp, TSR);
if (!(status & MACB_BIT(TGO)))
return 0;

udelay(250);
} while (time_before(halt_time, timeout));

return -ETIMEDOUT;
/* Poll TSR until TGO is cleared or timeout. */
return read_poll_timeout_atomic(macb_readl, status,
!(status & MACB_BIT(TGO)),
250, MACB_HALT_TIMEOUT, false,
bp, TSR);
}

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

0 comments on commit aace6b6

Please sign in to comment.