From: "Théo Lebrun" <theo.lebrun@bootlin.com>
To: <netdev-bot+sashiko@kernel.org>
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 v7 3/3] net: macb: distribute evenly Tx SRAM segments
Date: Mon, 23 Nov 2026 17:16:26 +0100 [thread overview]
Message-ID: <DN2Q44M3PG5M.1Q2PKJ5A3RKNY@bootlin.com> (raw)
In-Reply-To: <179537769513.3135.7979336425983650280@kernel.org>
Hello netdev-bot+sashiko,
On Sun Nov 22, 2026 at 9:01 PM CET, wrote:
> 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() in
> drivers/net/ethernet/cadence/macb_main.c handles num_queues >=…
> - [Low] The comment above static_assert(MACB_MAX_QUEUES == 8) in
> gem_sram_distribute_segments()…
>
> --
>
> net: macb: distribute evenly Tx SRAM segments
>
> This patch adds gem_sram_distribute_segments(). It programs the GEM
> TXQSEGALLOC register so that the Tx SRAM segments reported in DCFG6 are
> spread across the active queues as powers of two. It is called from
> macb_init_hw() and macb_context_swap_end(), and it is enabled for the
> zynqmp, versal and eyeq5 configs.
>
>> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
>> index 180da5d62f09a..5d382f0e4aec3 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 return a u64 here and
>> + * to write into GEM_TXQSEGALLOC_UPPER.
>> + */
>> + static_assert(MACB_MAX_QUEUES == 8);
>
> [Severity: Low]
> This isn't a bug, but the comment talks about returning a u64.
> gem_sram_distribute_segments() is a static void function. It builds its
> result in the local u32 val and writes it with:
>
> gem_writel(bp, TXQSEGALLOC_LOWER, val);
>
> To support more than 8 queues, wouldn't the change be to widen (or split)
> val and add a second write to TXQSEGALLOC_UPPER, rather than to change a
> return type? Could the comment say that instead?
Yes; we shall replace:
When growing the max # of queues, make sure to return a u64 here and
to write into GEM_TXQSEGALLOC_UPPER.
By:
When growing the max # of queues, make sure to write into
TXQSEGALLOC_UPPER.
For the full story for why this comment went stale:
gem_sram_distribute_segments() used to return a u64 with the low 32
bits written into LOWER and the high 32 bits written into UPPER. That
returned value was then writel() by the caller. But now that it can be
called from two places, the writel() was moved into the function to
avoid code duplication.
>> +
>> + /* pow=0 for all queues. ilog2(0) is dangerous. */
>> + if (num_queues >= num_segments)
>> + goto writel;
>
> [Severity: Low]
> What happens here when num_queues is strictly greater than num_segments?
I don't know, but this is not our worry.
This check has been introduced to deal with the equality case.
From my understanding, `num_queues > num_segments` is unreachable.
And if `num_queues > num_segments` ever occurs, yes, we give each active
queue 1 segment by doing a:
writel(0, TXQSEGALLOC_LOWER)
We will *not* introduce code to lower max_num_queues if num_segments is
found to be lower than the runtime detected queue count from
macb_probe_queues(). This would be useless.
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com
prev parent reply other threads:[~2026-11-23 16:16 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 20:53 [PATCH net-next v7 0/3] net: macb: implement ethtool set channels count operation Théo Lebrun
2026-11-18 20:53 ` [PATCH net-next v7 1/3] net: macb: cache ENST config across link down/up Théo Lebrun
2026-11-19 11:49 ` Nicolai Buchwitz
2026-11-19 12:36 ` Vineeth Karumanchi
2026-11-19 15:40 ` Théo Lebrun
2026-11-19 16:10 ` Théo Lebrun
2026-11-20 6:44 ` Vineeth Karumanchi
2026-11-23 17:51 ` Théo Lebrun
2026-11-23 18:50 ` Théo Lebrun
2026-11-22 20:01 ` netdev-bot+sashiko
2026-11-23 15:37 ` Théo Lebrun
2026-11-18 20:53 ` [PATCH net-next v7 2/3] net: macb: implement ethtool_ops.get|set_channels() Théo Lebrun
2026-11-19 11:54 ` Nicolai Buchwitz
2026-11-19 16:19 ` Théo Lebrun
2026-11-22 20:01 ` netdev-bot+sashiko
2026-11-23 16:04 ` Théo Lebrun
2026-11-18 20:53 ` [PATCH net-next v7 3/3] net: macb: distribute evenly Tx SRAM segments Théo Lebrun
2026-11-19 11:45 ` Nicolai Buchwitz
2026-11-22 20:01 ` netdev-bot+sashiko
2026-11-23 16:16 ` Théo Lebrun [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=DN2Q44M3PG5M.1Q2PKJ5A3RKNY@bootlin.com \
--to=theo.lebrun@bootlin.com \
--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-bot+sashiko@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=pvalerio@redhat.com \
--cc=tawfik.bayouk@mobileye.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
all inboxes | Powered by JetHome®