Re: [PATCH net-next v4 05/11] net: dsa: realtek: use phy_read in ds->ops

Florian Fainelli
2022-01-17T04:15:21Z

On 1/4/2022 7:15 PM, Luiz Angelo Daros de Luca wrote:
> The ds->ops->phy_read will only be used if the ds->slave_mii_bus
> was not initialized. Calling realtek_smi_setup_mdio will create a
> ds->slave_mii_bus, making ds->ops->phy_read dormant.
>
> Using ds->ops->phy_read will allow switches connected through non-SMI
> interfaces (like mdio) to let ds allocate slave_mii_bus and reuse the
> same code.
>
> Signed-off-by: Luiz Angelo Daros de Luca <luizluca@gmail.com>
> Tested-by: Arınç ÜNAL <arinc.unal@arinc9.com>
> Reviewed-by: Linus Walleij <linus.walleij@linaro.org>

Humm assigning dsa_switch_ops::phy_read will force DSA into tearing down
the MDIO bus in dsa_switch_teardown() instead of letting your driver do
it and since realtek-smi-core.c uses devm_mdiobus_unregister(), it is
not clear to me what is going to happen but it sounds like a double free
might happen?

It seems more prudent to me to leave existing code.
--
Florian