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

Merge branch 'net-stmmac-more-cleanups'

Russell King says:

====================
net: stmmac: more cleanups

The subject for the cover message is wearing thin as I've used it a
number of times, but the scope for cleaning up the driver continues,
and continue it will do, because this is just a small fraction of the
queue.

1. make a better job of one of my previous commits, moving the holding
of the lock into stmmac_mdio.c

2. move the mac_finish() method to be in-order with the layout of
struct phylink_mac_ops - this order was chosen because it reflects
the order that the methods are called, thus making the flow more
obvious when reading code.

3. continuing on the "removal of stuff that doesn't need to happen",
patch 3 removes the phylink_speed_(up|down) out of the path that
is used for MTU changes - we really don't need to fiddle with the
PHY advertisement when changing the MTU!

4. clean up tc_init()'s initialisation of flow_entries_max - this is
the sole place that this is written, and we might as well make the
code more easy to follow.

5. stmmac_phy_setup() really confuses me when I read the code, it's
not really about PHY setup, but about phylink setup. So, name its
name reflect its functionality.
====================

Link: https://patch.msgid.link/aO_HIwT_YvxkDS8D@shell.armlinux.org.uk
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+46 -29
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
··· 162 162 priv = netdev_priv(dev_get_drvdata(eqos->dev)); 163 163 164 164 /* Calibration should be done with the MDIO bus idle */ 165 - mutex_lock(&priv->mii->mdio_lock); 165 + stmmac_mdio_lock(priv); 166 166 167 167 /* calibrate */ 168 168 value = readl(eqos->regs + SDMEMCOMPPADCTRL); ··· 198 198 value &= ~SDMEMCOMPPADCTRL_PAD_E_INPUT_OR_E_PWRD; 199 199 writel(value, eqos->regs + SDMEMCOMPPADCTRL); 200 200 201 - mutex_unlock(&priv->mii->mdio_lock); 201 + stmmac_mdio_unlock(priv); 202 202 } else { 203 203 value = readl(eqos->regs + AUTO_CAL_CONFIG); 204 204 value &= ~AUTO_CAL_CONFIG_ENABLE;
+2
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 388 388 int stmmac_mdio_unregister(struct net_device *ndev); 389 389 int stmmac_mdio_register(struct net_device *ndev); 390 390 int stmmac_mdio_reset(struct mii_bus *mii); 391 + void stmmac_mdio_lock(struct stmmac_priv *priv); 392 + void stmmac_mdio_unlock(struct stmmac_priv *priv); 391 393 int stmmac_pcs_setup(struct net_device *ndev); 392 394 void stmmac_pcs_clean(struct net_device *ndev); 393 395 void stmmac_set_ethtool_ops(struct net_device *netdev);
+25 -24
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 859 859 /* Nothing to do, xpcs_config() handles everything */ 860 860 } 861 861 862 + static int stmmac_mac_finish(struct phylink_config *config, unsigned int mode, 863 + phy_interface_t interface) 864 + { 865 + struct net_device *ndev = to_net_dev(config->dev); 866 + struct stmmac_priv *priv = netdev_priv(ndev); 867 + 868 + if (priv->plat->mac_finish) 869 + priv->plat->mac_finish(ndev, priv->plat->bsp_priv, mode, interface); 870 + 871 + return 0; 872 + } 873 + 862 874 static void stmmac_mac_link_down(struct phylink_config *config, 863 875 unsigned int mode, phy_interface_t interface) 864 876 { ··· 1065 1053 return 0; 1066 1054 } 1067 1055 1068 - static int stmmac_mac_finish(struct phylink_config *config, unsigned int mode, 1069 - phy_interface_t interface) 1070 - { 1071 - struct net_device *ndev = to_net_dev(config->dev); 1072 - struct stmmac_priv *priv = netdev_priv(ndev); 1073 - 1074 - if (priv->plat->mac_finish) 1075 - priv->plat->mac_finish(ndev, priv->plat->bsp_priv, mode, interface); 1076 - 1077 - return 0; 1078 - } 1079 - 1080 1056 static const struct phylink_mac_ops stmmac_phylink_mac_ops = { 1081 1057 .mac_get_caps = stmmac_mac_get_caps, 1082 1058 .mac_select_pcs = stmmac_mac_select_pcs, 1083 1059 .mac_config = stmmac_mac_config, 1060 + .mac_finish = stmmac_mac_finish, 1084 1061 .mac_link_down = stmmac_mac_link_down, 1085 1062 .mac_link_up = stmmac_mac_link_up, 1086 1063 .mac_disable_tx_lpi = stmmac_mac_disable_tx_lpi, 1087 1064 .mac_enable_tx_lpi = stmmac_mac_enable_tx_lpi, 1088 - .mac_finish = stmmac_mac_finish, 1089 1065 }; 1090 1066 1091 1067 /** ··· 1185 1185 return 0; 1186 1186 } 1187 1187 1188 - static int stmmac_phy_setup(struct stmmac_priv *priv) 1188 + static int stmmac_phylink_setup(struct stmmac_priv *priv) 1189 1189 { 1190 1190 struct stmmac_mdio_bus_data *mdio_bus_data; 1191 1191 struct phylink_config *config; ··· 3963 3963 stmmac_init_coalesce(priv); 3964 3964 3965 3965 phylink_start(priv->phylink); 3966 - /* We may have called phylink_speed_down before */ 3967 - phylink_speed_up(priv->phylink); 3968 3966 3969 3967 ret = stmmac_request_irq(dev); 3970 3968 if (ret) ··· 4013 4015 4014 4016 kfree(dma_conf); 4015 4017 4018 + /* We may have called phylink_speed_down before */ 4019 + phylink_speed_up(priv->phylink); 4020 + 4016 4021 return ret; 4017 4022 4018 4023 err_disconnect_phy: ··· 4032 4031 { 4033 4032 struct stmmac_priv *priv = netdev_priv(dev); 4034 4033 u32 chan; 4035 - 4036 - /* If the PHY or MAC has WoL enabled, then the PHY will not be 4037 - * suspended when phylink_stop() is called below. Set the PHY 4038 - * to its slowest speed to save power. 4039 - */ 4040 - if (device_may_wakeup(priv->device)) 4041 - phylink_speed_down(priv->phylink, false); 4042 4034 4043 4035 /* Stop and disconnect the PHY */ 4044 4036 phylink_stop(priv->phylink); ··· 4071 4077 static int stmmac_release(struct net_device *dev) 4072 4078 { 4073 4079 struct stmmac_priv *priv = netdev_priv(dev); 4080 + 4081 + /* If the PHY or MAC has WoL enabled, then the PHY will not be 4082 + * suspended when phylink_stop() is called below. Set the PHY 4083 + * to its slowest speed to save power. 4084 + */ 4085 + if (device_may_wakeup(priv->device)) 4086 + phylink_speed_down(priv->phylink, false); 4074 4087 4075 4088 __stmmac_release(dev); 4076 4089 ··· 7642 7641 if (ret) 7643 7642 goto error_pcs_setup; 7644 7643 7645 - ret = stmmac_phy_setup(priv); 7644 + ret = stmmac_phylink_setup(priv); 7646 7645 if (ret) { 7647 7646 netdev_err(ndev, "failed to setup phy (%d)\n", ret); 7648 7647 goto error_phy_setup;
+14
drivers/net/ethernet/stmicro/stmmac/stmmac_mdio.c
··· 734 734 735 735 return 0; 736 736 } 737 + 738 + void stmmac_mdio_lock(struct stmmac_priv *priv) 739 + { 740 + if (priv->mii) 741 + mutex_lock(&priv->mii->mdio_lock); 742 + } 743 + EXPORT_SYMBOL_GPL(stmmac_mdio_lock); 744 + 745 + void stmmac_mdio_unlock(struct stmmac_priv *priv) 746 + { 747 + if (priv->mii) 748 + mutex_unlock(&priv->mii->mdio_lock); 749 + } 750 + EXPORT_SYMBOL_GPL(stmmac_mdio_unlock);
+3 -3
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c
··· 262 262 unsigned int count; 263 263 int ret, i; 264 264 265 - if (dma_cap->l3l4fnum) { 266 - priv->flow_entries_max = dma_cap->l3l4fnum; 265 + priv->flow_entries_max = dma_cap->l3l4fnum; 266 + if (priv->flow_entries_max) { 267 267 priv->flow_entries = devm_kcalloc(priv->device, 268 - dma_cap->l3l4fnum, 268 + priv->flow_entries_max, 269 269 sizeof(*priv->flow_entries), 270 270 GFP_KERNEL); 271 271 if (!priv->flow_entries)