linux-sg2042/include/linux/mlx5
Bodong Wang 6f4e02193c net/mlx5: E-Switch, Use atomic rep state to serialize state change
When the state of rep was introduced, it was also designed to prevent
duplicate unloading of the same rep. Considering the following two
flows when an eswitch manager is at switchdev mode with n VF reps loaded.

+--------------------------------------+--------------------------------+
| cpu-0                                | cpu-1                          |
| --------                             | --------                       |
| mlx5_ib_remove                       | mlx5_eswitch_disable_sriov     |
|  mlx5_ib_unregister_vport_reps       |  esw_offloads_cleanup          |
|   mlx5_eswitch_unregister_vport_reps |   esw_offloads_unload_all_reps |
|    __unload_reps_all_vport           |    __unload_reps_all_vport     |
+--------------------------------------+--------------------------------+

These two flows will try to unload the same rep. Per original design,
once one flow unloads the rep, the state moves to REGISTERED. The 2nd
flow will no longer needs to do the unload and bails out. However, as
read and write of the state is not atomic, when 1st flow is doing the
unload, the state is still LOADED, 2nd flow is able to do the same
unload action. Kernel crash will happen.

To solve this, driver should do atomic test-and-set for the state. So
that only one flow can change the rep state from LOADED to REGISTERED,
and proceed to do the actual unloading.

Since the state is changing to atomic type, all other read/write should
be atomic action as well.

Fixes: f121e0ea95 (net/mlx5: E-Switch, Add state to eswitch vport representors)
Signed-off-by: Bodong Wang <bodong@mellanox.com>
Reviewed-by: Parav Pandit <parav@mellanox.com>
Reviewed-by: Vu Pham <vuhuong@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2019-05-01 14:39:17 -07:00
..
accel.h net/mlx5: IPSec, Add support for ESN 2018-03-07 15:54:36 -08:00
cmd.h
cq.h net/mlx5: Remove spinlock support from mlx5_write64 2019-04-02 12:49:37 -07:00
device.h Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux 2019-05-01 13:57:48 -07:00
doorbell.h net/mlx5: Remove spinlock support from mlx5_write64 2019-04-02 12:49:37 -07:00
driver.h Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux 2019-05-01 13:57:48 -07:00
eq.h net/mlx5: EQ, Introduce atomic notifier chain subscription API 2018-11-26 13:39:33 -08:00
eswitch.h net/mlx5: E-Switch, Use atomic rep state to serialize state change 2019-05-01 14:39:17 -07:00
fs.h net/mlx5: Add support in RDMA RX steering 2019-04-29 16:55:05 -07:00
fs_helpers.h {net,IB}/mlx5: Add ipsec helper 2018-04-04 12:06:27 -06:00
mlx5_ifc.h Merge branch 'mlx5-next' of git://git.kernel.org/pub/scm/linux/kernel/git/mellanox/linux 2019-05-01 13:57:48 -07:00
mlx5_ifc_fpga.h net/mlx5: Accel, add TLS rx offload routines 2018-07-16 00:13:11 -07:00
port.h net/mlx5e: ethtool, Add support for EEPROM high pages query 2019-05-01 14:39:16 -07:00
qp.h net/mlx5e: XDP, Inline small packets into the TX MPWQE in XDP xmit flow 2019-04-23 12:09:20 -07:00
transobj.h net/mlx5: Introduce new TIR creation core API 2019-04-24 12:33:37 -07:00
vport.h net/mlx5: Remove unused mlx5_query_nic_vport_vlans 2019-05-01 14:39:16 -07:00