All of lore.kernel.org
 help / color / mirror / Atom feed
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 5/6] net: dsa: mxl862xx: recover switch stuck in MCUboot rescue mode
Date: Tue, 8 Sep 2026 14:38:26 +0200	[thread overview]
Message-ID: <efdade1e-3d15-4e0f-8a80-8465e963f6d3@lunn.ch> (raw)
In-Reply-To: <f373ce50bf741c50ff5249a538088a9451aa5730.1788783126.git.daniel@makrotopia.org>

On Mon, Sep 07, 2026 at 07:38:40PM +0100, Daniel Golle wrote:
> A broken or interrupted firmware image, or the sticky rescue bit, keeps
> the switch in its MCUboot bootloader, which exposes only the clause-22
> SMDIO download interface. The clause-45 MMD API never comes up, so probe
> would fail with -ETIMEDOUT and the only way back would be the switch's
> UART console, or a power cycle or out-of-band reset (not currently
> implemented).
> 
> Probe for the loader over SB PDI at setup, before any clause-45 access,
> since the C45 API floods the log with CRC errors when no firmware
> answers. A scratch write to two mailbox registers first establishes
> that a switch is there at all. It reaches a running firmware as well,
> but lands in registers that firmware does not read, so it is inert
> there. The status register the loader publishes then tells the cases
> apart without touching C45: a running firmware, which answers with its
> own non-zero status word (0x0003 on the firmware tested), so probe
> continues normally; a loader idle in its console loop, confirmed live
> by a register-read challenge; a loader wedged mid-download, the one
> case that publishes zero; the flashless download loop, which this
> driver cannot drive; and a switch whose scratch write does not latch --
> absent, unpowered, misdescribed in the device tree (wrong address or
> bus, or a reset GPIO with inverted polarity), or with its SB PDI window
> somewhere other than the OTP reset offsets assumed here. The first
> three enter rescue mode or normal operation, the last two fail probe
> cleanly with -EOPNOTSUPP and -ENODEV instead of a CRC-error storm.
> 
> A loader that publishes the ready magic but never services the
> register-read challenge fails probe too, with -ENXIO. The challenge is
> what tells the loader apart from a firmware whose status word happens
> to read the same value, and offering to flash a healthy firmware would
> be worse than refusing to bind, so a mailbox that does not answer is
> treated as unusable rather than as a flash target. Every loader tested
> services it.
> 
> In rescue mode the switch registers without user interfaces so devlink
> stays available: user ports fail port_setup with -ENODEV (the DSA core
> re-registers them as unused) while shared and CPU ports succeed, and the
> CPU port works on its fixed link with mac_select_pcs returning no PCS.
> Firmware API commands fail fast with -ENODEV and the port and STP
> callbacks become no-ops.
> 
> An interrupted download can leave the loader wedged mid-payload. A
> background work item off the devlink flash path drains it back to a
> clean ready state by feeding the outstanding byte count one byte at a
> time, which takes tens of minutes for a large image and is logged as it
> progresses; until then devlink dev info reports no version and devlink
> dev flash returns -EBUSY, and -EIO once a drain has failed for good.
> Reaching the end of the count is all the drain does: the loader then
> verifies the corrupt image and returns to its console loop on its own,
> so the drain reprobes and lets the probe-time detection re-classify the
> switch -- a valid image that a last-moment interruption left bootable
> comes up as running firmware, with no second-guessing in the drain path.
> 
> The re-probe the drain schedules is the same device_schedule_reprobe()
> hand-off the flash path uses: the core skips it if the device is
> unbound or shut down before it fires, so a drain finishing after the
> driver is gone does nothing. Should scheduling it fail, recovery is
> marked failed, since the loader would otherwise sit at a clean ready
> state that nothing reclassifies while devlink keeps promising that a
> retry will work.
> 
> The CHIP ID registers need a running firmware, so no asic.id/asic.rev is
> reported in rescue mode. Once the loader is ready, devlink dev info
> reports the null firmware version "0.0.0" as both running and stored:
> 
>   $ devlink dev info mdio_bus/mdio-bus:10
>   mdio_bus/mdio-bus:10:
>     driver mxl862xx
>     versions:
>         running:
>           fw 0.0.0
>         stored:
>           fw 0.0.0
> 
> An operational switch never reports 0.0.0 (a released firmware's major
> is non-zero), so version-comparing tools like fwupd offer every release
> as an upgrade, recovering the switch through the regular flash flow,
> matched on the driver name. The flash skips the FW_UPDATE command since
> MCUboot is already waiting. A successful flash reboots the switch into
> the new firmware and the reprobe then brings the driver up against it
> normally; after a failed one the switch is still in MCUboot, rescue mode
> is detected again, and the user can retry.
> 
> Signed-off-by: Daniel Golle <daniel@makrotopia.org>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

  reply	other threads:[~2026-09-08 12:38 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
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 [this message]
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=efdade1e-3d15-4e0f-8a80-8465e963f6d3@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.