Re: [PATCH 1/1] net: phy: microchip_t1s: enable lan865x revb1

From: Russell King (Oracle)
Date: Fri May 24 2024 - 11:12:21 EST


On Fri, May 24, 2024 at 04:07:06PM +0200, Ramón Nordin Rodriguez wrote:
> +/* this func is copy pasted from Parthibans ongoing work with oa_tc6
> + * see https://lore.kernel.org/netdev/20240418125648.372526-7-Parthiban.Veerasooran@xxxxxxxxxxxxx/
> + */

Oh dear...

> +static int lan865x_phy_read_mmd(struct phy_device *phydev, int devnum,
> + u16 regnum)
> +{
> + struct mii_bus *bus = phydev->mdio.bus;
> + int addr = phydev->mdio.addr;
> +
> + return bus->read_c45(bus, addr, devnum, regnum);
> +}
> +
> +/* this func is copy pasted from Parthibans ongoing work with oa_tc6
> + * see https://lore.kernel.org/netdev/20240418125648.372526-7-Parthiban.Veerasooran@xxxxxxxxxxxxx/
> + */
> +static int lan865x_phy_write_mmd(struct phy_device *phydev, int devnum,
> + u16 regnum, u16 val)
> +{
> + struct mii_bus *bus = phydev->mdio.bus;
> + int addr = phydev->mdio.addr;
> +
> + return bus->write_c45(bus, addr, devnum, regnum, val);
> +}

So you need both of these to (dangerously) read and write the C45
address using a devnum with bit 31 set. Please at the very least
take the MDIO bus lock so the locking of these operations remains
consistent.

I'm not sure that abusing the interface by setting bit 31 in the
device address, which is supposed to be between 0 and 31 is
something we're prepared to entertain.

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!