]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
net: mvpp2: only update the XLG configuration when needed
authorAntoine Tenart <antoine.tenart@bootlin.com>
Fri, 1 Mar 2019 10:52:12 +0000 (11:52 +0100)
committerDavid S. Miller <davem@davemloft.net>
Sat, 2 Mar 2019 07:23:34 +0000 (23:23 -0800)
This patch improves the XLG configuration function, to only update the
XLG configuration register when a change is needed. This helps not
writing over and over the same XLG configuration each time phylink
request the MAC to be configured. This mimics the GMAC configuration
function.

Signed-off-by: Antoine Tenart <antoine.tenart@bootlin.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

index e9cbbe871a1a2f93a9b11cd373cc534ceb1e398f..b1add5c6b75c3b54127ee908a83bf03c3e4233d2 100644 (file)
@@ -4505,10 +4505,11 @@ static void mvpp2_mac_an_restart(struct net_device *dev)
 static void mvpp2_xlg_config(struct mvpp2_port *port, unsigned int mode,
                             const struct phylink_link_state *state)
 {
-       u32 ctrl0, ctrl4;
+       u32 old_ctrl0, ctrl0;
+       u32 old_ctrl4, ctrl4;
 
-       ctrl0 = readl(port->base + MVPP22_XLG_CTRL0_REG);
-       ctrl4 = readl(port->base + MVPP22_XLG_CTRL4_REG);
+       old_ctrl0 = ctrl0 = readl(port->base + MVPP22_XLG_CTRL0_REG);
+       old_ctrl4 = ctrl4 = readl(port->base + MVPP22_XLG_CTRL4_REG);
 
        if (state->pause & MLO_PAUSE_TX)
                ctrl0 |= MVPP22_XLG_CTRL0_TX_FLOW_CTRL_EN;
@@ -4524,8 +4525,10 @@ static void mvpp2_xlg_config(struct mvpp2_port *port, unsigned int mode,
        ctrl4 |= MVPP22_XLG_CTRL4_FWD_FC | MVPP22_XLG_CTRL4_FWD_PFC |
                 MVPP22_XLG_CTRL4_EN_IDLE_CHECK;
 
-       writel(ctrl0, port->base + MVPP22_XLG_CTRL0_REG);
-       writel(ctrl4, port->base + MVPP22_XLG_CTRL4_REG);
+       if (old_ctrl0 != ctrl0)
+               writel(ctrl0, port->base + MVPP22_XLG_CTRL0_REG);
+       if (old_ctrl4 != ctrl4)
+               writel(ctrl4, port->base + MVPP22_XLG_CTRL4_REG);
 }
 
 static void mvpp2_gmac_config(struct mvpp2_port *port, unsigned int mode,