Re: [PATCH net-next v3 1/3] net: dsa: qca8k: propagate MDIO errors
From: Andrew Lunn
Date: Mon Oct 05 2026 - 13:01:09 EST
On Sat, Oct 03, 2026 at 07:24:02PM +0200, Yongzhao Chen wrote:
> qca8k_mii_write32() ignores errors from both 16-bit half-word writes.
> Its callers (register writes and read-modify-write helpers) then return
> the earlier successful page selection or read result, incorrectly
> reporting success even when writing the switch register failed.
>
> Propagate write errors from both the low and high half-words through the
> regmap paths and internal MDIO master transactions. Attempt to clear
> MASTER_EN even if a transaction fails, preserving the initial error, and
> report a cleanup failure if the transaction itself succeeded. Preserve
> the existing Ethernet-to-MDIO fallback order.
>
> Propagate read errors through the internal and legacy MDIO bus callbacks
> instead of masking them as 0xffff. Returning 0xffff causes PHY
> read-modify-write callers to treat the failed read as valid register
> data, which can corrupt unrelated bits on writeback.
>
> Stop polling when reading the MDIO busy status fails, and return the
> error immediately. Because the read helper clears its output on failure,
> checking only the BUSY bit mistakes an unsuccessful read for transaction
> completion.
>
> Code inspection found these problems. Fault injection into a userspace
> model of the driver's functions reproduces them; the corresponding cases
> pass after this change.
>
> qca8k_mii_write32() has not returned write errors since its introduction
> in commit 6b93fb46480a ("net-next: dsa: add new driver for qca8xxx
> family").
>
> Signed-off-by: Yongzhao Chen <yongzhao.derek@xxxxxxxxx>
Reviewed-by: Andrew Lunn <andrew@xxxxxxx>
Andrew