Skip to content

Commit ccb717a

Browse files
Jianbo LiuPaolo Abeni
authored andcommitted
net/mlx5: Add init and destruction functions for a single HW clock
Move hardware clock initialization and destruction to the functions, which will be used for dynamically allocated clock. Such clock is shared by all the devices if the queried clock identities are same. The out_work is for PPS out event, which can't be triggered when clock is shared, so INIT_WORK is not moved to the initialization function. Besides, we still need to register notifier for each device. Signed-off-by: Jianbo Liu <jianbol@nvidia.com> Reviewed-by: Carolina Jubran <cjubran@nvidia.com> Reviewed-by: Dragos Tatulea <dtatulea@nvidia.com> Signed-off-by: Tariq Toukan <tariqt@nvidia.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 9f722fb commit ccb717a

File tree

1 file changed

+31
-17
lines changed
  • drivers/net/ethernet/mellanox/mlx5/core/lib

1 file changed

+31
-17
lines changed

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

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1153,17 +1153,11 @@ static void mlx5_init_pps(struct mlx5_core_dev *mdev)
11531153
mlx5_init_pin_config(mdev);
11541154
}
11551155

1156-
void mlx5_init_clock(struct mlx5_core_dev *mdev)
1156+
static void mlx5_init_clock_dev(struct mlx5_core_dev *mdev)
11571157
{
11581158
struct mlx5_clock *clock = &mdev->clock;
11591159

1160-
if (!MLX5_CAP_GEN(mdev, device_frequency_khz)) {
1161-
mlx5_core_warn(mdev, "invalid device_frequency_khz, aborting HW clock init\n");
1162-
return;
1163-
}
1164-
11651160
seqlock_init(&clock->lock);
1166-
INIT_WORK(&clock->pps_info.out_work, mlx5_pps_out);
11671161

11681162
/* Initialize the device clock */
11691163
mlx5_init_timer_clock(mdev);
@@ -1179,32 +1173,52 @@ void mlx5_init_clock(struct mlx5_core_dev *mdev)
11791173
clock->ptp = NULL;
11801174
}
11811175

1182-
MLX5_NB_INIT(&clock->pps_nb, mlx5_pps_event, PPS_EVENT);
1183-
mlx5_eq_notifier_register(mdev, &clock->pps_nb);
1184-
11851176
if (clock->ptp)
11861177
ptp_schedule_worker(clock->ptp, 0);
11871178
}
11881179

1189-
void mlx5_cleanup_clock(struct mlx5_core_dev *mdev)
1180+
static void mlx5_destroy_clock_dev(struct mlx5_core_dev *mdev)
11901181
{
11911182
struct mlx5_clock *clock = &mdev->clock;
11921183

1193-
if (!MLX5_CAP_GEN(mdev, device_frequency_khz))
1194-
return;
1195-
1196-
mlx5_eq_notifier_unregister(mdev, &clock->pps_nb);
11971184
if (clock->ptp) {
11981185
ptp_clock_unregister(clock->ptp);
11991186
clock->ptp = NULL;
12001187
}
12011188

1202-
cancel_work_sync(&clock->pps_info.out_work);
1203-
12041189
if (mdev->clock_info) {
12051190
free_page((unsigned long)mdev->clock_info);
12061191
mdev->clock_info = NULL;
12071192
}
12081193

12091194
kfree(clock->ptp_info.pin_config);
12101195
}
1196+
1197+
void mlx5_init_clock(struct mlx5_core_dev *mdev)
1198+
{
1199+
struct mlx5_clock *clock = &mdev->clock;
1200+
1201+
if (!MLX5_CAP_GEN(mdev, device_frequency_khz)) {
1202+
mlx5_core_warn(mdev, "invalid device_frequency_khz, aborting HW clock init\n");
1203+
return;
1204+
}
1205+
1206+
mlx5_init_clock_dev(mdev);
1207+
1208+
INIT_WORK(&clock->pps_info.out_work, mlx5_pps_out);
1209+
MLX5_NB_INIT(&clock->pps_nb, mlx5_pps_event, PPS_EVENT);
1210+
mlx5_eq_notifier_register(mdev, &clock->pps_nb);
1211+
}
1212+
1213+
void mlx5_cleanup_clock(struct mlx5_core_dev *mdev)
1214+
{
1215+
struct mlx5_clock *clock = &mdev->clock;
1216+
1217+
if (!MLX5_CAP_GEN(mdev, device_frequency_khz))
1218+
return;
1219+
1220+
mlx5_eq_notifier_unregister(mdev, &clock->pps_nb);
1221+
cancel_work_sync(&clock->pps_info.out_work);
1222+
1223+
mlx5_destroy_clock_dev(mdev);
1224+
}

0 commit comments

Comments
 (0)