DPDK patches and discussions
 help / color / mirror / Atom feed
From: "Min Hu (Connor)" <humin29@huawei.com>
To: <dev@dpdk.org>
Cc: <ferruh.yigit@intel.com>
Subject: [dpdk-dev] [PATCH v2 6/7] net/hns3: fix queue state when concurrent with reset
Date: Sat, 10 Apr 2021 09:11:19 +0800	[thread overview]
Message-ID: <1618017080-50053-7-git-send-email-humin29@huawei.com> (raw)
In-Reply-To: <1618017080-50053-1-git-send-email-humin29@huawei.com>

From: Chengchang Tang <tangchengchang@huawei.com>

At the end of the reset, the state of queues need to be restored according
to the states saved in the driver. If the start and stop operations of the
queues are concurrent at this time, it may cause the final status to be
uncertain.

This patch requires queues to acquire the hw lock before starting and
stopping. If the device is being restored due to reset at this time, it
will block until the reset is completed.

Fixes: fa29fe45a7b4 ("net/hns3: support queue start and stop")
Cc: stable@dpdk.org

Signed-off-by: Chengchang Tang <tangchengchang@huawei.com>
Signed-off-by: Min Hu (Connor) <humin29@huawei.com>
---
 drivers/net/hns3/hns3_rxtx.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/net/hns3/hns3_rxtx.c b/drivers/net/hns3/hns3_rxtx.c
index be93618..b45afcd 100644
--- a/drivers/net/hns3/hns3_rxtx.c
+++ b/drivers/net/hns3/hns3_rxtx.c
@@ -4270,10 +4270,12 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	if (!hns3_dev_indep_txrx_supported(hw))
 		return -ENOTSUP;
 
+	rte_spinlock_lock(&hw->lock);
 	ret = hns3_reset_queue(hw, rx_queue_id, HNS3_RING_TYPE_RX);
 	if (ret) {
 		hns3_err(hw, "fail to reset Rx queue %u, ret = %d.",
 			 rx_queue_id, ret);
+		rte_spinlock_unlock(&hw->lock);
 		return ret;
 	}
 
@@ -4281,11 +4283,13 @@ hns3_dev_rx_queue_start(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	if (ret) {
 		hns3_err(hw, "fail to init Rx queue %u, ret = %d.",
 			 rx_queue_id, ret);
+		rte_spinlock_unlock(&hw->lock);
 		return ret;
 	}
 
 	hns3_enable_rxq(rxq, true);
 	dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+	rte_spinlock_unlock(&hw->lock);
 
 	return ret;
 }
@@ -4312,12 +4316,14 @@ hns3_dev_rx_queue_stop(struct rte_eth_dev *dev, uint16_t rx_queue_id)
 	if (!hns3_dev_indep_txrx_supported(hw))
 		return -ENOTSUP;
 
+	rte_spinlock_lock(&hw->lock);
 	hns3_enable_rxq(rxq, false);
 
 	hns3_rx_queue_release_mbufs(rxq);
 
 	hns3_reset_sw_rxq(rxq);
 	dev->data->rx_queue_state[rx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+	rte_spinlock_unlock(&hw->lock);
 
 	return 0;
 }
@@ -4332,16 +4338,19 @@ hns3_dev_tx_queue_start(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	if (!hns3_dev_indep_txrx_supported(hw))
 		return -ENOTSUP;
 
+	rte_spinlock_lock(&hw->lock);
 	ret = hns3_reset_queue(hw, tx_queue_id, HNS3_RING_TYPE_TX);
 	if (ret) {
 		hns3_err(hw, "fail to reset Tx queue %u, ret = %d.",
 			 tx_queue_id, ret);
+		rte_spinlock_unlock(&hw->lock);
 		return ret;
 	}
 
 	hns3_init_txq(txq);
 	hns3_enable_txq(txq, true);
 	dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STARTED;
+	rte_spinlock_unlock(&hw->lock);
 
 	return ret;
 }
@@ -4355,6 +4364,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	if (!hns3_dev_indep_txrx_supported(hw))
 		return -ENOTSUP;
 
+	rte_spinlock_lock(&hw->lock);
 	hns3_enable_txq(txq, false);
 	hns3_tx_queue_release_mbufs(txq);
 	/*
@@ -4366,6 +4376,7 @@ hns3_dev_tx_queue_stop(struct rte_eth_dev *dev, uint16_t tx_queue_id)
 	 */
 	hns3_init_txq(txq);
 	dev->data->tx_queue_state[tx_queue_id] = RTE_ETH_QUEUE_STATE_STOPPED;
+	rte_spinlock_unlock(&hw->lock);
 
 	return 0;
 }
-- 
2.7.4


  parent reply	other threads:[~2021-04-10  1:11 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-04-09 10:15 [dpdk-dev] [PATCH 0/7] Bugfix for hns3 PMD Min Hu (Connor)
2021-04-09 10:15 ` [dpdk-dev] [PATCH 1/7] net/hns3: remove ariables of selecting Rx/Tx function Min Hu (Connor)
2021-04-09 10:16 ` [dpdk-dev] [PATCH 2/7] net/hns3: fix missing rollback in PF init Min Hu (Connor)
2021-04-09 10:16 ` [dpdk-dev] [PATCH 3/7] net/hns3: fix FLR failure when RAS concurrently with FLR Min Hu (Connor)
2021-04-09 10:16 ` [dpdk-dev] [PATCH 4/7] net/hns3: fix some packet type calc error Min Hu (Connor)
2021-04-09 10:16 ` [dpdk-dev] [PATCH 5/7] net/hns3: fix incorrect timing in resetting queues Min Hu (Connor)
2021-04-09 10:16 ` [dpdk-dev] [PATCH 6/7] net/hns3: fix queue state when concurrent with reset Min Hu (Connor)
2021-04-09 10:16 ` [dpdk-dev] [PATCH 7/7] net/hns3: fix configure FEC " Min Hu (Connor)
2021-04-10  1:11 ` [dpdk-dev] [PATCH v2 0/7] Bugfix for hns3 PMD Min Hu (Connor)
2021-04-10  1:11   ` [dpdk-dev] [PATCH v2 1/7] net/hns3: remove variables of selecting Rx/Tx function Min Hu (Connor)
2021-04-10  1:11   ` [dpdk-dev] [PATCH v2 2/7] net/hns3: fix missing rollback in PF init Min Hu (Connor)
2021-04-10  1:11   ` [dpdk-dev] [PATCH v2 3/7] net/hns3: fix FLR failure when RAS concurrent with FLR Min Hu (Connor)
2021-04-10  1:11   ` [dpdk-dev] [PATCH v2 4/7] net/hns3: fix some packet type calc error Min Hu (Connor)
2021-04-10  1:11   ` [dpdk-dev] [PATCH v2 5/7] net/hns3: fix incorrect timing in resetting queues Min Hu (Connor)
2021-04-10  1:11   ` Min Hu (Connor) [this message]
2021-04-10  1:11   ` [dpdk-dev] [PATCH v2 7/7] net/hns3: fix configure FEC when concurrent with reset Min Hu (Connor)
2021-04-13  9:28   ` [dpdk-dev] [PATCH v2 0/7] Bugfix for hns3 PMD Ferruh Yigit

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=1618017080-50053-7-git-send-email-humin29@huawei.com \
    --to=humin29@huawei.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    /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).