Skip to content

Commit

Permalink
nfp: make bar_lock a semaphore
Browse files Browse the repository at this point in the history
We will need to release the bar lock from a workqueue
so move from a mutex to a semaphore.  This lock should
not be too hot.  Unfortunately semaphores don't have
lockdep support.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jakub Kicinski authored and David S. Miller committed Jun 6, 2019
1 parent 76581af commit 3ed77bf
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
7 changes: 4 additions & 3 deletions drivers/net/ethernet/netronome/nfp/nfp_net.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include <linux/netdevice.h>
#include <linux/pci.h>
#include <linux/io-64-nonatomic-hi-lo.h>
#include <linux/semaphore.h>
#include <net/xdp.h>

#include "nfp_net_ctrl.h"
Expand Down Expand Up @@ -620,7 +621,7 @@ struct nfp_net {
struct timer_list reconfig_timer;
u32 reconfig_in_progress_update;

struct mutex bar_lock;
struct semaphore bar_lock;

u32 rx_coalesce_usecs;
u32 rx_coalesce_max_frames;
Expand Down Expand Up @@ -848,12 +849,12 @@ static inline void nfp_ctrl_unlock(struct nfp_net *nn)

static inline void nn_ctrl_bar_lock(struct nfp_net *nn)
{
mutex_lock(&nn->bar_lock);
down(&nn->bar_lock);
}

static inline void nn_ctrl_bar_unlock(struct nfp_net *nn)
{
mutex_unlock(&nn->bar_lock);
up(&nn->bar_lock);
}

/* Globals */
Expand Down
8 changes: 1 addition & 7 deletions drivers/net/ethernet/netronome/nfp/nfp_net_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@
#include <linux/interrupt.h>
#include <linux/ip.h>
#include <linux/ipv6.h>
#include <linux/lockdep.h>
#include <linux/mm.h>
#include <linux/overflow.h>
#include <linux/page_ref.h>
Expand Down Expand Up @@ -275,8 +274,6 @@ static int __nfp_net_reconfig(struct nfp_net *nn, u32 update)
{
int ret;

lockdep_assert_held(&nn->bar_lock);

nfp_net_reconfig_sync_enter(nn);

nfp_net_reconfig_start(nn, update);
Expand Down Expand Up @@ -331,7 +328,6 @@ int nfp_net_mbox_reconfig(struct nfp_net *nn, u32 mbox_cmd)
u32 mbox = nn->tlv_caps.mbox_off;
int ret;

lockdep_assert_held(&nn->bar_lock);
nn_writeq(nn, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);

ret = __nfp_net_reconfig(nn, NFP_NET_CFG_UPDATE_MBOX);
Expand Down Expand Up @@ -3702,7 +3698,7 @@ nfp_net_alloc(struct pci_dev *pdev, void __iomem *ctrl_bar, bool needs_netdev,
nn->dp.txd_cnt = NFP_NET_TX_DESCS_DEFAULT;
nn->dp.rxd_cnt = NFP_NET_RX_DESCS_DEFAULT;

mutex_init(&nn->bar_lock);
sema_init(&nn->bar_lock, 1);

spin_lock_init(&nn->reconfig_lock);
spin_lock_init(&nn->link_status_lock);
Expand Down Expand Up @@ -3732,8 +3728,6 @@ void nfp_net_free(struct nfp_net *nn)
{
WARN_ON(timer_pending(&nn->reconfig_timer) || nn->reconfig_posted);

mutex_destroy(&nn->bar_lock);

if (nn->dp.netdev)
free_netdev(nn->dp.netdev);
else
Expand Down

0 comments on commit 3ed77bf

Please sign in to comment.