Skip to content

Commit f4e9163

Browse files
committed
net/mlx5: Move PPS notifier and out_work to clock_state
jira LE-3615 Rebuild_History Non-Buildable kernel-5.14.0-570.28.1.el9_6 commit-author Jianbo Liu <jianbol@nvidia.com> commit 79faf9d The PPS notifier is currently in mlx5_clock, and mlx5_clock can be shared in later patch, so the notifier should be registered for each device to avoid any event miss. Besides, the out_work is scheduled by PPS out event which is triggered only when the device is in free running mode. So, both are moved to mlx5_core_dev's clock_state. 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> (cherry picked from commit 79faf9d) Signed-off-by: Jonathan Maple <jmaple@ciq.com>
1 parent 0380262 commit f4e9163

File tree

2 files changed

+18
-21
lines changed

2 files changed

+18
-21
lines changed

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

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,10 @@ enum {
8080
};
8181

8282
struct mlx5_clock_dev_state {
83+
struct mlx5_core_dev *mdev;
8384
struct mlx5_devcom_comp_dev *compdev;
85+
struct mlx5_nb pps_nb;
86+
struct work_struct out_work;
8487
};
8588

8689
struct mlx5_clock_priv {
@@ -336,11 +339,10 @@ static void mlx5_update_clock_info_page(struct mlx5_core_dev *mdev)
336339

337340
static void mlx5_pps_out(struct work_struct *work)
338341
{
339-
struct mlx5_pps *pps_info = container_of(work, struct mlx5_pps,
340-
out_work);
341-
struct mlx5_clock *clock = container_of(pps_info, struct mlx5_clock,
342-
pps_info);
343-
struct mlx5_core_dev *mdev = mlx5_clock_mdev_get(clock);
342+
struct mlx5_clock_dev_state *clock_state = container_of(work, struct mlx5_clock_dev_state,
343+
out_work);
344+
struct mlx5_core_dev *mdev = clock_state->mdev;
345+
struct mlx5_clock *clock = mdev->clock;
344346
u32 in[MLX5_ST_SZ_DW(mtpps_reg)] = {0};
345347
unsigned long flags;
346348
int i;
@@ -1012,16 +1014,16 @@ static u64 perout_conf_next_event_timer(struct mlx5_core_dev *mdev,
10121014
static int mlx5_pps_event(struct notifier_block *nb,
10131015
unsigned long type, void *data)
10141016
{
1015-
struct mlx5_clock *clock = mlx5_nb_cof(nb, struct mlx5_clock, pps_nb);
1017+
struct mlx5_clock_dev_state *clock_state = mlx5_nb_cof(nb, struct mlx5_clock_dev_state,
1018+
pps_nb);
1019+
struct mlx5_core_dev *mdev = clock_state->mdev;
1020+
struct mlx5_clock *clock = mdev->clock;
10161021
struct ptp_clock_event ptp_event;
10171022
struct mlx5_eqe *eqe = data;
10181023
int pin = eqe->data.pps.pin;
1019-
struct mlx5_core_dev *mdev;
10201024
unsigned long flags;
10211025
u64 ns;
10221026

1023-
mdev = mlx5_clock_mdev_get(clock);
1024-
10251027
switch (clock->ptp_info.pin_config[pin].func) {
10261028
case PTP_PF_EXTTS:
10271029
ptp_event.index = pin;
@@ -1045,7 +1047,7 @@ static int mlx5_pps_event(struct notifier_block *nb,
10451047
write_seqlock_irqsave(&clock->lock, flags);
10461048
clock->pps_info.start[pin] = ns;
10471049
write_sequnlock_irqrestore(&clock->lock, flags);
1048-
schedule_work(&clock->pps_info.out_work);
1050+
schedule_work(&clock_state->out_work);
10491051
break;
10501052
default:
10511053
mlx5_core_err(mdev, " Unhandled clock PPS event, func %d\n",
@@ -1271,7 +1273,6 @@ int mlx5_init_clock(struct mlx5_core_dev *mdev)
12711273
{
12721274
u8 identity[MLX5_RT_CLOCK_IDENTITY_SIZE];
12731275
struct mlx5_clock_dev_state *clock_state;
1274-
struct mlx5_clock *clock;
12751276
u64 key;
12761277
int err;
12771278

@@ -1284,6 +1285,7 @@ int mlx5_init_clock(struct mlx5_core_dev *mdev)
12841285
clock_state = kzalloc(sizeof(*clock_state), GFP_KERNEL);
12851286
if (!clock_state)
12861287
return -ENOMEM;
1288+
clock_state->mdev = mdev;
12871289
mdev->clock_state = clock_state;
12881290

12891291
if (MLX5_CAP_MCAM_REG3(mdev, mrtcq) && mlx5_real_time_mode(mdev)) {
@@ -1301,24 +1303,21 @@ int mlx5_init_clock(struct mlx5_core_dev *mdev)
13011303
mdev->clock_state = NULL;
13021304
return err;
13031305
}
1304-
clock = mdev->clock;
13051306

1306-
INIT_WORK(&clock->pps_info.out_work, mlx5_pps_out);
1307-
MLX5_NB_INIT(&clock->pps_nb, mlx5_pps_event, PPS_EVENT);
1308-
mlx5_eq_notifier_register(mdev, &clock->pps_nb);
1307+
INIT_WORK(&mdev->clock_state->out_work, mlx5_pps_out);
1308+
MLX5_NB_INIT(&mdev->clock_state->pps_nb, mlx5_pps_event, PPS_EVENT);
1309+
mlx5_eq_notifier_register(mdev, &mdev->clock_state->pps_nb);
13091310

13101311
return 0;
13111312
}
13121313

13131314
void mlx5_cleanup_clock(struct mlx5_core_dev *mdev)
13141315
{
1315-
struct mlx5_clock *clock = mdev->clock;
1316-
13171316
if (!MLX5_CAP_GEN(mdev, device_frequency_khz))
13181317
return;
13191318

1320-
mlx5_eq_notifier_unregister(mdev, &clock->pps_nb);
1321-
cancel_work_sync(&clock->pps_info.out_work);
1319+
mlx5_eq_notifier_unregister(mdev, &mdev->clock_state->pps_nb);
1320+
cancel_work_sync(&mdev->clock_state->out_work);
13221321

13231322
mlx5_clock_free(mdev);
13241323
mlx5_shared_clock_unregister(mdev);

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@
3838
#define MAX_PIN_NUM 8
3939
struct mlx5_pps {
4040
u8 pin_caps[MAX_PIN_NUM];
41-
struct work_struct out_work;
4241
u64 start[MAX_PIN_NUM];
4342
u8 enabled;
4443
u64 min_npps_period;
@@ -53,7 +52,6 @@ struct mlx5_timer {
5352
};
5453

5554
struct mlx5_clock {
56-
struct mlx5_nb pps_nb;
5755
seqlock_t lock;
5856
struct hwtstamp_config hwtstamp_config;
5957
struct ptp_clock *ptp;

0 commit comments

Comments
 (0)