🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #27507

[PATCH net-next v10 00/14] net: ethernet: cortina: Fix Gemini RX buffer management

#27507
From: Linus Walleij
Date: Sat, 05 Dec 2026 21:46
183 lines
17443 bytes
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 now stops at the RX queue memory sizing changes. Statistics,
RX coalescing timer lifetime and retained TX pointer handling are split
out into gemini-ethernet-fixes-4.

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.

Sashiko's remaining comments on this series are down to [low] issues.
The [medium] issues were addressed in v9; those reports mostly concerned
patches moved out of this series on request, or exotic hardware-failure
scenarios.

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.

Target this series at net-next. I will backport these changes to OpenWrt.

Signed-off-by: Linus Walleij <linusw@kernel.org>
---
Changes in v10:
- Rebased on the net-next tree.
- Link to v9: https://patch.msgid.link/20261120-gemini-ethernet-fixes-3-v9-0-298671d799d5@kernel.org

Changes in v9:
- Rebased on net-next.
- Drop all Fixes: tags.
- Move statistics and other follow-ups out of the series.
- Chop off patches to force the series down to 14 patches, save other concerns for later
- Link to v8: https://patch.msgid.link/20261112-gemini-ethernet-fixes-3-v8-0-f55bd43e02d3@kernel.org

Changes in v8:
- Protect TX fragment statistics updates during process-context teardown.
- Rebuild idle shared free queues on reopen to reclaim unclaimed fragments.
- Separate RX buffer capacity from retained-pointer descriptor ring sizing.
- Preserve PHY probe deferral and clean up fixed links on probe failure or removal.
- Link to v7: https://patch.msgid.link/20261110-gemini-ethernet-fixes-3-v7-0-9c32a1a46aec@kernel.org

Changes in v7:
- Bound free queue refill work and release surplus metadata on downsizing.
- Serialize TX completion statistics with the IRQ-side writers.
- Fix ethtool statistics retry bounds and counter synchronization.
- Reject pfmemalloc pages when recycling RX buffers.
- Document XArray dependency for lifetime and recycling backports.
- Reject TX rings smaller than retained hardware pointers, so now the
  series has also started to fix things on the TX path.
- Document the retained SWFQ pointer shrink and allocation limits.
- Keep ports IRQ-only after PHY setup or netdev registration failure.
- Keep parent-held port clocks enabled through IRQ draining and queue teardown.
- Link to v6: https://patch.msgid.link/20261103-gemini-ethernet-fixes-3-v6-0-c4b5ff8a65d8@kernel.org

Changes in v6:
- Initialize statistics synchronization objects for lockdep.
- Post free queue pages from the exact retained descriptor pointer.
- Document replacement-page lookup failures and tag the DMA mapping fix.
- Initialize and drain the RX coalescing timer around its IRQ lifetime.
- Rebased on v7.4-rc1
- Link to v5: https://patch.msgid.link/20261015-gemini-ethernet-fixes-3-v5-0-b5c9e2f7b8a3@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 ports 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: Separate RX buffer capacity from free queue size
      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

 drivers/net/ethernet/cortina/gemini.c | 924 +++++++++++++++++++++++++---------
 drivers/net/ethernet/cortina/gemini.h |   2 +-
 2 files changed, 699 insertions(+), 227 deletions(-)
---
base-commit: d5cf954cebe4f175dfd834e1dc471a3aa203ec7d
change-id: 20260919-gemini-ethernet-fixes-3-f0403653f23a

Best regards,
--  
Linus Walleij <linusw@kernel.org>
Technical Details
Message-ID: <20261205-gemini-ethernet-fixes-3-v10-0-9edd2057429c@kernel.org>
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378135-linux-kernel-netdev=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!feed-us-txt.newsdeef.eu!feed-us-mo.newsdeef.eu!srv.newsdeef.eu!newsfeed.endofthelinebbs.com!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-378135-linux-kernel-netdev=dewy.ru
From: linusw@kernel.org (Linus Walleij)
Newsgroups: linux.kernel.netdev
Subject: [PATCH net-next v10 00/14] net: ethernet: cortina: Fix Gemini RX
 buffer management
Date: Sat, 05 Dec 2026 22:46:43 +0100
Organization: Usenet Network
Message-ID: <20261205-gemini-ethernet-fixes-3-v10-0-9edd2057429c@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 7bit
Injection-Info: usenet.network;
	logging-data="3125790"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:fyfMVz31pa9H2aq0kLdcOv859f8= sha256:KdqgY1J1VQJx512MYc/ErnOoN4K5QloirdPV5KraEG0=
	sha1:AUo5BWaEmlr//JiCdcnsyULlYBg= sha256:fQddKyaPAZy+Oor+F/Ft+rRLHKC7AuBLPQREF4c0Kzo=
List-ID: <netdev.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 55A02117EBA; Sun,  6 Dec 2026 00:47:17 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.639
X-Spam-Status: No, score=-3.639 tagged_above=-9999 required=6.31
	tests=[DKIMWL_WL_HIGH=-0.14, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, MAILING_LIST_MULTI=-1,
	RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001, SPF_PASS=-0.001,
	URIBL_BLOCKED=0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=kernel.org
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id FFzngXRQ3Com;
	Sun,  6 Dec 2026 00:47:14 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=netdev+bounces-378135-linux-kernel-netdev=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=pass (p=quarantine dis=none) header.from=kernel.org
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 4003A117EAE; Sun,  6 Dec 2026 00:47:00 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92])
	by tor.lore.kernel.org (Postfix) with ESMTP id 183722847D; Sat,  5 Dec 2026 21:46:57 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-ARC-Seal: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=pass;
	t=1796507215;
	b=h81l4Mitg40DFQEnSsQaX2fcNzHI7Bzv8mBpRWYM3kKlJSHzlbayYcxKQL9FobbxKa/G
	 UQeeMfs5cl+6wP8rME+wjvG1e8r9bTjymDIUwI7QPX21GKtnDIEc3H99sogbwW/BN/aFr
	 6XFbZPXIHt7MQx30jQwv26tJmkCdrcoM0FT4LuVC09JCVmuOXAnsrt35WuDYxfp5lmj+P
	 871KPOi/DHmY1MZ4zz4Ixtg4Ytlh0FkpAupVhSqxjZ3kfMNwA9LsKrGDXt1etlcGdG4O2
	 qDihnw0xO+823hZ/CpXCdXeCGjRucszM/9GlCLrPWZ/9wiku/1quViS/U5tda69+y4w==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796507215;
	h=X-Original-To:Received:Received:DKIM-Signature:From:Subject:Date:
	 Message-Id:X-Mailing-List:List-Id:List-Post:List-Help:List-Subscribe:
	 List-Unsubscribe:List-Owner:Precedence:MIME-Version:Content-Type:
	 Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:Cc:X-Mailer;
	bh=nmQk5x0uZkWaKGsECHKRPBqfqEPsd8Pvz0pV12tzDrQ=;
	b=ef4NYvurmwADVJ9P4wFKsocrlFmizZNghJYgsKKp8S88s+gu3RekSvcYhEMA9UA53Wvh
	 kGkmruaXGTIzMVw+FBSpgEOI3zbmCTAog/LmHchdz2lddoNrotRIHzoZlBFWXpN7V0vT5
	 1LtTE8RhdDXj9OOAIxEOEdI5I+sYaOJHzAl1T2GGUkxVjj67IQbrJHC728DA93Qvjd4vO
	 KLprPqNmjcr9KflwRBsMcaHgK4o43hT2fHegcdyjry5MFGVKiLXKpkyyoL3YqTEVQ3/SR
	 odCEGXwLu0PBfYmTuh9Mw2yCtyL6OLYPzsR7xYCqgXaIx/DzjYo0DIwDcUCOrxjzm0g==
X-ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aK+txOJI;
	arc=pass header.oldest-pass=0 smtp.remote-ip=127.0.0.1
X-Received: from localhost.localdomain (localhost [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 5D603606A322;
	Sat,  5 Dec 2026 21:46:55 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aK+txOJI
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18
X-ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none;
	t=1796507209;
	b=H3sYvZe7vzNc+/L3OEn/VmdA4Yw/SJI+qNEOo/JYlY9qrBCwHwC68SOQRR48N4cO/LLI
	 9/DBlseMvX9EA6Stz63yWpzVZ0YW8sHZHOVaFLHCos91R5iUcapFnIJdo0HJKKqQd+O4m
	 H+i9iEr2wVj2xAQab+8AWbuh9nfdPxawKqe/ARBOskl9nRrJtTjKfGdwmkpErz4IKi5Z/
	 o92Nw4HanLm7R1nsSac7PEDb/LzPfHQx147AE4zCnqRYuavMegI7Z7N+gdj1162PmVQC2
	 D6CW6dtUtFWGgp8yICp6J4pxqJDq9FdAZOge7HKOOci5KemVtYavYUpYSdyUXhFLDxg==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015;
	a=rsa-sha256; c=relaxed/relaxed; t=1796507209;
	h=Received:DKIM-Signature:From:Subject:Date:Message-Id:MIME-Version:
	 Content-Type:Content-Transfer-Encoding:X-B4-Tracking:X-Change-ID:To:
	 Cc:X-Mailer;
	bh=nmQk5x0uZkWaKGsECHKRPBqfqEPsd8Pvz0pV12tzDrQ=;
	b=q+koBH6+798mcEejXNksoyQeuzVrRXPcYctBBYEpfhUi8GNvojUzqdgWXLdDdtFfwxW/
	 O3Oa6x0WqSvNo4qxFojy7W+uS25W8iyltFC+2k3+kLaEfwHzCG35evp36N6BgKPBzzA+G
	 uL6XxkX1xcNCWCiWzZ+XSODIgg9XeSwNplkNBa0lOoeo3/GS7r5qiNhMt3+nv1d3/Wvvn
	 5M1kmQy04Fz4pFNmUVYct5/B75PQle+UyGeMX9+L+EJox8AT8O2dDhv+0zMHqxP9vreA7
	 rTdz/XzSYPv2VkQReBV3XMttyVlWWtOJhF62noj73/zoCW5pjM0AtScgI0buSegklrg==
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; 
	dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=aK+txOJI;
	arc=none smtp.remote-ip=100.103.45.18
X-Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18])
	(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)
	 key-exchange X25519 server-signature ECDSA (prime256v1))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 78A25606A31F
	for <netdev@vger.kernel.org>; Sat,  5 Dec 2026 21:46:49 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id A30C61F0092B;
	Sat,  5 Dec 2026 21:46:46 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org;
	s=k20260515; t=1796507209;
	bh=nmQk5x0uZkWaKGsECHKRPBqfqEPsd8Pvz0pV12tzDrQ=;
	h=From:Subject:Date:To:Cc;
	b=aK+txOJI/58JCl5XdGluPx8zRazfA87yPX3/SDvJKKTtq6HoQq9z1axfFa7M1QwlG
	 FzXl3bcp7baHSJT/5L8/+A5xtlNyqY1NtndiQHkDg2xlfoR5Hf42smka/aCwd7Ogtu
	 CLCLcRjK37VsJ6ov22eKLn787Rda83ei9HebbaNWCrEOyEZJAcQY+MfuYViCdA+UW5
	 7Y4Br7KCVW1so8/+6urBeZ0QHyQWBv6ui+l6eZig0HcyfeU7AaEihGTm4Us+rPQnpz
	 fhNk/qUXfwbVW4x/eu7wytFpz44pB+f4PdSya8lDP75AInJ3SPVaks3jVQBs0/hgJL
	 D+zKzjNTMwK9w==
X-Mailing-List: netdev@vger.kernel.org
X-List-Post: <mailto:netdev@vger.kernel.org>
X-List-Help: <mailto:netdev+help@vger.kernel.org>
X-List-Subscribe: <mailto:netdev+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:netdev+unsubscribe@vger.kernel.org>
X-List-Owner: <mailto:netdev+owner@vger.kernel.org>
X-Precedence: list
X-B4-Tracking: v=1; b=H4sIAAAAAAAA/33SzWrDMAwA4FcxPldDtiP/5LT3GDs4sdyabelIQ
 ugofffRDLYMk54lPv1e5cRj4Um24ipHXspUzoNshcKDkP0pDkeGkmQrpEZtMagAR/4oQwGeTzw
 OPEMuF57AQMYGjSWTtYnyIOTnyGtItuJF3hMHvszy9SDkqUzzefxaay5qjf/oGnf1RQGCiToSR
 m+SD89v94T3p/N4XNFFbyG/D2lAcOSjC5RcdL6CzC+kEPU+ZO4dscqafMDINdRsIKX2oQYQmk5
 Zozr0mVIF0RaifYgAoaM+sM6u89FUkP2DFJp9yAJC33SUs4+WUj2a20DqwdUcIITe6KhiYyP3F
 eS30INle0DIRF1qDKNO9WhhAz36owAIOnjrVHIhJPoH3W63b9Y1BC4SAwAA
X-Change-ID: 20260919-gemini-ethernet-fixes-3-f0403653f23a
X-Cc: netdev@vger.kernel.org, Linus Walleij <linusw@kernel.org>
X-Mailer: b4 0.16.0