🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.netdev
Article #14741

Re: [PATCH net-next v7 07/18] net: ethernet: cortina: Preserve in-flight free queue pages

#14741
From: netdev-bot+sashiko
Date: Wed, 11 Nov 2026 23:10
153 lines
13313 bytes
Thank you for your contribution! Sashiko AI review found 1 potential
issue(s) to consider.

Critical: 0 · High: 0 · Medium: 1 · Low: 0

If you believe none of the issues are legitimate, please reply to each
issue of Medium severity or higher and explain why the AI is wrong.
If any of them are legitimate and you plan to respin, please let patchwork
know by including "pw-bot: cr" as a separate line at the end of your reply
(one such reply per series is enough).

- [Medium] The page metadata pool is now a fixed set of slots tracked by
  freeq_page_bitmap, and nothing reclaims a slot while the queue is…

--

net: ethernet: cortina: Preserve in-flight free queue pages

This patch stops tying Gemini free queue page metadata to free queue
ring positions. Metadata slots come from a fixed pool tracked by a
bitmap, each posted fragment holds its own page reference, and a slot
is released only once all of its fragments have been claimed from RX
descriptors.

> diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
> index add1d3e563b62..bdbbc6d7844b9 100644
> --- a/drivers/net/ethernet/cortina/gemini.c
> +++ b/drivers/net/ethernet/cortina/gemini.c

[ ... ]

> @@ -735,15 +740,32 @@ geth_freeq_mapping_index(const struct gemini_ethernet *geth,
>  	return (unsigned long)(mapping >> geth->freeq_frag_order);
>  }
>  
> -static struct page *geth_freeq_lookup(struct gemini_ethernet *geth,
> -				      dma_addr_t mapping,
> -				      unsigned int *page_offs)
> +static int geth_freeq_alloc_slot(struct gemini_ethernet *geth)
> +{
> +	unsigned int slot;
> +
> +	lockdep_assert_held(&geth->freeq_lock);
> +
> +	slot = find_first_zero_bit(geth->freeq_page_bitmap,
> +				   geth->num_freeq_pages);
> +	if (slot == geth->num_freeq_pages)
> +		return -ENOSPC;
> +
> +	__set_bit(slot, geth->freeq_page_bitmap);
> +
> +	return slot;
> +}
> +
> +static struct page *geth_freeq_claim(struct gemini_ethernet *geth,
> +				     dma_addr_t mapping,
> +				     unsigned int *page_offs)
>  {

[ ... ]

> @@ -762,6 +784,21 @@ static struct page *geth_freeq_lookup(struct gemini_ethernet *geth,
>  	if (!valid)
>  		goto err_unlock;
>  
> +	dma_sync_single_range_for_cpu(geth->dev, page_mapping,
> +				      mapping - page_mapping, frag_len,
> +				      DMA_FROM_DEVICE);
> +	xa_erase(&geth->freeq_mappings, index);
> +	if (!--gpage->fragments) {
> +		slot = gpage - geth->freeq_pages;
> +		dma_unmap_single_attrs(geth->dev, page_mapping, PAGE_SIZE,
> +				       DMA_FROM_DEVICE,
> +				       DMA_ATTR_SKIP_CPU_SYNC);
> +		gpage->page = NULL;
> +		gpage->mapping = 0;
> +		__clear_bit(slot, geth->freeq_page_bitmap);
> +		put_page(page);
> +	}

[Severity: Medium]
Can the fixed slot pool run out while the queue is running?

At runtime, geth_freeq_claim() is the only place that clears a bit in
freeq_page_bitmap and drops the page reference and DMA mapping for that
slot. The only other place is teardown in geth_freeq_release_pages().
So every fragment of a posted page has to come back from hardware as an
RX descriptor address that resolves.

gmac_rx() has two paths that drop a descriptor without claiming it:

	if (!mapping) {
		if (net_ratelimit())
			netdev_err(netdev,
				   "rxq[%u]: HW BUG: zero DMA desc\n",
				   r);
		goto err_drop;
	}

	page = geth_freeq_claim(geth, mapping, &page_offs);
	if (!page) {
		dev_err_ratelimited(geth->dev,
				    "could not find mapping\n");
		goto err_drop;
	}

The "could not find page" path in gmac_cleanup_rxq() behaves the same
way. Buffers that RX DMA has already pulled for a frame when
gmac_stop()->gmac_stop_dma() stops it mid-frame are also never claimed,
because gmac_cleanup_rxq() only walks the descriptors between r and w.

If the hardware has consumed a free queue fragment in any of these
cases, its slot stays set in freeq_page_bitmap permanently. The page
reference and streaming DMA mapping stay pinned with it.

geth_freeq_page_slots() sizes the pool at roughly the worst-case number
of live pages, with little slack:

	unsigned int slots = 1 << (order - fpp_order);

	if (geth->port0 && geth->port0->netdev)
		slots += 1 << geth->port0->rxq_order;
	if (geth->port1 && geth->port1->netdev)
		slots += 1 << geth->port1->rxq_order;

An ifdown/ifup cycle does not recover leaked slots either. If the peer
port is running, the existing queue is kept. If both ports are idle and
the geometry has not changed, geth_resize_freeq() returns early:

	if (geth->freeq_order == new_order &&
	    geth->num_freeq_pages == page_slots)
		return 0;

Once enough slots have leaked, geth_freeq_alloc_slot() returns -ENOSPC
on every call. geth_fill_freeq() then maps a candidate page, unmaps and
frees it, and breaks without posting anything.

Would the shared SWFQ then drain and stop RX on both GMAC ports? It
looks like the only recovery is an ethtool geometry change with both
ports down, or a driver unbind.

Before this patch, metadata was indexed by queue position. A lost
fragment leaked page memory, but a later refill reused that position,
so refill never stalled.

The follow-up "Recycle claimed free queue pages" patch only recycles
slots whose fragments have all been claimed. The zero-descriptor and
lookup-failure paths still claim nothing, so this looks like it remains
at the end of the series.

-- 
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261110-gemini-ethernet-fixes-3-v7-0-9c32a1a46aec%40kernel.org
Technical Details
Message-ID: <179443864989.2199510.5071007686286136865@kernel.org>
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361353-linux-kernel-netdev=dewy.ru
References: <20261110-gemini-ethernet-fixes-3-v7-7-9c32a1a46aec@kernel.org>

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!srl.newsdeef.eu!news.mb-net.net!open-news-network.org!3.eu.feeder.erje.net!feeder.erje.net!feeder1.feed.ams11.usenet.farm!feed.usenet.farm!feeder.usenetexpress.com!tr3.eu1.usenetexpress.com!news.neodome.net!usenet.network!.POSTED!vger.kernel.org!netdev+bounces-361353-linux-kernel-netdev=dewy.ru
From: netdev-bot+sashiko@kernel.org
Newsgroups: linux.kernel.netdev
Subject: Re: [PATCH net-next v7 07/18] net: ethernet: cortina: Preserve in-flight free queue pages
Date: Wed, 11 Nov 2026 23:10:49 +0000
Organization: Usenet Network
Message-ID: <179443864989.2199510.5071007686286136865@kernel.org>
References: <20261110-gemini-ethernet-fixes-3-v7-7-9c32a1a46aec@kernel.org>
MIME-Version: 1.0
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network; logging-data="960975"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:c5+2Uru8zH/XS3Z8zvwsxQyvSHY= sha256:/z2WT9RuroHrCJBSJ2boDPCtQ/f3gzU1B/w0HPFmrOw= sha1:WvCJBy/gn0NYlI5uWj1lqBXD1Gg= sha256:H/Xn8UoKCeErWJg6Q9KC5Q3Ab0KM6syUsfE6Nz5g3WQ=
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 B2C6E11403D; Thu, 12 Nov 2026 02:14:16 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.5
X-Spam-Status: No, score=-3.5 tagged_above=-9999 required=6.31 tests=[DKIMWL_WL_HIGH=-0.001, 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 0YaHl2DLgpqq; Thu, 12 Nov 2026 02:14:12 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.232.135.74; helo=sto.lore.kernel.org; envelope-from=netdev+bounces-361353-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 sto.lore.kernel.org (sto.lore.kernel.org [172.232.135.74]) by mail.dewy.ru (Postfix) with ESMTPS id DB40011404E; Thu, 12 Nov 2026 02:14:03 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.77.114.92]) by sto.lore.kernel.org (Postfix) with ESMTP id 14171663FB6; Wed, 11 Nov 2026 23:11:03 +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=1794438652; b=PXCVpcMXhnd3bisxdxo1d1JqqQ7bX4g/hXkOmFx5ZUbeGZGoGHz5zgCXA2ASznwaVEr9 96LeM08Q7dUEMwj6uIgPcs0s9tQ0pCcVOFF7sIaT8NdXX13DYhD5wDubTxDK+7ITOMAul Tou7gIQ8T+iMoxNKA94p2kspxC56oQP6XY4Pcr/kYyFR+Cpxp8TO+hmFvPWES4NBvmRAi ME8M8MpKb7ODv+r/vGfNTcPBz6NltxE/FD9TwpGiv+dB5qVUZ5laxU5eNYuXmrw1tzyBg Kp00MA7w8E8u9vsKqsN2hQGQHzjEEpvMUTtr8fMCsH5yNpi6hsFZFP3FaZGVOamCWdw==
X-ARC-Message-Signature: i=2; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794438652; h=X-Original-To:Received:Received:DKIM-Signature:Subject:From:To:Cc: Date:Message-ID:In-Reply-To:References:X-sashiko-severity: Content-Type:Content-Transfer-Encoding:X-Mailing-List:List-Id: List-Post:List-Help:List-Subscribe:List-Unsubscribe:List-Owner: Precedence:MIME-Version; bh=tedSJNMhboDpX5BhYovW6i9/A5e4PA5SgBHzsdfRiww=; b=AL2s/4p5toirS/7wOZg+GnmFM3ITKg/0rDjKsS+JUinLM1teHea6As3f9ywtwdsJyAjO qJC4+4mn0a43ObsXxeAUtV29mCfweX2U3j94x93pX8S9+WcovOLJiuNq16CrsZiR7zdjZ hSQTL6Kp9+sZpsSDTJ2ppgyVW5VsRli1Kwg2XTLoulLWOQHx/Lu1Xo0/mPSKXIMkmQ7un YXEVQODvqHLOQ25oBG3df4ff7JJZ4RLhE5vm4g01jGmBRR1XAeY942wN7Sj4n8cPn4Z16 Oo0N0tprYI/rPuj3nnVt/gGcSt1ETvdiV2X98Wsy9EwKDYPbw2ooMfsahyea8R1EudA==
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="Z4aVq/qx"; 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 29830606A88A; Wed, 11 Nov 2026 23:10:52 +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=Z4aVq/qx
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=1794438651; b=uysHCwCXdS3hjpca1SxRi3YiMGqRLBGWzZzAopKpvNcVslkRgoWzAk4Ndx5okzZeaw4K HHb9fwkFVFEDqCxISu5/Uld+WV5IWRfg+YI9AN+9GfhznzaC9JZl3kadb27+GcgrxGlDj 8q1/6ferTeMZCcjR3NqY0SIBCqDDK5HjVUQ7IYfY8FlNnzoqpy62zSkeZpwoKzdbUl0Ln XYDer4tFNHgoh5Kcv2ZVd1qiN1ZnNU+DuZFBjf8TSDiZ8BFXk5MnZAZ8dzksVds7jlTvU fS4ByRitsUYMLOUHuUx077B9makcRt2xLlPO693X5Ak/Hky8pdK+s6qFnsU+Ir5GgVw==
X-ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1794438651; h=Received:DKIM-Signature:Subject:From:To:Cc:Date:Message-ID: In-Reply-To:References:X-sashiko-severity:Content-Type: Content-Transfer-Encoding:MIME-Version; bh=tedSJNMhboDpX5BhYovW6i9/A5e4PA5SgBHzsdfRiww=; b=zILfIitgWQ2hB22wnFi0smWOLT3nn+WQL/srsnzSWgAC8KUZmIQyHyYL0qbHLLL58cXN xxQxH6hQRm9i5fvOelRRxRHH6SOmiXf1xQ5aEQUdyytX0KQS4UIjfc4ieUcUuE3uOvDhF Y0hDkxIT7tTG48fVFQAFoWYXpEVRVnl7lzDY3zCDa2co76M6+Rq84b2uUWQZsf0/REIrn WTEf6gXf97qOwkuctpfuT/fqS+qHk1sVuuRZOfpLdc7UwJDjPlJ8ruU3dRdU38Unj6u9v mqF2J5QbRfCgd0rqCYDCf+bh7jSblg+hM3T6NjHl01q0UfBsy1g4A0euLPzloWVJxtg==
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="Z4aVq/qx"; 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 48532606A886 for <netdev@vger.kernel.org>; Wed, 11 Nov 2026 23:10:51 +0000 (UTC)
X-Received: by smtp.kernel.org (Postfix) with ESMTPSA id 5A7071F00A0B; Wed, 11 Nov 2026 23:10:50 +0000 (UTC)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1794438650; bh=tedSJNMhboDpX5BhYovW6i9/A5e4PA5SgBHzsdfRiww=; h=Subject:From:To:Cc:Date:In-Reply-To:References; b=Z4aVq/qxF386zqiW8JBdPF42kBwGCk8lBstihXlOTTBEATtEXxcaIH5X3XSpyTAEM eZG0Z/lWY0RAbsH7I79dWfG3VLQWqcUxOx2JYbRHATessbb56dzbq73Pq7+ALuhmax CLeVVqiIGDiZotsRHTuQ/YhGqfJZ+GDA282WNysAcVqqYD5368uG0yvWeK2OJF8X6N TPwZTqoGEqq/8iXLlssLHuPKssJhl8rYnNCwRDupoNUytmKlHk+U0VdzkDy3F7KUAZ zyT6b5EjZW9SykPcgCDFkMnicr52uy7404ZgwnmmA45kG4mKHvMDXjpsL3Bc+xHbnH fB+eeT/0xCtWQ==
X-Cc: ulli.kroll@googlemail.com, andrew+netdev@lunn.ch, davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, mirq-linux@rere.qmqm.pl, mhun512@gmail.com, edumazet@kernel.org, netdev@vger.kernel.org
X-In-Reply-To: <20261110-gemini-ethernet-fixes-3-v7-7-9c32a1a46aec@kernel.org>
X-sashiko-severity: Medium
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