Re: [PATCH net-next] net: dsa: motorcomm: Resync SMI slave after interrupted MDIO access

From: Andrew Lunn

Date: Sat Nov 14 2026 - 10:40:49 EST


> static int yt921x_reg_mdio_read(void *context, u32 reg, u32 *valp)
> {
> struct yt921x_reg_mdio *mdio = context;
> @@ -108,6 +196,12 @@ static int yt921x_reg_mdio_read(void *context, u32 reg, u32 *valp)
> u32 val;
> int res;
>
> + if (!mdio->synced) {
> + res = yt921x_reg_mdio_resync(mdio);
> + if (res)
> + return res;
> + }
> +
> /* Hold the mdio bus lock to avoid (un)locking for 4 times */
> mutex_lock_nested(&bus->mdio_lock, MDIO_MUTEX_NESTED);
>
> @@ -136,6 +230,9 @@ static int yt921x_reg_mdio_read(void *context, u32 reg, u32 *valp)
>
> end:
> mutex_unlock(&bus->mdio_lock);
> +
> + if (res)
> + mdio->synced = false;

Why defer the recovery to the next transaction? Why not do it now. And
if the recovery fails, you can report the transaction which actually
killed it, which might be useful for debugging.

Andrew