[PATCH 12/27] net/mlx5: Use timecounter_initialize interface

From: Sagar Arun Kamble
Date: Fri Dec 15 2017 - 02:41:31 EST


With new interface timecounter_initialize we can initialize timecounter
fields and underlying cyclecounter together. Update mlx5 timecounter
init with this new function.

Signed-off-by: Sagar Arun Kamble <sagar.a.kamble@xxxxxxxxx>
Cc: Richard Cochran <richardcochran@xxxxxxxxx>
Cc: Saeed Mahameed <saeedm@xxxxxxxxxxxx>
Cc: Matan Barak <matanb@xxxxxxxxxxxx>
Cc: Leon Romanovsky <leonro@xxxxxxxxxxxx>
Cc: Eugenia Emantayev <eugenia@xxxxxxxxxxxx>
Cc: Eitan Rabin <rabin@xxxxxxxxxxxx>
Cc: Feras Daoud <ferasda@xxxxxxxxxxxx>
Cc: Sagar Arun Kamble <sagar.a.kamble@xxxxxxxxx>
Cc: Miroslav Lichvar <mlichvar@xxxxxxxxxx>
Cc: netdev@xxxxxxxxxxxxxxx
Cc: linux-rdma@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | 18 +++++++++++-------
1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
index 8cb6838..071f78a 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
@@ -458,6 +458,7 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev)
u64 ns;
u64 frac = 0;
u32 dev_freq;
+ u32 mult, shift;

dev_freq = MLX5_CAP_GEN(mdev, device_frequency_khz);
if (!dev_freq) {
@@ -465,13 +466,16 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev)
return;
}
rwlock_init(&clock->lock);
- cc->read = read_internal_timer;
- cc->shift = MLX5_CYCLES_SHIFT;
- cc->mult = clocksource_khz2mult(dev_freq, cc->shift);
- clock->nominal_c_mult = cc->mult;
- cc->mask = CLOCKSOURCE_MASK(41);
-
- timecounter_init(&clock->tc, ktime_to_ns(ktime_get_real()));
+ shift = MLX5_CYCLES_SHIFT;
+ mult = clocksource_khz2mult(dev_freq, shift);
+ clock->nominal_c_mult = mult;
+
+ timecounter_initialize(&clock->tc,
+ read_internal_timer,
+ CLOCKSOURCE_MASK(41),
+ mult,
+ shift,
+ ktime_to_ns(ktime_get_real()));

/* Calculate period in seconds to call the overflow watchdog - to make
* sure counter is checked at least once every wrap around.
--
1.9.1