Skip to content

Commit e61e6c4

Browse files
vvfedorenkoPaolo Abeni
authored andcommitted
net/mlx5: use do_aux_work for PHC overflow checks
The overflow_work is using system wq to do overflow checks and updates for PHC device timecounter, which might be overhelmed by other tasks. But there is dedicated kthread in PTP subsystem designed for such things. This patch changes the work queue to proper align with PTP subsystem and to avoid overloading system work queue. The adjfine() function acts the same way as overflow check worker, we can postpone ptp aux worker till the next overflow period after adjfine() was called. Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com> Signed-off-by: Vadim Fedorenko <vadfed@meta.com> Acked-by: Tariq Toukan <tariqt@nvidia.com> Link: https://patch.msgid.link/20250107104812.380225-1-vadfed@meta.com Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent e62de01 commit e61e6c4

File tree

2 files changed

+13
-12
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/lib
  • include/linux/mlx5

2 files changed

+13
-12
lines changed

drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -322,17 +322,16 @@ static void mlx5_pps_out(struct work_struct *work)
322322
}
323323
}
324324

325-
static void mlx5_timestamp_overflow(struct work_struct *work)
325+
static long mlx5_timestamp_overflow(struct ptp_clock_info *ptp_info)
326326
{
327-
struct delayed_work *dwork = to_delayed_work(work);
328327
struct mlx5_core_dev *mdev;
329328
struct mlx5_timer *timer;
330329
struct mlx5_clock *clock;
331330
unsigned long flags;
332331

333-
timer = container_of(dwork, struct mlx5_timer, overflow_work);
334-
clock = container_of(timer, struct mlx5_clock, timer);
332+
clock = container_of(ptp_info, struct mlx5_clock, ptp_info);
335333
mdev = container_of(clock, struct mlx5_core_dev, clock);
334+
timer = &clock->timer;
336335

337336
if (mdev->state == MLX5_DEVICE_STATE_INTERNAL_ERROR)
338337
goto out;
@@ -343,7 +342,7 @@ static void mlx5_timestamp_overflow(struct work_struct *work)
343342
write_sequnlock_irqrestore(&clock->lock, flags);
344343

345344
out:
346-
schedule_delayed_work(&timer->overflow_work, timer->overflow_period);
345+
return timer->overflow_period;
347346
}
348347

349348
static int mlx5_ptp_settime_real_time(struct mlx5_core_dev *mdev,
@@ -517,6 +516,7 @@ static int mlx5_ptp_adjfine(struct ptp_clock_info *ptp, long scaled_ppm)
517516
timer->cycles.mult = mult;
518517
mlx5_update_clock_info_page(mdev);
519518
write_sequnlock_irqrestore(&clock->lock, flags);
519+
ptp_schedule_worker(clock->ptp, timer->overflow_period);
520520

521521
return 0;
522522
}
@@ -852,6 +852,7 @@ static const struct ptp_clock_info mlx5_ptp_clock_info = {
852852
.settime64 = mlx5_ptp_settime,
853853
.enable = NULL,
854854
.verify = NULL,
855+
.do_aux_work = mlx5_timestamp_overflow,
855856
};
856857

857858
static int mlx5_query_mtpps_pin_mode(struct mlx5_core_dev *mdev, u8 pin,
@@ -1052,12 +1053,11 @@ static void mlx5_init_overflow_period(struct mlx5_clock *clock)
10521053
do_div(ns, NSEC_PER_SEC / HZ);
10531054
timer->overflow_period = ns;
10541055

1055-
INIT_DELAYED_WORK(&timer->overflow_work, mlx5_timestamp_overflow);
1056-
if (timer->overflow_period)
1057-
schedule_delayed_work(&timer->overflow_work, 0);
1058-
else
1056+
if (!timer->overflow_period) {
1057+
timer->overflow_period = HZ;
10591058
mlx5_core_warn(mdev,
1060-
"invalid overflow period, overflow_work is not scheduled\n");
1059+
"invalid overflow period, overflow_work is scheduled once per second\n");
1060+
}
10611061

10621062
if (clock_info)
10631063
clock_info->overflow_period = timer->overflow_period;
@@ -1172,6 +1172,9 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev)
11721172

11731173
MLX5_NB_INIT(&clock->pps_nb, mlx5_pps_event, PPS_EVENT);
11741174
mlx5_eq_notifier_register(mdev, &clock->pps_nb);
1175+
1176+
if (clock->ptp)
1177+
ptp_schedule_worker(clock->ptp, 0);
11751178
}
11761179

11771180
void mlx5_cleanup_clock(struct mlx5_core_dev *mdev)
@@ -1188,7 +1191,6 @@ void mlx5_cleanup_clock(struct mlx5_core_dev *mdev)
11881191
}
11891192

11901193
cancel_work_sync(&clock->pps_info.out_work);
1191-
cancel_delayed_work_sync(&clock->timer.overflow_work);
11921194

11931195
if (mdev->clock_info) {
11941196
free_page((unsigned long)mdev->clock_info);

include/linux/mlx5/driver.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,6 @@ struct mlx5_timer {
691691
struct timecounter tc;
692692
u32 nominal_c_mult;
693693
unsigned long overflow_period;
694-
struct delayed_work overflow_work;
695694
};
696695

697696
struct mlx5_clock {

0 commit comments

Comments
 (0)