bnxt: use the devlink instance lock to protect sriov
authorJakub Kicinski <kuba@kernel.org>
Fri, 18 Mar 2022 19:23:40 +0000 (12:23 -0700)
committerDavid S. Miller <davem@davemloft.net>
Mon, 21 Mar 2022 14:11:38 +0000 (14:11 +0000)
In prep for .eswitch_mode_set being called with the devlink instance
lock held use that lock explicitly instead of creating a local mutex
just for the sriov reconfig.

Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/broadcom/bnxt/bnxt.c
drivers/net/ethernet/broadcom/bnxt/bnxt.h
drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c

index 92a1a43b3beece40f9574467ed95181378e82c5c..1c28495875cfcaf1ff8968ca60f460cdf1fd2f8a 100644 (file)
@@ -13470,7 +13470,6 @@ static int bnxt_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
 
 #ifdef CONFIG_BNXT_SRIOV
        init_waitqueue_head(&bp->sriov_cfg_wait);
-       mutex_init(&bp->sriov_lock);
 #endif
        if (BNXT_SUPPORTS_TPA(bp)) {
                bp->gro_func = bnxt_gro_func_5730x;
index 447a9406b8a27137ef97214506fefa45abd3f54e..61aa3e8c59527469df1c2f72544e5d122e1b24a3 100644 (file)
@@ -2072,12 +2072,6 @@ struct bnxt {
        wait_queue_head_t       sriov_cfg_wait;
        bool                    sriov_cfg;
 #define BNXT_SRIOV_CFG_WAIT_TMO        msecs_to_jiffies(10000)
-
-       /* lock to protect VF-rep creation/cleanup via
-        * multiple paths such as ->sriov_configure() and
-        * devlink ->eswitch_mode_set()
-        */
-       struct mutex            sriov_lock;
 #endif
 
 #if BITS_PER_LONG == 32
index 1d177fed44a6c4d0abebe38abf3e0665968b2b2d..ddf2f3963abeef81f35d3580f500af1c4bc223ff 100644 (file)
@@ -846,7 +846,7 @@ void bnxt_sriov_disable(struct bnxt *bp)
                return;
 
        /* synchronize VF and VF-rep create and destroy */
-       mutex_lock(&bp->sriov_lock);
+       devl_lock(bp->dl);
        bnxt_vf_reps_destroy(bp);
 
        if (pci_vfs_assigned(bp->pdev)) {
@@ -859,7 +859,7 @@ void bnxt_sriov_disable(struct bnxt *bp)
                /* Free the HW resources reserved for various VF's */
                bnxt_hwrm_func_vf_resource_free(bp, num_vfs);
        }
-       mutex_unlock(&bp->sriov_lock);
+       devl_unlock(bp->dl);
 
        bnxt_free_vf_resources(bp);
 
index 8eb28e088582069c9e648b2424b1c448e49efe48..b2a9528b456b984b5ed451db9f2e1b9bb9920aa6 100644 (file)
@@ -561,7 +561,7 @@ int bnxt_dl_eswitch_mode_set(struct devlink *devlink, u16 mode,
        struct bnxt *bp = bnxt_get_bp_from_dl(devlink);
        int rc = 0;
 
-       mutex_lock(&bp->sriov_lock);
+       devl_lock(devlink);
        if (bp->eswitch_mode == mode) {
                netdev_info(bp->dev, "already in %s eswitch mode\n",
                            mode == DEVLINK_ESWITCH_MODE_LEGACY ?
@@ -595,7 +595,7 @@ int bnxt_dl_eswitch_mode_set(struct devlink *devlink, u16 mode,
                goto done;
        }
 done:
-       mutex_unlock(&bp->sriov_lock);
+       devl_unlock(devlink);
        return rc;
 }