net/mlx5: Move the esw mode notifier chain outside the devlink lock

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>
This commit is contained in:
Cosmin Ratiu
2025-11-16 22:45:36 +02:00
committed by Jakub Kicinski
parent b6b03097f9
commit 3fee828789
5 changed files with 17 additions and 12 deletions

View 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);
}
/**

View 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);

View 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;
}

View 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);

View 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;