mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index
@ 2026-09-21  9:13 Gajdos Tamás
  2026-09-21  9:13 ` [PATCH 1/3] net: atl1c: fix soft lockup on out-of-range tpd_cons read Gajdos Tamás
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Gajdos Tamás @ 2026-09-21  9:13 UTC (permalink / raw)
  To: netdev
  Cc: Chris Snook, Andrew Lunn, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Gatis Peisenieks, linux-kernel,
	Gajdos Tamás

atl1c_clean_tx() reads a hardware-maintained tx consumer index and
walks a software index towards it:

    while (next_to_clean != hw_next_to_clean) {
            ...
            if (++next_to_clean == tpd_ring->count)
                    next_to_clean = 0;
    }

next_to_clean only ever takes values in [0, tpd_ring->count). If the
hardware read returns a value outside that range - seen as 0xffff
while the PCIe link/MAC is resetting, e.g. during a neighboring
device's reboot - the loop condition can never become false, and the
NAPI thread spins forever. This produced a real soft lockup on
current hardware:

    watchdog: BUG: soft lockup - CPU#12 stuck for 354s! [napi/eth%d-0]
    RIP: 0010:atl1c_clean_tx+0x142/0x2d0 [atl1c]

Patch 1 fixes this in atl1c. atl1e and atl1 (atlx) share the exact
same loop shape, reading their own hardware-maintained consumer index
with no bounds check either, and are just as reachable from the same
kind of PCIe link event. Patches 2 and 3 apply the same guard to each.

Gajdos Tamás (3):
  net: atl1c: fix soft lockup on out-of-range tpd_cons read
  net: atl1e: fix soft lockup on out-of-range hw_next_to_clean read
  net: atl1: fix soft lockup on out-of-range cmb_tpd_next_to_clean read

 drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 3 +++
 drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 3 +++
 drivers/net/ethernet/atheros/atlx/atl1.c        | 3 +++
 3 files changed, 9 insertions(+)

-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/3] net: atl1c: fix soft lockup on out-of-range tpd_cons read
  2026-09-21  9:13 [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index Gajdos Tamás
@ 2026-09-21  9:13 ` Gajdos Tamás
  2026-09-21  9:13 ` [PATCH 2/3] net: atl1e: fix soft lockup on out-of-range hw_next_to_clean read Gajdos Tamás
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Gajdos Tamás @ 2026-09-21  9:13 UTC (permalink / raw)
  To: netdev
  Cc: Chris Snook, Andrew Lunn, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Gatis Peisenieks, linux-kernel,
	Gajdos Tamás, stable

The hardware can report an out-of-range tpd_cons (seen as 0xffff)
while the PCIe link/MAC is resetting. An out-of-range value can
never be reached and the loop below would spin forever. To avoid
a soft lockup treat it as "nothing new to clean" instead.

Reproduced on two machines, same NIC (Qualcomm Atheros AR8151 v2.0,
4-port), triggered by rebooting a Mikrotik CCR2004 PCIe card that
the ports are directly linked to:

- Ubuntu 26.04.1 LTS, kernel 7.0.0-31-generic. The link-flap
  precursor, before the lockup was captured with a full trace
  elsewhere:

    atl1c 0000:05:00.0 enp5s0f0: NETDEV WATCHDOG: CPU: 4: transmit queue 2 timed out 489984 ms
    atl1c 0000:05:00.0: MAC state machine can't be idle since disabled for 10ms second
    atl1c 0000:05:00.0: atl1c: enp5s0f0 NIC Link is Up<65535 Mbps Full Duplex>

  65535 (0xffff) here is the same value tpd_cons reads back once the
  loop below gets stuck.

- Proxmox VE, kernel 7.0.14-11-pve. Same NIC/trigger, this time
  caught by the soft lockup watchdog with a full stack trace:

    watchdog: BUG: soft lockup - CPU#12 stuck for 354s! [napi/eth%d-0:329]
    CPU: 12 UID: 0 PID: 329 Comm: napi/eth%d-0 Tainted: P O L 7.0.14-11-pve #1 PREEMPT(lazy)
    RIP: 0010:atl1c_clean_tx+0x142/0x2d0 [atl1c]
    Call Trace:
     <TASK>
     __napi_poll+0x32/0x1e0
     napi_threaded_poll_loop+0x286/0x2e0
     napi_threaded_poll+0xfd/0x140
     kthread+0xf7/0x130
     ret_from_fork+0x2da/0x3a0
     ret_from_fork_asm+0x1a/0x30
     </TASK>

Fixes: 43250ddd75a35d ("atl1c: Atheros L1C Gigabit Ethernet driver")
Cc: stable@vger.kernel.org
Signed-off-by: Gajdos Tamás <tamas@rimpianto.com>
---
 drivers/net/ethernet/atheros/atl1c/atl1c_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
index 7efa3fc257..e58f1d2c26 100644
--- a/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
+++ b/drivers/net/ethernet/atheros/atl1c/atl1c_main.c
@@ -1602,6 +1602,9 @@ static int atl1c_clean_tx(struct napi_struct *napi, int budget)
 	AT_READ_REGW(&adapter->hw, atl1c_qregs[tpd_ring->num].tpd_cons,
 		     &hw_next_to_clean);
 
+	if (unlikely(hw_next_to_clean >= tpd_ring->count))
+		hw_next_to_clean = next_to_clean;
+
 	while (next_to_clean != hw_next_to_clean) {
 		buffer_info = &tpd_ring->buffer_info[next_to_clean];
 		if (buffer_info->skb) {
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 2/3] net: atl1e: fix soft lockup on out-of-range hw_next_to_clean read
  2026-09-21  9:13 [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index Gajdos Tamás
  2026-09-21  9:13 ` [PATCH 1/3] net: atl1c: fix soft lockup on out-of-range tpd_cons read Gajdos Tamás
@ 2026-09-21  9:13 ` Gajdos Tamás
  2026-09-21  9:13 ` [PATCH 3/3] net: atl1: fix soft lockup on out-of-range cmb_tpd_next_to_clean read Gajdos Tamás
  2026-09-24 10:50 ` [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Gajdos Tamás @ 2026-09-21  9:13 UTC (permalink / raw)
  To: netdev
  Cc: Chris Snook, Andrew Lunn, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Gatis Peisenieks, linux-kernel,
	Gajdos Tamás, stable

Same issue as atl1c (see the first commit in this series, "net:
atl1c: fix soft lockup on out-of-range tpd_cons read"): the hardware
can report an out-of-range hw_next_to_clean (seen as 0xffff) while
the PCIe link/MAC is resetting. An out-of-range value can never be
reached and the loop below would spin forever. Treat it as "nothing
new to clean" instead.

Fixes: a6a5325239c202 ("atl1e: Atheros L1E Gigabit Ethernet driver")
Cc: stable@vger.kernel.org
Signed-off-by: Gajdos Tamás <tamas@rimpianto.com>
---
 drivers/net/ethernet/atheros/atl1e/atl1e_main.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
index 4029002858..437989edb7 100644
--- a/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
+++ b/drivers/net/ethernet/atheros/atl1e/atl1e_main.c
@@ -1234,6 +1234,9 @@ static bool atl1e_clean_tx_irq(struct atl1e_adapter *adapter)
 	u16 hw_next_to_clean = AT_READ_REGW(&adapter->hw, REG_TPD_CONS_IDX);
 	u16 next_to_clean = atomic_read(&tx_ring->next_to_clean);
 
+	if (unlikely(hw_next_to_clean >= tx_ring->count))
+		hw_next_to_clean = next_to_clean;
+
 	while (next_to_clean != hw_next_to_clean) {
 		tx_buffer = &tx_ring->tx_buffer[next_to_clean];
 		if (tx_buffer->dma) {
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 3/3] net: atl1: fix soft lockup on out-of-range cmb_tpd_next_to_clean read
  2026-09-21  9:13 [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index Gajdos Tamás
  2026-09-21  9:13 ` [PATCH 1/3] net: atl1c: fix soft lockup on out-of-range tpd_cons read Gajdos Tamás
  2026-09-21  9:13 ` [PATCH 2/3] net: atl1e: fix soft lockup on out-of-range hw_next_to_clean read Gajdos Tamás
@ 2026-09-21  9:13 ` Gajdos Tamás
  2026-09-24 10:50 ` [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: Gajdos Tamás @ 2026-09-21  9:13 UTC (permalink / raw)
  To: netdev
  Cc: Chris Snook, Andrew Lunn, David S . Miller, Eric Dumazet,
	Jakub Kicinski, Paolo Abeni, Gatis Peisenieks, linux-kernel,
	Gajdos Tamás, stable

Same issue as atl1c (see the first commit in this series, "net:
atl1c: fix soft lockup on out-of-range tpd_cons read"): the hardware
can report an out-of-range cmb_tpd_next_to_clean (seen as 0xffff)
while the PCIe link/MAC is resetting. An out-of-range value can
never be reached and the loop below would spin forever. Treat it as
"nothing new to clean" instead.

Fixes: f3cc28c797604f ("Add Attansic L1 ethernet driver.")
Cc: stable@vger.kernel.org
Signed-off-by: Gajdos Tamás <tamas@rimpianto.com>
---
 drivers/net/ethernet/atheros/atlx/atl1.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/net/ethernet/atheros/atlx/atl1.c b/drivers/net/ethernet/atheros/atlx/atl1.c
index 98a4d08927..957d5598dd 100644
--- a/drivers/net/ethernet/atheros/atlx/atl1.c
+++ b/drivers/net/ethernet/atheros/atlx/atl1.c
@@ -2066,6 +2066,9 @@ static int atl1_intr_tx(struct atl1_adapter *adapter)
 	sw_tpd_next_to_clean = atomic_read(&tpd_ring->next_to_clean);
 	cmb_tpd_next_to_clean = le16_to_cpu(adapter->cmb.cmb->tpd_cons_idx);
 
+	if (unlikely(cmb_tpd_next_to_clean >= tpd_ring->count))
+		cmb_tpd_next_to_clean = sw_tpd_next_to_clean;
+
 	while (cmb_tpd_next_to_clean != sw_tpd_next_to_clean) {
 		buffer_info = &tpd_ring->buffer_info[sw_tpd_next_to_clean];
 		if (buffer_info->dma) {
-- 
2.53.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index
  2026-09-21  9:13 [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index Gajdos Tamás
                   ` (2 preceding siblings ...)
  2026-09-21  9:13 ` [PATCH 3/3] net: atl1: fix soft lockup on out-of-range cmb_tpd_next_to_clean read Gajdos Tamás
@ 2026-09-24 10:50 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-09-24 10:50 UTC (permalink / raw)
  To: =?utf-8?q?Gajdos_Tam=C3=A1s_=3Ctamas=40rimpianto=2Ecom=3E?=
  Cc: netdev, chris.snook, andrew+netdev, davem, edumazet, kuba,
	pabeni, gatis, linux-kernel

Hello:

This series was applied to netdev/net.git (main)
by Paolo Abeni <pabeni@redhat.com>:

On Mon, 21 Sep 2026 11:13:31 +0200 you wrote:
> atl1c_clean_tx() reads a hardware-maintained tx consumer index and
> walks a software index towards it:
> 
>     while (next_to_clean != hw_next_to_clean) {
>             ...
>             if (++next_to_clean == tpd_ring->count)
>                     next_to_clean = 0;
>     }
> 
> [...]

Here is the summary with links:
  - [1/3] net: atl1c: fix soft lockup on out-of-range tpd_cons read
    https://git.kernel.org/netdev/net/c/36c2009d90f2
  - [2/3] net: atl1e: fix soft lockup on out-of-range hw_next_to_clean read
    https://git.kernel.org/netdev/net/c/374bf9e4b90f
  - [3/3] net: atl1: fix soft lockup on out-of-range cmb_tpd_next_to_clean read
    https://git.kernel.org/netdev/net/c/43e746821f5f

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] 5+ messages in thread

end of thread, other threads:[~2026-09-24 10:51 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-21  9:13 [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index Gajdos Tamás
2026-09-21  9:13 ` [PATCH 1/3] net: atl1c: fix soft lockup on out-of-range tpd_cons read Gajdos Tamás
2026-09-21  9:13 ` [PATCH 2/3] net: atl1e: fix soft lockup on out-of-range hw_next_to_clean read Gajdos Tamás
2026-09-21  9:13 ` [PATCH 3/3] net: atl1: fix soft lockup on out-of-range cmb_tpd_next_to_clean read Gajdos Tamás
2026-09-24 10:50 ` [PATCH 0/3] net: atl1c/atl1e/atl1: fix soft lockup on out-of-range tx consumer index patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®