mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Federico Musto <federico@rimpianto.com>
To: Chris Snook <chris.snook@gmail.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S . Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@kernel.org>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	netdev@vger.kernel.org
Cc: linux-kernel@vger.kernel.org, Federico Musto <federico@rimpianto.com>
Subject: [PATCH net v5 0/2] net: atl1c: fix the RX buffer leak on errored frames
Date: Wed, 25 Nov 2026 12:31:18 +0100	[thread overview]
Message-ID: <20261125113120.99743-1-federico@rimpianto.com> (raw)

Patch 2 is v5 of the fix for the skb and the DMA mapping leaked by every
RX frame whose descriptor reports an error. Patch 1 closes the race
between the RX poll and the ring reset of the link-down path.

v5 addresses the Sashiko AI review of v4:

 - 1/2 no longer proceeds with the ring reset when it stops waiting
   because __AT_DOWN appeared: a concurrent close/down/suspend resets the
   rings itself after napi_disable(), so the work item now leaves them
   alone. The wait is also bounded (~0.5-1 s, then the reset is skipped
   with a ratelimited warning), so a threaded busy-poll cannot stall the
   work item with interrupts masked. The wait only runs on the work-item
   path; atl1c_up() reaches the handler before napi_enable() and skips
   it. The carrier-off store is now ordered before the NAPI_STATE_SCHED
   sampling with an explicit smp_mb(): the handshake is a store-buffer
   pattern and the scheduling side is ordered by the cmpxchg in
   napi_schedule_prep().
 - 2/2 adds a dma_rmb() between the valid-bit test on word3 and the rest
   of the descriptor. word0 now decides whether a reset is scheduled and
   the ring is zeroed after a reset, so without the barrier a stale word0
   could schedule a spurious reset on weakly ordered CPUs.

The per-patch changelogs are below the "---" of each patch.

Both problems were found by code inspection. Build-tested with W=1 and
sparse on netdev/net: no new warnings.

Runtime-tested on a MikroTik CCR2004-1G-2XS-PCIe, which exposes emulated
AR8151 functions, with these two patches ported onto the driver of a
7.0.14-29-pve kernel plus diagnostic counters.  27 link-down events were
handled and the link recovered every time: 9 from the first campaign (3
PHY link flaps and 6 link drops that this card produces about 1.3 s
after an MTU change), and 18 from later flap campaigns, partly under
sustained RX load.  The load caught an RX poll in flight four times:
the wait loop iterated, the poll finished within a few milliseconds and
the reset proceeded normally.  The __AT_DOWN skip, the timeout branch,
the out-of-sync reset and the error path of patch 2 have not been
exercised on hardware.  No RRD out-of-sync events across ~4.3 GiB of
traffic plus the load campaigns, no Oops, no warnings.

One observation, reported for completeness: twice, about 1.3 s after an
MTU change and immediately before the device signalled link down, the
IOMMU blocked a DMA read from the device to an unmapped address.  Both
faults precede the link-down interrupt, so before the work item touched
by this series ran.  I have not established the cause; this card is
known to issue stale DMA around that event.

v4: https://lore.kernel.org/netdev/20261117225521.19689-1-federico@rimpianto.com/
v3: https://lore.kernel.org/netdev/20261103225218.19206-1-federico@rimpianto.com/
v2: https://lore.kernel.org/netdev/20261102215253.68185-1-federico@rimpianto.com/
v1: https://lore.kernel.org/netdev/20261027115156.17128-1-federico@rimpianto.com/

Federico Musto (2):
  net: atl1c: wait for in-flight RX polls before the link-down ring
    reset
  net: atl1c: free the RX buffer when the descriptor reports an error

 .../net/ethernet/atheros/atl1c/atl1c_main.c   | 169 +++++++++++++-----
 1 file changed, 121 insertions(+), 48 deletions(-)

-- 
2.54.0 (Apple Git-157)


             reply	other threads:[~2026-11-25 11:32 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-25 11:31 Federico Musto [this message]
2026-11-25 11:31 ` [PATCH net v5 1/2] net: atl1c: wait for in-flight RX polls before the link-down ring reset Federico Musto
2026-11-29 11:48   ` netdev-bot+sashiko
2026-11-25 11:31 ` [PATCH net v5 2/2] net: atl1c: free the RX buffer when the descriptor reports an error Federico Musto
2026-11-29 11:48   ` netdev-bot+sashiko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261125113120.99743-1-federico@rimpianto.com \
    --to=federico@rimpianto.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=chris.snook@gmail.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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®