[RFC PATCH net-next 3/3] net: dsa: allow the phy_connect() call to return -EPROBE_DEFER

Vladimir Oltean
2021-09-01T22:51:51Z

Currently DSA ignores any errors coming from dsa_port_setup(), and this
includes:

dsa_port_setup
-> dsa_slave_create
-> dsa_slave_phy_setup
-> phylink_of_phy_connect
-> ...
-> phy_attach_direct

This is done such that PHYs present on optional riser cards which are
missing do not cause the entire switch probing to fail.

Now that phy_attach_direct tries harder to probe the specific PHY driver
instead of genphy, it can actually return -EPROBE_DEFER. It makes sense
to treat this error separately, and not just give up. Trigger the normal
error path, unwind the setup done so far, and come back later.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
---
net/dsa/dsa2.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/net/dsa/dsa2.c b/net/dsa/dsa2.c
index e78901d33a10..282bdebac835 100644
--- a/net/dsa/dsa2.c
+++ b/net/dsa/dsa2.c
@@ -912,6 +912,8 @@ static int dsa_tree_setup_switches(struct dsa_switch_tree *dst)

list_for_each_entry(dp, &dst->ports, list) {
err = dsa_port_setup(dp);
+ if (err == -EPROBE_DEFER)
+ goto teardown;
if (err) {
dsa_port_devlink_teardown(dp);
dp->type = DSA_PORT_TYPE_UNUSED;
--
2.25.1