netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next 0/3] net: stmmac: further cleanups
@ 2025-02-18 10:24 Russell King (Oracle)
  2025-02-18 10:24 ` [PATCH net-next 1/3] net: stmmac: clarify priv->pause and pause module parameter Russell King (Oracle)
                   ` (3 more replies)
  0 siblings, 4 replies; 11+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 10:24 UTC (permalink / raw)
  To: netdev
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jan Petrous, Jernej Skrabec,
	Jerome Brunet, Kevin Hilman, linux-amlogic, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-stm32, linux-sunxi,
	Martin Blumenstingl, Maxime Coquelin, Minda Chen, Neil Armstrong,
	Nobuhiro Iwamatsu, NXP S32 Linux Team, Paolo Abeni,
	Pengutronix Kernel Team, Samuel Holland, Sascha Hauer, Shawn Guo,
	Vinod Koul

Hi,

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.

 .../ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c    |  4 +--
 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c    |  8 ++---
 .../net/ethernet/stmicro/stmmac/dwmac-intel-plat.c |  4 +--
 .../net/ethernet/stmicro/stmmac/dwmac-ipq806x.c    |  8 ++---
 .../net/ethernet/stmicro/stmmac/dwmac-loongson.c   |  3 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c  |  2 +-
 .../ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c    |  6 ++--
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c     |  2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c    |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-socfpga.c    |  2 +-
 .../net/ethernet/stmicro/stmmac/dwmac-starfive.c   |  4 +--
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c    |  8 ++---
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c  |  2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c  |  4 +--
 .../net/ethernet/stmicro/stmmac/dwmac-visconti.c   |  2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |  3 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c  | 37 +++++++++++-----------
 include/linux/stmmac.h                             |  2 +-
 18 files changed, 50 insertions(+), 53 deletions(-)

-- 
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH net-next 1/3] net: stmmac: clarify priv->pause and pause module parameter
  2025-02-18 10:24 [PATCH net-next 0/3] net: stmmac: further cleanups Russell King (Oracle)
@ 2025-02-18 10:24 ` Russell King (Oracle)
  2025-02-18 11:17   ` Mateusz Polchlopek
  2025-02-18 10:24 ` [PATCH net-next 2/3] net: stmmac: remove useless priv->flow_ctrl Russell King (Oracle)
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 11+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 10:24 UTC (permalink / raw)
  To: netdev
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jan Petrous, Jernej Skrabec,
	Jerome Brunet, Kevin Hilman, linux-amlogic, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-stm32, linux-sunxi,
	Martin Blumenstingl, Maxime Coquelin, Minda Chen, Neil Armstrong,
	Nobuhiro Iwamatsu, NXP S32 Linux Team, Paolo Abeni,
	Pengutronix Kernel Team, Samuel Holland, Sascha Hauer, Shawn Guo,
	Vinod Koul

priv->pause corresponds with "pause_time" in the 802.3 specification,
and is also called "pause_time" in the various MAC backends. For
consistency, use the same name in the core stmmac code.

Clarify the units of the "pause" module parameter which sets up this
struct member to indicate that it's in units of the pause_quanta
defined by 802.3, which is 512 bit times.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h      | 2 +-
 drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
 2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index f05cae103d83..c602ace572b2 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -283,7 +283,7 @@ struct stmmac_priv {
 
 	int speed;
 	unsigned int flow_ctrl;
-	unsigned int pause;
+	unsigned int pause_time;
 	struct mii_bus *mii;
 
 	struct phylink_config phylink_config;
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index fd8ca1524e43..c3a13bd8c9b3 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -94,7 +94,7 @@ MODULE_PARM_DESC(flow_ctrl, "Flow control ability [on/off]");
 
 static int pause = PAUSE_TIME;
 module_param(pause, int, 0644);
-MODULE_PARM_DESC(pause, "Flow Control Pause Time");
+MODULE_PARM_DESC(pause, "Flow Control Pause Time (units of 512 bit times)");
 
 #define TC_DEFAULT 64
 static int tc = TC_DEFAULT;
@@ -865,7 +865,7 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
 	u32 tx_cnt = priv->plat->tx_queues_to_use;
 
 	stmmac_flow_ctrl(priv, priv->hw, duplex, priv->flow_ctrl,
-			priv->pause, tx_cnt);
+			 priv->pause_time, tx_cnt);
 }
 
 static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
@@ -7404,7 +7404,7 @@ int stmmac_dvr_probe(struct device *device,
 		return -ENOMEM;
 
 	stmmac_set_ethtool_ops(ndev);
-	priv->pause = pause;
+	priv->pause_time = pause;
 	priv->plat = plat_dat;
 	priv->ioaddr = res->addr;
 	priv->dev->base_addr = (unsigned long)res->addr;
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 2/3] net: stmmac: remove useless priv->flow_ctrl
  2025-02-18 10:24 [PATCH net-next 0/3] net: stmmac: further cleanups Russell King (Oracle)
  2025-02-18 10:24 ` [PATCH net-next 1/3] net: stmmac: clarify priv->pause and pause module parameter Russell King (Oracle)
@ 2025-02-18 10:24 ` Russell King (Oracle)
  2025-02-18 16:02   ` Andrew Lunn
  2025-02-19  1:11   ` nobuhiro1.iwamatsu
  2025-02-18 10:24 ` [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int Russell King (Oracle)
  2025-02-20  3:10 ` [PATCH net-next 0/3] net: stmmac: further cleanups patchwork-bot+netdevbpf
  3 siblings, 2 replies; 11+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 10:24 UTC (permalink / raw)
  To: netdev
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jan Petrous, Jernej Skrabec,
	Jerome Brunet, Kevin Hilman, linux-amlogic, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-stm32, linux-sunxi,
	Martin Blumenstingl, Maxime Coquelin, Minda Chen, Neil Armstrong,
	Nobuhiro Iwamatsu, NXP S32 Linux Team, Paolo Abeni,
	Pengutronix Kernel Team, Samuel Holland, Sascha Hauer, Shawn Guo,
	Vinod Koul

priv->flow_ctrl is only accessed by stmmac_main.c, and the only place
that it is read is in stmmac_mac_flow_ctrl(). This function is only
called from stmmac_mac_link_up() which always sets priv->flow_ctrl
immediately before calling this function.

Therefore, initialising this at probe time is ineffectual because it
will always be overwritten before it's read. As such, the "flow_ctrl"
module parameter has been useless for some time. Rather than remove
the module parameter, which would risk module load failure, change the
description to indicate that it is obsolete, and warn if it is set by
userspace.

Moreover, storing the value in the stmmac_priv has no benefit as it's
set and then immediately read stmmac_mac_flow_ctrl(). Instead, pass it
as a parameter to this function..

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h  |  1 -
 .../net/ethernet/stmicro/stmmac/stmmac_main.c | 33 +++++++++----------
 2 files changed, 16 insertions(+), 18 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index c602ace572b2..3395188c198a 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -282,7 +282,6 @@ struct stmmac_priv {
 	struct stmmac_channel channel[STMMAC_CH_MAX];
 
 	int speed;
-	unsigned int flow_ctrl;
 	unsigned int pause_time;
 	struct mii_bus *mii;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
index c3a13bd8c9b3..4d542f482ecb 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
@@ -88,9 +88,9 @@ MODULE_PARM_DESC(phyaddr, "Physical device address");
 #define STMMAC_XDP_TX		BIT(1)
 #define STMMAC_XDP_REDIRECT	BIT(2)
 
-static int flow_ctrl = FLOW_AUTO;
+static int flow_ctrl = 0xdead;
 module_param(flow_ctrl, int, 0644);
-MODULE_PARM_DESC(flow_ctrl, "Flow control ability [on/off]");
+MODULE_PARM_DESC(flow_ctrl, "Flow control ability [on/off] (obsolete)");
 
 static int pause = PAUSE_TIME;
 module_param(pause, int, 0644);
@@ -188,12 +188,11 @@ static void stmmac_verify_args(void)
 		watchdog = TX_TIMEO;
 	if (unlikely((buf_sz < DEFAULT_BUFSIZE) || (buf_sz > BUF_SIZE_16KiB)))
 		buf_sz = DEFAULT_BUFSIZE;
-	if (unlikely(flow_ctrl > 1))
-		flow_ctrl = FLOW_AUTO;
-	else if (likely(flow_ctrl < 0))
-		flow_ctrl = FLOW_OFF;
 	if (unlikely((pause < 0) || (pause > 0xffff)))
 		pause = PAUSE_TIME;
+
+	if (flow_ctrl != 0xdead)
+		pr_warn("stmmac: module parameter 'flow_ctrl' is obsolete - please remove from your module configuration\n");
 }
 
 static void __stmmac_disable_all_queues(struct stmmac_priv *priv)
@@ -858,14 +857,16 @@ static void stmmac_release_ptp(struct stmmac_priv *priv)
  *  stmmac_mac_flow_ctrl - Configure flow control in all queues
  *  @priv: driver private structure
  *  @duplex: duplex passed to the next function
+ *  @flow_ctrl: desired flow control modes
  *  Description: It is used for configuring the flow control in all queues
  */
-static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
+static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex,
+				 unsigned int flow_ctrl)
 {
 	u32 tx_cnt = priv->plat->tx_queues_to_use;
 
-	stmmac_flow_ctrl(priv, priv->hw, duplex, priv->flow_ctrl,
-			 priv->pause_time, tx_cnt);
+	stmmac_flow_ctrl(priv, priv->hw, duplex, flow_ctrl, priv->pause_time,
+			 tx_cnt);
 }
 
 static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
@@ -925,6 +926,7 @@ static void stmmac_mac_link_up(struct phylink_config *config,
 			       bool tx_pause, bool rx_pause)
 {
 	struct stmmac_priv *priv = netdev_priv(to_net_dev(config->dev));
+	unsigned int flow_ctrl;
 	u32 old_ctrl, ctrl;
 
 	if ((priv->plat->flags & STMMAC_FLAG_SERDES_UP_AFTER_PHY_LINKUP) &&
@@ -1005,15 +1007,15 @@ static void stmmac_mac_link_up(struct phylink_config *config,
 
 	/* Flow Control operation */
 	if (rx_pause && tx_pause)
-		priv->flow_ctrl = FLOW_AUTO;
+		flow_ctrl = FLOW_AUTO;
 	else if (rx_pause && !tx_pause)
-		priv->flow_ctrl = FLOW_RX;
+		flow_ctrl = FLOW_RX;
 	else if (!rx_pause && tx_pause)
-		priv->flow_ctrl = FLOW_TX;
+		flow_ctrl = FLOW_TX;
 	else
-		priv->flow_ctrl = FLOW_OFF;
+		flow_ctrl = FLOW_OFF;
 
-	stmmac_mac_flow_ctrl(priv, duplex);
+	stmmac_mac_flow_ctrl(priv, duplex, flow_ctrl);
 
 	if (ctrl != old_ctrl)
 		writel(ctrl, priv->ioaddr + MAC_CTRL_REG);
@@ -7600,9 +7602,6 @@ int stmmac_dvr_probe(struct device *device,
 			 "%s: warning: maxmtu having invalid value (%d)\n",
 			 __func__, priv->plat->maxmtu);
 
-	if (flow_ctrl)
-		priv->flow_ctrl = FLOW_AUTO;	/* RX/TX pause on */
-
 	ndev->priv_flags |= IFF_LIVE_ADDR_CHANGE;
 
 	/* Setup channels NAPI */
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int
  2025-02-18 10:24 [PATCH net-next 0/3] net: stmmac: further cleanups Russell King (Oracle)
  2025-02-18 10:24 ` [PATCH net-next 1/3] net: stmmac: clarify priv->pause and pause module parameter Russell King (Oracle)
  2025-02-18 10:24 ` [PATCH net-next 2/3] net: stmmac: remove useless priv->flow_ctrl Russell King (Oracle)
@ 2025-02-18 10:24 ` Russell King (Oracle)
  2025-02-18 12:29   ` Chen-Yu Tsai
                     ` (2 more replies)
  2025-02-20  3:10 ` [PATCH net-next 0/3] net: stmmac: further cleanups patchwork-bot+netdevbpf
  3 siblings, 3 replies; 11+ messages in thread
From: Russell King (Oracle) @ 2025-02-18 10:24 UTC (permalink / raw)
  To: netdev
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jan Petrous, Jernej Skrabec,
	Jerome Brunet, Kevin Hilman, linux-amlogic, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-stm32, linux-sunxi,
	Martin Blumenstingl, Maxime Coquelin, Minda Chen, Neil Armstrong,
	Nobuhiro Iwamatsu, NXP S32 Linux Team, Paolo Abeni,
	Pengutronix Kernel Team, Samuel Holland, Sascha Hauer, Shawn Guo,
	Vinod Koul

priv->plat->fix_mac_speed() is called from stmmac_mac_link_up(), which
is passed the speed as an "int". However, fix_mac_speed() implicitly
casts this to an unsigned int. Some platform glue code print this value
using %u, others with %d. Some implicitly cast it back to an int, and
others to u32.

Good practice is to use one type and only one type to represent a value
being passed around a driver.

Switch all of these over to consistently use "int" when dealing with a
speed passed from stmmac_mac_link_up(), even though the speed will
always be positive.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c | 4 ++--
 drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c         | 8 ++++----
 drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c  | 4 ++--
 drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c     | 8 ++++----
 drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c    | 3 +--
 drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c       | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c | 6 +++---
 drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c          | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c         | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c     | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c    | 4 ++--
 drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c         | 8 ++++----
 drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c       | 2 +-
 drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c       | 4 ++--
 drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c    | 2 +-
 include/linux/stmmac.h                                  | 2 +-
 16 files changed, 31 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
index 1fadb8ba1d2f..392574bdd4a4 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-dwc-qos-eth.c
@@ -141,7 +141,7 @@ static int dwc_qos_probe(struct platform_device *pdev,
 #define AUTO_CAL_STATUS 0x880c
 #define  AUTO_CAL_STATUS_ACTIVE BIT(31)
 
-static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mode)
+static void tegra_eqos_fix_speed(void *priv, int speed, unsigned int mode)
 {
 	struct tegra_eqos *eqos = priv;
 	bool needs_calibration = false;
@@ -160,7 +160,7 @@ static void tegra_eqos_fix_speed(void *priv, unsigned int speed, unsigned int mo
 		break;
 
 	default:
-		dev_err(eqos->dev, "invalid speed %u\n", speed);
+		dev_err(eqos->dev, "invalid speed %d\n", speed);
 		break;
 	}
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
index 20d3a202bb8d..610204b51e3f 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-imx.c
@@ -51,7 +51,7 @@ struct imx_dwmac_ops {
 
 	int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
 	int (*set_intf_mode)(struct plat_stmmacenet_data *plat_dat);
-	void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode);
+	void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
 };
 
 struct imx_priv_data {
@@ -192,7 +192,7 @@ static void imx_dwmac_exit(struct platform_device *pdev, void *priv)
 	/* nothing to do now */
 }
 
-static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode)
+static void imx_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
 {
 	struct plat_stmmacenet_data *plat_dat;
 	struct imx_priv_data *dwmac = priv;
@@ -208,7 +208,7 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod
 
 	rate = rgmii_clock(speed);
 	if (rate < 0) {
-		dev_err(dwmac->dev, "invalid speed %u\n", speed);
+		dev_err(dwmac->dev, "invalid speed %d\n", speed);
 		return;
 	}
 
@@ -217,7 +217,7 @@ static void imx_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mod
 		dev_err(dwmac->dev, "failed to set tx rate %lu\n", rate);
 }
 
-static void imx93_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode)
+static void imx93_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
 {
 	struct imx_priv_data *dwmac = priv;
 	unsigned int iface;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
index ddee6154d40b..0591756a2100 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-intel-plat.c
@@ -22,13 +22,13 @@ struct intel_dwmac {
 };
 
 struct intel_dwmac_data {
-	void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode);
+	void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
 	unsigned long ptp_ref_clk_rate;
 	unsigned long tx_clk_rate;
 	bool tx_clk_en;
 };
 
-static void kmb_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
+static void kmb_eth_fix_mac_speed(void *priv, int speed, unsigned int mode)
 {
 	struct intel_dwmac *dwmac = priv;
 	long rate;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
index 61227dcf56dc..7f4b9c1cc32b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-ipq806x.c
@@ -112,7 +112,7 @@ struct ipq806x_gmac {
 	phy_interface_t phy_mode;
 };
 
-static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, unsigned int speed)
+static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, int speed)
 {
 	struct device *dev = &gmac->pdev->dev;
 	int div;
@@ -138,7 +138,7 @@ static int get_clk_div_sgmii(struct ipq806x_gmac *gmac, unsigned int speed)
 	return div;
 }
 
-static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, unsigned int speed)
+static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, int speed)
 {
 	struct device *dev = &gmac->pdev->dev;
 	int div;
@@ -164,7 +164,7 @@ static int get_clk_div_rgmii(struct ipq806x_gmac *gmac, unsigned int speed)
 	return div;
 }
 
-static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, unsigned int speed)
+static int ipq806x_gmac_set_speed(struct ipq806x_gmac *gmac, int speed)
 {
 	uint32_t clk_bits, val;
 	int div;
@@ -260,7 +260,7 @@ static int ipq806x_gmac_of_parse(struct ipq806x_gmac *gmac)
 	return PTR_ERR_OR_ZERO(gmac->qsgmii_csr);
 }
 
-static void ipq806x_gmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
+static void ipq806x_gmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
 {
 	struct ipq806x_gmac *gmac = priv;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
index 79acdf38c525..60a4e3330ccd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-loongson.c
@@ -149,8 +149,7 @@ static struct stmmac_pci_info loongson_gmac_pci_info = {
 	.setup = loongson_gmac_data,
 };
 
-static void loongson_gnet_fix_speed(void *priv, unsigned int speed,
-				    unsigned int mode)
+static void loongson_gnet_fix_speed(void *priv, int speed, unsigned int mode)
 {
 	struct loongson_data *ld = (struct loongson_data *)priv;
 	struct net_device *ndev = dev_get_drvdata(ld->dev);
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
index 5469fa1b429e..b115b7873cef 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-meson.c
@@ -22,7 +22,7 @@ struct meson_dwmac {
 	void __iomem	*reg;
 };
 
-static void meson6_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
+static void meson6_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
 {
 	struct meson_dwmac *dwmac = priv;
 	unsigned int val;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
index 2a5b38723635..192f270197c8 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-qcom-ethqos.c
@@ -111,7 +111,7 @@ struct qcom_ethqos {
 	unsigned int link_clk_rate;
 	struct clk *link_clk;
 	struct phy *serdes_phy;
-	unsigned int speed;
+	int speed;
 	int serdes_speed;
 	phy_interface_t phy_mode;
 
@@ -175,7 +175,7 @@ static void rgmii_dump(void *priv)
 #define RGMII_ID_MODE_10_LOW_SVS_CLK_FREQ	  (5 * 1000 * 1000UL)
 
 static void
-ethqos_update_link_clk(struct qcom_ethqos *ethqos, unsigned int speed)
+ethqos_update_link_clk(struct qcom_ethqos *ethqos, int speed)
 {
 	if (!phy_interface_mode_is_rgmii(ethqos->phy_mode))
 		return;
@@ -699,7 +699,7 @@ static int ethqos_configure(struct qcom_ethqos *ethqos)
 	return ethqos->configure_func(ethqos);
 }
 
-static void ethqos_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
+static void ethqos_fix_mac_speed(void *priv, int speed, unsigned int mode)
 {
 	struct qcom_ethqos *ethqos = priv;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
index a4dc89e23a68..83d104a274c5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-rk.c
@@ -1920,7 +1920,7 @@ static void rk_gmac_powerdown(struct rk_priv_data *gmac)
 	gmac_clk_enable(gmac, false);
 }
 
-static void rk_fix_speed(void *priv, unsigned int speed, unsigned int mode)
+static void rk_fix_speed(void *priv, int speed, unsigned int mode)
 {
 	struct rk_priv_data *bsp_priv = priv;
 	struct device *dev = &bsp_priv->pdev->dev;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
index 9cc0e5817416..6a498833b8ed 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-s32.c
@@ -100,7 +100,7 @@ static void s32_gmac_exit(struct platform_device *pdev, void *priv)
 	clk_disable_unprepare(gmac->rx_clk);
 }
 
-static void s32_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
+static void s32_fix_mac_speed(void *priv, int speed, unsigned int mode)
 {
 	struct s32_priv_data *gmac = priv;
 	long tx_clk_rate;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
index 16020b72dec8..6b78ae730466 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-socfpga.c
@@ -61,7 +61,7 @@ struct socfpga_dwmac {
 	struct mdio_device *pcs_mdiodev;
 };
 
-static void socfpga_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
+static void socfpga_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
 {
 	struct socfpga_dwmac *dwmac = (struct socfpga_dwmac *)priv;
 	void __iomem *splitter_base = dwmac->splitter_base;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
index 0a0a363d3730..282c846dad0b 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-starfive.c
@@ -31,7 +31,7 @@ struct starfive_dwmac {
 	const struct starfive_dwmac_data *data;
 };
 
-static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
+static void starfive_dwmac_fix_mac_speed(void *priv, int speed, unsigned int mode)
 {
 	struct starfive_dwmac *dwmac = priv;
 	long rate;
@@ -39,7 +39,7 @@ static void starfive_dwmac_fix_mac_speed(void *priv, unsigned int speed, unsigne
 
 	rate = rgmii_clock(speed);
 	if (rate < 0) {
-		dev_err(dwmac->dev, "invalid speed %u\n", speed);
+		dev_err(dwmac->dev, "invalid speed %d\n", speed);
 		return;
 	}
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
index f25461c292fe..13b9c2a51fce 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sti.c
@@ -99,12 +99,12 @@ struct sti_dwmac {
 	int clk_sel_reg;	/* GMAC ext clk selection register */
 	struct regmap *regmap;
 	bool gmac_en;
-	u32 speed;
-	void (*fix_retime_src)(void *priv, unsigned int speed, unsigned int mode);
+	int speed;
+	void (*fix_retime_src)(void *priv, int speed, unsigned int mode);
 };
 
 struct sti_dwmac_of_data {
-	void (*fix_retime_src)(void *priv, unsigned int speed, unsigned int mode);
+	void (*fix_retime_src)(void *priv, int speed, unsigned int mode);
 };
 
 static u32 phy_intf_sels[] = {
@@ -132,7 +132,7 @@ static u32 stih4xx_tx_retime_val[] = {
 				 | STIH4XX_ETH_SEL_INTERNAL_NOTEXT_PHYCLK,
 };
 
-static void stih4xx_fix_retime_src(void *priv, u32 spd, unsigned int mode)
+static void stih4xx_fix_retime_src(void *priv, int spd, unsigned int mode)
 {
 	struct sti_dwmac *dwmac = priv;
 	u32 src = dwmac->tx_retime_src;
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
index 9ae318436c4a..1b1ce2888b2e 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c
@@ -72,7 +72,7 @@ static void sun7i_gmac_exit(struct platform_device *pdev, void *priv)
 		regulator_disable(gmac->regulator);
 }
 
-static void sun7i_fix_speed(void *priv, unsigned int speed, unsigned int mode)
+static void sun7i_fix_speed(void *priv, int speed, unsigned int mode)
 {
 	struct sunxi_priv_data *gmac = priv;
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
index dce84ed184e9..ddb1d8aba321 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-thead.c
@@ -104,7 +104,7 @@ static int thead_dwmac_set_txclk_dir(struct plat_stmmacenet_data *plat)
 	return 0;
 }
 
-static void thead_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int mode)
+static void thead_dwmac_fix_speed(void *priv, int speed, unsigned int mode)
 {
 	struct plat_stmmacenet_data *plat;
 	struct thead_dwmac *dwmac = priv;
@@ -142,7 +142,7 @@ static void thead_dwmac_fix_speed(void *priv, unsigned int speed, unsigned int m
 			div = rate * 10 / GMAC_MII_RATE;
 			break;
 		default:
-			dev_err(dwmac->dev, "invalid speed %u\n", speed);
+			dev_err(dwmac->dev, "invalid speed %d\n", speed);
 			return;
 		}
 
diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
index eccf7f537467..33cf99797df5 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
@@ -54,7 +54,7 @@ struct visconti_eth {
 	spinlock_t lock; /* lock to protect register update */
 };
 
-static void visconti_eth_fix_mac_speed(void *priv, unsigned int speed, unsigned int mode)
+static void visconti_eth_fix_mac_speed(void *priv, int speed, unsigned int mode)
 {
 	struct visconti_eth *dwmac = priv;
 	struct net_device *netdev = dev_get_drvdata(dwmac->dev);
diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h
index 24422ac4e417..6d2aa77ea963 100644
--- a/include/linux/stmmac.h
+++ b/include/linux/stmmac.h
@@ -231,7 +231,7 @@ struct plat_stmmacenet_data {
 	u8 tx_sched_algorithm;
 	struct stmmac_rxq_cfg rx_queues_cfg[MTL_MAX_RX_QUEUES];
 	struct stmmac_txq_cfg tx_queues_cfg[MTL_MAX_TX_QUEUES];
-	void (*fix_mac_speed)(void *priv, unsigned int speed, unsigned int mode);
+	void (*fix_mac_speed)(void *priv, int speed, unsigned int mode);
 	int (*fix_soc_reset)(void *priv, void __iomem *ioaddr);
 	int (*serdes_powerup)(struct net_device *ndev, void *priv);
 	void (*serdes_powerdown)(struct net_device *ndev, void *priv);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 1/3] net: stmmac: clarify priv->pause and pause module parameter
  2025-02-18 10:24 ` [PATCH net-next 1/3] net: stmmac: clarify priv->pause and pause module parameter Russell King (Oracle)
@ 2025-02-18 11:17   ` Mateusz Polchlopek
  0 siblings, 0 replies; 11+ messages in thread
From: Mateusz Polchlopek @ 2025-02-18 11:17 UTC (permalink / raw)
  To: Russell King (Oracle), netdev
  Cc: Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jan Petrous, Jernej Skrabec,
	Jerome Brunet, Kevin Hilman, linux-amlogic, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-stm32, linux-sunxi,
	Martin Blumenstingl, Maxime Coquelin, Minda Chen, Neil Armstrong,
	Nobuhiro Iwamatsu, NXP S32 Linux Team, Paolo Abeni,
	Pengutronix Kernel Team, Samuel Holland, Sascha Hauer, Shawn Guo,
	Vinod Koul



On 2/18/2025 11:24 AM, Russell King (Oracle) wrote:
> priv->pause corresponds with "pause_time" in the 802.3 specification,
> and is also called "pause_time" in the various MAC backends. For
> consistency, use the same name in the core stmmac code.
> 
> Clarify the units of the "pause" module parameter which sets up this
> struct member to indicate that it's in units of the pause_quanta
> defined by 802.3, which is 512 bit times.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>   drivers/net/ethernet/stmicro/stmmac/stmmac.h      | 2 +-
>   drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 6 +++---
>   2 files changed, 4 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> index f05cae103d83..c602ace572b2 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
> @@ -283,7 +283,7 @@ struct stmmac_priv {
>   
>   	int speed;
>   	unsigned int flow_ctrl;
> -	unsigned int pause;
> +	unsigned int pause_time;
>   	struct mii_bus *mii;
>   
>   	struct phylink_config phylink_config;
> diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> index fd8ca1524e43..c3a13bd8c9b3 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c
> @@ -94,7 +94,7 @@ MODULE_PARM_DESC(flow_ctrl, "Flow control ability [on/off]");
>   
>   static int pause = PAUSE_TIME;
>   module_param(pause, int, 0644);
> -MODULE_PARM_DESC(pause, "Flow Control Pause Time");
> +MODULE_PARM_DESC(pause, "Flow Control Pause Time (units of 512 bit times)");
>   
>   #define TC_DEFAULT 64
>   static int tc = TC_DEFAULT;
> @@ -865,7 +865,7 @@ static void stmmac_mac_flow_ctrl(struct stmmac_priv *priv, u32 duplex)
>   	u32 tx_cnt = priv->plat->tx_queues_to_use;
>   
>   	stmmac_flow_ctrl(priv, priv->hw, duplex, priv->flow_ctrl,
> -			priv->pause, tx_cnt);
> +			 priv->pause_time, tx_cnt);
>   }
>   
>   static unsigned long stmmac_mac_get_caps(struct phylink_config *config,
> @@ -7404,7 +7404,7 @@ int stmmac_dvr_probe(struct device *device,
>   		return -ENOMEM;
>   
>   	stmmac_set_ethtool_ops(ndev);
> -	priv->pause = pause;
> +	priv->pause_time = pause;
>   	priv->plat = plat_dat;
>   	priv->ioaddr = res->addr;
>   	priv->dev->base_addr = (unsigned long)res->addr;

Reviewed-by: Mateusz Polchlopek <mateusz.polchlopek@intel.com>


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int
  2025-02-18 10:24 ` [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int Russell King (Oracle)
@ 2025-02-18 12:29   ` Chen-Yu Tsai
  2025-02-18 16:04   ` Andrew Lunn
  2025-02-19  1:08   ` nobuhiro1.iwamatsu
  2 siblings, 0 replies; 11+ messages in thread
From: Chen-Yu Tsai @ 2025-02-18 12:29 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Drew Fustini, Emil Renner Berthing, Eric Dumazet, Fabio Estevam,
	Fu Wei, Guo Ren, imx, Jakub Kicinski, Jan Petrous, Jernej Skrabec,
	Jerome Brunet, Kevin Hilman, linux-amlogic, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-stm32, linux-sunxi,
	Martin Blumenstingl, Maxime Coquelin, Minda Chen, Neil Armstrong,
	Nobuhiro Iwamatsu, NXP S32 Linux Team, Paolo Abeni,
	Pengutronix Kernel Team, Samuel Holland, Sascha Hauer, Shawn Guo,
	Vinod Koul

On Tue, Feb 18, 2025 at 6:25 PM Russell King (Oracle)
<rmk+kernel@armlinux.org.uk> wrote:
>
> priv->plat->fix_mac_speed() is called from stmmac_mac_link_up(), which
> is passed the speed as an "int". However, fix_mac_speed() implicitly
> casts this to an unsigned int. Some platform glue code print this value
> using %u, others with %d. Some implicitly cast it back to an int, and
> others to u32.
>
> Good practice is to use one type and only one type to represent a value
> being passed around a driver.
>
> Switch all of these over to consistently use "int" when dealing with a
> speed passed from stmmac_mac_link_up(), even though the speed will
> always be positive.
>
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---

>  drivers/net/ethernet/stmicro/stmmac/dwmac-sunxi.c       | 2 +-

Acked-by: Chen-Yu Tsai <wens@csie.org>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 2/3] net: stmmac: remove useless priv->flow_ctrl
  2025-02-18 10:24 ` [PATCH net-next 2/3] net: stmmac: remove useless priv->flow_ctrl Russell King (Oracle)
@ 2025-02-18 16:02   ` Andrew Lunn
  2025-02-19  1:11   ` nobuhiro1.iwamatsu
  1 sibling, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2025-02-18 16:02 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai,
	David S. Miller, Drew Fustini, Emil Renner Berthing, Eric Dumazet,
	Fabio Estevam, Fu Wei, Guo Ren, imx, Jakub Kicinski, Jan Petrous,
	Jernej Skrabec, Jerome Brunet, Kevin Hilman, linux-amlogic,
	linux-arm-kernel, linux-arm-msm, linux-riscv, linux-stm32,
	linux-sunxi, Martin Blumenstingl, Maxime Coquelin, Minda Chen,
	Neil Armstrong, Nobuhiro Iwamatsu, NXP S32 Linux Team,
	Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vinod Koul

On Tue, Feb 18, 2025 at 10:24:34AM +0000, Russell King (Oracle) wrote:
> priv->flow_ctrl is only accessed by stmmac_main.c, and the only place
> that it is read is in stmmac_mac_flow_ctrl(). This function is only
> called from stmmac_mac_link_up() which always sets priv->flow_ctrl
> immediately before calling this function.
> 
> Therefore, initialising this at probe time is ineffectual because it
> will always be overwritten before it's read. As such, the "flow_ctrl"
> module parameter has been useless for some time. Rather than remove
> the module parameter, which would risk module load failure, change the
> description to indicate that it is obsolete, and warn if it is set by
> userspace.
> 
> Moreover, storing the value in the stmmac_priv has no benefit as it's
> set and then immediately read stmmac_mac_flow_ctrl(). Instead, pass it
> as a parameter to this function..
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int
  2025-02-18 10:24 ` [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int Russell King (Oracle)
  2025-02-18 12:29   ` Chen-Yu Tsai
@ 2025-02-18 16:04   ` Andrew Lunn
  2025-02-19  1:08   ` nobuhiro1.iwamatsu
  2 siblings, 0 replies; 11+ messages in thread
From: Andrew Lunn @ 2025-02-18 16:04 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: netdev, Alexandre Torgue, Andrew Lunn, Chen-Yu Tsai,
	David S. Miller, Drew Fustini, Emil Renner Berthing, Eric Dumazet,
	Fabio Estevam, Fu Wei, Guo Ren, imx, Jakub Kicinski, Jan Petrous,
	Jernej Skrabec, Jerome Brunet, Kevin Hilman, linux-amlogic,
	linux-arm-kernel, linux-arm-msm, linux-riscv, linux-stm32,
	linux-sunxi, Martin Blumenstingl, Maxime Coquelin, Minda Chen,
	Neil Armstrong, Nobuhiro Iwamatsu, NXP S32 Linux Team,
	Paolo Abeni, Pengutronix Kernel Team, Samuel Holland,
	Sascha Hauer, Shawn Guo, Vinod Koul

On Tue, Feb 18, 2025 at 10:24:39AM +0000, Russell King (Oracle) wrote:
> priv->plat->fix_mac_speed() is called from stmmac_mac_link_up(), which
> is passed the speed as an "int". However, fix_mac_speed() implicitly
> casts this to an unsigned int. Some platform glue code print this value
> using %u, others with %d. Some implicitly cast it back to an int, and
> others to u32.
> 
> Good practice is to use one type and only one type to represent a value
> being passed around a driver.
> 
> Switch all of these over to consistently use "int" when dealing with a
> speed passed from stmmac_mac_link_up(), even though the speed will
> always be positive.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Andrew Lunn <andrew@lunn.ch>

    Andrew

^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int
  2025-02-18 10:24 ` [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int Russell King (Oracle)
  2025-02-18 12:29   ` Chen-Yu Tsai
  2025-02-18 16:04   ` Andrew Lunn
@ 2025-02-19  1:08   ` nobuhiro1.iwamatsu
  2 siblings, 0 replies; 11+ messages in thread
From: nobuhiro1.iwamatsu @ 2025-02-19  1:08 UTC (permalink / raw)
  To: rmk+kernel, netdev
  Cc: alexandre.torgue, andrew+netdev, wens, davem, drew, kernel,
	edumazet, festevam, wefu, guoren, imx, kuba, jan.petrous,
	jernej.skrabec, jbrunet, khilman, linux-amlogic, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-stm32, linux-sunxi,
	martin.blumenstingl, mcoquelin.stm32, minda.chen, neil.armstrong,
	s32, pabeni, kernel, samuel, s.hauer, shawnguo, vkoul

Hi Russell,

> -----Original Message-----
> From: Russell King <rmk@armlinux.org.uk> On Behalf Of Russell King (Oracle)
> Sent: Tuesday, February 18, 2025 7:25 PM
> To: netdev@vger.kernel.org
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; Chen-Yu Tsai <wens@csie.org>; David S. Miller
> <davem@davemloft.net>; Drew Fustini <drew@pdp7.com>; Emil Renner
> Berthing <kernel@esmil.dk>; Eric Dumazet <edumazet@google.com>; Fabio
> Estevam <festevam@gmail.com>; Fu Wei <wefu@redhat.com>; Guo Ren
> <guoren@kernel.org>; imx@lists.linux.dev; Jakub Kicinski
> <kuba@kernel.org>; Jan Petrous <jan.petrous@oss.nxp.com>; Jernej Skrabec
> <jernej.skrabec@gmail.com>; Jerome Brunet <jbrunet@baylibre.com>; Kevin
> Hilman <khilman@baylibre.com>; linux-amlogic@lists.infradead.org;
> linux-arm-kernel@lists.infradead.org; linux-arm-msm@vger.kernel.org;
> linux-riscv@lists.infradead.org; linux-stm32@st-md-mailman.stormreply.com;
> linux-sunxi@lists.linux.dev; Martin Blumenstingl
> <martin.blumenstingl@googlemail.com>; Maxime Coquelin
> <mcoquelin.stm32@gmail.com>; Minda Chen
> <minda.chen@starfivetech.com>; Neil Armstrong
> <neil.armstrong@linaro.org>; iwamatsu nobuhiro(岩松 信洋 ○DITC□D
> IT○OST) <nobuhiro1.iwamatsu@toshiba.co.jp>; NXP S32 Linux Team
> <s32@nxp.com>; Paolo Abeni <pabeni@redhat.com>; Pengutronix Kernel
> Team <kernel@pengutronix.de>; Samuel Holland <samuel@sholland.org>;
> Sascha Hauer <s.hauer@pengutronix.de>; Shawn Guo
> <shawnguo@kernel.org>; Vinod Koul <vkoul@kernel.org>
> Subject: [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed
> is an int
> 
> priv->plat->fix_mac_speed() is called from stmmac_mac_link_up(), which
> is passed the speed as an "int". However, fix_mac_speed() implicitly casts this
> to an unsigned int. Some platform glue code print this value using %u, others
> with %d. Some implicitly cast it back to an int, and others to u32.
> 
> Good practice is to use one type and only one type to represent a value being
> passed around a driver.
> 
> Switch all of these over to consistently use "int" when dealing with a speed
> passed from stmmac_mac_link_up(), even though the speed will always be
> positive.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---

>  drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c    | 2 +-

Acked-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>

Best regards,
  Nobuhiro 



^ permalink raw reply	[flat|nested] 11+ messages in thread

* RE: [PATCH net-next 2/3] net: stmmac: remove useless priv->flow_ctrl
  2025-02-18 10:24 ` [PATCH net-next 2/3] net: stmmac: remove useless priv->flow_ctrl Russell King (Oracle)
  2025-02-18 16:02   ` Andrew Lunn
@ 2025-02-19  1:11   ` nobuhiro1.iwamatsu
  1 sibling, 0 replies; 11+ messages in thread
From: nobuhiro1.iwamatsu @ 2025-02-19  1:11 UTC (permalink / raw)
  To: rmk+kernel, netdev
  Cc: alexandre.torgue, andrew+netdev, wens, davem, drew, kernel,
	edumazet, festevam, wefu, guoren, imx, kuba, jan.petrous,
	jernej.skrabec, jbrunet, khilman, linux-amlogic, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-stm32, linux-sunxi,
	martin.blumenstingl, mcoquelin.stm32, minda.chen, neil.armstrong,
	s32, pabeni, kernel, samuel, s.hauer, shawnguo, vkoul

Hi Russell,

> -----Original Message-----
> From: Russell King <rmk@armlinux.org.uk> On Behalf Of Russell King (Oracle)
> Sent: Tuesday, February 18, 2025 7:25 PM
> To: netdev@vger.kernel.org
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; Chen-Yu Tsai <wens@csie.org>; David S. Miller
> <davem@davemloft.net>; Drew Fustini <drew@pdp7.com>; Emil Renner
> Berthing <kernel@esmil.dk>; Eric Dumazet <edumazet@google.com>; Fabio
> Estevam <festevam@gmail.com>; Fu Wei <wefu@redhat.com>; Guo Ren
> <guoren@kernel.org>; imx@lists.linux.dev; Jakub Kicinski
> <kuba@kernel.org>; Jan Petrous <jan.petrous@oss.nxp.com>; Jernej Skrabec
> <jernej.skrabec@gmail.com>; Jerome Brunet <jbrunet@baylibre.com>; Kevin
> Hilman <khilman@baylibre.com>; linux-amlogic@lists.infradead.org;
> linux-arm-kernel@lists.infradead.org; linux-arm-msm@vger.kernel.org;
> linux-riscv@lists.infradead.org; linux-stm32@st-md-mailman.stormreply.com;
> linux-sunxi@lists.linux.dev; Martin Blumenstingl
> <martin.blumenstingl@googlemail.com>; Maxime Coquelin
> <mcoquelin.stm32@gmail.com>; Minda Chen
> <minda.chen@starfivetech.com>; Neil Armstrong
> <neil.armstrong@linaro.org>; iwamatsu nobuhiro(岩松 信洋 ○DITC□D
> IT○OST) <nobuhiro1.iwamatsu@toshiba.co.jp>; NXP S32 Linux Team
> <s32@nxp.com>; Paolo Abeni <pabeni@redhat.com>; Pengutronix Kernel
> Team <kernel@pengutronix.de>; Samuel Holland <samuel@sholland.org>;
> Sascha Hauer <s.hauer@pengutronix.de>; Shawn Guo
> <shawnguo@kernel.org>; Vinod Koul <vkoul@kernel.org>
> Subject: [PATCH net-next 2/3] net: stmmac: remove useless priv->flow_ctrl
> 
> priv->flow_ctrl is only accessed by stmmac_main.c, and the only place
> that it is read is in stmmac_mac_flow_ctrl(). This function is only called from
> stmmac_mac_link_up() which always sets priv->flow_ctrl immediately before
> calling this function.
> 
> Therefore, initialising this at probe time is ineffectual because it will always be
> overwritten before it's read. As such, the "flow_ctrl"
> module parameter has been useless for some time. Rather than remove the
> module parameter, which would risk module load failure, change the
> description to indicate that it is obsolete, and warn if it is set by userspace.
> 
> Moreover, storing the value in the stmmac_priv has no benefit as it's set and
> then immediately read stmmac_mac_flow_ctrl(). Instead, pass it as a
> parameter to this function..
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

Reviewed-by: Nobuhiro Iwamatsu <nobuhiro1.iwamatsu@toshiba.co.jp>

Best regards,
  Nobuhiro

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH net-next 0/3] net: stmmac: further cleanups
  2025-02-18 10:24 [PATCH net-next 0/3] net: stmmac: further cleanups Russell King (Oracle)
                   ` (2 preceding siblings ...)
  2025-02-18 10:24 ` [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int Russell King (Oracle)
@ 2025-02-20  3:10 ` patchwork-bot+netdevbpf
  3 siblings, 0 replies; 11+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-02-20  3:10 UTC (permalink / raw)
  To: Russell King
  Cc: netdev, alexandre.torgue, andrew+netdev, wens, davem, drew,
	kernel, edumazet, festevam, wefu, guoren, imx, kuba, jan.petrous,
	jernej.skrabec, jbrunet, khilman, linux-amlogic, linux-arm-kernel,
	linux-arm-msm, linux-riscv, linux-stm32, linux-sunxi,
	martin.blumenstingl, mcoquelin.stm32, minda.chen, neil.armstrong,
	nobuhiro1.iwamatsu, s32, pabeni, kernel, samuel, s.hauer,
	shawnguo, vkoul

Hello:

This series was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:

On Tue, 18 Feb 2025 10:24:25 +0000 you wrote:
> Hi,
> 
> 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.
> 
> [...]

Here is the summary with links:
  - [net-next,1/3] net: stmmac: clarify priv->pause and pause module parameter
    https://git.kernel.org/netdev/net-next/c/ff1a9b2e311f
  - [net-next,2/3] net: stmmac: remove useless priv->flow_ctrl
    https://git.kernel.org/netdev/net-next/c/bc9d75b0aaed
  - [net-next,3/3] net: stmmac: "speed" passed to fix_mac_speed is an int
    https://git.kernel.org/netdev/net-next/c/ac9a8587edc7

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-02-20  3:10 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-18 10:24 [PATCH net-next 0/3] net: stmmac: further cleanups Russell King (Oracle)
2025-02-18 10:24 ` [PATCH net-next 1/3] net: stmmac: clarify priv->pause and pause module parameter Russell King (Oracle)
2025-02-18 11:17   ` Mateusz Polchlopek
2025-02-18 10:24 ` [PATCH net-next 2/3] net: stmmac: remove useless priv->flow_ctrl Russell King (Oracle)
2025-02-18 16:02   ` Andrew Lunn
2025-02-19  1:11   ` nobuhiro1.iwamatsu
2025-02-18 10:24 ` [PATCH net-next 3/3] net: stmmac: "speed" passed to fix_mac_speed is an int Russell King (Oracle)
2025-02-18 12:29   ` Chen-Yu Tsai
2025-02-18 16:04   ` Andrew Lunn
2025-02-19  1:08   ` nobuhiro1.iwamatsu
2025-02-20  3:10 ` [PATCH net-next 0/3] net: stmmac: further cleanups patchwork-bot+netdevbpf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).