summaryrefslogtreecommitdiff
path: root/include/net/netdev_lock.h
diff options
context:
space:
mode:
authorJakub Kicinski <kuba@kernel.org>2025-03-25 01:45:32 +0300
committerJakub Kicinski <kuba@kernel.org>2025-03-25 20:06:49 +0300
commit310ae9eb2617c62deedef8f121d7ca1ae774fa76 (patch)
tree2257965b50c36fe428e5040ef6f040e675bbda35 /include/net/netdev_lock.h
parent0a65dcf6249b75c841b4218426b0d246a805c7e0 (diff)
downloadlinux-310ae9eb2617c62deedef8f121d7ca1ae774fa76.tar.xz
net: designate queue -> napi linking as "ops protected"
netdev netlink is the only reader of netdev_{,rx_}queue->napi, and it already holds netdev->lock. Switch protection of the writes to netdev->lock to "ops protected". The expectation will be now that accessing queue->napi will require netdev->lock for "ops locked" drivers, and rtnl_lock for all other drivers. Current "ops locked" drivers don't require any changes. gve and netdevsim use _locked() helpers right next to netif_queue_set_napi() so they must be holding the instance lock. iavf doesn't call it. bnxt is a bit messy but all paths seem locked. Acked-by: Stanislav Fomichev <sdf@fomichev.me> Link: https://patch.msgid.link/20250324224537.248800-7-kuba@kernel.org Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Diffstat (limited to 'include/net/netdev_lock.h')
-rw-r--r--include/net/netdev_lock.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/include/net/netdev_lock.h b/include/net/netdev_lock.h
index efd302375ef2..1c0c9a94cc22 100644
--- a/include/net/netdev_lock.h
+++ b/include/net/netdev_lock.h
@@ -56,6 +56,14 @@ static inline void netdev_ops_assert_locked(const struct net_device *dev)
ASSERT_RTNL();
}
+static inline void
+netdev_ops_assert_locked_or_invisible(const struct net_device *dev)
+{
+ if (dev->reg_state == NETREG_REGISTERED ||
+ dev->reg_state == NETREG_UNREGISTERING)
+ netdev_ops_assert_locked(dev);
+}
+
static inline int netdev_lock_cmp_fn(const struct lockdep_map *a,
const struct lockdep_map *b)
{