* [PATCH] net: mv643xx_eth: ensure coalesce settings survive read-modify-write
@ 2016-11-01 10:50 Russell King
2016-11-01 11:10 ` Andrew Lunn
2016-11-01 16:18 ` David Miller
0 siblings, 2 replies; 3+ messages in thread
From: Russell King @ 2016-11-01 10:50 UTC (permalink / raw)
To: Sebastian Hesselbarth; +Cc: netdev
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>
---
drivers/net/ethernet/marvell/mv643xx_eth.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ethernet/marvell/mv643xx_eth.c b/drivers/net/ethernet/marvell/mv643xx_eth.c
index 2a85202de6da..8a472cbfda09 100644
--- a/drivers/net/ethernet/marvell/mv643xx_eth.c
+++ b/drivers/net/ethernet/marvell/mv643xx_eth.c
@@ -1429,6 +1429,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;
@@ -1465,6 +1466,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;
--
2.1.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] net: mv643xx_eth: ensure coalesce settings survive read-modify-write
2016-11-01 10:50 [PATCH] net: mv643xx_eth: ensure coalesce settings survive read-modify-write Russell King
@ 2016-11-01 11:10 ` Andrew Lunn
2016-11-01 16:18 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: Andrew Lunn @ 2016-11-01 11:10 UTC (permalink / raw)
To: Russell King; +Cc: Sebastian Hesselbarth, netdev
On Tue, Nov 01, 2016 at 10:50:01AM +0000, Russell King wrote:
> 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>
Andrew
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] net: mv643xx_eth: ensure coalesce settings survive read-modify-write
2016-11-01 10:50 [PATCH] net: mv643xx_eth: ensure coalesce settings survive read-modify-write Russell King
2016-11-01 11:10 ` Andrew Lunn
@ 2016-11-01 16:18 ` David Miller
1 sibling, 0 replies; 3+ messages in thread
From: David Miller @ 2016-11-01 16:18 UTC (permalink / raw)
To: rmk+kernel; +Cc: sebastian.hesselbarth, netdev
From: Russell King <rmk+kernel@armlinux.org.uk>
Date: Tue, 01 Nov 2016 10:50:01 +0000
> 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>
Applied, thanks.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2016-11-01 16:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-11-01 10:50 [PATCH] net: mv643xx_eth: ensure coalesce settings survive read-modify-write Russell King
2016-11-01 11:10 ` Andrew Lunn
2016-11-01 16:18 ` David Miller
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.