From: netdev-bot+sashiko@kernel.org
To: theo.lebrun@bootlin.com
Cc: conor.dooley@microchip.com, andrew+netdev@lunn.ch,
davem@davemloft.net, edumazet@kernel.org, kuba@kernel.org,
pabeni@redhat.com, linux@armlinux.org.uk, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, nb@tipi-net.de,
pvalerio@redhat.com, vladimir.kondratiev@mobileye.com,
gregory.clement@bootlin.com, benoit.monin@bootlin.com,
tawfik.bayouk@mobileye.com, thomas.petazzoni@bootlin.com
Subject: Re: [PATCH net-next v6 2/2] net: macb: distribute evenly Tx SRAM segments
Date: Tue, 17 Nov 2026 19:43:30 +0000 [thread overview]
Message-ID: <179494461057.3136.14140856412630551606@kernel.org> (raw)
In-Reply-To: <20261113-macb-set-channels-v6-2-5de59d9e7f02@bootlin.com>
Thank you for your contribution! Sashiko AI review found 2 potential
issue(s) to consider.
Critical: 0 · High: 1 · 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).
- [High] The commit message says TXQSEGALLOC must be re-applied "if/when
number of active queues is modified", but the patch only programs it…
- [Medium] gem_sram_distribute_segments() can build a TXQSEGALLOC value
whose total segment count is larger than the num_segments that…
--
net: macb: distribute evenly Tx SRAM segments
This patch programs the GEM TXQSEGALLOC register from macb_init_hw(). It
spreads the Tx SRAM segments advertised in DCFG6 across the active
queues, with each queue's share encoded as a power of two. The new
MACB_CAPS_TXQSEGALLOC capability is enabled for ZynqMP, Versal and EyeQ5.
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index e7325af4b399c..dc1624815f71e 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -3432,6 +3432,63 @@ static void macb_context_swap_end(struct macb *bp,
[ ... ]
> +static u32 gem_sram_distribute_segments(unsigned int num_queues,
> + unsigned int num_segments)
> +{
[ ... ]
> + /* pow=0 for all queues. ilog2(0) is dangerous. */
> + if (num_queues >= num_segments)
> + return 0;
[ ... ]
> + for (i = 0; i < num_advantaged_queues; i++)
> + val |= field_prep(GEM_TXQSEGALLOC_MASK(i), pow + 1);
> + for (i = num_advantaged_queues; i < num_queues; i++)
> + val |= field_prep(GEM_TXQSEGALLOC_MASK(i), pow);
> +
> + return val;
> +}
[Severity: Medium]
Can the value built by gem_sram_distribute_segments() add up to more
segments than the num_segments read from DCFG6?
A field value of 0 still means 2^0 = 1 segment. There seem to be two ways
to over-allocate.
First, when num_queues > num_segments, the early return gives every
active queue 1 segment. The comment above uses num_queues=4 and
num_segments=2 as an example, which claims 4 segments out of 2.
Second, the loops only fill fields for i < num_queues. macb_init_hw()
passes bp->ctx->num_queues, not the hardware queue count. The fields for
hardware queues from ctx->num_queues up to bp->max_num_queues stay at 0.
Each of those still claims 1 segment, on top of an active split that
already uses every segment. With 4 hardware queues and 16 segments:
num_queues=2: 8 + 8 + 1 + 1 = 18
num_queues=3: 8 + 4 + 4 + 1 = 17
On Versal and EyeQ5 (MACB_CAPS_QUEUE_DISABLE), this happens after
ethtool -L while the interface is down, followed by an open. The reset
value is an even split over all hardware queues, so it adds up to the
available segments.
If the GEM requires the total to stay within the DCFG6 count, could this
give queues overlapping or out-of-range Tx SRAM regions?
> @@ -3465,6 +3522,20 @@ static void macb_init_hw(struct macb *bp)
> if (bp->caps & MACB_CAPS_JUMBO)
> bp->rx_frm_len_mask = MACB_RX_JFRMLEN_MASK;
>
> + /* Distribute Tx SRAM segments evenly based on active number of queues.
> + * TXQSEGALLOC is only documented for some GEM integrations.
> + */
> + if (bp->caps & MACB_CAPS_TXQSEGALLOC) {
> + unsigned int num_segments;
> + u32 val;
> +
> + num_segments = 1U << GEM_BFEXT(SEGMENTS_BIT_SIZE,
> + gem_readl(bp, DCFG6));
> + val = gem_sram_distribute_segments(bp->ctx->num_queues,
> + num_segments);
> + gem_writel(bp, TXQSEGALLOC_LOWER, val);
> + }
[Severity: High]
The commit message says the distribution needs care "if/when number of
active queues is modified". Is that case covered when the queue count
changes on a running interface?
Only macb_open() and the resume path call macb_init_hw(). Running
ethtool -L ethX combined N while the interface is up goes through:
macb_set_channels()
macb_context_swap_start()
macb_context_swap_end(bp, new_ctx)
macb_init_buffers()
macb_configure_dma()
macb_context_swap_end() installs a context with the new num_queues and
turns RE/TE back on. Nothing on this path rewrites GEM_TXQSEGALLOC_LOWER.
The Tx SRAM split stays sized for the old queue count until the next
down/up or suspend/resume.
Two examples:
Open with 1 queue. q0 gets 8 segments and the other fields stay at 0
(1 segment each). If the interface then grows to N queues while up, each
new queue runs with a single segment while TXPBMS is set in DMACFG.
Going from 2 queues to 1 while up leaves half of the SRAM assigned to
the disabled queue.
Versal and EyeQ5 set both MACB_CAPS_QUEUE_DISABLE and
MACB_CAPS_TXQSEGALLOC, so this path is reachable there.
Could the write be moved into a helper and also called from
macb_context_swap_end() under bp->lock, next to macb_configure_dma()?
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261113-macb-set-channels-v6-0-5de59d9e7f02%40bootlin.com
prev parent reply other threads:[~2026-11-17 19:43 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-13 17:32 [PATCH net-next v6 0/2] net: macb: implement ethtool set channels count operation Théo Lebrun
2026-11-13 17:32 ` [PATCH net-next v6 1/2] net: macb: implement ethtool_ops.get|set_channels() Théo Lebrun
2026-11-15 19:39 ` Nicolai Buchwitz
2026-11-17 10:20 ` Théo Lebrun
2026-11-17 19:43 ` netdev-bot+sashiko
2026-11-13 17:32 ` [PATCH net-next v6 2/2] net: macb: distribute evenly Tx SRAM segments Théo Lebrun
2026-11-13 18:18 ` Théo Lebrun
2026-11-15 19:40 ` Nicolai Buchwitz
2026-11-17 10:23 ` Théo Lebrun
2026-11-17 19:43 ` netdev-bot+sashiko [this message]
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=179494461057.3136.14140856412630551606@kernel.org \
--to=netdev-bot+sashiko@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=benoit.monin@bootlin.com \
--cc=conor.dooley@microchip.com \
--cc=davem@davemloft.net \
--cc=edumazet@kernel.org \
--cc=gregory.clement@bootlin.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@armlinux.org.uk \
--cc=nb@tipi-net.de \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pvalerio@redhat.com \
--cc=tawfik.bayouk@mobileye.com \
--cc=theo.lebrun@bootlin.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=vladimir.kondratiev@mobileye.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