Commit 8a38f2cc authored by Jakub Kicinski's avatar Jakub Kicinski

eth: nfp: wrap locking assertions in helpers

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: default avatarJakub Kicinski <kuba@kernel.org>
parent 2cb7b489
...@@ -266,7 +266,7 @@ nfp_flower_reprs_reify(struct nfp_app *app, enum nfp_repr_type type, ...@@ -266,7 +266,7 @@ nfp_flower_reprs_reify(struct nfp_app *app, enum nfp_repr_type type,
int i, err, count = 0; int i, err, count = 0;
reprs = rcu_dereference_protected(app->reprs[type], reprs = rcu_dereference_protected(app->reprs[type],
lockdep_is_held(&app->pf->lock)); nfp_app_is_locked(app));
if (!reprs) if (!reprs)
return 0; return 0;
...@@ -295,7 +295,7 @@ nfp_flower_wait_repr_reify(struct nfp_app *app, atomic_t *replies, int tot_repl) ...@@ -295,7 +295,7 @@ nfp_flower_wait_repr_reify(struct nfp_app *app, atomic_t *replies, int tot_repl)
if (!tot_repl) if (!tot_repl)
return 0; return 0;
lockdep_assert_held(&app->pf->lock); assert_nfp_app_locked(app);
if (!wait_event_timeout(priv->reify_wait_queue, if (!wait_event_timeout(priv->reify_wait_queue,
atomic_read(replies) >= tot_repl, atomic_read(replies) >= tot_repl,
NFP_FL_REPLY_TIMEOUT)) { NFP_FL_REPLY_TIMEOUT)) {
......
...@@ -121,7 +121,7 @@ struct nfp_reprs * ...@@ -121,7 +121,7 @@ struct nfp_reprs *
nfp_reprs_get_locked(struct nfp_app *app, enum nfp_repr_type type) nfp_reprs_get_locked(struct nfp_app *app, enum nfp_repr_type type)
{ {
return rcu_dereference_protected(app->reprs[type], return rcu_dereference_protected(app->reprs[type],
lockdep_is_held(&app->pf->lock)); nfp_app_is_locked(app));
} }
struct nfp_reprs * struct nfp_reprs *
......
...@@ -4,10 +4,12 @@ ...@@ -4,10 +4,12 @@
#ifndef _NFP_APP_H #ifndef _NFP_APP_H
#define _NFP_APP_H 1 #define _NFP_APP_H 1
#include <linux/lockdep.h>
#include <net/devlink.h> #include <net/devlink.h>
#include <trace/events/devlink.h> #include <trace/events/devlink.h>
#include "nfp_main.h"
#include "nfp_net_repr.h" #include "nfp_net_repr.h"
#define NFP_APP_CTRL_MTU_MAX U32_MAX #define NFP_APP_CTRL_MTU_MAX U32_MAX
...@@ -174,6 +176,13 @@ struct nfp_app { ...@@ -174,6 +176,13 @@ struct nfp_app {
void *priv; 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); 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);
bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb); bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
......
...@@ -20,7 +20,7 @@ struct net_device * ...@@ -20,7 +20,7 @@ struct net_device *
nfp_repr_get_locked(struct nfp_app *app, struct nfp_reprs *set, unsigned int id) nfp_repr_get_locked(struct nfp_app *app, struct nfp_reprs *set, unsigned int id)
{ {
return rcu_dereference_protected(set->reprs[id], return rcu_dereference_protected(set->reprs[id],
lockdep_is_held(&app->pf->lock)); nfp_app_is_locked(app));
} }
static void static void
...@@ -476,7 +476,7 @@ nfp_reprs_clean_and_free_by_type(struct nfp_app *app, enum nfp_repr_type type) ...@@ -476,7 +476,7 @@ nfp_reprs_clean_and_free_by_type(struct nfp_app *app, enum nfp_repr_type type)
int i; int i;
reprs = rcu_dereference_protected(app->reprs[type], reprs = rcu_dereference_protected(app->reprs[type],
lockdep_is_held(&app->pf->lock)); nfp_app_is_locked(app));
if (!reprs) if (!reprs)
return; return;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment