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: 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>
This commit is contained in:
parent
76581af254
commit
3ed77bf766
@ -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"
|
||||
@ -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;
|
||||
@ -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 */
|
||||
|
@ -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>
|
||||
@ -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);
|
||||
@ -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);
|
||||
@ -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);
|
||||
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user