net/mlx4_en: fix overflow in mlx4_en_init_timestamp()
[ Upstream commit 47d3a07528ecbbccf53bc4390d70b4e3d1c04fcf ] The cited commit makes a great job of finding optimal shift/multiplier values assuming a 10 seconds wrap around, but forgot to change the overflow_period computation. It overflows in cyclecounter_cyc2ns(), and the final result is 804 ms, which is silly. Lets simply use 5 seconds, no need to recompute this, given how it is supposed to work. Later, we will use a timer instead of a work queue, since the new RX allocation schem will no longer need mlx4_en_recover_from_oom() and the service_task firing every 250 ms. Fixes: 31c128b66e5b ("net/mlx4_en: Choose time-stamping shift value according to HW frequency") Signed-off-by: Eric Dumazet <edumazet@google.com> Cc: Tariq Toukan <tariqt@mellanox.com> Cc: Eugenia Emantayev <eugenia@mellanox.com> Reviewed-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Sasha Levin <alexander.levin@verizon.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
7ed668eeb8
commit
743a3ce1e0
2 changed files with 8 additions and 11 deletions
|
@ -88,10 +88,17 @@ void mlx4_en_remove_timestamp(struct mlx4_en_dev *mdev)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define MLX4_EN_WRAP_AROUND_SEC 10UL
|
||||||
|
/* By scheduling the overflow check every 5 seconds, we have a reasonably
|
||||||
|
* good chance we wont miss a wrap around.
|
||||||
|
* TOTO: Use a timer instead of a work queue to increase the guarantee.
|
||||||
|
*/
|
||||||
|
#define MLX4_EN_OVERFLOW_PERIOD (MLX4_EN_WRAP_AROUND_SEC * HZ / 2)
|
||||||
|
|
||||||
void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev)
|
void mlx4_en_ptp_overflow_check(struct mlx4_en_dev *mdev)
|
||||||
{
|
{
|
||||||
bool timeout = time_is_before_jiffies(mdev->last_overflow_check +
|
bool timeout = time_is_before_jiffies(mdev->last_overflow_check +
|
||||||
mdev->overflow_period);
|
MLX4_EN_OVERFLOW_PERIOD);
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
if (timeout) {
|
if (timeout) {
|
||||||
|
@ -236,7 +243,6 @@ static const struct ptp_clock_info mlx4_en_ptp_clock_info = {
|
||||||
.enable = mlx4_en_phc_enable,
|
.enable = mlx4_en_phc_enable,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define MLX4_EN_WRAP_AROUND_SEC 10ULL
|
|
||||||
|
|
||||||
/* This function calculates the max shift that enables the user range
|
/* This function calculates the max shift that enables the user range
|
||||||
* of MLX4_EN_WRAP_AROUND_SEC values in the cycles register.
|
* of MLX4_EN_WRAP_AROUND_SEC values in the cycles register.
|
||||||
|
@ -258,7 +264,6 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev)
|
||||||
{
|
{
|
||||||
struct mlx4_dev *dev = mdev->dev;
|
struct mlx4_dev *dev = mdev->dev;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
u64 ns, zero = 0;
|
|
||||||
|
|
||||||
/* mlx4_en_init_timestamp is called for each netdev.
|
/* mlx4_en_init_timestamp is called for each netdev.
|
||||||
* mdev->ptp_clock is common for all ports, skip initialization if
|
* mdev->ptp_clock is common for all ports, skip initialization if
|
||||||
|
@ -282,13 +287,6 @@ void mlx4_en_init_timestamp(struct mlx4_en_dev *mdev)
|
||||||
ktime_to_ns(ktime_get_real()));
|
ktime_to_ns(ktime_get_real()));
|
||||||
write_unlock_irqrestore(&mdev->clock_lock, flags);
|
write_unlock_irqrestore(&mdev->clock_lock, flags);
|
||||||
|
|
||||||
/* Calculate period in seconds to call the overflow watchdog - to make
|
|
||||||
* sure counter is checked at least once every wrap around.
|
|
||||||
*/
|
|
||||||
ns = cyclecounter_cyc2ns(&mdev->cycles, mdev->cycles.mask, zero, &zero);
|
|
||||||
do_div(ns, NSEC_PER_SEC / 2 / HZ);
|
|
||||||
mdev->overflow_period = ns;
|
|
||||||
|
|
||||||
/* Configure the PHC */
|
/* Configure the PHC */
|
||||||
mdev->ptp_clock_info = mlx4_en_ptp_clock_info;
|
mdev->ptp_clock_info = mlx4_en_ptp_clock_info;
|
||||||
snprintf(mdev->ptp_clock_info.name, 16, "mlx4 ptp");
|
snprintf(mdev->ptp_clock_info.name, 16, "mlx4 ptp");
|
||||||
|
|
|
@ -409,7 +409,6 @@ struct mlx4_en_dev {
|
||||||
struct cyclecounter cycles;
|
struct cyclecounter cycles;
|
||||||
struct timecounter clock;
|
struct timecounter clock;
|
||||||
unsigned long last_overflow_check;
|
unsigned long last_overflow_check;
|
||||||
unsigned long overflow_period;
|
|
||||||
struct ptp_clock *ptp_clock;
|
struct ptp_clock *ptp_clock;
|
||||||
struct ptp_clock_info ptp_clock_info;
|
struct ptp_clock_info ptp_clock_info;
|
||||||
struct notifier_block nb;
|
struct notifier_block nb;
|
||||||
|
|
Loading…
Add table
Reference in a new issue