@@ -2997,7 +2997,6 @@ int mlx5_ib_dev_res_srq_init(struct mlx5_ib_dev *dev)
29972997static int mlx5_ib_dev_res_init (struct mlx5_ib_dev * dev )
29982998{
29992999 struct mlx5_ib_resources * devr = & dev -> devr ;
3000- int port ;
30013000 int ret ;
30023001
30033002 if (!MLX5_CAP_GEN (dev -> mdev , xrc ))
@@ -3013,10 +3012,6 @@ static int mlx5_ib_dev_res_init(struct mlx5_ib_dev *dev)
30133012 return ret ;
30143013 }
30153014
3016- for (port = 0 ; port < ARRAY_SIZE (devr -> ports ); ++ port )
3017- INIT_WORK (& devr -> ports [port ].pkey_change_work ,
3018- pkey_change_handler );
3019-
30203015 mutex_init (& devr -> cq_lock );
30213016 mutex_init (& devr -> srq_lock );
30223017
@@ -3026,16 +3021,6 @@ static int mlx5_ib_dev_res_init(struct mlx5_ib_dev *dev)
30263021static void mlx5_ib_dev_res_cleanup (struct mlx5_ib_dev * dev )
30273022{
30283023 struct mlx5_ib_resources * devr = & dev -> devr ;
3029- int port ;
3030-
3031- /*
3032- * Make sure no change P_Key work items are still executing.
3033- *
3034- * At this stage, the mlx5_ib_event should be unregistered
3035- * and it ensures that no new works are added.
3036- */
3037- for (port = 0 ; port < ARRAY_SIZE (devr -> ports ); ++ port )
3038- cancel_work_sync (& devr -> ports [port ].pkey_change_work );
30393024
30403025 /* After s0/s1 init, they are not unset during the device lifetime. */
30413026 if (devr -> s1 ) {
@@ -4470,6 +4455,13 @@ static void mlx5_ib_stage_delay_drop_cleanup(struct mlx5_ib_dev *dev)
44704455
44714456static int mlx5_ib_stage_dev_notifier_init (struct mlx5_ib_dev * dev )
44724457{
4458+ struct mlx5_ib_resources * devr = & dev -> devr ;
4459+ int port ;
4460+
4461+ for (port = 0 ; port < ARRAY_SIZE (devr -> ports ); ++ port )
4462+ INIT_WORK (& devr -> ports [port ].pkey_change_work ,
4463+ pkey_change_handler );
4464+
44734465 dev -> mdev_events .notifier_call = mlx5_ib_event ;
44744466 mlx5_notifier_register (dev -> mdev , & dev -> mdev_events );
44754467
@@ -4480,8 +4472,14 @@ static int mlx5_ib_stage_dev_notifier_init(struct mlx5_ib_dev *dev)
44804472
44814473static void mlx5_ib_stage_dev_notifier_cleanup (struct mlx5_ib_dev * dev )
44824474{
4475+ struct mlx5_ib_resources * devr = & dev -> devr ;
4476+ int port ;
4477+
44834478 mlx5r_macsec_event_unregister (dev );
44844479 mlx5_notifier_unregister (dev -> mdev , & dev -> mdev_events );
4480+
4481+ for (port = 0 ; port < ARRAY_SIZE (devr -> ports ); ++ port )
4482+ cancel_work_sync (& devr -> ports [port ].pkey_change_work );
44854483}
44864484
44874485void mlx5_ib_data_direct_bind (struct mlx5_ib_dev * ibdev ,
@@ -4571,9 +4569,6 @@ static const struct mlx5_ib_profile pf_profile = {
45714569 STAGE_CREATE (MLX5_IB_STAGE_DEVICE_RESOURCES ,
45724570 mlx5_ib_dev_res_init ,
45734571 mlx5_ib_dev_res_cleanup ),
4574- STAGE_CREATE (MLX5_IB_STAGE_DEVICE_NOTIFIER ,
4575- mlx5_ib_stage_dev_notifier_init ,
4576- mlx5_ib_stage_dev_notifier_cleanup ),
45774572 STAGE_CREATE (MLX5_IB_STAGE_ODP ,
45784573 mlx5_ib_odp_init_one ,
45794574 mlx5_ib_odp_cleanup_one ),
@@ -4598,6 +4593,9 @@ static const struct mlx5_ib_profile pf_profile = {
45984593 STAGE_CREATE (MLX5_IB_STAGE_IB_REG ,
45994594 mlx5_ib_stage_ib_reg_init ,
46004595 mlx5_ib_stage_ib_reg_cleanup ),
4596+ STAGE_CREATE (MLX5_IB_STAGE_DEVICE_NOTIFIER ,
4597+ mlx5_ib_stage_dev_notifier_init ,
4598+ mlx5_ib_stage_dev_notifier_cleanup ),
46014599 STAGE_CREATE (MLX5_IB_STAGE_POST_IB_REG_UMR ,
46024600 mlx5_ib_stage_post_ib_reg_umr_init ,
46034601 NULL ),
@@ -4634,9 +4632,6 @@ const struct mlx5_ib_profile raw_eth_profile = {
46344632 STAGE_CREATE (MLX5_IB_STAGE_DEVICE_RESOURCES ,
46354633 mlx5_ib_dev_res_init ,
46364634 mlx5_ib_dev_res_cleanup ),
4637- STAGE_CREATE (MLX5_IB_STAGE_DEVICE_NOTIFIER ,
4638- mlx5_ib_stage_dev_notifier_init ,
4639- mlx5_ib_stage_dev_notifier_cleanup ),
46404635 STAGE_CREATE (MLX5_IB_STAGE_COUNTERS ,
46414636 mlx5_ib_counters_init ,
46424637 mlx5_ib_counters_cleanup ),
@@ -4658,6 +4653,9 @@ const struct mlx5_ib_profile raw_eth_profile = {
46584653 STAGE_CREATE (MLX5_IB_STAGE_IB_REG ,
46594654 mlx5_ib_stage_ib_reg_init ,
46604655 mlx5_ib_stage_ib_reg_cleanup ),
4656+ STAGE_CREATE (MLX5_IB_STAGE_DEVICE_NOTIFIER ,
4657+ mlx5_ib_stage_dev_notifier_init ,
4658+ mlx5_ib_stage_dev_notifier_cleanup ),
46614659 STAGE_CREATE (MLX5_IB_STAGE_POST_IB_REG_UMR ,
46624660 mlx5_ib_stage_post_ib_reg_umr_init ,
46634661 NULL ),
0 commit comments