]> git.baikalelectronics.ru Git - kernel.git/commit
net: mvpp2: handle too large value in mvpp2_rx_time_coal_set()
authorThomas Petazzoni <thomas.petazzoni@free-electrons.com>
Tue, 21 Feb 2017 10:28:04 +0000 (11:28 +0100)
committerDavid S. Miller <davem@davemloft.net>
Tue, 21 Feb 2017 18:16:14 +0000 (13:16 -0500)
commit1648a73951509c17d9a0cd35d0f334e75878ca21
tree6581425291a2e1102bb18fbc9964c3192c33ad11
parent2f4c2459362620320a71d5a9e18b2e0746a797dc
net: mvpp2: handle too large value in mvpp2_rx_time_coal_set()

When configuring the MVPP2_ISR_RX_THRESHOLD_REG with the RX coalescing
time threshold, we do not check for the maximum allowed value supported
by the driver, which means we might overflow and use a bogus value. This
commit adds a check for this situation, and if a value higher than what
is supported by the hardware is provided, then we use the maximum value
supported by the hardware.

In order to achieve this in a way that avoids overflow and rounding
errors, we introduce two utility functions mvpp2_usec_to_cycles() and
cycles_to_usec(). Many thanks to Russell King for suggesting this
implementation.

Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
Acked-by: Russell King <rmk+kernel@armlinux.org.uk>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/marvell/mvpp2.c