From: Ajit Khaparde <ajit.khaparde@broadcom.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com,
Somnath Kotur <somnath.kotur@broadcom.com>,
stable@dpdk.org, Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Subject: [dpdk-dev] [PATCH 5/7] net/bnxt: fix race between interrupt handler and dev config
Date: Sun, 13 Oct 2019 17:01:18 -0700 [thread overview]
Message-ID: <20191014000120.3020-6-ajit.khaparde@broadcom.com> (raw)
In-Reply-To: <20191014000120.3020-1-ajit.khaparde@broadcom.com>
From: Somnath Kotur <somnath.kotur@broadcom.com>
Fix a possible that while interrupt handler is in the middle of processing,
dev_configure_op() might come in and try to destroy/realloc the default
completion ring on which interrupt completions arrive.
Synchronize the two so they don't race each other
Fixes: 7bc8e9a227cc ("net/bnxt: support async link notification")
Cc: stable@dpdk.org
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Kalesh AP <kalesh-anakkur.purayil@broadcom.com>
Reviewed-by: Ajit Khaparde <ajit.khaparde@broadcom.com>
---
drivers/net/bnxt/bnxt.h | 1 +
drivers/net/bnxt/bnxt_ethdev.c | 19 +++++++++++++++++--
drivers/net/bnxt/bnxt_irq.c | 7 ++++++-
3 files changed, 24 insertions(+), 3 deletions(-)
diff --git a/drivers/net/bnxt/bnxt.h b/drivers/net/bnxt/bnxt.h
index 189f693b06..e5bdf63602 100644
--- a/drivers/net/bnxt/bnxt.h
+++ b/drivers/net/bnxt/bnxt.h
@@ -574,6 +574,7 @@ struct bnxt {
void *hwrm_short_cmd_req_addr;
rte_iova_t hwrm_short_cmd_req_dma_addr;
rte_spinlock_t hwrm_lock;
+ pthread_mutex_t def_cp_lock;
uint16_t max_req_len;
uint16_t max_resp_len;
uint16_t hwrm_max_ext_req_len;
diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c
index b58a875c7d..e7ec99e15d 100644
--- a/drivers/net/bnxt/bnxt_ethdev.c
+++ b/drivers/net/bnxt/bnxt_ethdev.c
@@ -627,6 +627,9 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
* resource reservation. This will ensure the resource counts
* are calculated correctly.
*/
+
+ pthread_mutex_lock(&bp->def_cp_lock);
+
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
bnxt_disable_int(bp);
bnxt_free_cp_ring(bp, bp->async_cp_ring);
@@ -635,15 +638,20 @@ static int bnxt_dev_configure_op(struct rte_eth_dev *eth_dev)
rc = bnxt_hwrm_func_reserve_vf_resc(bp, false);
if (rc) {
PMD_DRV_LOG(ERR, "HWRM resource alloc fail:%x\n", rc);
+ pthread_mutex_unlock(&bp->def_cp_lock);
return -ENOSPC;
}
if (!BNXT_HAS_NQ(bp) && bp->async_cp_ring) {
rc = bnxt_alloc_async_cp_ring(bp);
- if (rc)
+ if (rc) {
+ pthread_mutex_unlock(&bp->def_cp_lock);
return rc;
+ }
bnxt_enable_int(bp);
}
+
+ pthread_mutex_unlock(&bp->def_cp_lock);
} else {
/* legacy driver needs to get updated values */
rc = bnxt_hwrm_func_qcaps(bp);
@@ -4585,8 +4593,14 @@ bnxt_init_locks(struct bnxt *bp)
int err;
err = pthread_mutex_init(&bp->flow_lock, NULL);
- if (err)
+ if (err) {
PMD_DRV_LOG(ERR, "Unable to initialize flow_lock\n");
+ return err;
+ }
+
+ err = pthread_mutex_init(&bp->def_cp_lock, NULL);
+ if (err)
+ PMD_DRV_LOG(ERR, "Unable to initialize def_cp_lock\n");
return err;
}
@@ -4735,6 +4749,7 @@ static void
bnxt_uninit_locks(struct bnxt *bp)
{
pthread_mutex_destroy(&bp->flow_lock);
+ pthread_mutex_destroy(&bp->def_cp_lock);
}
static int
diff --git a/drivers/net/bnxt/bnxt_irq.c b/drivers/net/bnxt/bnxt_irq.c
index 6c5bcfb623..4feb637e22 100644
--- a/drivers/net/bnxt/bnxt_irq.c
+++ b/drivers/net/bnxt/bnxt_irq.c
@@ -30,9 +30,12 @@ void bnxt_int_handler(void *param)
return;
raw_cons = cpr->cp_raw_cons;
+ pthread_mutex_lock(&bp->def_cp_lock);
while (1) {
- if (!cpr || !cpr->cp_ring_struct || !cpr->cp_db.doorbell)
+ if (!cpr || !cpr->cp_ring_struct || !cpr->cp_db.doorbell) {
+ pthread_mutex_unlock(&bp->def_cp_lock);
return;
+ }
cons = RING_CMP(cpr->cp_ring_struct, raw_cons);
cmp = &cpr->cp_desc_ring[cons];
@@ -49,6 +52,8 @@ void bnxt_int_handler(void *param)
bnxt_db_nq_arm(cpr);
else
B_CP_DB_REARM(cpr, cpr->cp_raw_cons);
+
+ pthread_mutex_unlock(&bp->def_cp_lock);
}
int bnxt_free_int(struct bnxt *bp)
--
2.20.1 (Apple Git-117)
next prev parent reply other threads:[~2019-10-14 0:02 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-10-14 0:01 [dpdk-dev] [PATCH 0/7] patchset for bnxt Ajit Khaparde
2019-10-14 0:01 ` [dpdk-dev] [PATCH 1/7] net/bnxt: fix dereference before null check Ajit Khaparde
2019-10-14 0:01 ` [dpdk-dev] [PATCH 2/7] net/bnxt: reset Rx allocation state on Rx queue restart Ajit Khaparde
2019-10-14 0:01 ` [dpdk-dev] [PATCH 3/7] net/bnxt: cleanup comments in source Ajit Khaparde
2019-10-14 0:01 ` [dpdk-dev] [PATCH 4/7] net/bnxt: move macro definitions to header file Ajit Khaparde
2019-10-14 0:01 ` Ajit Khaparde [this message]
2019-10-14 0:01 ` [dpdk-dev] [PATCH 6/7] net/bnxt: fix endianness while retrieving MTU from FW Ajit Khaparde
2019-10-14 0:01 ` [dpdk-dev] [PATCH 7/7] net/bnxt: fix error handling Ajit Khaparde
2019-10-14 3:58 ` [dpdk-dev] [PATCH 0/7] patchset for bnxt Ajit Khaparde
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20191014000120.3020-6-ajit.khaparde@broadcom.com \
--to=ajit.khaparde@broadcom.com \
--cc=dev@dpdk.org \
--cc=ferruh.yigit@intel.com \
--cc=kalesh-anakkur.purayil@broadcom.com \
--cc=somnath.kotur@broadcom.com \
--cc=stable@dpdk.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).