netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: stmmac: visconti: convert to set_clk_tx_rate() method
@ 2025-04-15 16:52 Russell King (Oracle)
  2025-04-15 16:58 ` Andrew Lunn
  2025-04-16  4:56 ` nobuhiro1.iwamatsu
  0 siblings, 2 replies; 3+ messages in thread
From: Russell King (Oracle) @ 2025-04-15 16:52 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit
  Cc: Alexandre Torgue, Andrew Lunn, David S. Miller, Eric Dumazet,
	Jakub Kicinski, linux-arm-kernel, linux-stm32, Maxime Coquelin,
	netdev, Nobuhiro Iwamatsu, Paolo Abeni

Convert visconti to use the set_clk_tx_rate() method. By doing so,
the GMAC control register will already have been updated (unlike with
the fix_mac_speed() method) so this code can be removed while porting
to the set_clk_tx_rate() method.

There is also no need for the spinlock, and has never been - neither
fix_mac_speed() nor set_clk_tx_rate() can be called by more than one
thread at a time, so the lock does nothing useful.

Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
---
 .../ethernet/stmicro/stmmac/dwmac-visconti.c   | 18 ++++--------------
 1 file changed, 4 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
index e1de471b215c..2215aef3ef42 100644
--- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
+++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
@@ -51,22 +51,16 @@ struct visconti_eth {
 	u32 phy_intf_sel;
 	struct clk *phy_ref_clk;
 	struct device *dev;
-	spinlock_t lock; /* lock to protect register update */
 };
 
-static void visconti_eth_fix_mac_speed(void *priv, int speed, unsigned int mode)
+static int visconti_eth_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
+					phy_interface_t interface, int speed)
 {
 	struct visconti_eth *dwmac = priv;
 	struct net_device *netdev = dev_get_drvdata(dwmac->dev);
 	unsigned int val, clk_sel_val = 0;
 	unsigned long flags;
 
-	spin_lock_irqsave(&dwmac->lock, flags);
-
-	/* adjust link */
-	val = readl(dwmac->reg + MAC_CTRL_REG);
-	val &= ~(GMAC_CONFIG_PS | GMAC_CONFIG_FES);
-
 	switch (speed) {
 	case SPEED_1000:
 		if (dwmac->phy_intf_sel == ETHER_CONFIG_INTF_RGMII)
@@ -89,12 +83,9 @@ static void visconti_eth_fix_mac_speed(void *priv, int speed, unsigned int mode)
 	default:
 		/* No bit control */
 		netdev_err(netdev, "Unsupported speed request (%d)", speed);
-		spin_unlock_irqrestore(&dwmac->lock, flags);
 		return;
 	}
 
-	writel(val, dwmac->reg + MAC_CTRL_REG);
-
 	/* Stop internal clock */
 	val = readl(dwmac->reg + REG_ETHER_CLOCK_SEL);
 	val &= ~(ETHER_CLK_SEL_RMII_CLK_EN | ETHER_CLK_SEL_RX_TX_CLK_EN);
@@ -136,7 +127,7 @@ static void visconti_eth_fix_mac_speed(void *priv, int speed, unsigned int mode)
 		break;
 	}
 
-	spin_unlock_irqrestore(&dwmac->lock, flags);
+	return 0;
 }
 
 static int visconti_eth_init_hw(struct platform_device *pdev, struct plat_stmmacenet_data *plat_dat)
@@ -228,7 +219,6 @@ static int visconti_eth_dwmac_probe(struct platform_device *pdev)
 	if (!dwmac)
 		return -ENOMEM;
 
-	spin_lock_init(&dwmac->lock);
 	dwmac->reg = stmmac_res.addr;
 	dwmac->dev = &pdev->dev;
 
@@ -237,7 +227,7 @@ static int visconti_eth_dwmac_probe(struct platform_device *pdev)
 	__set_bit(PHY_INTERFACE_MODE_RMII, plat_dat->supported_interfaces);
 
 	plat_dat->bsp_priv = dwmac;
-	plat_dat->fix_mac_speed = visconti_eth_fix_mac_speed;
+	plat_dat->set_clk_tx_rate = visconti_eth_set_clk_tx_rate;
 
 	ret = visconti_eth_clock_probe(pdev, plat_dat);
 	if (ret)
-- 
2.30.2


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

* Re: [PATCH net-next] net: stmmac: visconti: convert to set_clk_tx_rate() method
  2025-04-15 16:52 [PATCH net-next] net: stmmac: visconti: convert to set_clk_tx_rate() method Russell King (Oracle)
@ 2025-04-15 16:58 ` Andrew Lunn
  2025-04-16  4:56 ` nobuhiro1.iwamatsu
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2025-04-15 16:58 UTC (permalink / raw)
  To: Russell King (Oracle)
  Cc: Heiner Kallweit, Alexandre Torgue, Andrew Lunn, David S. Miller,
	Eric Dumazet, Jakub Kicinski, linux-arm-kernel, linux-stm32,
	Maxime Coquelin, netdev, Nobuhiro Iwamatsu, Paolo Abeni

On Tue, Apr 15, 2025 at 05:52:48PM +0100, Russell King (Oracle) wrote:
> Convert visconti to use the set_clk_tx_rate() method. By doing so,
> the GMAC control register will already have been updated (unlike with
> the fix_mac_speed() method) so this code can be removed while porting
> to the set_clk_tx_rate() method.
> 
> There is also no need for the spinlock, and has never been - neither
> fix_mac_speed() nor set_clk_tx_rate() can be called by more than one
> thread at a time, so the lock does nothing useful.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>

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

    Andrew

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

* RE: [PATCH net-next] net: stmmac: visconti: convert to set_clk_tx_rate() method
  2025-04-15 16:52 [PATCH net-next] net: stmmac: visconti: convert to set_clk_tx_rate() method Russell King (Oracle)
  2025-04-15 16:58 ` Andrew Lunn
@ 2025-04-16  4:56 ` nobuhiro1.iwamatsu
  1 sibling, 0 replies; 3+ messages in thread
From: nobuhiro1.iwamatsu @ 2025-04-16  4:56 UTC (permalink / raw)
  To: rmk+kernel, andrew, hkallweit1
  Cc: alexandre.torgue, andrew+netdev, davem, edumazet, kuba,
	linux-arm-kernel, linux-stm32, mcoquelin.stm32, netdev, pabeni

Hi Russell,

Thanks for your update!

> -----Original Message-----
> From: Russell King <rmk@armlinux.org.uk> On Behalf Of Russell King (Oracle)
> Sent: Wednesday, April 16, 2025 1:53 AM
> To: Andrew Lunn <andrew@lunn.ch>; Heiner Kallweit
> <hkallweit1@gmail.com>
> Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>; Andrew Lunn
> <andrew+netdev@lunn.ch>; David S. Miller <davem@davemloft.net>; Eric
> Dumazet <edumazet@google.com>; Jakub Kicinski <kuba@kernel.org>;
> linux-arm-kernel@lists.infradead.org;
> linux-stm32@st-md-mailman.stormreply.com; Maxime Coquelin
> <mcoquelin.stm32@gmail.com>; netdev@vger.kernel.org; iwamatsu
> nobuhiro(岩松 信洋 □DITC○CPT)
> <nobuhiro1.iwamatsu@toshiba.co.jp>; Paolo Abeni <pabeni@redhat.com>
> Subject: [PATCH net-next] net: stmmac: visconti: convert to set_clk_tx_rate()
> method
> 
> Convert visconti to use the set_clk_tx_rate() method. By doing so, the GMAC
> control register will already have been updated (unlike with the
> fix_mac_speed() method) so this code can be removed while porting to the
> set_clk_tx_rate() method.
> 
> There is also no need for the spinlock, and has never been - neither
> fix_mac_speed() nor set_clk_tx_rate() can be called by more than one thread at
> a time, so the lock does nothing useful.
> 
> Signed-off-by: Russell King (Oracle) <rmk+kernel@armlinux.org.uk>
> ---
>  .../ethernet/stmicro/stmmac/dwmac-visconti.c   | 18 ++++--------------
>  1 file changed, 4 insertions(+), 14 deletions(-)
> 
> diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> index e1de471b215c..2215aef3ef42 100644
> --- a/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac-visconti.c
> @@ -51,22 +51,16 @@ struct visconti_eth {
>  	u32 phy_intf_sel;
>  	struct clk *phy_ref_clk;
>  	struct device *dev;
> -	spinlock_t lock; /* lock to protect register update */
>  };
> 
> -static void visconti_eth_fix_mac_speed(void *priv, int speed, unsigned int
> mode)
> +static int visconti_eth_set_clk_tx_rate(void *bsp_priv, struct clk *clk_tx_i,
> +					phy_interface_t interface, int speed)
>  {
>  	struct visconti_eth *dwmac = priv;
>  	struct net_device *netdev = dev_get_drvdata(dwmac->dev);
>  	unsigned int val, clk_sel_val = 0;
>  	unsigned long flags;
> 
> -	spin_lock_irqsave(&dwmac->lock, flags);
> -
> -	/* adjust link */
> -	val = readl(dwmac->reg + MAC_CTRL_REG);
> -	val &= ~(GMAC_CONFIG_PS | GMAC_CONFIG_FES);
> -
>  	switch (speed) {
>  	case SPEED_1000:
>  		if (dwmac->phy_intf_sel == ETHER_CONFIG_INTF_RGMII)
> @@ -89,12 +83,9 @@ static void visconti_eth_fix_mac_speed(void *priv, int
> speed, unsigned int mode)
>  	default:
>  		/* No bit control */
>  		netdev_err(netdev, "Unsupported speed request (%d)",
> speed);
> -		spin_unlock_irqrestore(&dwmac->lock, flags);
>  		return;

We need to set the return code (-EINVAL). 


Best regards,
 Nobuhiro

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

end of thread, other threads:[~2025-04-16  7:23 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-15 16:52 [PATCH net-next] net: stmmac: visconti: convert to set_clk_tx_rate() method Russell King (Oracle)
2025-04-15 16:58 ` Andrew Lunn
2025-04-16  4:56 ` nobuhiro1.iwamatsu

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).