net: hold netdev instance lock during ndo_open/ndo_stop
authorStanislav Fomichev <sdf@fomichev.me>
Wed, 5 Mar 2025 16:37:19 +0000 (08:37 -0800)
committerJakub Kicinski <kuba@kernel.org>
Thu, 6 Mar 2025 20:59:43 +0000 (12:59 -0800)
commitd4c22ec680c8db832ffc0b964c6008e65436cba8
tree0192f20d1598d69c93b8932a1df6f7cc1941cc88
parentf130a0cc1b4ff1ef28a307428d40436032e2b66e
net: hold netdev instance lock during ndo_open/ndo_stop

For the drivers that use shaper API, switch to the mode where
core stack holds the netdev lock. This affects two drivers:

* iavf - already grabs netdev lock in ndo_open/ndo_stop, so mostly
         remove these
* netdevsim - switch to _locked APIs to avoid deadlock

iavf_close diff is a bit confusing, the existing call looks like this:
  iavf_close() {
    netdev_lock()
    ..
    netdev_unlock()
    wait_event_timeout(down_waitqueue)
  }

I change it to the following:
  netdev_lock()
  iavf_close() {
    ..
    netdev_unlock()
    wait_event_timeout(down_waitqueue)
    netdev_lock() // reusing this lock call
  }
  netdev_unlock()

Since I'm reusing existing netdev_lock call, so it looks like I only
add netdev_unlock.

Cc: Saeed Mahameed <saeed@kernel.org>
Signed-off-by: Stanislav Fomichev <sdf@fomichev.me>
Link: https://patch.msgid.link/20250305163732.2766420-2-sdf@fomichev.me
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/intel/iavf/iavf_main.c
drivers/net/netdevsim/netdev.c
include/linux/netdevice.h
net/core/dev.c
net/core/dev.h