Skip to content

Commit 1f9f214

Browse files
vladimirolteankuba-moo
authored andcommitted
net: mdio-mux: fix C45 access returning -EIO after API change
The mii_bus API conversion to read_c45() and write_c45() did not cover the mdio-mux driver before read() and write() were made C22-only. This broke arch/arm64/boot/dts/freescale/fsl-ls1028a-qds-13bb.dtso. The -EOPNOTSUPP from mdiobus_c45_read() is transformed by get_phy_c45_devs_in_pkg() into -EIO, is further propagated to of_mdiobus_register() and this makes the mdio-mux driver fail to probe the entire child buses, not just the PHYs that cause access errors. Fix the regression by introducing special c45 read and write accessors to mdio-mux which forward the operation to the parent MDIO bus. Fixes: db1a63a ("net: phy: Remove fallback to old C45 method") Signed-off-by: Vladimir Oltean <[email protected]> Reviewed-by: Florian Fainelli <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Reviewed-by: Russell King (Oracle) <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent f921a4a commit 1f9f214

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

drivers/net/mdio/mdio-mux.c

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,27 @@ static int mdio_mux_read(struct mii_bus *bus, int phy_id, int regnum)
5555
return r;
5656
}
5757

58+
static int mdio_mux_read_c45(struct mii_bus *bus, int phy_id, int dev_addr,
59+
int regnum)
60+
{
61+
struct mdio_mux_child_bus *cb = bus->priv;
62+
struct mdio_mux_parent_bus *pb = cb->parent;
63+
int r;
64+
65+
mutex_lock_nested(&pb->mii_bus->mdio_lock, MDIO_MUTEX_MUX);
66+
r = pb->switch_fn(pb->current_child, cb->bus_number, pb->switch_data);
67+
if (r)
68+
goto out;
69+
70+
pb->current_child = cb->bus_number;
71+
72+
r = pb->mii_bus->read_c45(pb->mii_bus, phy_id, dev_addr, regnum);
73+
out:
74+
mutex_unlock(&pb->mii_bus->mdio_lock);
75+
76+
return r;
77+
}
78+
5879
/*
5980
* The parent bus' lock is used to order access to the switch_fn.
6081
*/
@@ -80,6 +101,28 @@ static int mdio_mux_write(struct mii_bus *bus, int phy_id,
80101
return r;
81102
}
82103

104+
static int mdio_mux_write_c45(struct mii_bus *bus, int phy_id, int dev_addr,
105+
int regnum, u16 val)
106+
{
107+
struct mdio_mux_child_bus *cb = bus->priv;
108+
struct mdio_mux_parent_bus *pb = cb->parent;
109+
110+
int r;
111+
112+
mutex_lock_nested(&pb->mii_bus->mdio_lock, MDIO_MUTEX_MUX);
113+
r = pb->switch_fn(pb->current_child, cb->bus_number, pb->switch_data);
114+
if (r)
115+
goto out;
116+
117+
pb->current_child = cb->bus_number;
118+
119+
r = pb->mii_bus->write_c45(pb->mii_bus, phy_id, dev_addr, regnum, val);
120+
out:
121+
mutex_unlock(&pb->mii_bus->mdio_lock);
122+
123+
return r;
124+
}
125+
83126
static int parent_count;
84127

85128
static void mdio_mux_uninit_children(struct mdio_mux_parent_bus *pb)
@@ -173,6 +216,10 @@ int mdio_mux_init(struct device *dev,
173216
cb->mii_bus->parent = dev;
174217
cb->mii_bus->read = mdio_mux_read;
175218
cb->mii_bus->write = mdio_mux_write;
219+
if (parent_bus->read_c45)
220+
cb->mii_bus->read_c45 = mdio_mux_read_c45;
221+
if (parent_bus->write_c45)
222+
cb->mii_bus->write_c45 = mdio_mux_write_c45;
176223
r = of_mdiobus_register(cb->mii_bus, child_bus_node);
177224
if (r) {
178225
mdiobus_free(cb->mii_bus);

0 commit comments

Comments
 (0)