]> www.infradead.org Git - users/dwmw2/linux.git/commitdiff
net/mlx5: Don't call timecounter cyc2time directly from 1PPS flow
authorEran Ben Elisha <eranbe@mellanox.com>
Tue, 16 Jun 2020 09:07:10 +0000 (12:07 +0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 29 Oct 2020 08:57:39 +0000 (09:57 +0100)
[ Upstream commit 0d2ffdc8d4002a62de31ff7aa3bef28c843c3cbe ]

Before calling timecounter_cyc2time(), clock->lock must be taken.
Use mlx5_timecounter_cyc2time instead which guarantees a safe access.

Fixes: afc98a0b46d8 ("net/mlx5: Update ptp_clock_event foreach PPS event")
Signed-off-by: Eran Ben Elisha <eranbe@mellanox.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c

index 75fc283cacc36427916b4abc87ccc4e7e5d20e71..492ff2ef9a40462547a1983829b11e00a8c69171 100644 (file)
@@ -498,8 +498,9 @@ static int mlx5_pps_event(struct notifier_block *nb,
        switch (clock->ptp_info.pin_config[pin].func) {
        case PTP_PF_EXTTS:
                ptp_event.index = pin;
-               ptp_event.timestamp = timecounter_cyc2time(&clock->tc,
-                                       be64_to_cpu(eqe->data.pps.time_stamp));
+               ptp_event.timestamp =
+                       mlx5_timecounter_cyc2time(clock,
+                                                 be64_to_cpu(eqe->data.pps.time_stamp));
                if (clock->pps_info.enabled) {
                        ptp_event.type = PTP_CLOCK_PPSUSR;
                        ptp_event.pps_times.ts_real =