From: Linus Walleij <linusw@kernel.org>
To: "Hans Ulli Kroll" <ulli.kroll@googlemail.com>,
"Andrew Lunn" <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Michał Mirosław" <mirq-linux@rere.qmqm.pl>,
"Myeonghun Pak" <mhun512@gmail.com>,
"Eric Dumazet" <edumazet@kernel.org>
Cc: netdev@vger.kernel.org, Linus Walleij <linusw@kernel.org>
Subject: [PATCH net-next v5 00/14] net: ethernet: cortina: Fix Gemini RX buffer management
Date: Thu, 15 Oct 2026 17:24:00 +0200 [thread overview]
Message-ID: <20261015-gemini-ethernet-fixes-3-v5-0-b5c9e2f7b8a3@kernel.org> (raw)
The Gemini ethernet uses a custom software free queue shared by both
ports. Its page metadata, DMA mappings and fragment references are not
managed consistently as pages move through the free queue and RX queues.
Correct the DMA address bookkeeping and synchronization.
Track exact fragment mappings with an XArray and keep
in-flight page metadata in bitmap-allocated slots until all hardware
references have been claimed.
Serialize queue resize against the refill interrupt, harden fragment
validation and teardown, then scale the default queue sizes for systems
with 32 or 64 MiB of RAM.
This series wasn't so complex to begin with but Sashiko and the other
LLMs just find more and more corner cases. It's for the better I
guess.
Before these patches the network driver would crash under strong load
but it does not happen any more after. Tested on the D-Link DIR-685
playing back media and transfering new media using ksmbd while
issuing ping storms.
Assisted-by: LLM
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
Changes in v5:
- Preserve complete frames terminated by an empty EOF descriptor.
- Recheck concurrently retired pages before consuming fresh metadata slots.
- Fold RX ring metadata sizing and resize rollback into the page lifetime
fix.
- Match free queue teardown unmaps to the saved full-page DMA mapping.
- Preserve the hardware-owned free queue read pointer across rebuilds and
keep replacement rings large enough for its retained position.
- Keep shared initialization parent-owned, quiesce inherited IRQ state
before child handlers register and force first queue setup from ring
state.
- Link to v4: https://patch.msgid.link/20261011-gemini-ethernet-fixes-3-v4-0-4b1631b08f5d@kernel.org
Changes in v4:
- Protect stop-path RX statistics updates against preemption on 32-bit systems.
- Validate final RX lengths against the Ethernet minimum and descriptor
transfer size so malformed chains cannot pass short skbs to GRO.
- Charge the full posted RX fragment size in skb truesize accounting.
- Reject free queue geometries that cannot post one complete page and
document the changed refill and recycling behavior.
- Reset the free queue allocation cursor with its bitmap during teardown.
- Bound recycler IRQ latency and release retained mappings for stack-owned
pages before allocating replacements.
- Rebuild oversized free queues while both ports are down so RX ring
downsizing releases the surplus pages.
- Scope RX statistics writer sections to counter updates for PREEMPT_RT.
- Restrict shared free queue handling to port 1 so IRQ draining covers
every registered handler path.
- Reset and mask free queue pointers when rebuilding the queue.
- Reorder the shared queue ownership fix before the port lifetime fix.
- Publish ports only after setup, serialize their lifetime with RTNL and
suppress independent child unbind while port 1 owns the shared IRQ.
- Move child-unbind suppression and PHY teardown ordering into the
parent-ownership patch.
- Link to v3: https://patch.msgid.link/20261002-gemini-ethernet-fixes-3-v3-0-3e1f25890ae8@kernel.org
Changes in v3:
- Add Fixes tags throughout the series, using the original driver commit
where no more specific offending commit exists, and replace Resolves with
Closes on the lifetime fix. I did not retarget the series to net
because there are dependencies in net-next and we are getting closer
to the merge window.
- Keep PHY-less port 1 bound as the shared free queue IRQ owner and clear
stale parent port pointers.
- Disable the port 1 Linux IRQ throughout free queue resizing so no newly
woken threaded handler can race queue teardown or setup.
- Keep failed queue rebuilds quiescent in the IRQ-drain patch.
- Serialize linear DMA lookups before converting them to an XArray.
- Keep all XArray mutation under the IRQ-safe free queue lock.
- Defer page unmapping until fragment lifetime is tracked, and fold DMA
synchronization into that fix.
- Check free queue space before allocating and mapping a candidate page.
- Rebuild free queue metadata when RX rings grow and roll back rejected
ring changes.
- Recycle released pages with explicit DMA synchronization using the
existing free queue allocator.
- Account inconsistent RX descriptor lengths as drops rather than wire
length errors.
- Count partial RX frames discarded during stop as dropped.
- Drop the cleanup guard conversion because it is not recommended for
network drivers.
- Link to v2: https://patch.msgid.link/20260928-gemini-ethernet-fixes-3-v2-0-758a795d7a78@kernel.org
Changes in v2:
- Replace the page_pool conversion with several smaller fixes using the
existing free queue page allocator.
- Split DMA bookkeeping, XArray lookup, bitmap allocation, cursor rotation,
synchronization, validation and teardown into individual patches.
- Drain the threaded free queue interrupt before resizing the shared queue.
- Allocate and DMA-map refill pages outside the IRQ-disabled free queue
lock.
- Reject and unwind partial initial free queue fills, reset their hardware
pointers and leave the refill interrupt masked so setup can be retried.
- Avoid full-page CPU synchronization after fragments enter the network
stack.
- Bound RX lengths to the posted fragment and account rejected lengths as
receive errors.
- Keep the fixes, and keep the add-on RAM sizing patch.
- Link to v1: https://patch.msgid.link/20260920-gemini-ethernet-fixes-3-v1-0-3a2a50a83d89@kernel.org
---
Linus Walleij (14):
net: ethernet: cortina: Keep shared free queue parent-owned
net: ethernet: cortina: Keep PHY-less port bound for shared IRQ
net: ethernet: cortina: Drain free queue IRQ before resize
net: ethernet: cortina: Normalize free queue pointers on rebuild
net: ethernet: cortina: Correct free queue DMA mappings
net: ethernet: cortina: Index free queue fragments with XArray
net: ethernet: cortina: Preserve in-flight free queue pages
net: ethernet: cortina: Rotate free queue page allocation
net: ethernet: cortina: Recycle claimed free queue pages
net: ethernet: cortina: Validate RX fragment lengths
net: ethernet: cortina: Account RX buffer size in truesize
net: ethernet: cortina: Release partial RX frames on stop
net: ethernet: cortina: Scale Gemini RX queues to system memory
net: ethernet: cortina: Scope RX statistics updates
drivers/net/ethernet/cortina/gemini.c | 830 +++++++++++++++++++++++++---------
drivers/net/ethernet/cortina/gemini.h | 2 +-
2 files changed, 616 insertions(+), 216 deletions(-)
---
base-commit: 071876fd50482a68603a9460d80dd6dd58827ee1
change-id: 20260919-gemini-ethernet-fixes-3-f0403653f23a
Best regards,
--
Linus Walleij <linusw@kernel.org>
next reply other threads:[~2026-10-15 15:24 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-15 15:24 Linus Walleij [this message]
2026-10-15 15:24 ` [PATCH net-next v5 01/14] net: ethernet: cortina: Keep shared free queue parent-owned Linus Walleij
2026-10-19 17:28 ` netdev-bot+sashiko
2026-10-21 13:17 ` Paolo Abeni
2026-10-15 15:24 ` [PATCH net-next v5 02/14] net: ethernet: cortina: Keep PHY-less port bound for shared IRQ Linus Walleij
2026-10-15 15:24 ` [PATCH net-next v5 03/14] net: ethernet: cortina: Drain free queue IRQ before resize Linus Walleij
2026-10-15 15:24 ` [PATCH net-next v5 04/14] net: ethernet: cortina: Normalize free queue pointers on rebuild Linus Walleij
2026-10-19 17:28 ` netdev-bot+sashiko
2026-10-15 15:24 ` [PATCH net-next v5 05/14] net: ethernet: cortina: Correct free queue DMA mappings Linus Walleij
2026-10-19 17:28 ` netdev-bot+sashiko
2026-10-15 15:24 ` [PATCH net-next v5 06/14] net: ethernet: cortina: Index free queue fragments with XArray Linus Walleij
2026-10-15 15:24 ` [PATCH net-next v5 07/14] net: ethernet: cortina: Preserve in-flight free queue pages Linus Walleij
2026-10-19 17:28 ` netdev-bot+sashiko
2026-10-15 15:24 ` [PATCH net-next v5 08/14] net: ethernet: cortina: Rotate free queue page allocation Linus Walleij
2026-10-15 15:24 ` [PATCH net-next v5 09/14] net: ethernet: cortina: Recycle claimed free queue pages Linus Walleij
2026-10-19 17:28 ` netdev-bot+sashiko
2026-10-15 15:24 ` [PATCH net-next v5 10/14] net: ethernet: cortina: Validate RX fragment lengths Linus Walleij
2026-10-19 17:28 ` netdev-bot+sashiko
2026-10-15 15:24 ` [PATCH net-next v5 11/14] net: ethernet: cortina: Account RX buffer size in truesize Linus Walleij
2026-10-19 17:28 ` netdev-bot+sashiko
2026-10-15 15:24 ` [PATCH net-next v5 12/14] net: ethernet: cortina: Release partial RX frames on stop Linus Walleij
2026-10-19 17:28 ` netdev-bot+sashiko
2026-10-15 15:24 ` [PATCH net-next v5 13/14] net: ethernet: cortina: Scale Gemini RX queues to system memory Linus Walleij
2026-10-15 15:24 ` [PATCH net-next v5 14/14] net: ethernet: cortina: Scope RX statistics updates Linus Walleij
2026-10-19 17:28 ` 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=20261015-gemini-ethernet-fixes-3-v5-0-b5c9e2f7b8a3@kernel.org \
--to=linusw@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=kuba@kernel.org \
--cc=mhun512@gmail.com \
--cc=mirq-linux@rere.qmqm.pl \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=ulli.kroll@googlemail.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