liquidio: Overcome missing device lock protection in init/remove flows
authorLeon Romanovsky <leonro@nvidia.com>
Sat, 25 Sep 2021 11:22:43 +0000 (14:22 +0300)
committerDavid S. Miller <davem@davemloft.net>
Mon, 27 Sep 2021 15:31:58 +0000 (16:31 +0100)
commit8d44b5cf60602568f951fbff86f1e0e0435d2a57
tree74e84f1e451c6bc03cfaf0fcfd8056f462ac8be4
parent5df290e7a70367d476406420d19c4dea14d45dd1
liquidio: Overcome missing device lock protection in init/remove flows

The liquidio driver is broken by design. It initialize PCI devices
in separate delayed works. It causes to the situation where device lock
is dropped during initialize and remove sequences.

That lock is part of driver/core and needed to protect from races during
init, destroy and bus invocations.

In addition to lack of locking protection, it has incorrect order of
destroy flows and very questionable synchronization scheme based on
atomic_t.

This change doesn't fix that driver but makes sure that rest of the
netdev subsystem doesn't suffer from such basic protection by adding
device_lock over devlink_*() APIs and by moving devlink_register()
to be last command in setup_nic_devices().

Signed-off-by: Leon Romanovsky <leonro@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/cavium/liquidio/lio_main.c