Re: [PATCH net-next v3 6/9] net: sparx5/lan969x: add support for resizing the FDMA buffers
From: netdev-bot+sashiko
Date: Mon Nov 23 2026 - 09:59:10 EST
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] After a resize, sparx5_fdma_resume() does not turn the injection
(TX) channel's DB interrupt back on.
- [Low] The new runtime resize path fills the whole replacement RX ring
from sleepable process context, but it uses the NAPI refill callbacks,…
--
net: sparx5/lan969x: add support for resizing the FDMA buffers
This adds an fdma_resize operation for Sparx5 and lan969x. It allocates
new FDMA buffers sized for a new MTU, then pauses the FDMA, swaps in the
new buffers and resumes. Pausing stops the TX queues and CPU forwarding
and drains the queues before stopping and resetting the FDMA. On lan969x
only the RX buffers and page_pool are replaced.
> diff --git a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
> index b92d249777f0b..6c6387cb8a505 100644
> --- a/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
> +++ b/drivers/net/ethernet/microchip/sparx5/sparx5_fdma.c
[ ... ]
> @@ -564,3 +576,174 @@ int sparx5_fdma_stop(struct sparx5 *sparx5)
[ ... ]
> +void sparx5_fdma_pause(struct sparx5 *sparx5)
> +{
[ ... ]
> + sparx5_fdma_stop(sparx5);
> +
> + /* Reset FDMA state */
> + spx5_wr(FDMA_CTRL_NRESET_SET(0), sparx5, FDMA_CTRL);
> + spx5_wr(FDMA_CTRL_NRESET_SET(1), sparx5, FDMA_CTRL);
> +
> + /* Discard frames queued for the CPU, as they may not fit the new
> + * buffers.
> + */
> + sparx5_xtr_flush(sparx5, XTR_QUEUE);
> +}
> +
> +/* Restart the FDMA and the port TX queues after sparx5_fdma_pause() */
> +void sparx5_fdma_resume(struct sparx5 *sparx5)
> +{
> + struct sparx5_rx *rx = &sparx5->rx;
> + struct sparx5_tx *tx = &sparx5->tx;
> +
> + /* Enable NAPI before the RX interrupt is enabled, as the interrupt
> + * handler schedules NAPI, as in sparx5_fdma_start().
> + */
> + napi_enable(&rx->napi);
> +
> + sparx5_fdma_rx_activate(sparx5, rx);
> + sparx5_fdma_tx_activate(sparx5, tx);
[Severity: Low]
On lan969x, does the injection channel's DB interrupt stay masked after
a resize?
sparx5_fdma_pause() pulses FDMA_CTRL_NRESET after sparx5_fdma_stop() has
already cleared the RX bit in FDMA_INTR_DB_ENA. Here,
sparx5_fdma_rx_activate() only sets the XTR channel bit:
spx5_rmw(BIT(fdma->channel_id),
BIT(fdma->channel_id) & FDMA_INTR_DB_ENA_INTR_DB_ENA,
sparx5, FDMA_INTR_DB_ENA);
sparx5_fdma_tx_activate() does not touch FDMA_INTR_DB_ENA at all.
On lan969x, the TX channel bit is only enabled in
lan969x_fdma_napi_poll(), which runs only after an interrupt has
scheduled NAPI:
if (counter < weight && napi_complete_done(napi, counter))
spx5_wr(0xff, sparx5, FDMA_INTR_DB_ENA);
lan969x reclaims TX buffers only from NAPI, in
lan969x_fdma_tx_clear_buf(). lan969x_fdma_xmit() sets
FDMA_DCB_STATUS_INTR on every TX DB and expects that interrupt.
Suppose the NRESET pulse puts FDMA_INTR_DB_ENA back to a cleared
default. Could the TX DCBs then fill up, so that
lan969x_fdma_get_next_dcb() returns -ENOSPC and sparx5_port_xmit_impl()
keeps returning NETDEV_TX_BUSY? That would last until an RX frame
raises the IRQ and NAPI writes 0xff again.
This depends on whether NRESET actually clears FDMA_INTR_DB_ENA, which
the code alone can't confirm. The state after resize would match the
existing post-boot state, since sparx5_fdma_start() also enables only
the RX bit. The behaviour is still present at the end of the series:
"net: sparx5/lan969x: add support for changing the MTU" calls
fdma_resize from ndo_change_mtu without changing sparx5_fdma_resume().
> +
> + /* Forward frames to the CPU again, now the FDMA can extract them */
> + sparx5_fdma_cpu_fwd_set(sparx5, true);
[ ... ]
> +int sparx5_fdma_resize(struct sparx5 *sparx5, struct sparx5_port *port,
> + int new_mtu)
> +{
[ ... ]
> + sparx5_fdma_rx_init(sparx5, rx_new, FDMA_XTR_CHANNEL, db_size);
> + sparx5_fdma_tx_init(sparx5, &tx_new, FDMA_INJ_CHANNEL, db_size);
> +
> + err = sparx5_fdma_rx_alloc(rx_new);
[Severity: Low]
This runs from sleepable process context under RTNL. The caller is
sparx5_port_change_mtu(), added later in the series. The whole ring is
refilled through the NAPI dataptr callback, though:
sparx5_fdma_resize()
sparx5_fdma_rx_alloc(rx_new)
fdma_dcbs_init()
fdma_dcb_add()
__fdma_dcb_add()
sparx5_fdma_rx_dataptr_cb()
__netdev_alloc_skb(rx->ndev, fdma->db_size, GFP_ATOMIC);
That is FDMA_DCB_MAX * FDMA_RX_DCB_MAX_DBS = 960 skbs. With a jumbo MTU,
db_size is about 14 KB, so each data buffer becomes a 16 KB (order-2)
allocation. That adds up to roughly 15 MB of GFP_ATOMIC allocations
while the old ring of similar size is still allocated.
lan969x_fdma_resize() does the same thing.
lan969x_fdma_rx_alloc(rx_new) fills 64 slots through
lan969x_fdma_rx_dataptr_cb() and page_pool_dev_alloc_pages(), with pages
of up to order 2.
On a fragmented, long-running system, can an MTU increase fail with
-ENOMEM when a GFP_KERNEL allocation, which can reclaim and compact,
would have succeeded? Could the burst also use up the atomic reserves
that other RX paths depend on?
> + if (err)
> + goto out;
[ ... ]
--
Sashiko AI review · https://netdev-ai.bots.linux.dev/sashiko/#/patchset/20261120-sparx5-mtu-change-v3-0-55c272fe1acc%40microchip.com