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

net: thunderx: Cleanup PHY probing code.

Remove the call to force the octeon-mdio driver to be loaded. Allow
the standard driver loading mechanisms to load the PHY drivers, and
use -EPROBE_DEFER to cause the BGX driver to be probed only after the
PHY drivers are available.

Reorder the setting of MAC addresses and PHY probing to allow BGX
LMACs with no attached PHY to still be assigned a MAC address.

Signed-off-by: David Daney <david.daney@cavium.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

David Daney and committed by
David S. Miller
5fc7cf17 0df83e7a

+18 -11
+18 -11
drivers/net/ethernet/cavium/thunder/thunder_bgx.c
··· 978 978 const char *mac; 979 979 980 980 device_for_each_child_node(&bgx->pdev->dev, fwn) { 981 + struct phy_device *pd; 981 982 struct device_node *phy_np; 982 983 struct device_node *node = to_of_node(fwn); 983 984 984 - /* If it is not an OF node we cannot handle it yet, so 985 - * exit the loop. 985 + /* Should always be an OF node. But if it is not, we 986 + * cannot handle it, so exit the loop. 986 987 */ 987 988 if (!node) 988 989 break; 989 - 990 - phy_np = of_parse_phandle(node, "phy-handle", 0); 991 - if (!phy_np) 992 - continue; 993 - 994 - bgx->lmac[lmac].phydev = of_phy_find_device(phy_np); 995 990 996 991 mac = of_get_mac_address(node); 997 992 if (mac) ··· 994 999 995 1000 SET_NETDEV_DEV(&bgx->lmac[lmac].netdev, &bgx->pdev->dev); 996 1001 bgx->lmac[lmac].lmacid = lmac; 1002 + 1003 + phy_np = of_parse_phandle(node, "phy-handle", 0); 1004 + /* If there is no phy or defective firmware presents 1005 + * this cortina phy, for which there is no driver 1006 + * support, ignore it. 1007 + */ 1008 + if (phy_np && 1009 + !of_device_is_compatible(phy_np, "cortina,cs4223-slice")) { 1010 + /* Wait until the phy drivers are available */ 1011 + pd = of_phy_find_device(phy_np); 1012 + if (!pd) 1013 + return -EPROBE_DEFER; 1014 + bgx->lmac[lmac].phydev = pd; 1015 + } 1016 + 997 1017 lmac++; 998 1018 if (lmac == MAX_LMAC_PER_BGX) { 999 1019 of_node_put(node); ··· 1041 1031 struct device *dev = &pdev->dev; 1042 1032 struct bgx *bgx = NULL; 1043 1033 u8 lmac; 1044 - 1045 - /* Load octeon mdio driver */ 1046 - octeon_mdiobus_force_mod_depencency(); 1047 1034 1048 1035 bgx = devm_kzalloc(dev, sizeof(*bgx), GFP_KERNEL); 1049 1036 if (!bgx)