]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
net: mv643xx_eth: ensure coalesce settings survive read-modify-write
authorRussell King <rmk+kernel@armlinux.org.uk>
Tue, 1 Nov 2016 10:50:01 +0000 (10:50 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 1 Nov 2016 16:17:16 +0000 (12:17 -0400)
The coalesce settings behave badly when changing just one value:

... # ethtool -c eth0
rx-usecs: 249
... # ethtool -C eth0 tx-usecs 250
... # ethtool -c eth0
rx-usecs: 248

This occurs due to rounding errors when calculating the microseconds
value - the divisons round down.  This causes (eg) the rx-usecs to
decrease by one every time the tx-usecs value is set as per the above.

Fix this by making the divison round-to-nearest.

Signed-off-by: Russell King <rmk+kernel@armlinux.org.uk>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/mv643xx_eth.c

index bf5cc55ba24cbe9aeb44352462dccb254117abed..5b12022adf1f74fe47411615f6f622ef91c8840c 100644 (file)
@@ -1381,6 +1381,7 @@ static unsigned int get_rx_coal(struct mv643xx_eth_private *mp)
                temp = (val & 0x003fff00) >> 8;
 
        temp *= 64000000;
+       temp += mp->t_clk / 2;
        do_div(temp, mp->t_clk);
 
        return (unsigned int)temp;
@@ -1417,6 +1418,7 @@ static unsigned int get_tx_coal(struct mv643xx_eth_private *mp)
 
        temp = (rdlp(mp, TX_FIFO_URGENT_THRESHOLD) & 0x3fff0) >> 4;
        temp *= 64000000;
+       temp += mp->t_clk / 2;
        do_div(temp, mp->t_clk);
 
        return (unsigned int)temp;