All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net-next] net: pcs: rzn1-miic: update speed only if interface is changed
@ 2022-06-29 12:20 Clément Léger
  2022-07-02  3:20 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Clément Léger @ 2022-06-29 12:20 UTC (permalink / raw)
  To: Andrew Lunn, Heiner Kallweit, Russell King, David S. Miller,
	Eric Dumazet, Jakub Kicinski, Paolo Abeni
  Cc: Clément Léger, linux-renesas-soc, netdev, linux-kernel,
	Thomas Petazzoni, Herve Codina, Miquèl Raynal,
	Milan Stevanovic, Jimmy Lalande, Pascal Eberhard

As stated by Russel King, miic_config() can be called as a result of
ethtool setting the configuration while the link is already up. Since
the speed is also set in this function, it could potentially modify
the current speed that is set. This will only happen if there is
no PHY present and we aren't using fixed-link mode.

Handle that by storing the current interface mode in the miic_port
structure and update the speed only if the interface mode is going to
be changed.

Signed-off-by: Clément Léger <clement.leger@bootlin.com>
---
 drivers/net/pcs/pcs-rzn1-miic.c | 21 ++++++++++++++++-----
 1 file changed, 16 insertions(+), 5 deletions(-)

diff --git a/drivers/net/pcs/pcs-rzn1-miic.c b/drivers/net/pcs/pcs-rzn1-miic.c
index 8f5e910f443d..a7dab7b48dda 100644
--- a/drivers/net/pcs/pcs-rzn1-miic.c
+++ b/drivers/net/pcs/pcs-rzn1-miic.c
@@ -138,11 +138,13 @@ struct miic {
  * @miic: backiling to MII converter structure
  * @pcs: PCS structure associated to the port
  * @port: port number
+ * @interface: interface mode of the port
  */
 struct miic_port {
 	struct miic *miic;
 	struct phylink_pcs pcs;
 	int port;
+	phy_interface_t interface;
 };
 
 static struct miic_port *phylink_pcs_to_miic_port(struct phylink_pcs *pcs)
@@ -190,8 +192,8 @@ static int miic_config(struct phylink_pcs *pcs, unsigned int mode,
 {
 	struct miic_port *miic_port = phylink_pcs_to_miic_port(pcs);
 	struct miic *miic = miic_port->miic;
+	u32 speed, conv_mode, val, mask;
 	int port = miic_port->port;
-	u32 speed, conv_mode, val;
 
 	switch (interface) {
 	case PHY_INTERFACE_MODE_RMII:
@@ -216,11 +218,20 @@ static int miic_config(struct phylink_pcs *pcs, unsigned int mode,
 		return -EOPNOTSUPP;
 	}
 
-	val = FIELD_PREP(MIIC_CONVCTRL_CONV_MODE, conv_mode) |
-	      FIELD_PREP(MIIC_CONVCTRL_CONV_SPEED, speed);
+	val = FIELD_PREP(MIIC_CONVCTRL_CONV_MODE, conv_mode);
+	mask = MIIC_CONVCTRL_CONV_MODE;
 
-	miic_reg_rmw(miic, MIIC_CONVCTRL(port),
-		     MIIC_CONVCTRL_CONV_MODE | MIIC_CONVCTRL_CONV_SPEED, val);
+	/* Update speed only if we are going to change the interface because
+	 * the link might already be up and it would break it if the speed is
+	 * changed.
+	 */
+	if (interface != miic_port->interface) {
+		val |= FIELD_PREP(MIIC_CONVCTRL_CONV_SPEED, speed);
+		mask |= MIIC_CONVCTRL_CONV_SPEED;
+		miic_port->interface = interface;
+	}
+
+	miic_reg_rmw(miic, MIIC_CONVCTRL(port), mask, val);
 	miic_converter_enable(miic_port->miic, miic_port->port, 1);
 
 	return 0;
-- 
2.36.1


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

* Re: [PATCH net-next] net: pcs: rzn1-miic: update speed only if interface is changed
  2022-06-29 12:20 [PATCH net-next] net: pcs: rzn1-miic: update speed only if interface is changed Clément Léger
@ 2022-07-02  3:20 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-07-02  3:20 UTC (permalink / raw)
  To: =?utf-8?b?Q2zDqW1lbnQgTMOpZ2VyIDxjbGVtZW50LmxlZ2VyQGJvb3RsaW4uY29tPg==?=
  Cc: andrew, hkallweit1, linux, davem, edumazet, kuba, pabeni,
	linux-renesas-soc, netdev, linux-kernel, thomas.petazzoni,
	herve.codina, miquel.raynal, milan.stevanovic, jimmy.lalande,
	pascal.eberhard

Hello:

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

On Wed, 29 Jun 2022 14:20:03 +0200 you wrote:
> As stated by Russel King, miic_config() can be called as a result of
> ethtool setting the configuration while the link is already up. Since
> the speed is also set in this function, it could potentially modify
> the current speed that is set. This will only happen if there is
> no PHY present and we aren't using fixed-link mode.
> 
> Handle that by storing the current interface mode in the miic_port
> structure and update the speed only if the interface mode is going to
> be changed.
> 
> [...]

Here is the summary with links:
  - [net-next] net: pcs: rzn1-miic: update speed only if interface is changed
    https://git.kernel.org/netdev/net-next/c/90c74f4d90ad

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] 2+ messages in thread

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

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-29 12:20 [PATCH net-next] net: pcs: rzn1-miic: update speed only if interface is changed Clément Léger
2022-07-02  3:20 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.