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

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
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -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)) {
+1 −1
Original line number Diff line number Diff line
@@ -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 *
+9 −0
Original line number Diff line number Diff line
@@ -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);
+2 −2
Original line number Diff line number Diff line
@@ -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;