Re: [PATCH v3 5/7] net: dsa: mediatek: support MDIO switch downstream of MMIO switch

From: Caleb James DeLisle

Date: Wed Oct 28 2026 - 11:14:44 EST



On 28/10/2026 13:50, Andrew Lunn wrote:
On Wed, Oct 28, 2026 at 12:59:23PM +0100, Caleb James DeLisle wrote:
On 28/10/2026 03:20, Andrew Lunn wrote:
On Wed, Oct 28, 2026 at 01:13:15AM +0000, Caleb James DeLisle wrote:
The MT7530 / MT7531 can connect via either MDIO or MMIO. In MMIO mode
the switch provides its own MDIO bus which connects to its integrated
PHYs, but also can be connected to other things, such as another
switch.

If the MDIO bus contains another switch, then the upstream switch
will register but it will not setup the DSA tree because the
downstream switch is missing. Without the complete DSA tree,
mt753x_setup() will not be called on the switch and therefore
mt7530_setup_mdio() is never called so the downstream switch never
registers.

Update mt7530_setup_mdio() so that it can be called multiple times,
export the symbol, and call it again after dsa_register_switch()
from mt7988_probe().
I would suggest just moving it to probe. Don't also have it in setup.
KISS.

I don't think there's a way to do that which will work. And I guess I need
to add a few comments to explain why. Basically when dsa_register_switch()
is called, one of three things can happen:

1. return error (often without calling mt753x_setup), typically this is
EPROBE_DEFER because the ethernet driver is not there yet.

2. return 0 without calling mt753x_setup (because not all switches in the
tree are yet probed)

3. call mt753x_setup, complete setup, and return 0


In case 1, mt7530_setup_mdio must not be called, because it would be setting
up an MDIO on a driver that's about to get deleted.
Which is fine, because when the probe fails, you unregister the MDIO
bus. That should work. The second time around, you do have the netdev,
and it should work.


When I tried doing this it did not work. The first issue is that mt7530_setup_mdio() uses a static int and increments it to make its ID. And normally this would create higher numbered busses but still work, however from what I remember there's something (not mt7530) that searches for mt7530-0 anyway and is unable to find it. I don't remember now what was doing it but I remember thinking I would need a global ID generator with reuse of released IDs.


Furthermore, I think I'd have to test all of the PHYs that are downstream of this switch because this is the first time we would actually be asking them actually register and unregister multiple times each startup, so if there are bugs, then they're kinda my bugs.


So if this is a requirement, then I think this patchset will need to go on the back burner and that support would probably be its own patch/patchset. So please let me know how you're feeling on this because I don't want to put too much time into the rest of this patchset if it is going to have to get shelved for a while anyway.


Thanks,

Caleb



It is not great, you are doing extra work, but many DSA drivers are
structured like this, the MDIO bus is registered in probe. The bus is
scanned, PHY are found, and then the probe fails, and the PHYs are all
thrown away etc.

Hanging one switch off another switch like this using MDIO, kind of
pushes you in this direction. Typical DSA setups don't do this, there
is one MDIO bus which all switches hang off, sometimes with a
multiplexor to make one MDIO bus act like many.

Something to look at which might be interesting, Vladimir had some
patches which allowed for partial switch topologies, where you could
take a switch in a DSA setup off line. Maybe there is something in
those patches which help, you can bring the switches up independently?

Andrew