Netdev List
 help / color / mirror / Atom feed
* [PATCH net v2 0/5] net: dsa: mt7530: fix swallowed MDIO read errors
@ 2026-07-30  0:14 Daniel Golle
  2026-07-30  0:14 ` [PATCH net v2 1/5] net: pcs: mtk-lynxi: check regmap reads in mtk_pcs_lynxi_get_state() Daniel Golle
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Daniel Golle @ 2026-07-30  0:14 UTC (permalink / raw)
  To: Chester A. Unal, Daniel Golle, Andrew Lunn, Vladimir Oltean,
	David S. Miller, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	Matthias Brugger, AngeloGioacchino Del Regno, Alexander Couzens,
	Heiner Kallweit, Russell King, Russell King, Sean Wang,
	Florian Fainelli, Landen Chao, netdev, linux-kernel,
	linux-arm-kernel, linux-mediatek

While working on a register access cleanup for the mt7530 driver, the
Sashiko AI reviewers flagged long-standing error handling gaps in the
driver's read paths [1].

The MDIO regmap backend truncates negative bus->read() errnos into u16
register halves and returns success, handing garbage data to callers
and to read-modify-write cycles which then write it back to the switch.

The ATC/VTCR command polls and the MT7531 indirect PHY polls consume
reads through a helper which returns 0 when the underlying read fails.
A failed bus transaction thus clears the polled busy bit and is
mistaken for command completion, defeats the subsequent
ATC_INVALID/VTCR_INVALID checks the same way, and lets the indirect
PHY access functions return garbage PHY register data.

Fix the backend to propagate bus->read() errors, and convert the
command and PHY access polls to regmap_read_poll_timeout(), which
terminates polling on read errors and propagates them. The driver's
legacy read helpers return plain u32 values and cannot convey errors,
hence the affected reads switch to the plain regmap API the helpers
are built on, while all other accesses are deliberately left
untouched; the cleanup series converts the rest of the driver.

The Sashiko reviewers went over v1 as well [2] and found that the same
unchecked-read pattern recurs in a couple of other places, and that the
read-error propagation above widens a pre-existing gap in a PCS driver
consumer; patches 1-3 grew companion fixes for those. They also found a
separate locking gap between the switch regmap and its IRQ chip, fixed
in the new patch 4 with its own Fixes: tag.

The cleanup series depending on these fixes will be submitted to
net-next separately.

Changes since v1:
 * 1/4: also check the identical unchecked bus->read() in core_rmw(),
   and fix mtk_pcs_lynxi_get_state() (drivers/net/pcs/pcs-mtk-lynxi.c)
   to check regmap_read() now that a failed read can leave its output
   unwritten instead of holding truncated-but-defined garbage
 * 2/4: drop the redundant regmap_read() after
   regmap_read_poll_timeout(), and print ret in the error messages
 * 3/4: also check mt7530_mii_write()'s return for the PHY_IAC command
   word in all four PHY access helpers, and print ret in the poll
   error messages
 * add 4/4, calling mt7530_mutex_lock()/unlock() around the regmap IRQ
   chip's own accesses via handle_pre_irq/handle_post_irq/
   handle_mask_sync, the same driver-provided locking every other user
   of the unlocked switch regmap already goes through, instead of
   adding a second regmap instance

[1] https://lore.kernel.org/netdev/cover.1784481922.git.daniel@makrotopia.org/
[2] https://lore.kernel.org/netdev/cover.1785213071.git.daniel@makrotopia.org/

Daniel Golle (5):
  net: pcs: mtk-lynxi: check regmap reads in mtk_pcs_lynxi_get_state()
  net: dsa: mt7530: check bus->read() errors in the MDIO regmap backend
  net: dsa: mt7530: error out on failed reads in ATC/VTCR command
    polling
  net: dsa: mt7530: error out on failed reads in MT7531 PHY polling
  net: dsa: mt7530: serialize the regmap IRQ chip like every other user

 drivers/net/dsa/mt7530-mdio.c   |  11 ++-
 drivers/net/dsa/mt7530.c        | 170 ++++++++++++++++++--------------
 drivers/net/pcs/pcs-mtk-lynxi.c |   5 +-
 3 files changed, 108 insertions(+), 78 deletions(-)


base-commit: 51b093a7ba27476e1f639455f005e8d2e75390e4
prerequisite-patch-id: 0000000000000000000000000000000000000000
-- 
2.55.0

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-07-30  1:44 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-07-30  0:14 [PATCH net v2 0/5] net: dsa: mt7530: fix swallowed MDIO read errors Daniel Golle
2026-07-30  0:14 ` [PATCH net v2 1/5] net: pcs: mtk-lynxi: check regmap reads in mtk_pcs_lynxi_get_state() Daniel Golle
2026-07-30  0:14 ` [PATCH net v2 2/5] net: dsa: mt7530: check bus->read() errors in the MDIO regmap backend Daniel Golle
2026-07-30  0:14 ` [PATCH net v2 3/5] net: dsa: mt7530: error out on failed reads in ATC/VTCR command polling Daniel Golle
2026-07-30  0:14 ` [PATCH net v2 4/5] net: dsa: mt7530: error out on failed reads in MT7531 PHY polling Daniel Golle
2026-07-30  0:15 ` [PATCH net v2 5/5] net: dsa: mt7530: serialize the regmap IRQ chip like every other user Daniel Golle
2026-07-30  1:44 ` [PATCH net v2 0/5] net: dsa: mt7530: fix swallowed MDIO read errors Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox