Commit 3ed77bf7 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: make bar_lock a semaphore

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: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarDirk van der Merwe <dirk.vandermerwe@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 76581af2
...@@ -17,6 +17,7 @@ ...@@ -17,6 +17,7 @@
#include <linux/netdevice.h> #include <linux/netdevice.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/io-64-nonatomic-hi-lo.h> #include <linux/io-64-nonatomic-hi-lo.h>
#include <linux/semaphore.h>
#include <net/xdp.h> #include <net/xdp.h>
#include "nfp_net_ctrl.h" #include "nfp_net_ctrl.h"
...@@ -620,7 +621,7 @@ struct nfp_net { ...@@ -620,7 +621,7 @@ struct nfp_net {
struct timer_list reconfig_timer; struct timer_list reconfig_timer;
u32 reconfig_in_progress_update; u32 reconfig_in_progress_update;
struct mutex bar_lock; struct semaphore bar_lock;
u32 rx_coalesce_usecs; u32 rx_coalesce_usecs;
u32 rx_coalesce_max_frames; u32 rx_coalesce_max_frames;
...@@ -848,12 +849,12 @@ static inline void nfp_ctrl_unlock(struct nfp_net *nn) ...@@ -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) 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) static inline void nn_ctrl_bar_unlock(struct nfp_net *nn)
{ {
mutex_unlock(&nn->bar_lock); up(&nn->bar_lock);
} }
/* Globals */ /* Globals */
......
...@@ -23,7 +23,6 @@ ...@@ -23,7 +23,6 @@
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/ipv6.h> #include <linux/ipv6.h>
#include <linux/lockdep.h>
#include <linux/mm.h> #include <linux/mm.h>
#include <linux/overflow.h> #include <linux/overflow.h>
#include <linux/page_ref.h> #include <linux/page_ref.h>
...@@ -275,8 +274,6 @@ static int __nfp_net_reconfig(struct nfp_net *nn, u32 update) ...@@ -275,8 +274,6 @@ static int __nfp_net_reconfig(struct nfp_net *nn, u32 update)
{ {
int ret; int ret;
lockdep_assert_held(&nn->bar_lock);
nfp_net_reconfig_sync_enter(nn); nfp_net_reconfig_sync_enter(nn);
nfp_net_reconfig_start(nn, update); nfp_net_reconfig_start(nn, update);
...@@ -331,7 +328,6 @@ int nfp_net_mbox_reconfig(struct nfp_net *nn, u32 mbox_cmd) ...@@ -331,7 +328,6 @@ int nfp_net_mbox_reconfig(struct nfp_net *nn, u32 mbox_cmd)
u32 mbox = nn->tlv_caps.mbox_off; u32 mbox = nn->tlv_caps.mbox_off;
int ret; int ret;
lockdep_assert_held(&nn->bar_lock);
nn_writeq(nn, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd); nn_writeq(nn, mbox + NFP_NET_CFG_MBOX_SIMPLE_CMD, mbox_cmd);
ret = __nfp_net_reconfig(nn, NFP_NET_CFG_UPDATE_MBOX); ret = __nfp_net_reconfig(nn, NFP_NET_CFG_UPDATE_MBOX);
...@@ -3702,7 +3698,7 @@ nfp_net_alloc(struct pci_dev *pdev, void __iomem *ctrl_bar, bool needs_netdev, ...@@ -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.txd_cnt = NFP_NET_TX_DESCS_DEFAULT;
nn->dp.rxd_cnt = NFP_NET_RX_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->reconfig_lock);
spin_lock_init(&nn->link_status_lock); spin_lock_init(&nn->link_status_lock);
...@@ -3732,8 +3728,6 @@ void nfp_net_free(struct nfp_net *nn) ...@@ -3732,8 +3728,6 @@ void nfp_net_free(struct nfp_net *nn)
{ {
WARN_ON(timer_pending(&nn->reconfig_timer) || nn->reconfig_posted); WARN_ON(timer_pending(&nn->reconfig_timer) || nn->reconfig_posted);
mutex_destroy(&nn->bar_lock);
if (nn->dp.netdev) if (nn->dp.netdev)
free_netdev(nn->dp.netdev); free_netdev(nn->dp.netdev);
else else
......
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