Re: [PATCH net-next v8 3/3] net: macb: distribute evenly Tx SRAM segments
From: Théo Lebrun
Date: Fri Nov 27 2026 - 12:16:14 EST
Hello netdev-bot+sashiko,
On Thu Nov 26, 2026 at 5:45 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()
> (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?
Argh, once again it does this review. I'll prompt the LLMs in my commit
message (or below the '---' fold line) to avoid that in the future.
https://lore.kernel.org/all/DN2Q44M3PG5M.1Q2PKJ5A3RKNY@xxxxxxxxxxx/
[...]
Thanks,
--
Théo Lebrun, Bootlin
Embedded Linux and Kernel engineering
https://bootlin.com