]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
nfp: make bar_lock a semaphore
authorJakub Kicinski <jakub.kicinski@netronome.com>
Wed, 5 Jun 2019 21:11:32 +0000 (14:11 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 6 Jun 2019 21:13:39 +0000 (14:13 -0700)
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>
drivers/net/ethernet/netronome/nfp/nfp_net.h
drivers/net/ethernet/netronome/nfp/nfp_net_common.c

index df9aff2684ed0a57ed9c70451b384e270433ce67..e006b3abc9f6f2cfbb66350bef78e7b1f9af2884 100644 (file)
@@ -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 */
index 0c163b086de5b8dc081f38f4381699077d4dfd06..39d70936c741df40799516ecba05341659ff5e46 100644 (file)
@@ -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