linux_dsm_epyc7002/drivers/net/ethernet
Parav Pandit 8e0aa4bc95 net/mlx5: E-switch, Protect eswitch mode changes
Currently eswitch mode change is occurring from 2 different execution
contexts as below.
1. sriov sysfs enable/disable
2. devlink eswitch set commands

Both of them need to access eswitch related data structures in
synchronized manner.
Without any synchronization below race condition exist.

SR-IOV enable/disable with devlink eswitch mode change:

          cpu-0                         cpu-1
          -----                         -----
mlx5_device_disable_sriov()        mlx5_devlink_eswitch_mode_set()
  mlx5_eswitch_disable()             esw_offloads_stop()
    esw_offloads_disable()             mlx5_eswitch_disable()
                                         esw_offloads_disable()

Hence, they are synchronized using a new mode_lock.
eswitch's state_lock is not used as it can lead to a deadlock scenario
below and state_lock is only for vport and fdb exclusive access.

ip link set vf <param>
  netlink rcv_msg() - Lock A
    rtnl_lock
    vfinfo()
      esw->state_lock() - Lock B
devlink eswitch_set
   devlink_mutex
     esw->state_lock() - Lock B
       attach_netdev()
         register_netdev()
           rtnl_lock - Lock A

Alternatives considered:
1. Acquiring rtnl lock before taking esw->state_lock to follow similar
locking sequence as ip link flow during eswitch mode set.
rtnl lock is not good idea for two reasons.
(a) Holding rtnl lock for several hundred device commands is not good
    idea.
(b) It leads to below and more similar deadlocks.

devlink eswitch_set
   devlink_mutex
     rtnl_lock - Lock A
       esw->state_lock() - Lock B
         eswitch_disable()
           reload()
             ib_register_device()
               ib_cache_setup_one()
                 rtnl_lock()

2. Exporting devlink lock may lead to undesired use of it in vendor
driver(s) in future.

3. Unloading representors outside of the mode_lock requires
serialization with other process trying to enable the eswitch.

4. Differing the representors life cycle to a different workqueue
requires synchronization with func_change_handler workqueue.

Reviewed-by: Roi Dayan <roid@mellanox.com>
Reviewed-by: Bodong Wang <bodong@mellanox.com>
Reviewed-by: Mark Bloch <markb@mellanox.com>
Signed-off-by: Parav Pandit <parav@mellanox.com>
Signed-off-by: Saeed Mahameed <saeedm@mellanox.com>
2020-03-25 23:19:25 -07:00
..
3com net: typhoon: Add required whitespace after keywords 2020-03-23 22:10:28 -07:00
8390
adaptec net/adaptec: Clean driver versions 2020-02-24 11:23:36 -08:00
aeroflex net/aeroflex: Don't assign FW if it is not available 2020-02-24 11:23:37 -08:00
agere net/agere: Delete unneeded driver version 2020-02-24 11:23:37 -08:00
alacritech net/alacritech: Delete driver version 2020-02-24 11:23:37 -08:00
allwinner net/allwinner: Remove driver version 2020-02-24 11:23:37 -08:00
alteon net/alteon: Properly report FW version 2020-02-24 11:23:37 -08:00
altera net/althera: Delete hardcoded driver version 2020-02-24 11:23:37 -08:00
amazon net: ena: ethtool: clean up minor indentation issue 2020-03-14 20:50:27 -07:00
amd xgbe: let core reject the unsupported coalescing parameters 2020-03-05 12:12:34 -08:00
apm net/apm: Properly mark absence of FW 2020-02-24 11:24:47 -08:00
apple
aquantia net: aquantia: reject all unsupported coalescing params 2020-03-10 16:28:52 -07:00
arc net/arc: Delete driver version 2020-02-24 11:24:47 -08:00
atheros net: ag71xx: port to phylink 2020-02-29 21:34:20 -08:00
aurora
broadcom net: rename flow_action_hw_stats_types* -> flow_action_hw_stats* 2020-03-17 21:12:39 -07:00
brocade net: bna: reject unsupported coalescing params 2020-03-10 16:28:53 -07:00
cadence net: macb: use resolved link config in mac_link_up() 2020-02-27 12:02:14 -08:00
calxeda
cavium net: thunderx: remove set but not used variable 'tail' 2020-03-23 21:53:32 -07:00
chelsio cxgb4: remove set but not used variable 'tab' 2020-03-25 11:18:27 -07:00
cirrus net/cirrus: Delete driver version 2020-03-03 17:54:54 -08:00
cisco enic: let core reject the unsupported coalescing parameters 2020-03-05 12:12:34 -08:00
cortina net: gemini: reject unsupported coalescing params 2020-03-10 16:28:53 -07:00
davicom net/davicom: Delete ethtool version assignment 2020-03-03 17:54:54 -08:00
dec net: tulip: Replace zero-length array with flexible-array member 2020-03-05 14:55:48 -08:00
dlink net/dlink: Remove driver version and release date 2020-03-03 17:54:54 -08:00
emulex net: be2net: reject unsupported coalescing params 2020-03-12 11:32:35 -07:00
ezchip
faraday ftgmac100: Remove redundant judgement 2020-03-11 13:38:19 -07:00
freescale enetc: Remove unused variable 'enetc_drv_name' 2020-03-23 13:09:32 -07:00
fujitsu
google
hisilicon net: hns3: refactor mailbox response scheme between PF and VF 2020-03-21 20:22:25 -07:00
huawei hinic: fix a bug of rss configuration 2020-02-27 11:08:01 -08:00
i825xx Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-01-28 16:02:33 -08:00
ibm Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-03-12 22:34:48 -07:00
intel ice: add board identifier info to devlink .info_get 2020-03-21 01:02:19 -07:00
marvell octeontx2-pf: Remove wrapper APIs for mutex lock and unlock 2020-03-23 21:11:44 -07:00
mediatek net: phylink: propagate resolved link config via mac_link_up() 2020-02-27 12:02:14 -08:00
mellanox net/mlx5: E-switch, Protect eswitch mode changes 2020-03-25 23:19:25 -07:00
micrel Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-02-27 18:31:39 -08:00
microchip
moxa
mscc net: rename flow_action_hw_stats_types* -> flow_action_hw_stats* 2020-03-17 21:12:39 -07:00
myricom net: myri10ge: reject unsupported coalescing params 2020-03-14 21:13:54 -07:00
natsemi net/macsonic: Remove interrupt handler wrapper 2020-02-16 19:48:22 -08:00
neterion
netronome devlink: promote "fw.bundle_id" to a generic info version 2020-03-21 00:57:16 -07:00
ni net: nixge: let core reject the unsupported coalescing parameters 2020-03-14 21:13:54 -07:00
nvidia
nxp
oki-semi
packetengines
pasemi
pensando ionic: check for NULL structs on teardown 2020-03-21 19:56:04 -07:00
qlogic net: rename flow_action_hw_stats_types* -> flow_action_hw_stats* 2020-03-17 21:12:39 -07:00
qualcomm net: rmnet: set NETIF_F_LLTX flag 2020-03-08 21:36:37 -07:00
rdc
realtek r8169: improve RTL8168b FIFO overflow workaround 2020-03-23 21:38:21 -07:00
renesas sh_eth: use Gigabit register map for R7S72100 2020-02-16 19:44:41 -08:00
rocker
samsung net: sxgbe: reject unsupported coalescing params 2020-03-14 21:13:55 -07:00
seeq
sfc net: sfc: reject unsupported coalescing params 2020-03-17 20:56:57 -07:00
sgi net: sgi: ioc3-eth: Remove phy workaround 2020-03-09 10:09:45 -07:00
silan
sis
smsc Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-01-28 16:02:33 -08:00
socionext net: socionext: reject unsupported coalescing params 2020-03-17 20:56:57 -07:00
stmicro net: sched: rename more stats_types 2020-03-23 20:54:23 -07:00
sun net: sun: use pci_status_get_and_clear_errors 2020-03-04 14:21:00 -08:00
synopsys net: dwc-xlgmac: let core reject the unsupported coalescing parameters 2020-03-17 20:56:57 -07:00
tehuti net: tehuti: reject unsupported coalescing params 2020-03-17 20:56:57 -07:00
ti net: davinci_emac: reject unsupported coalescing params 2020-03-17 20:56:58 -07:00
toshiba toshiba: Replace zero-length array with flexible-array member 2020-02-24 15:26:17 -08:00
tundra
via net: via: reject unsupported coalescing params 2020-03-14 21:13:55 -07:00
wiznet
xilinx net: axienet: Allow DMA to beyond 4GB 2020-03-24 16:33:05 -07:00
xircom
xscale
dnet.c net/dnet: Delete static version from the driver 2020-03-03 17:54:55 -08:00
dnet.h net/dnet: Delete static version from the driver 2020-03-03 17:54:55 -08:00
ec_bhf.c
ethoc.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-01-28 16:02:33 -08:00
fealnx.c net/fealnx: Delete driver version 2020-03-03 17:54:55 -08:00
jme.c net: jme: reject unsupported coalescing params 2020-03-14 21:13:54 -07:00
jme.h
Kconfig
korina.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-01-28 16:02:33 -08:00
lantiq_etop.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net-next 2020-01-28 16:02:33 -08:00
lantiq_xrx200.c
Makefile