Thread View: linux.kernel.netdev
5 messages
5 total messages
Started by Linus Walleij
Thu, 12 Nov 2026 13:30
[PATCH net-next v8 10/19] net: ethernet: cortina: Separate RX buffer capacity from free queue size
Author: Linus Walleij
Date: Thu, 12 Nov 2026 13:30
Date: Thu, 12 Nov 2026 13:30
167 lines
14712 bytes
14712 bytes
Containing a retained hardware read pointer can force an order-15 free
queue even when the configured RX rings need far fewer buffers. Filling
that descriptor ring requires nearly 64 MiB of pages on systems with
32 to 128 MiB of RAM. Allocation failure persists across retries because
the stopped DMA engine cannot advance the pointer.
Keep the descriptor geometry required by the retained pointer, but size
the RX buffer budget from the configured port rings. Bound the posted
occupancy and refill work by that budget, including after dropping the
free queue lock to allocate a page. Size page metadata and the NAPI refill
threshold from the same budget.
For a retained pointer of 16384 and a requested buffer order of 10, this
keeps the 512 KiB descriptor ring but posts 2044 KiB of RX pages instead
of 65532 KiB. No hardware pointer-reset behaviour is assumed.
Found by review and checked with a ring-geometry model covering every
supported retained pointer and buffer order.
Fixes: 0bf8c8c94af2 ("net: ethernet: cortina: Normalize free queue pointers on rebuild")
Signed-off-by: Linus Walleij <linusw@kernel.org>
---
drivers/net/ethernet/cortina/gemini.c | 40 ++++++++++++++++++++++-------------
1 file changed, 25 insertions(+), 15 deletions(-)
diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c
index aedd8eca3f15..72d2c002f8fc 100644
--- a/drivers/net/ethernet/cortina/gemini.c
+++ b/drivers/net/ethernet/cortina/gemini.c
@@ -168,6 +168,7 @@ struct gemini_ethernet {
spinlock_t irq_lock; /* Locks IRQ-related registers */
unsigned int freeq_order;
+ unsigned int freeq_buf_order; /* RX buffer budget, independent of ring size */
unsigned int freeq_frag_order;
struct gmac_rxdesc *freeq_ring;
dma_addr_t freeq_dma_base;
@@ -1099,15 +1100,17 @@ static unsigned int geth_fill_freeq(struct gemini_ethernet *geth)
unsigned int fragments = 1 << fpp_order;
unsigned int len = 1 << geth->freeq_order;
unsigned int ring_mask = len - 1;
- unsigned int remaining = geth->num_freeq_pages + (len >> fpp_order);
+ unsigned int buf_len = 1 << geth->freeq_buf_order;
+ unsigned int capacity = buf_len - fragments;
+ unsigned int remaining = geth->num_freeq_pages + (buf_len >> fpp_order);
unsigned int count = 0;
unsigned int rptr, wptr;
unsigned long flags;
union dma_rwptr rw;
bool space;
- /* Bound retries and post at most one ring's worth of fragments. */
- while (remaining-- && count < len - fragments) {
+ /* Bound retries and post at most one buffer budget per refill. */
+ while (remaining-- && count < capacity) {
dma_addr_t page_mapping;
struct page *page;
int ret;
@@ -1116,7 +1119,8 @@ static unsigned int geth_fill_freeq(struct gemini_ethernet *geth)
rw.bits32 = readl(geth->base + GLOBAL_SWFQ_RWPTR_REG);
rptr = rw.bits.rptr & ring_mask;
wptr = rw.bits.wptr & ring_mask;
- space = CIRC_SPACE(wptr, rptr, len) >= fragments;
+ space = CIRC_SPACE(wptr, rptr, len) >= fragments &&
+ CIRC_CNT(wptr, rptr, len) <= capacity - fragments;
ret = -ENOSPC;
if (space && geth->freeq_recycle_pending) {
ret = geth_freeq_recycle_page(geth, wptr);
@@ -1143,7 +1147,8 @@ static unsigned int geth_fill_freeq(struct gemini_ethernet *geth)
rw.bits32 = readl(geth->base + GLOBAL_SWFQ_RWPTR_REG);
rptr = rw.bits.rptr & ring_mask;
wptr = rw.bits.wptr & ring_mask;
- if (CIRC_SPACE(wptr, rptr, len) < fragments) {
+ if (CIRC_SPACE(wptr, rptr, len) < fragments ||
+ CIRC_CNT(wptr, rptr, len) > capacity - fragments) {
ret = -ENOSPC;
} else if (geth->freeq_recycle_pending) {
ret = -EAGAIN;
@@ -1213,10 +1218,10 @@ static void geth_freeq_release_pages(struct gemini_ethernet *geth)
}
static unsigned int
-geth_freeq_page_slots(struct gemini_ethernet *geth, unsigned int order)
+geth_freeq_page_slots(struct gemini_ethernet *geth, unsigned int buf_order)
{
unsigned int fpp_order = PAGE_SHIFT - geth->freeq_frag_order;
- unsigned int slots = 1 << (order - fpp_order);
+ unsigned int slots = 1 << (buf_order - fpp_order);
if (geth->port0 && geth->port0->netdev)
slots += 1 << geth->port0->rxq_order;
@@ -1237,7 +1242,7 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)
unsigned int filled;
u16 rptr;
- page_slots = geth_freeq_page_slots(geth, geth->freeq_order);
+ page_slots = geth_freeq_page_slots(geth, geth->freeq_buf_order);
geth->freeq_ring = dma_alloc_coherent(geth->dev,
sizeof(*geth->freeq_ring) << geth->freeq_order,
@@ -1266,7 +1271,7 @@ static int geth_setup_freeq(struct gemini_ethernet *geth)
rptr = GET_RPTR(geth->base + GLOBAL_SWFQ_RWPTR_REG);
SET_WPTR(geth->base + GLOBAL_SWFQ_RWPTR_REG, rptr & (len - 1));
- expected = len - (1 << fpp_order);
+ expected = (1 << geth->freeq_buf_order) - (1 << fpp_order);
filled = geth_fill_freeq(geth);
if (filled != expected)
goto err_freeq_bitmap;
@@ -1367,6 +1372,7 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)
unsigned int new_size = 0;
unsigned int page_slots;
unsigned int new_order;
+ unsigned int buf_order;
u16 rptr;
int ret;
@@ -1396,20 +1402,23 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)
other_port->rxq_order);
}
- new_order = min(15, ilog2(new_size - 1) + 1);
+ buf_order = min(15, ilog2(new_size - 1) + 1);
+ if (buf_order <= PAGE_SHIFT - geth->freeq_frag_order)
+ return -EINVAL;
+
rptr = GET_RPTR(geth->base + GLOBAL_SWFQ_RWPTR_REG);
if (rptr >= BIT(15))
return -EIO;
- new_order = max_t(unsigned int, new_order, fls(rptr));
+ /* Contain the retained pointer without increasing RX buffer memory. */
+ new_order = max_t(unsigned int, buf_order, fls(rptr));
dev_dbg(geth->dev, "set shared queue to size %d order %d\n",
new_size, new_order);
- if (new_order <= PAGE_SHIFT - geth->freeq_frag_order)
- return -EINVAL;
/* Rebuild an idle queue to reclaim fragments which were never claimed. */
if (geth->freeq_ring && other_running) {
- page_slots = geth_freeq_page_slots(geth, geth->freeq_order);
+ page_slots = geth_freeq_page_slots(geth, buf_order);
if (geth->freeq_order >= new_order &&
+ geth->freeq_buf_order >= buf_order &&
geth->num_freeq_pages >= page_slots)
return 0;
}
@@ -1426,6 +1435,7 @@ static int geth_resize_freeq(struct gemini_ethernet_port *port)
/* Allocate a new queue with the desired order */
geth->freeq_order = new_order;
+ geth->freeq_buf_order = buf_order;
ret = geth_setup_freeq(geth);
/* Enable the queue interrupt only after successful setup. */
@@ -1927,7 +1937,7 @@ static int gmac_napi_poll(struct napi_struct *napi, int budget)
unsigned int received;
bool reschedule;
- freeq_threshold = 1 << (geth->freeq_order - 1);
+ freeq_threshold = 1 << (geth->freeq_buf_order - 1);
u64_stats_update_begin(&port->rx_stats_syncp);
received = gmac_rx(napi->dev, budget, &freeq_consumed, &reschedule);
--
2.56.0
Re: [PATCH net-next v8 10/19] net: ethernet: cortina: Separate RX buffer capacity from free queue size
Author: netdev-bot+sashiko
Date: Mon, 16 Nov 2026 14:45
Date: Mon, 16 Nov 2026 14:45
63 lines
10618 bytes
10618 bytes
Thank you for your contribution! Sashiko AI review found more severe
issue(s) in other patches of this series. This mail is only an FYI, in case
you want to address the nit picks below when you respin.
Low priority / nit picks for your consideration:
- [Low] The commit message has `Fixes: 0bf8c8c94af2 ("net: ethernet:
cortina: Normalize free queue pointers on rebuild")`, but that SHA…
--
net: ethernet: cortina: Separate RX buffer capacity from free queue size
This patch keeps the free queue descriptor ring large enough to contain
the retained hardware read pointer. The RX page budget is now sized
separately, from the configured port RX rings. Refill occupancy, page
metadata and the NAPI refill threshold are bounded by that new
freeq_buf_order instead of freeq_order.
> Fixes: 0bf8c8c94af2 ("net: ethernet: cortina: Normalize free queue pointers on rebuild")
[Severity: Low]
Is this Fixes tag pointing at the right commit? 0bf8c8c94af2 does not
resolve in the tree. The commit with this subject is 1e7aa52a9993,
earlier in this same series.
That commit adds the floor in geth_resize_freeq():
new_order = max_t(unsigned int, new_order, fls(rptr));
Page allocation is still tied to the ring order at that point. So any
retained rptr >= 16384 forces an order-15 ring and about 64 MiB of RX
pages.
Its message only says "a following patch decouples the RX buffer budget
from descriptor geometry". It carries Fixes: 4d5ae32f5e1e, which makes it
a stable candidate. It does not name this patch as a required companion.
Other patches in the series do state their pairings. For example,
"Preserve in-flight free queue pages" says "Backport both changes
together with their prerequisites".
Since the tag here does not resolve, could stable or AUTOSEL tooling pick
up "Normalize free queue pointers on rebuild" without this follow-up? On
32 to 128 MiB Gemini boards, open() would then keep failing whenever the
retained rptr is >= 16384. The bisect window between the two commits in
this series has the same allocation problem.
This patch also cannot be applied directly on top of "Normalize free
queue pointers on rebuild". It changes geth_freeq_page_slots(), the
capacity-bounded loop in geth_fill_freeq() and the
freeq_recycle_pending path. Those come from "Preserve in-flight free
queue pages" and "Recycle claimed free queue pages", and the commit
message does not mention them as prerequisites.
Would it be cleaner to squash this change into "Normalize free queue
pointers on rebuild"? If not, could the Fixes tag be corrected to
1e7aa52a9993, with the backport pairing and prerequisites listed in both
commit messages?
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261112-gemini-ethernet-fixes-3-v8-0-f55bd43e02d3%40kernel.org
Re: [PATCH net-next v8 10/19] net: ethernet: cortina: Separate RX buffer capacity from free queue size
Author: Linus Walleij
Date: Tue, 17 Nov 2026 08:04
Date: Tue, 17 Nov 2026 08:04
22 lines
9600 bytes
9600 bytes
On Mon, Nov 16, 2026 at 3:45 PM <netdev-bot+sashiko@kernel.org> wrote:
> > Fixes: 0bf8c8c94af2 ("net: ethernet: cortina: Normalize free queue pointers on rebuild")
>
> [Severity: Low]
> Is this Fixes tag pointing at the right commit? 0bf8c8c94af2 does not
> resolve in the tree. The commit with this subject is 1e7aa52a9993,
> earlier in this same series.
(...)
> Would it be cleaner to squash this change into "Normalize free queue
> pointers on rebuild"? If not, could the Fixes tag be corrected to
> 1e7aa52a9993, with the backport pairing and prerequisites listed in both
> commit messages?
I see the point but the patches are big enough as they are, it's better
to solve one thing at the time.
Yours,
Linus Walleij
Re: [PATCH net-next v8 10/19] net: ethernet: cortina: Separate RX buffer capacity from free queue size
Author: Simon Horman
Date: Wed, 18 Nov 2026 20:49
Date: Wed, 18 Nov 2026 20:49
30 lines
9206 bytes
9206 bytes
On Thu, Nov 12, 2026 at 02:30:25PM +0100, Linus Walleij wrote:
> Containing a retained hardware read pointer can force an order-15 free
> queue even when the configured RX rings need far fewer buffers. Filling
> that descriptor ring requires nearly 64 MiB of pages on systems with
> 32 to 128 MiB of RAM. Allocation failure persists across retries because
> the stopped DMA engine cannot advance the pointer.
>
> Keep the descriptor geometry required by the retained pointer, but size
> the RX buffer budget from the configured port rings. Bound the posted
> occupancy and refill work by that budget, including after dropping the
> free queue lock to allocate a page. Size page metadata and the NAPI refill
> threshold from the same budget.
>
> For a retained pointer of 16384 and a requested buffer order of 10, this
> keeps the 512 KiB descriptor ring but posts 2044 KiB of RX pages instead
> of 65532 KiB. No hardware pointer-reset behaviour is assumed.
>
> Found by review and checked with a ring-geometry model covering every
> supported retained pointer and buffer order.
>
> Fixes: 0bf8c8c94af2 ("net: ethernet: cortina: Normalize free queue pointers on rebuild")
Hi Linus,
I don't see this commit in net-next. Perhaps it is a local commit?
> Signed-off-by: Linus Walleij <linusw@kernel.org>
...
Re: [PATCH net-next v8 10/19] net: ethernet: cortina: Separate RX buffer capacity from free queue size
Author: Linus Walleij
Date: Wed, 18 Nov 2026 21:01
Date: Wed, 18 Nov 2026 21:01
52 lines
11140 bytes
11140 bytes
On Wed, Nov 18, 2026 at 9:49 PM Simon Horman <horms@kernel.org> wrote:
> On Thu, Nov 12, 2026 at 02:30:25PM +0100, Linus Walleij wrote:
> > Containing a retained hardware read pointer can force an order-15 free
> > queue even whhttps://lore.kernel.org/netdev/20261112-gemini-ethernet-fixes-3-v8-4-f55bd43e02d3@kernel.org/en the configured RX rings need far fewer buffers. Filling
> > that descriptor ring requires nearly 64 MiB of pages on systems with
> > 32 to 128 MiB of RAM. Allocation failure persists across retries because
> > the stopped DMA engine cannot advance the pointer.
> >
> > Keep the descriptor geometry required by the retained pointer, but size
> > the RX buffer budget from the configured port rings. Bound the posted
> > occupancy and refill work by that budget, including after dropping the
> > free queue lock to allocate a page. Size page metadata and the NAPI refill
> > threshold from the same budget.
> >
> > For a retained pointer of 16384 and a requested buffer order of 10, this
> > keeps the 512 KiB descriptor ring but posts 2044 KiB of RX pages instead
> > of 65532 KiB. No hardware pointer-reset behaviour is assumed.
> >
> > Found by review and checked with a ring-geometry model covering every
> > supported retained pointer and buffer order.
> >
> > Fixes: 0bf8c8c94af2 ("net: ethernet: cortina: Normalize free queue pointers on rebuild")
>
> Hi Linus,
>
> I don't see this commit in net-next. Perhaps it is a local commit?
Yeah well it's part of the series:
https://lore.kernel.org/netdev/20261112-gemini-ethernet-fixes-3-v8-4-f55bd43e02d3@kernel.org/
So Sashiko wants me to squash the patches which is usually a good
idea (no introducing problems and then fixing them right) the thing is
that they are fixing different problems more like two lego bricks on
top of each other, it's not always as a clean cut as one would
like, it's two technical steps.
But I guess if this is how everyone wants it I'll cave in and just squash
it to one commit.
Yours,
Linus Walleij
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads