From: Andrew Lunn <andrew@lunn.ch>
To: Daniel Golle <daniel@makrotopia.org>
Cc: Jiri Pirko <jiri@resnulli.us>,
"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>, Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Randy Dunlap <rdunlap@infradead.org>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
"Rafael J. Wysocki" <rafael@kernel.org>,
Danilo Krummrich <dakr@kernel.org>,
Vladimir Oltean <olteanv@gmail.com>,
Frank Wunderlich <frank.wunderlich@linux.dev>,
John Crispin <john@phrozen.org>,
"Benny (Ying-Tsan) Weng" <yweng@maxlinear.com>,
netdev@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, driver-core@lists.linux.dev
Subject: Re: [PATCH net-next v13 4/6] net: dsa: mxl862xx: add devlink flash_update and info_get
Date: Tue, 8 Sep 2026 14:36:25 +0200 [thread overview]
Message-ID: <c825c54d-a5f7-4ef7-a19a-bc0a78da0225@lunn.ch> (raw)
In-Reply-To: <0f075bdb2c3740d502ab1211f2d20e44ea055c75.1788783126.git.daniel@makrotopia.org>
On Mon, Sep 07, 2026 at 07:38:28PM +0100, Daniel Golle wrote:
> Implement runtime firmware upgrade via "devlink dev flash" and version
> reporting via "devlink dev info":
>
> $ devlink dev info mdio_bus/mdio-bus:10
> mdio_bus/mdio-bus:10:
> driver mxl862xx
> versions:
> fixed:
> asic.id 8628
> asic.rev 0
> running:
> fw 1.0.70
> stored:
> fw 1.0.70
>
> The "asic.id" and "asic.rev" fixed versions carry the numeric chip part
> number and revision from the static CHIP ID registers (SYS_MISC_REG_RD),
> which userspace such as fwupd matches firmware against; they are omitted
> if the read fails or the part is unfused, so no bogus "0000" is
> published. The switch boots its firmware from its own flash, so "fw" is
> reported as both the running and the stored version; a flashless part
> would omit "stored", distinguishing the two without an API change.
>
> $ devlink dev flash mdio_bus/mdio-bus:10 file mxl862xx-fw.bin
>
> The image, including both payload CRCs, is validated first, so a
> malformed file is rejected without disturbing the running switch. The
> driver then sends SYS_MISC_FW_UPDATE, which reboots the switch into its
> MCUboot bootloader, and transfers the signed image over the SB PDI
> protocol (clause-22 SMDIO), checking every write: a failed address write
> at the half-bank boundary would otherwise misplace half the payload
> unnoticed. A successful transfer reboots the switch into the new
> firmware. The loader verifies the image once the last slice has been
> programmed and publishes the verdict, so a rejected image is reported as
> such rather than as a transfer timeout. The whole cycle takes just under
> a minute.
>
> For its duration the driver closes all user and conduit interfaces and
> marks the user ports not-present with netif_device_detach() so userspace
> cannot reopen them; the conduit belongs to the MAC driver and is only
> closed. This also stops phylib polling the switch-internal PHYs,
> unreachable in MCUboot. The bridge's deferred STP DISABLED transitions
> are flushed under rtnl so they reach the firmware while it still runs;
> the stats poll and CRC error handler are stopped; and firmware API
> commands from other paths are blocked under the MDIO bus lock so none
> reaches the bus once the switch has rebooted. Progress is reported
> through devlink status notifications.
>
> The switch leaves MCUboot on its own by booting the new image, but the
> driver has no in-place path back, so it reinitialises with a deferred
> re-probe scheduled regardless of the transfer outcome, using
> device_schedule_reprobe() from the previous patch. The helper's work
> runs in the driver core, off the devlink caller's locking and signal
> context, without this driver holding module or device references, and
> it skips the re-probe if the device is unbound or shut down before it
> fires, so a stale re-probe can neither undo an administrative unbind
> nor detach a device whose ->shutdown() has already run. During the
> teardown the driver's API reads return -ENODEV and writes fake success,
> so it neither stalls on the absent firmware nor consumes buffers it
> never filled; port_mdb_del() takes that -ENODEV for a MAC table that is
> gone and reports success, since there is nothing left to delete. A
> failed re-probe leaves the device unbound, exactly as a failed initial
> probe would, and a further flash is refused until it has run. An
> aborted transfer leaves the switch in MCUboot, where nothing here can
> reach it; the next patch adds the detection that makes such a switch
> flashable again.
>
> Scheduling the re-probe can only fail on memory allocation, and only
> after the switch has already been flashed. -ENOMEM there is a
> system-wide condition that no driver-level message or recovery attempt
> improves, so it is returned as-is with no further action: the driver
> stays bound with its firmware API short-circuited, and unbinding and
> rebinding it runs the same teardown and fresh probe the re-probe would
> have.
>
> The closed user ports and conduit are not returned to their pre-flash
> administrative state across the reprobe; userspace brings them back up,
> and restoring it in-driver would need DSA-core support that does not
> yet exist.
>
> Assisted-by: LLM
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Andrew
next prev parent reply other threads:[~2026-09-08 12:36 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-07 18:37 [PATCH net-next v13 0/6] net: dsa: mxl862xx: devlink flash and rescue Daniel Golle
2026-09-07 18:37 ` [PATCH net-next v13 1/6] net: dsa: add devlink flash_update callback to dsa_switch_ops Daniel Golle
2026-09-08 12:28 ` Andrew Lunn
2026-09-07 18:37 ` [PATCH net-next v13 2/6] net: dsa: mxl862xx: add SMDIO clause-22 register access Daniel Golle
2026-09-07 18:37 ` [PATCH net-next v13 3/6] driver core: add device_schedule_reprobe() Daniel Golle
2026-09-07 18:38 ` [PATCH net-next v13 4/6] net: dsa: mxl862xx: add devlink flash_update and info_get Daniel Golle
2026-09-08 12:36 ` Andrew Lunn [this message]
2026-09-07 18:38 ` [PATCH net-next v13 5/6] net: dsa: mxl862xx: recover switch stuck in MCUboot rescue mode Daniel Golle
2026-09-08 12:38 ` Andrew Lunn
2026-09-07 18:38 ` [PATCH net-next v13 6/6] net: dsa: mxl862xx: document devlink flash and info support Daniel Golle
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=c825c54d-a5f7-4ef7-a19a-bc0a78da0225@lunn.ch \
--to=andrew@lunn.ch \
--cc=corbet@lwn.net \
--cc=dakr@kernel.org \
--cc=daniel@makrotopia.org \
--cc=davem@davemloft.net \
--cc=driver-core@lists.linux.dev \
--cc=edumazet@google.com \
--cc=frank.wunderlich@linux.dev \
--cc=gregkh@linuxfoundation.org \
--cc=horms@kernel.org \
--cc=jiri@resnulli.us \
--cc=john@phrozen.org \
--cc=kuba@kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=rafael@kernel.org \
--cc=rdunlap@infradead.org \
--cc=skhan@linuxfoundation.org \
--cc=yweng@maxlinear.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