DPDK patches and discussions
 help / color / mirror / Atom feed
From: Amit Prakash Shukla <amitprakashs@marvell.com>
To: Vamsi Attunuru <vattunuru@marvell.com>
Cc: <dev@dpdk.org>, <jerinj@marvell.com>,
	Amit Prakash Shukla <amitprakashs@marvell.com>, <stable@dpdk.org>
Subject: [PATCH v5 04/12] dma/cnxk: flag support for dma device
Date: Wed, 23 Aug 2023 16:45:17 +0530	[thread overview]
Message-ID: <20230823111525.3975662-4-amitprakashs@marvell.com> (raw)
In-Reply-To: <20230823111525.3975662-1-amitprakashs@marvell.com>

Multiple call to configure, setup queues without stopping the device
would leak the ring descriptor and hardware queue memory. This patch
adds flags support to prevent configuring without stopping the
device.

Fixes: b56f1e2dad38 ("dma/cnxk: add channel operations")
Cc: stable@dpdk.org

Signed-off-by: Amit Prakash Shukla <amitprakashs@marvell.com>
---
v2:
- Fix for bugs observed in v1.
- Squashed few commits.

v3:
- Resolved review suggestions.
- Code improvement.

v4:
- Resolved checkpatch warnings.

v5:
- Updated commit message.
- Split the commits.

 drivers/dma/cnxk/cnxk_dmadev.c | 32 +++++++++++++++++++++++++++++---
 drivers/dma/cnxk/cnxk_dmadev.h |  5 +++++
 2 files changed, 34 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/cnxk/cnxk_dmadev.c b/drivers/dma/cnxk/cnxk_dmadev.c
index d8bd61a048..a7279fbd3a 100644
--- a/drivers/dma/cnxk/cnxk_dmadev.c
+++ b/drivers/dma/cnxk/cnxk_dmadev.c
@@ -45,14 +45,22 @@ cnxk_dmadev_configure(struct rte_dma_dev *dev,
 	int rc = 0;
 
 	RTE_SET_USED(conf);
-	RTE_SET_USED(conf);
-	RTE_SET_USED(conf_sz);
 	RTE_SET_USED(conf_sz);
+
 	dpivf = dev->fp_obj->dev_private;
+
+	if (dpivf->flag & CNXK_DPI_DEV_CONFIG)
+		return rc;
+
 	rc = roc_dpi_configure(&dpivf->rdpi);
-	if (rc < 0)
+	if (rc < 0) {
 		plt_err("DMA configure failed err = %d", rc);
+		goto done;
+	}
 
+	dpivf->flag |= CNXK_DPI_DEV_CONFIG;
+
+done:
 	return rc;
 }
 
@@ -69,6 +77,9 @@ cnxk_dmadev_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,
 	RTE_SET_USED(vchan);
 	RTE_SET_USED(conf_sz);
 
+	if (dpivf->flag & CNXK_DPI_VCHAN_CONFIG)
+		return 0;
+
 	header->cn9k.pt = DPI_HDR_PT_ZBW_CA;
 
 	switch (conf->direction) {
@@ -109,6 +120,7 @@ cnxk_dmadev_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,
 	dpivf->conf.c_desc.head = 0;
 	dpivf->conf.c_desc.tail = 0;
 	dpivf->pending = 0;
+	dpivf->flag |= CNXK_DPI_VCHAN_CONFIG;
 
 	return 0;
 }
@@ -126,6 +138,10 @@ cn10k_dmadev_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,
 	RTE_SET_USED(vchan);
 	RTE_SET_USED(conf_sz);
 
+
+	if (dpivf->flag & CNXK_DPI_VCHAN_CONFIG)
+		return 0;
+
 	header->cn10k.pt = DPI_HDR_PT_ZBW_CA;
 
 	switch (conf->direction) {
@@ -166,6 +182,7 @@ cn10k_dmadev_vchan_setup(struct rte_dma_dev *dev, uint16_t vchan,
 	dpivf->conf.c_desc.head = 0;
 	dpivf->conf.c_desc.tail = 0;
 	dpivf->pending = 0;
+	dpivf->flag |= CNXK_DPI_VCHAN_CONFIG;
 
 	return 0;
 }
@@ -175,11 +192,16 @@ cnxk_dmadev_start(struct rte_dma_dev *dev)
 {
 	struct cnxk_dpi_vf_s *dpivf = dev->fp_obj->dev_private;
 
+	if (dpivf->flag & CNXK_DPI_DEV_START)
+		return 0;
+
 	dpivf->desc_idx = 0;
 	dpivf->pending = 0;
 	dpivf->pnum_words = 0;
 	roc_dpi_enable(&dpivf->rdpi);
 
+	dpivf->flag |= CNXK_DPI_DEV_START;
+
 	return 0;
 }
 
@@ -190,6 +212,8 @@ cnxk_dmadev_stop(struct rte_dma_dev *dev)
 
 	roc_dpi_disable(&dpivf->rdpi);
 
+	dpivf->flag &= ~CNXK_DPI_DEV_START;
+
 	return 0;
 }
 
@@ -201,6 +225,8 @@ cnxk_dmadev_close(struct rte_dma_dev *dev)
 	roc_dpi_disable(&dpivf->rdpi);
 	roc_dpi_dev_fini(&dpivf->rdpi);
 
+	dpivf->flag = 0;
+
 	return 0;
 }
 
diff --git a/drivers/dma/cnxk/cnxk_dmadev.h b/drivers/dma/cnxk/cnxk_dmadev.h
index 943e9e3013..573bcff165 100644
--- a/drivers/dma/cnxk/cnxk_dmadev.h
+++ b/drivers/dma/cnxk/cnxk_dmadev.h
@@ -16,6 +16,10 @@
  */
 #define DPI_REQ_CDATA		0xFF
 
+#define CNXK_DPI_DEV_CONFIG   (1ULL << 0)
+#define CNXK_DPI_VCHAN_CONFIG (1ULL << 1)
+#define CNXK_DPI_DEV_START    (1ULL << 2)
+
 struct cnxk_dpi_compl_s {
 	uint64_t cdata;
 	void *cb_data;
@@ -41,6 +45,7 @@ struct cnxk_dpi_vf_s {
 	uint16_t pending;
 	uint16_t pnum_words;
 	uint16_t desc_idx;
+	uint16_t flag;
 };
 
 #endif
-- 
2.25.1


  parent reply	other threads:[~2023-08-23 11:16 UTC|newest]

Thread overview: 46+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-28 17:18 [PATCH 1/7] dma/cnxk: changes for dmadev autotest Amit Prakash Shukla
2023-06-28 17:18 ` [PATCH 2/7] drivers: changes for dmadev driver Amit Prakash Shukla
2023-06-28 17:18 ` [PATCH 3/7] dma/cnxk: add DMA devops for all models of cn10xxx Amit Prakash Shukla
2023-06-28 17:18 ` [PATCH 4/7] dma/cnxk: update func field based on transfer type Amit Prakash Shukla
2023-06-28 17:18 ` [PATCH 5/7] dma/cnxk: increase vchan per queue to max 4 Amit Prakash Shukla
2023-06-28 17:18 ` [PATCH 6/7] dma/cnxk: vchan support enhancement Amit Prakash Shukla
2023-06-28 17:18 ` [PATCH 7/7] common/cnxk: use unique name for DPI memzone Amit Prakash Shukla
2023-07-31 12:12 ` [PATCH v2 1/7] drivers: changes for dmadev driver Amit Prakash Shukla
2023-07-31 12:12   ` [PATCH v2 2/7] dma/cnxk: add DMA devops for all models of cn10xxx Amit Prakash Shukla
2023-07-31 12:12   ` [PATCH v2 3/7] dma/cnxk: update func field based on transfer type Amit Prakash Shukla
2023-07-31 12:12   ` [PATCH v2 4/7] dma/cnxk: increase vchan per queue to max 4 Amit Prakash Shukla
2023-07-31 12:12   ` [PATCH v2 5/7] dma/cnxk: vchan support enhancement Amit Prakash Shukla
2023-07-31 12:12   ` [PATCH v2 6/7] common/cnxk: use unique name for DPI memzone Amit Prakash Shukla
2023-07-31 12:12   ` [PATCH v2 7/7] dma/cnxk: add completion ring tail wrap check Amit Prakash Shukla
2023-08-16  8:13   ` [PATCH v2 1/7] drivers: changes for dmadev driver Jerin Jacob
2023-08-16 10:09     ` [EXT] " Amit Prakash Shukla
2023-08-18  9:01   ` [PATCH v3 1/8] common/cnxk: use unique name for DPI memzone Amit Prakash Shukla
2023-08-18  9:01     ` [PATCH v3 2/8] dma/cnxk: changes for dmadev driver Amit Prakash Shukla
2023-08-18  9:01     ` [PATCH v3 3/8] dma/cnxk: add DMA devops for all models of cn10xxx Amit Prakash Shukla
2023-08-18  9:01     ` [PATCH v3 4/8] dma/cnxk: update func field based on transfer type Amit Prakash Shukla
2023-08-18  9:01     ` [PATCH v3 5/8] dma/cnxk: increase vchan per queue to max 4 Amit Prakash Shukla
2023-08-18  9:01     ` [PATCH v3 6/8] dma/cnxk: vchan support enhancement Amit Prakash Shukla
2023-08-18  9:01     ` [PATCH v3 7/8] dma/cnxk: add completion ring tail wrap check Amit Prakash Shukla
2023-08-18  9:01     ` [PATCH v3 8/8] dma/cnxk: fix last index return value Amit Prakash Shukla
2023-08-21 13:27     ` [PATCH v3 1/8] common/cnxk: use unique name for DPI memzone Jerin Jacob
2023-08-21 17:49     ` [PATCH v4 " Amit Prakash Shukla
2023-08-21 17:49       ` [PATCH v4 2/8] dma/cnxk: changes for dmadev driver Amit Prakash Shukla
2023-08-21 17:49       ` [PATCH v4 3/8] dma/cnxk: add DMA devops for all models of cn10xxx Amit Prakash Shukla
2023-08-21 17:49       ` [PATCH v4 4/8] dma/cnxk: update func field based on transfer type Amit Prakash Shukla
2023-08-21 17:49       ` [PATCH v4 5/8] dma/cnxk: increase vchan per queue to max 4 Amit Prakash Shukla
2023-08-21 17:49       ` [PATCH v4 6/8] dma/cnxk: vchan support enhancement Amit Prakash Shukla
2023-08-21 17:49       ` [PATCH v4 7/8] dma/cnxk: add completion ring tail wrap check Amit Prakash Shukla
2023-08-21 17:49       ` [PATCH v4 8/8] dma/cnxk: track last index return value Amit Prakash Shukla
2023-08-23 11:15       ` [PATCH v5 01/12] common/cnxk: use unique name for DPI memzone Amit Prakash Shukla
2023-08-23 11:15         ` [PATCH v5 02/12] dma/cnxk: support for burst capacity Amit Prakash Shukla
2023-08-23 11:15         ` [PATCH v5 03/12] dma/cnxk: set dmadev to ready state Amit Prakash Shukla
2023-08-23 11:15         ` Amit Prakash Shukla [this message]
2023-08-23 11:15         ` [PATCH v5 05/12] dma/cnxk: allocate completion ring buffer Amit Prakash Shukla
2023-08-23 11:15         ` [PATCH v5 06/12] dma/cnxk: chunk buffer failure return code Amit Prakash Shukla
2023-08-23 11:15         ` [PATCH v5 07/12] dma/cnxk: add DMA devops for all models of cn10xxx Amit Prakash Shukla
2023-08-23 11:15         ` [PATCH v5 08/12] dma/cnxk: update func field based on transfer type Amit Prakash Shukla
2023-08-23 11:15         ` [PATCH v5 09/12] dma/cnxk: increase vchan per queue to max 4 Amit Prakash Shukla
2023-08-23 11:15         ` [PATCH v5 10/12] dma/cnxk: vchan support enhancement Amit Prakash Shukla
2023-08-23 11:15         ` [PATCH v5 11/12] dma/cnxk: add completion ring tail wrap check Amit Prakash Shukla
2023-08-23 11:15         ` [PATCH v5 12/12] dma/cnxk: track last index return value Amit Prakash Shukla
2023-08-23 15:30         ` [PATCH v5 01/12] common/cnxk: use unique name for DPI memzone Jerin Jacob

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=20230823111525.3975662-4-amitprakashs@marvell.com \
    --to=amitprakashs@marvell.com \
    --cc=dev@dpdk.org \
    --cc=jerinj@marvell.com \
    --cc=stable@dpdk.org \
    --cc=vattunuru@marvell.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).