mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Manuel Ebner <manuelebner@mailbox.org>
To: Daniel Golle <daniel@makrotopia.org>,
	Andrew Lunn <andrew@lunn.ch>,
	 Vladimir Oltean <olteanv@gmail.com>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski	 <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman	 <horms@kernel.org>,
	linux-kernel@vger.kernel.org, netdev@vger.kernel.org
Subject: Re: [PATCH RFC net-next 3/3] net: dsa: mxl862xx: add devlink flash_update and info_get
Date: Wed, 08 Jul 2026 20:25:49 +0200	[thread overview]
Message-ID: <c6a291e752b889689c0776e59024e752e4306868.camel@mailbox.org> (raw)
In-Reply-To: <ak0KOrM5E2_sPIHf@makrotopia.org>

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@makrotopia.org>
> ---
>  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@makrotopia.org>
> + *
> + * 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

> [...]

      parent reply	other threads:[~2026-07-08 18:25 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-07 14:16 Daniel Golle
2026-07-08 17:27 ` Andrew Lunn
2026-07-08 20:02   ` Daniel Golle
2026-07-08 23:24     ` Andrew Lunn
2026-07-09  9:43       ` Daniel Golle
2026-07-08 18:25 ` Manuel Ebner [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=c6a291e752b889689c0776e59024e752e4306868.camel@mailbox.org \
    --to=manuelebner@mailbox.org \
    --cc=andrew@lunn.ch \
    --cc=daniel@makrotopia.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=olteanv@gmail.com \
    --cc=pabeni@redhat.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