net: dsa: fix phydev->speed being uninitialized for the CPU port fixed PHY
authorVladimir Oltean <vladimir.oltean@nxp.com>
Sat, 4 Dec 2021 23:00:34 +0000 (01:00 +0200)
committerRamon Fried <ramon@neureality.ai>
Sat, 15 Jan 2022 16:49:03 +0000 (18:49 +0200)
commit0fa4448d5191f9397e5acbd6c83073523cc6c4bd
tree8ff9d3ea2e018783b35981a79d6c4cdcb1ca5fbd
parentc2969792c46ce42a4429e41b4b81f42a5873ef07
net: dsa: fix phydev->speed being uninitialized for the CPU port fixed PHY

If the DSA API is going to allow drivers to do things such as:

- phy_config in dsa_ops :: port_probe
- phy_startup in dsa_ops :: port_enable

then it would actually be good if the ->port_probe() method would
actually be called in all cases before the ->port_enable() is.

Currently this is true for user ports, but not true for the CPU port,
because the CPU port does not have a udevice registered for it (this is
all part of DSA's design). So the current issue is that after
phy_startup has finished for the CPU port, its phydev->speed is an
uninitialized value, because phy_config() was never called for the
priv->cpu_port_fixed_phy, and it is precisely phy_config() who copies
the speed into the phydev in the case of the fixed PHY driver.

So we need to simulate a probing event for the CPU port by manually
calling the driver's ->port_probe() method for the CPU port.

Fixes: 8a2982574854 ("net: dsa: introduce a .port_probe() method in struct dsa_ops")
Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Reviewed-by: Ramon Fried <rfried.dev@gmail.com>
net/dsa-uclass.c