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

From: David Yang

Date: Sat Nov 14 2026 - 11:34:46 EST


On Sat, Nov 14, 2026 at 11:40 PM Andrew Lunn <andrew@xxxxxxx> wrote:
>
> > 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

If the recovery fails, you have to, anyway, try to resync in the next
transaction, so recovery here does not help other than adding more
code. And we did not and do not report failure here, instead we let
the caller do it.