]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net/mlx5: Move the esw mode notifier chain outside the devlink lock
authorCosmin Ratiu <cratiu@nvidia.com>
Sun, 16 Nov 2025 20:45:36 +0000 (22:45 +0200)
committerJakub Kicinski <kuba@kernel.org>
Thu, 20 Nov 2025 04:32:27 +0000 (20:32 -0800)
The esw mode change notifier chain is initialized/cleaned up in
mlx5_init_one() / mlx5_uninit_one() with the devlink lock held.

Move the notifier head from the eswitch struct into mlx5_priv directly,
and initialize it outside the critical section. This will allow notifier
registration to happen earlier in the init procedure in subsequent
patches.

Signed-off-by: Cosmin Ratiu <cratiu@nvidia.com>
Reviewed-by: Carolina Jubran <cjubran@nvidia.com>
Signed-off-by: Tariq Toukan <tariqt@nvidia.com>
Link: https://patch.msgid.link/1763325940-1231508-3-git-send-email-tariqt@nvidia.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
drivers/net/ethernet/mellanox/mlx5/core/main.c
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c
include/linux/mlx5/driver.h

index 25af8bd7f077953f5d460430d3c51eb3f3177631..3adf2b1cd26accfad150d2d162047f121254456e 100644 (file)
@@ -1474,7 +1474,7 @@ static void mlx5_esw_mode_change_notify(struct mlx5_eswitch *esw, u16 mode)
 
        info.new_mode = mode;
 
-       blocking_notifier_call_chain(&esw->n_head, 0, &info);
+       blocking_notifier_call_chain(&esw->dev->priv.esw_n_head, 0, &info);
 }
 
 static int mlx5_esw_egress_acls_init(struct mlx5_core_dev *dev)
@@ -2050,7 +2050,6 @@ int mlx5_eswitch_init(struct mlx5_core_dev *dev)
                esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_BASIC;
        else
                esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_NONE;
-       BLOCKING_INIT_NOTIFIER_HEAD(&esw->n_head);
 
        esw_info(dev,
                 "Total vports %d, per vport: max uc(%d) max mc(%d)\n",
@@ -2379,14 +2378,16 @@ bool mlx5_esw_multipath_prereq(struct mlx5_core_dev *dev0,
                dev1->priv.eswitch->mode == MLX5_ESWITCH_OFFLOADS);
 }
 
-int mlx5_esw_event_notifier_register(struct mlx5_eswitch *esw, struct notifier_block *nb)
+int mlx5_esw_event_notifier_register(struct mlx5_core_dev *dev,
+                                    struct notifier_block *nb)
 {
-       return blocking_notifier_chain_register(&esw->n_head, nb);
+       return blocking_notifier_chain_register(&dev->priv.esw_n_head, nb);
 }
 
-void mlx5_esw_event_notifier_unregister(struct mlx5_eswitch *esw, struct notifier_block *nb)
+void mlx5_esw_event_notifier_unregister(struct mlx5_core_dev *dev,
+                                       struct notifier_block *nb)
 {
-       blocking_notifier_chain_unregister(&esw->n_head, nb);
+       blocking_notifier_chain_unregister(&dev->priv.esw_n_head, nb);
 }
 
 /**
index beaec450a734365acc976963267e5ff4c21b80bb..ad1073f7b79f78ef34c172f58491f1b3d39ea63a 100644 (file)
@@ -403,7 +403,6 @@ struct mlx5_eswitch {
        struct {
                u32             large_group_num;
        }  params;
-       struct blocking_notifier_head n_head;
        struct xarray paired;
        struct mlx5_devcom_comp_dev *devcom;
        u16 enabled_ipsec_vf_count;
@@ -864,8 +863,10 @@ struct mlx5_esw_event_info {
        u16 new_mode;
 };
 
-int mlx5_esw_event_notifier_register(struct mlx5_eswitch *esw, struct notifier_block *n);
-void mlx5_esw_event_notifier_unregister(struct mlx5_eswitch *esw, struct notifier_block *n);
+int mlx5_esw_event_notifier_register(struct mlx5_core_dev *dev,
+                                    struct notifier_block *n);
+void mlx5_esw_event_notifier_unregister(struct mlx5_core_dev *dev,
+                                       struct notifier_block *n);
 
 bool mlx5_esw_hold(struct mlx5_core_dev *dev);
 void mlx5_esw_release(struct mlx5_core_dev *dev);
index 612fc4de9d3c4053c3569cfa3e8b556bd31bccbe..05f16f3e9c4f19db4eaaeacb14ee91aad03a03ae 100644 (file)
@@ -1834,6 +1834,8 @@ static int mlx5_notifiers_init(struct mlx5_core_dev *dev)
                return err;
        }
 
+       BLOCKING_INIT_NOTIFIER_HEAD(&dev->priv.esw_n_head);
+
        return 0;
 }
 
index 3304f25cc8055c1a3336e3af117d7c27681ea170..2ece4983d33f3268eac6571f43e73d951ffebff5 100644 (file)
@@ -481,7 +481,7 @@ int mlx5_sf_table_init(struct mlx5_core_dev *dev)
        xa_init(&table->function_ids);
        dev->priv.sf_table = table;
        table->esw_nb.notifier_call = mlx5_sf_esw_event;
-       err = mlx5_esw_event_notifier_register(dev->priv.eswitch, &table->esw_nb);
+       err = mlx5_esw_event_notifier_register(dev, &table->esw_nb);
        if (err)
                goto reg_err;
 
@@ -496,7 +496,7 @@ int mlx5_sf_table_init(struct mlx5_core_dev *dev)
        return 0;
 
 vhca_err:
-       mlx5_esw_event_notifier_unregister(dev->priv.eswitch, &table->esw_nb);
+       mlx5_esw_event_notifier_unregister(dev, &table->esw_nb);
 reg_err:
        mutex_destroy(&table->sf_state_lock);
        kfree(table);
@@ -513,7 +513,7 @@ void mlx5_sf_table_cleanup(struct mlx5_core_dev *dev)
 
        mlx5_blocking_notifier_unregister(dev, &table->mdev_nb);
        mlx5_vhca_event_notifier_unregister(table->dev, &table->vhca_nb);
-       mlx5_esw_event_notifier_unregister(dev->priv.eswitch, &table->esw_nb);
+       mlx5_esw_event_notifier_unregister(dev, &table->esw_nb);
        mutex_destroy(&table->sf_state_lock);
        WARN_ON(!xa_empty(&table->function_ids));
        kfree(table);
index 7aec53371cf0552d9769f70c11a562ce1df753f3..9a4a5112a59e607cff2b7a55bab162bc1dc683b5 100644 (file)
@@ -599,6 +599,7 @@ struct mlx5_priv {
 
        struct mlx5_flow_steering *steering;
        struct mlx5_mpfs        *mpfs;
+       struct blocking_notifier_head esw_n_head;
        struct mlx5_eswitch     *eswitch;
        struct mlx5_core_sriov  sriov;
        struct mlx5_lag         *lag;