Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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>

authored by

Cosmin Ratiu and committed by
Jakub Kicinski
3fee8287 b6b03097

+17 -12
+7 -6
drivers/net/ethernet/mellanox/mlx5/core/eswitch.c
··· 1474 1474 1475 1475 info.new_mode = mode; 1476 1476 1477 - blocking_notifier_call_chain(&esw->n_head, 0, &info); 1477 + blocking_notifier_call_chain(&esw->dev->priv.esw_n_head, 0, &info); 1478 1478 } 1479 1479 1480 1480 static int mlx5_esw_egress_acls_init(struct mlx5_core_dev *dev) ··· 2050 2050 esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_BASIC; 2051 2051 else 2052 2052 esw->offloads.encap = DEVLINK_ESWITCH_ENCAP_MODE_NONE; 2053 - BLOCKING_INIT_NOTIFIER_HEAD(&esw->n_head); 2054 2053 2055 2054 esw_info(dev, 2056 2055 "Total vports %d, per vport: max uc(%d) max mc(%d)\n", ··· 2378 2379 dev1->priv.eswitch->mode == MLX5_ESWITCH_OFFLOADS); 2379 2380 } 2380 2381 2381 - int mlx5_esw_event_notifier_register(struct mlx5_eswitch *esw, struct notifier_block *nb) 2382 + int mlx5_esw_event_notifier_register(struct mlx5_core_dev *dev, 2383 + struct notifier_block *nb) 2382 2384 { 2383 - return blocking_notifier_chain_register(&esw->n_head, nb); 2385 + return blocking_notifier_chain_register(&dev->priv.esw_n_head, nb); 2384 2386 } 2385 2387 2386 - void mlx5_esw_event_notifier_unregister(struct mlx5_eswitch *esw, struct notifier_block *nb) 2388 + void mlx5_esw_event_notifier_unregister(struct mlx5_core_dev *dev, 2389 + struct notifier_block *nb) 2387 2390 { 2388 - blocking_notifier_chain_unregister(&esw->n_head, nb); 2391 + blocking_notifier_chain_unregister(&dev->priv.esw_n_head, nb); 2389 2392 } 2390 2393 2391 2394 /**
+4 -3
drivers/net/ethernet/mellanox/mlx5/core/eswitch.h
··· 403 403 struct { 404 404 u32 large_group_num; 405 405 } params; 406 - struct blocking_notifier_head n_head; 407 406 struct xarray paired; 408 407 struct mlx5_devcom_comp_dev *devcom; 409 408 u16 enabled_ipsec_vf_count; ··· 863 864 u16 new_mode; 864 865 }; 865 866 866 - int mlx5_esw_event_notifier_register(struct mlx5_eswitch *esw, struct notifier_block *n); 867 - void mlx5_esw_event_notifier_unregister(struct mlx5_eswitch *esw, struct notifier_block *n); 867 + int mlx5_esw_event_notifier_register(struct mlx5_core_dev *dev, 868 + struct notifier_block *n); 869 + void mlx5_esw_event_notifier_unregister(struct mlx5_core_dev *dev, 870 + struct notifier_block *n); 868 871 869 872 bool mlx5_esw_hold(struct mlx5_core_dev *dev); 870 873 void mlx5_esw_release(struct mlx5_core_dev *dev);
+2
drivers/net/ethernet/mellanox/mlx5/core/main.c
··· 1834 1834 return err; 1835 1835 } 1836 1836 1837 + BLOCKING_INIT_NOTIFIER_HEAD(&dev->priv.esw_n_head); 1838 + 1837 1839 return 0; 1838 1840 } 1839 1841
+3 -3
drivers/net/ethernet/mellanox/mlx5/core/sf/devlink.c
··· 481 481 xa_init(&table->function_ids); 482 482 dev->priv.sf_table = table; 483 483 table->esw_nb.notifier_call = mlx5_sf_esw_event; 484 - err = mlx5_esw_event_notifier_register(dev->priv.eswitch, &table->esw_nb); 484 + err = mlx5_esw_event_notifier_register(dev, &table->esw_nb); 485 485 if (err) 486 486 goto reg_err; 487 487 ··· 496 496 return 0; 497 497 498 498 vhca_err: 499 - mlx5_esw_event_notifier_unregister(dev->priv.eswitch, &table->esw_nb); 499 + mlx5_esw_event_notifier_unregister(dev, &table->esw_nb); 500 500 reg_err: 501 501 mutex_destroy(&table->sf_state_lock); 502 502 kfree(table); ··· 513 513 514 514 mlx5_blocking_notifier_unregister(dev, &table->mdev_nb); 515 515 mlx5_vhca_event_notifier_unregister(table->dev, &table->vhca_nb); 516 - mlx5_esw_event_notifier_unregister(dev->priv.eswitch, &table->esw_nb); 516 + mlx5_esw_event_notifier_unregister(dev, &table->esw_nb); 517 517 mutex_destroy(&table->sf_state_lock); 518 518 WARN_ON(!xa_empty(&table->function_ids)); 519 519 kfree(table);
+1
include/linux/mlx5/driver.h
··· 599 599 600 600 struct mlx5_flow_steering *steering; 601 601 struct mlx5_mpfs *mpfs; 602 + struct blocking_notifier_head esw_n_head; 602 603 struct mlx5_eswitch *eswitch; 603 604 struct mlx5_core_sriov sriov; 604 605 struct mlx5_lag *lag;