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,
vineeth.karumanchi@amd.com
Subject: Re: [PATCH net-next v8 3/3] net: macb: distribute evenly Tx SRAM segments
Date: Thu, 26 Nov 2026 16:45:27 +0000 [thread overview]
Message-ID: <179571152787.3135.16045423533153390042@kernel.org> (raw)
In-Reply-To: <20261124-macb-set-channels-v8-3-770cf8e50e6d@bootlin.com>
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] gem_sram_distribute_segments()
(drivers/net/ethernet/cadence/macb_main.c) writes 0 to…
--
net: macb: distribute evenly Tx SRAM segments
This adds gem_sram_distribute_segments(), which programs the GEM
TXQSEGALLOC register so the Tx SRAM segments reported by DCFG6 are spread
across the active queues as powers of two. It runs from macb_init_hw() and
macb_context_swap_end(). The new MACB_CAPS_TXQSEGALLOC capability enables
it on zynqmp, versal and eyeq5.
> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
> index bcf77b2763448..b939a1391273b 100644
> --- a/drivers/net/ethernet/cadence/macb_main.c
> +++ b/drivers/net/ethernet/cadence/macb_main.c
> @@ -3319,6 +3319,69 @@ static u32 macb_dbw(struct macb *bp)
> }
> }
>
> +/*
> + * Distribute evenly available segments across active queues. The computation
> + * is complex because (1) segments are counted in powers of two and (2) a queue
> + * can only use up to 128 segments. There are four types of cases:
[ ... ]
> + * - Sharing all segments is not doable because not enough segments are
> + * available. Take num_queues=4 and num_segments=2.
[ ... ]
> +static void gem_sram_distribute_segments(struct macb *bp)
> +{
> + unsigned int num_segments, pow, remaining_segments, i;
> + unsigned int num_queues = bp->ctx->num_queues;
> + unsigned int num_advantaged_queues = 0;
> + u32 val = 0;
> +
> + if (!(bp->caps & MACB_CAPS_TXQSEGALLOC))
> + return;
> +
> + num_segments = 1U << GEM_BFEXT(SEGMENTS_BIT_SIZE, gem_readl(bp, DCFG6));
> +
> + /* When growing the max # of queues, make sure to write into
> + * TXQSEGALLOC_UPPER too.
> + */
> + static_assert(MACB_MAX_QUEUES == 8);
> +
> + /* pow=0 for all queues. ilog2(0) is dangerous. */
> + if (num_queues >= num_segments)
> + goto writel;
[Severity: Low]
Is the num_queues > num_segments case really handled here?
Each 3-bit GEM_TXQSEGALLOC_MASK() field encodes 2^v segments, so a field
cannot mean zero segments. Writing val = 0 gives every active queue
2^0 = 1 segment.
When num_queues == num_segments that fits exactly. When num_queues is
larger, the hardware is told to use num_queues segments on a buffer that
has only num_segments.
The block comment lists "num_queues=4 and num_segments=2" as one of the
four handled cases. In that example the code programs 4 x 1 = 4 segments
on a 2-segment SRAM.
Nothing seems to prevent this configuration. macb_set_channels() checks
the requested count only against max_num_queues:
if (num_queues > bp->max_num_queues)
return -EINVAL;
So on versal and eyeq5 (MACB_CAPS_QUEUE_DISABLE), ethtool -L can select
more queues than DCFG6 reports segments. The same applies at probe/open
time when all queues are active.
Should the active queue count be limited to num_segments on
MACB_CAPS_TXQSEGALLOC parts? If not, should the comment stop describing
this case as handled?
> +
> + pow = min_t(unsigned int, ilog2(num_segments / num_queues), 7);
> + remaining_segments = num_segments - num_queues * (1U << pow);
[ ... ]
> +writel:
> + gem_writel(bp, TXQSEGALLOC_LOWER, val);
> +}
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261124-macb-set-channels-v8-0-770cf8e50e6d%40bootlin.com
prev parent reply other threads:[~2026-11-26 16:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 16:45 [PATCH net-next v8 0/3] net: macb: implement ethtool set channels count operation Théo Lebrun
2026-11-24 16:45 ` [PATCH net-next v8 1/3] net: macb: cache ENST config across link down/up Théo Lebrun
2026-11-26 16:45 ` netdev-bot+sashiko
2026-11-24 16:45 ` [PATCH net-next v8 2/3] net: macb: implement ethtool_ops.get|set_channels() Théo Lebrun
2026-11-26 16:45 ` netdev-bot+sashiko
2026-11-24 16:45 ` [PATCH net-next v8 3/3] net: macb: distribute evenly Tx SRAM segments Théo Lebrun
2026-11-26 16:45 ` 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=179571152787.3135.16045423533153390042@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=vineeth.karumanchi@amd.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
all inboxes | Powered by JetHome®