Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

net: phy: phylink: fix DSA mac_select_pcs() introduction

Vladimir Oltean reports that probing on DSA drivers that aren't yet
populating supported_interfaces now fails. Fix this by allowing
phylink to detect whether DSA actually provides an underlying
mac_select_pcs() implementation.

Reported-by: Vladimir Oltean <olteanv@gmail.com>
Fixes: bde018222c6b ("net: dsa: add support for phylink mac_select_pcs()")
Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
Tested-by: Vladimir Oltean <olteanv@gmail.com>
Link: https://lore.kernel.org/r/E1nMCD6-00A0wC-FG@rmk-PC.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Russell King (Oracle) and committed by
Jakub Kicinski
10544570 12c740c8

+12 -4
+11 -3
drivers/net/phy/phylink.c
··· 74 74 struct work_struct resolve; 75 75 76 76 bool mac_link_dropped; 77 + bool using_mac_select_pcs; 77 78 78 79 struct sfp_bus *sfp_bus; 79 80 bool sfp_may_have_phy; ··· 417 416 int ret; 418 417 419 418 /* Get the PCS for this interface mode */ 420 - if (pl->mac_ops->mac_select_pcs) { 419 + if (pl->using_mac_select_pcs) { 421 420 pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface); 422 421 if (IS_ERR(pcs)) 423 422 return PTR_ERR(pcs); ··· 792 791 793 792 phylink_dbg(pl, "major config %s\n", phy_modes(state->interface)); 794 793 795 - if (pl->mac_ops->mac_select_pcs) { 794 + if (pl->using_mac_select_pcs) { 796 795 pcs = pl->mac_ops->mac_select_pcs(pl->config, state->interface); 797 796 if (IS_ERR(pcs)) { 798 797 phylink_err(pl, ··· 1206 1205 phy_interface_t iface, 1207 1206 const struct phylink_mac_ops *mac_ops) 1208 1207 { 1208 + bool using_mac_select_pcs = false; 1209 1209 struct phylink *pl; 1210 1210 int ret; 1211 1211 1212 - /* Validate the supplied configuration */ 1213 1212 if (mac_ops->mac_select_pcs && 1213 + mac_ops->mac_select_pcs(config, PHY_INTERFACE_MODE_NA) != 1214 + ERR_PTR(-EOPNOTSUPP)) 1215 + using_mac_select_pcs = true; 1216 + 1217 + /* Validate the supplied configuration */ 1218 + if (using_mac_select_pcs && 1214 1219 phy_interface_empty(config->supported_interfaces)) { 1215 1220 dev_err(config->dev, 1216 1221 "phylink: error: empty supported_interfaces but mac_select_pcs() method present\n"); ··· 1240 1233 return ERR_PTR(-EINVAL); 1241 1234 } 1242 1235 1236 + pl->using_mac_select_pcs = using_mac_select_pcs; 1243 1237 pl->phy_state.interface = iface; 1244 1238 pl->link_interface = iface; 1245 1239 if (iface == PHY_INTERFACE_MODE_MOCA)
+1 -1
net/dsa/port.c
··· 1058 1058 phy_interface_t interface) 1059 1059 { 1060 1060 struct dsa_port *dp = container_of(config, struct dsa_port, pl_config); 1061 + struct phylink_pcs *pcs = ERR_PTR(-EOPNOTSUPP); 1061 1062 struct dsa_switch *ds = dp->ds; 1062 - struct phylink_pcs *pcs = NULL; 1063 1063 1064 1064 if (ds->ops->phylink_mac_select_pcs) 1065 1065 pcs = ds->ops->phylink_mac_select_pcs(ds, dp->index, interface);