eth: nfp: wrap locking assertions in helpers
authorJakub Kicinski <kuba@kernel.org>
Tue, 15 Mar 2022 06:00:05 +0000 (23:00 -0700)
committerJakub Kicinski <kuba@kernel.org>
Wed, 16 Mar 2022 19:56:35 +0000 (12:56 -0700)
We can replace the PF lock with devlink instance lock in subsequent
changes. To make the patches easier to comprehend and limit line
lengths - factor out the existing locking assertions.

No functional changes.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/netronome/nfp/flower/main.c
drivers/net/ethernet/netronome/nfp/nfp_app.c
drivers/net/ethernet/netronome/nfp/nfp_app.h
drivers/net/ethernet/netronome/nfp/nfp_net_repr.c

index ac1dcfa..4d960a9 100644 (file)
@@ -266,7 +266,7 @@ nfp_flower_reprs_reify(struct nfp_app *app, enum nfp_repr_type type,
        int i, err, count = 0;
 
        reprs = rcu_dereference_protected(app->reprs[type],
-                                         lockdep_is_held(&app->pf->lock));
+                                         nfp_app_is_locked(app));
        if (!reprs)
                return 0;
 
@@ -295,7 +295,7 @@ nfp_flower_wait_repr_reify(struct nfp_app *app, atomic_t *replies, int tot_repl)
        if (!tot_repl)
                return 0;
 
-       lockdep_assert_held(&app->pf->lock);
+       assert_nfp_app_locked(app);
        if (!wait_event_timeout(priv->reify_wait_queue,
                                atomic_read(replies) >= tot_repl,
                                NFP_FL_REPLY_TIMEOUT)) {
index 3a97328..09f250e 100644 (file)
@@ -121,7 +121,7 @@ struct nfp_reprs *
 nfp_reprs_get_locked(struct nfp_app *app, enum nfp_repr_type type)
 {
        return rcu_dereference_protected(app->reprs[type],
-                                        lockdep_is_held(&app->pf->lock));
+                                        nfp_app_is_locked(app));
 }
 
 struct nfp_reprs *
index 3e9baff..60cb8a7 100644 (file)
@@ -4,10 +4,12 @@
 #ifndef _NFP_APP_H
 #define _NFP_APP_H 1
 
+#include <linux/lockdep.h>
 #include <net/devlink.h>
 
 #include <trace/events/devlink.h>
 
+#include "nfp_main.h"
 #include "nfp_net_repr.h"
 
 #define NFP_APP_CTRL_MTU_MAX   U32_MAX
@@ -174,6 +176,13 @@ struct nfp_app {
        void *priv;
 };
 
+static inline void assert_nfp_app_locked(struct nfp_app *app)
+{
+       lockdep_assert_held(&app->pf->lock);
+}
+
+#define nfp_app_is_locked(app) lockdep_is_held(&(app)->pf->lock)
+
 void nfp_check_rhashtable_empty(void *ptr, void *arg);
 bool __nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
 bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
index 181ac8e..ba3fa7e 100644 (file)
@@ -20,7 +20,7 @@ struct net_device *
 nfp_repr_get_locked(struct nfp_app *app, struct nfp_reprs *set, unsigned int id)
 {
        return rcu_dereference_protected(set->reprs[id],
-                                        lockdep_is_held(&app->pf->lock));
+                                        nfp_app_is_locked(app));
 }
 
 static void
@@ -476,7 +476,7 @@ nfp_reprs_clean_and_free_by_type(struct nfp_app *app, enum nfp_repr_type type)
        int i;
 
        reprs = rcu_dereference_protected(app->reprs[type],
-                                         lockdep_is_held(&app->pf->lock));
+                                         nfp_app_is_locked(app));
        if (!reprs)
                return;