netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net-next] net: dsa: mv88e6xxx: Only reconfigure MAC when something changes
@ 2019-04-18  1:11 Andrew Lunn
  2019-04-19 21:15 ` David Miller
  0 siblings, 1 reply; 2+ messages in thread
From: Andrew Lunn @ 2019-04-18  1:11 UTC (permalink / raw)
  To: David Miller; +Cc: Vivien Didelot, netdev, Andrew Lunn

phylink will call the mac_config() callback once per second when
polling a PHY or a fixed link. The MAC driver is not supposed to
reconfigure the MAC if nothing has changed.

Make the mv88e6xxx driver look at the current configuration of the
port, and return early if nothing has changed.

Signed-off-by: Andrew Lunn <andrew@lunn.ch>
---
 drivers/net/dsa/mv88e6xxx/chip.c | 17 +++++++++++++++++
 1 file changed, 17 insertions(+)

diff --git a/drivers/net/dsa/mv88e6xxx/chip.c b/drivers/net/dsa/mv88e6xxx/chip.c
index 65da6709a173..bfd5a7faef3b 100644
--- a/drivers/net/dsa/mv88e6xxx/chip.c
+++ b/drivers/net/dsa/mv88e6xxx/chip.c
@@ -553,11 +553,28 @@ int mv88e6xxx_port_setup_mac(struct mv88e6xxx_chip *chip, int port, int link,
 			     int speed, int duplex, int pause,
 			     phy_interface_t mode)
 {
+	struct phylink_link_state state;
 	int err;
 
 	if (!chip->info->ops->port_set_link)
 		return 0;
 
+	if (!chip->info->ops->port_link_state)
+		return 0;
+
+	err = chip->info->ops->port_link_state(chip, port, &state);
+	if (err)
+		return err;
+
+	/* Has anything actually changed? We don't expect the
+	 * interface mode to change without one of the other
+	 * parameters also changing
+	 */
+	if (state.link == link &&
+	    state.speed == speed &&
+	    state.duplex == duplex)
+		return 0;
+
 	/* Port's MAC control must not be changed unless the link is down */
 	err = chip->info->ops->port_set_link(chip, port, 0);
 	if (err)
-- 
2.20.1


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

* Re: [PATCH net-next] net: dsa: mv88e6xxx: Only reconfigure MAC when something changes
  2019-04-18  1:11 [PATCH net-next] net: dsa: mv88e6xxx: Only reconfigure MAC when something changes Andrew Lunn
@ 2019-04-19 21:15 ` David Miller
  0 siblings, 0 replies; 2+ messages in thread
From: David Miller @ 2019-04-19 21:15 UTC (permalink / raw)
  To: andrew; +Cc: vivien.didelot, netdev

From: Andrew Lunn <andrew@lunn.ch>
Date: Thu, 18 Apr 2019 03:11:39 +0200

> phylink will call the mac_config() callback once per second when
> polling a PHY or a fixed link. The MAC driver is not supposed to
> reconfigure the MAC if nothing has changed.
> 
> Make the mv88e6xxx driver look at the current configuration of the
> port, and return early if nothing has changed.
> 
> Signed-off-by: Andrew Lunn <andrew@lunn.ch>

Applied, thanks Andrew.

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

end of thread, other threads:[~2019-04-19 21:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-18  1:11 [PATCH net-next] net: dsa: mv88e6xxx: Only reconfigure MAC when something changes Andrew Lunn
2019-04-19 21:15 ` David Miller

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