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

Merge branch 'net-stmmac-further-cleanups'

Russell King says:

====================
net: stmmac: further cleanups

This small series does further cleanups to the stmmac driver:

1. Name priv->pause to indicate that it's a timeout and clarify the
units of the "pause" module parameter
2. Remove useless priv->flow_ctrl member and deprecate the useless
"flow_ctrl" module parameter
3. Fix long-standing signed-ness issue with "speed" passed around the
driver from the mac_link_up method.
====================

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

+50 -53
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
··· 141 141 #define AUTO_CAL_STATUS 0x880c 142 142 #define AUTO_CAL_STATUS_ACTIVE BIT(31) 143 143 144 - static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mode) 144 + static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode) 145 145 { 146 146 struct tegra_eqos *eqos = priv; 147 147 bool needs_calibration = false; ··· 160 160 break; 161 161 162 162 default: 163 - dev_err(eqos->dev, "invalid speed %u\n", speed); 163 + dev_err(eqos->dev, "invalid speed %d\n", speed); 164 164 break; 165 165 } 166 166
+4 -4
drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
··· 51 51 52 52 int (*fix_soc_reset)(void *priv, void __iomem *ioaddr); 53 53 int (*set_intf_mode)(struct plat_stmmacenet_data *plat_dat); 54 - void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode); 54 + void (*fix_mac_speed)(void *priv, int speed, unsigned int mode); 55 55 }; 56 56 57 57 struct imx_priv_data { ··· 192 192 /* nothing to do now */ 193 193 } 194 194 195 - static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode) 195 + static void imx_dwmac_fix_speed(void *priv, int speed, unsigned int mode) 196 196 { 197 197 struct plat_stmmacenet_data *plat_dat; 198 198 struct imx_priv_data *dwmac = priv; ··· 208 208 209 209 rate = rgmii_clock(speed); 210 210 if (rate < 0) { 211 - dev_err(dwmac->dev, "invalid speed %u\n", speed); 211 + dev_err(dwmac->dev, "invalid speed %d\n", speed); 212 212 return; 213 213 } 214 214 ··· 217 217 dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate); 218 218 } 219 219 220 - static void imx93_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode) 220 + static void imx93_dwmac_fix_speed(void *priv, int speed, unsigned int mode) 221 221 { 222 222 struct imx_priv_data *dwmac = priv; 223 223 unsigned int iface;
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
··· 22 22 }; 23 23 24 24 struct intel_dwmac_data { 25 - void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode); 25 + void (*fix_mac_speed)(void *priv, int speed, unsigned int mode); 26 26 unsigned long ptp_ref_clk_rate; 27 27 unsigned long tx_clk_rate; 28 28 bool tx_clk_en; 29 29 }; 30 30 31 - static void kmb_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 31 + static void kmb_eth_fix_mac_speed(void *priv, int speed, unsigned int mode) 32 32 { 33 33 struct intel_dwmac *dwmac = priv; 34 34 long rate;
+4 -4
drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
··· 112 112 phy_interface_t phy_mode; 113 113 }; 114 114 115 - static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, unsigned int speed) 115 + static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, int speed) 116 116 { 117 117 struct device *dev = &gmac->pdev->dev; 118 118 int div; ··· 138 138 return div; 139 139 } 140 140 141 - static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, unsigned int speed) 141 + static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, int speed) 142 142 { 143 143 struct device *dev = &gmac->pdev->dev; 144 144 int div; ··· 164 164 return div; 165 165 } 166 166 167 - static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, unsigned int speed) 167 + static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, int speed) 168 168 { 169 169 uint32_t clk_bits, val; 170 170 int div; ··· 260 260 return PTR_ERR_OR_ZERO(gmac->qsgmii_csr); 261 261 } 262 262 263 - static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 263 + static void ipq806x_gmac_fix_mac_speed(void *priv, int speed, unsigned int mode) 264 264 { 265 265 struct ipq806x_gmac *gmac = priv; 266 266
+1 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
··· 149 149 .setup = loongson_gmac_data, 150 150 }; 151 151 152 - static void loongson_gnet_fix_speed(void *priv, unsigned int speed, 153 - unsigned int mode) 152 + static void loongson_gnet_fix_speed(void *priv, int speed, unsigned int mode) 154 153 { 155 154 struct loongson_data *ld = (struct loongson_data *)priv; 156 155 struct net_device *ndev = dev_get_drvdata(ld->dev);
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
··· 22 22 void __iomem *reg; 23 23 }; 24 24 25 - static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 25 + static void meson6_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode) 26 26 { 27 27 struct meson_dwmac *dwmac = priv; 28 28 unsigned int val;
+3 -3
drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
··· 111 111 unsigned int link_clk_rate; 112 112 struct clk *link_clk; 113 113 struct phy *serdes_phy; 114 - unsigned int speed; 114 + int speed; 115 115 int serdes_speed; 116 116 phy_interface_t phy_mode; 117 117 ··· 175 175 #define RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ (5 * 1000 * 1000UL) 176 176 177 177 static void 178 - ethqos_update_link_clk(struct qcom_ethqos *ethqos, unsigned int speed) 178 + ethqos_update_link_clk(struct qcom_ethqos *ethqos, int speed) 179 179 { 180 180 if (!phy_interface_mode_is_rgmii(ethqos->phy_mode)) 181 181 return; ··· 699 699 return ethqos->configure_func(ethqos); 700 700 } 701 701 702 - static void ethqos_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 702 + static void ethqos_fix_mac_speed(void *priv, int speed, unsigned int mode) 703 703 { 704 704 struct qcom_ethqos *ethqos = priv; 705 705
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
··· 1920 1920 gmac_clk_enable(gmac, false); 1921 1921 } 1922 1922 1923 - static void rk_fix_speed(void *priv, unsigned int speed, unsigned int mode) 1923 + static void rk_fix_speed(void *priv, int speed, unsigned int mode) 1924 1924 { 1925 1925 struct rk_priv_data *bsp_priv = priv; 1926 1926 struct device *dev = &bsp_priv->pdev->dev;
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
··· 100 100 clk_disable_unprepare(gmac->rx_clk); 101 101 } 102 102 103 - static void s32_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 103 + static void s32_fix_mac_speed(void *priv, int speed, unsigned int mode) 104 104 { 105 105 struct s32_priv_data *gmac = priv; 106 106 long tx_clk_rate;
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
··· 61 61 struct mdio_device *pcs_mdiodev; 62 62 }; 63 63 64 - static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 64 + static void socfpga_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode) 65 65 { 66 66 struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)priv; 67 67 void __iomem *splitter_base = dwmac->splitter_base;
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
··· 31 31 const struct starfive_dwmac_data *data; 32 32 }; 33 33 34 - static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 34 + static void starfive_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode) 35 35 { 36 36 struct starfive_dwmac *dwmac = priv; 37 37 long rate; ··· 39 39 40 40 rate = rgmii_clock(speed); 41 41 if (rate < 0) { 42 - dev_err(dwmac->dev, "invalid speed %u\n", speed); 42 + dev_err(dwmac->dev, "invalid speed %d\n", speed); 43 43 return; 44 44 } 45 45
+4 -4
drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
··· 99 99 int clk_sel_reg; /* GMAC ext clk selection register */ 100 100 struct regmap *regmap; 101 101 bool gmac_en; 102 - u32 speed; 103 - void (*fix_retime_src)(void *priv, unsigned int speed, unsigned int mode); 102 + int speed; 103 + void (*fix_retime_src)(void *priv, int speed, unsigned int mode); 104 104 }; 105 105 106 106 struct sti_dwmac_of_data { 107 - void (*fix_retime_src)(void *priv, unsigned int speed, unsigned int mode); 107 + void (*fix_retime_src)(void *priv, int speed, unsigned int mode); 108 108 }; 109 109 110 110 static u32 phy_intf_sels[] = { ··· 132 132 | STIH4XX_ETH_SEL_INTERNAL_NOTEXT_PHYCLK, 133 133 }; 134 134 135 - static void stih4xx_fix_retime_src(void *priv, u32 spd, unsigned int mode) 135 + static void stih4xx_fix_retime_src(void *priv, int spd, unsigned int mode) 136 136 { 137 137 struct sti_dwmac *dwmac = priv; 138 138 u32 src = dwmac->tx_retime_src;
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
··· 72 72 regulator_disable(gmac->regulator); 73 73 } 74 74 75 - static void sun7i_fix_speed(void *priv, unsigned int speed, unsigned int mode) 75 + static void sun7i_fix_speed(void *priv, int speed, unsigned int mode) 76 76 { 77 77 struct sunxi_priv_data *gmac = priv; 78 78
+2 -2
drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
··· 104 104 return 0; 105 105 } 106 106 107 - static void thead_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode) 107 + static void thead_dwmac_fix_speed(void *priv, int speed, unsigned int mode) 108 108 { 109 109 struct plat_stmmacenet_data *plat; 110 110 struct thead_dwmac *dwmac = priv; ··· 142 142 div = rate * 10 / GMAC_MII_RATE; 143 143 break; 144 144 default: 145 - dev_err(dwmac->dev, "invalid speed %u\n", speed); 145 + dev_err(dwmac->dev, "invalid speed %d\n", speed); 146 146 return; 147 147 } 148 148
+1 -1
drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
··· 54 54 spinlock_t lock; /* lock to protect register update */ 55 55 }; 56 56 57 - static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode) 57 + static void visconti_eth_fix_mac_speed(void *priv, int speed, unsigned int mode) 58 58 { 59 59 struct visconti_eth *dwmac = priv; 60 60 struct net_device *netdev = dev_get_drvdata(dwmac->dev);
+1 -2
drivers/net/ethernet/stmicro/stmmac/stmmac.h
··· 282 282 struct stmmac_channel channel[STMMAC_CH_MAX]; 283 283 284 284 int speed; 285 - unsigned int flow_ctrl; 286 - unsigned int pause; 285 + unsigned int pause_time; 287 286 struct mii_bus *mii; 288 287 289 288 struct phylink_config phylink_config;
+18 -19
drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
··· 88 88 #define STMMAC_XDP_TX BIT(1) 89 89 #define STMMAC_XDP_REDIRECT BIT(2) 90 90 91 - static int flow_ctrl = FLOW_AUTO; 91 + static int flow_ctrl = 0xdead; 92 92 module_param(flow_ctrl, int, 0644); 93 - MODULE_PARM_DESC(flow_ctrl, "Flow control ability [on/off]"); 93 + MODULE_PARM_DESC(flow_ctrl, "Flow control ability [on/off] (obsolete)"); 94 94 95 95 static int pause = PAUSE_TIME; 96 96 module_param(pause, int, 0644); 97 - MODULE_PARM_DESC(pause, "Flow Control Pause Time"); 97 + MODULE_PARM_DESC(pause, "Flow Control Pause Time (units of 512 bit times)"); 98 98 99 99 #define TC_DEFAULT 64 100 100 static int tc = TC_DEFAULT; ··· 188 188 watchdog = TX_TIMEO; 189 189 if (unlikely((buf_sz < DEFAULT_BUFSIZE) || (buf_sz > BUF_SIZE_16KiB))) 190 190 buf_sz = DEFAULT_BUFSIZE; 191 - if (unlikely(flow_ctrl > 1)) 192 - flow_ctrl = FLOW_AUTO; 193 - else if (likely(flow_ctrl < 0)) 194 - flow_ctrl = FLOW_OFF; 195 191 if (unlikely((pause < 0) || (pause > 0xffff))) 196 192 pause = PAUSE_TIME; 193 + 194 + if (flow_ctrl != 0xdead) 195 + pr_warn("stmmac: module parameter 'flow_ctrl' is obsolete - please remove from your module configuration\n"); 197 196 } 198 197 199 198 static void __stmmac_disable_all_queues(struct stmmac_priv *priv) ··· 857 858 * stmmac_mac_flow_ctrl - Configure flow control in all queues 858 859 * @priv: driver private structure 859 860 * @duplex: duplex passed to the next function 861 + * @flow_ctrl: desired flow control modes 860 862 * Description: It is used for configuring the flow control in all queues 861 863 */ 862 - static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex) 864 + static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex, 865 + unsigned int flow_ctrl) 863 866 { 864 867 u32 tx_cnt = priv->plat->tx_queues_to_use; 865 868 866 - stmmac_flow_ctrl(priv, priv->hw, duplex, priv->flow_ctrl, 867 - priv->pause, tx_cnt); 869 + stmmac_flow_ctrl(priv, priv->hw, duplex, flow_ctrl, priv->pause_time, 870 + tx_cnt); 868 871 } 869 872 870 873 static unsigned long stmmac_mac_get_caps(struct phylink_config *config, ··· 926 925 bool tx_pause, bool rx_pause) 927 926 { 928 927 struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev)); 928 + unsigned int flow_ctrl; 929 929 u32 old_ctrl, ctrl; 930 930 931 931 if ((priv->plat->flags & STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP) && ··· 1007 1005 1008 1006 /* Flow Control operation */ 1009 1007 if (rx_pause && tx_pause) 1010 - priv->flow_ctrl = FLOW_AUTO; 1008 + flow_ctrl = FLOW_AUTO; 1011 1009 else if (rx_pause && !tx_pause) 1012 - priv->flow_ctrl = FLOW_RX; 1010 + flow_ctrl = FLOW_RX; 1013 1011 else if (!rx_pause && tx_pause) 1014 - priv->flow_ctrl = FLOW_TX; 1012 + flow_ctrl = FLOW_TX; 1015 1013 else 1016 - priv->flow_ctrl = FLOW_OFF; 1014 + flow_ctrl = FLOW_OFF; 1017 1015 1018 - stmmac_mac_flow_ctrl(priv, duplex); 1016 + stmmac_mac_flow_ctrl(priv, duplex, flow_ctrl); 1019 1017 1020 1018 if (ctrl != old_ctrl) 1021 1019 writel(ctrl, priv->ioaddr + MAC_CTRL_REG); ··· 7406 7404 return -ENOMEM; 7407 7405 7408 7406 stmmac_set_ethtool_ops(ndev); 7409 - priv->pause = pause; 7407 + priv->pause_time = pause; 7410 7408 priv->plat = plat_dat; 7411 7409 priv->ioaddr = res->addr; 7412 7410 priv->dev->base_addr = (unsigned long)res->addr; ··· 7601 7599 dev_warn(priv->device, 7602 7600 "%s: warning: maxmtu having invalid value (%d)\n", 7603 7601 __func__, priv->plat->maxmtu); 7604 - 7605 - if (flow_ctrl) 7606 - priv->flow_ctrl = FLOW_AUTO; /* RX/TX pause on */ 7607 7602 7608 7603 ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE; 7609 7604
+1 -1
include/linux/stmmac.h
··· 231 231 u8 tx_sched_algorithm; 232 232 struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES]; 233 233 struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES]; 234 - void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode); 234 + void (*fix_mac_speed)(void *priv, int speed, unsigned int mode); 235 235 int (*fix_soc_reset)(void *priv, void __iomem *ioaddr); 236 236 int (*serdes_powerup)(struct net_device *ndev, void *priv); 237 237 void (*serdes_powerdown)(struct net_device *ndev, void *priv);