Re: [PATCH RFC net-next 3/3] net: dsa: mxl862xx: add devlink flash_update and info_get

From: Manuel Ebner

Date: Wed Jul 08 2026 - 14:29:19 EST


Hi Daniel,

On Tue, 2026-07-07 at 16:16 +0200, Daniel Golle wrote:
> Implement runtime firmware upgrade via "devlink dev flash" and version
> reporting via "devlink dev info":
>
>   devlink dev info mdio_bus/<bus>/<addr>
>   devlink dev flash mdio_bus/<bus>/<addr> file <firmware.bin>
>
> The driver sends SYS_MISC_FW_UPDATE to enter MCUboot rescue mode,
> transfers the signed image over the SB PDI bulk-transfer protocol
> (clause-22 SMDIO), waits for the switch to reboot, then schedules
> device_reprobe() for a clean remove()+probe() cycle.

This could be split up into two sentences.


> Before the transfer begins the driver closes all conduit interfaces
> and marks every netdev (user and conduit) not-present via
> netif_device_detach() so that userspace cannot bring ports back up
> during the ~15 minute flash process. Progress is reported through
> devlink status notifications. Once the FW_UPDATE command has been
> sent the switch is in MCUboot mode and normal operation can only be
> restored by a reprobe, so the driver always schedules one regardless
> of transfer outcome.
>
> The reprobe work item is dynamically allocated (following the iwlwifi
> pattern)

I'm not familiar with the net subsystem, if the iwlwifi pattern is not
trivial consider adding a link or a explanation.

> because device_reprobe() triggers remove() which frees the
> devm-managed priv while the work is still executing.
>
> Signed-off-by: Daniel Golle <daniel@xxxxxxxxxxxxxx>
> ---
>  drivers/net/dsa/mxl862xx/Makefile        |   2 +-
>  drivers/net/dsa/mxl862xx/mxl862xx-cmd.h  |   1 +
>  drivers/net/dsa/mxl862xx/mxl862xx-fw.c   | 434 +++++++++++++++++++++++
>  drivers/net/dsa/mxl862xx/mxl862xx-fw.h   |  15 +
>  drivers/net/dsa/mxl862xx/mxl862xx-host.c |   7 +
>  drivers/net/dsa/mxl862xx/mxl862xx.c      |   3 +
>  drivers/net/dsa/mxl862xx/mxl862xx.h      |   2 +
>  7 files changed, 463 insertions(+), 1 deletion(-)
>  create mode 100644 drivers/net/dsa/mxl862xx/mxl862xx-fw.c
>  create mode 100644 drivers/net/dsa/mxl862xx/mxl862xx-fw.h
>
> diff --git a/drivers/net/dsa/mxl862xx/Makefile b/drivers/net/dsa/mxl862xx/Makefile
> index a7be0e6669df..bccac0d0f703 100644
> --- a/drivers/net/dsa/mxl862xx/Makefile
> +++ b/drivers/net/dsa/mxl862xx/Makefile
> @@ -1,3 +1,3 @@
>  # SPDX-License-Identifier: GPL-2.0
>  obj-$(CONFIG_NET_DSA_MXL862) += mxl862xx_dsa.o
> -mxl862xx_dsa-y := mxl862xx.o mxl862xx-host.o mxl862xx-phylink.o
> +mxl862xx_dsa-y := mxl862xx.o mxl862xx-host.o mxl862xx-phylink.o mxl862xx-fw.o
> diff --git a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
> b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
> index c87a955c13c4..e2aa2934e9e1 100644
> --- a/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
> +++ b/drivers/net/dsa/mxl862xx/mxl862xx-cmd.h
> @@ -70,6 +70,7 @@
>  #define INT_GPHY_READ (GPY_GPY2XX_MAGIC + 0x1)
>  #define INT_GPHY_WRITE (GPY_GPY2XX_MAGIC + 0x2)
>  
> +#define SYS_MISC_FW_UPDATE (SYS_MISC_MAGIC + 0x1)
>  #define SYS_MISC_FW_VERSION (SYS_MISC_MAGIC + 0x2)
>  
>  #define MXL862XX_XPCS_PCS_CONFIG (MXL862XX_XPCS_MAGIC + 0x1)
> diff --git a/drivers/net/dsa/mxl862xx/mxl862xx-fw.c b/drivers/net/dsa/mxl862xx/mxl862xx-
> fw.c
> new file mode 100644
> index 000000000000..7cd4a462667b
> --- /dev/null
> +++ b/drivers/net/dsa/mxl862xx/mxl862xx-fw.c
> @@ -0,0 +1,434 @@
> +// SPDX-License-Identifier: GPL-2.0-or-later
> +/*
> + * Firmware flash and devlink support for MaxLinear MxL862xx

If you have a data sheet for the device please add a link.

> + *
> + * Copyright (C) 2025 Daniel Golle <daniel@xxxxxxxxxxxxxx>
> + *
> + * Usage:
> + *   # Query running firmware version:
> + *   devlink dev info mdio_bus/<bus>/<addr>
> + *
> + *   # Flash new firmware (all ports are taken down automatically):
> + *   devlink dev flash mdio_bus/<bus>/<addr> file <firmware.bin>
> + *
> + * The flash process takes approximately 15 minutes. 

Does the user get informed about the wait?


> Progress is
> + * reported via devlink status notifications. After a successful (or
> + * failed) flash the driver reprobes the device automatically.
> + */
>
> [...]
> +
> +/* Timeouts */
> +#define MXL862XX_FW_READY_TIMEOUT_MS 30000
> +#define MXL862XX_FW_ACK_TIMEOUT_MS 5000
> +#define MXL862XX_FW_ERASE_TIMEOUT_MS 300000 /* flash erase is very slow */

Slow is relative.
Can you give an erase speed in MB/s or time for the whole memory?

> [...]
> +
> + dev_info(ds->dev, "flash: running firmware %u.%u.%u\n",
> + priv->fw_version.major, priv->fw_version.minor,
> + priv->fw_version.revision);
> +
> + /* Close all user and CPU ports while the firmware is still
> + * alive. dev_close() on user ports triggers multicast group
> + * leave and host MDB/FDB removal on the CPU port through the
> + * normal DSA callbacks so the core's tracking lists are
> + * drained before we enter MCUboot. Then mark user ports
> + * not-present so userspace cannot bring them back up during
> + * the (slow) flash process. The conduit is only closed, not

(slow) -> up to 20 minutes long flash process.
or -> circa 15 minutes long flash process.

> + * detached -- it is owned by the Ethernet MAC driver and
> + * dev_open() during reprobe must be able to bring it back.
> + */
> +[...]
> + /* Silently discard all API commands during the teardown that
> + * reprobe triggers -- the switch firmware has been reset and
> + * has no knowledge of the old configuration.
> + */
> + priv->skip_teardown = true;
> +
> + reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);

-> kzalloc_obj(*reprobe); - GFP_KERNEL is the default, therefore omitted.
as suggested in 2932ba8d9c99 ("slab: Introduce kmalloc_obj() and family")

Did you skip checkpatch or is it out of date?

Anyway thanks
Manuel

> [...]