patches for DPDK stable branches
 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>, <stable@dpdk.org>
Subject: [PATCH v5 11/12] dma/cnxk: add completion ring tail wrap check
Date: Wed, 23 Aug 2023 16:45:24 +0530	[thread overview]
Message-ID: <20230823111525.3975662-11-amitprakashs@marvell.com> (raw)
In-Reply-To: <20230823111525.3975662-1-amitprakashs@marvell.com>

From: Vamsi Attunuru <vattunuru@marvell.com>

Adds a check to avoid tail wrap when completion desc ring
is full. Also patch increase max desc size to 2048.

Fixes: b56f1e2dad38 ("dma/cnxk: add channel operations")
Fixes: 3340c3e22783 ("dma/cnxk: add scatter-gather copy")
Fixes: 681851b347ad ("dma/cnxk: support CN10K DMA engine")
Cc: stable@dpdk.org

Signed-off-by: Vamsi Attunuru <vattunuru@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 | 22 ++++++++++++++++++++--
 drivers/dma/cnxk/cnxk_dmadev.h |  2 +-
 2 files changed, 21 insertions(+), 3 deletions(-)

diff --git a/drivers/dma/cnxk/cnxk_dmadev.c b/drivers/dma/cnxk/cnxk_dmadev.c
index 0b77543f6a..89ff4c18ac 100644
--- a/drivers/dma/cnxk/cnxk_dmadev.c
+++ b/drivers/dma/cnxk/cnxk_dmadev.c
@@ -434,6 +434,11 @@ cnxk_dmadev_copy(void *dev_private, uint16_t vchan, rte_iova_t src, rte_iova_t d
 	header->cn9k.ptr = (uint64_t)comp_ptr;
 	STRM_INC(dpi_conf->c_desc, tail);
 
+	if (unlikely(dpi_conf->c_desc.tail == dpi_conf->c_desc.head)) {
+		STRM_DEC(dpi_conf->c_desc, tail);
+		return -ENOSPC;
+	}
+
 	header->cn9k.nfst = 1;
 	header->cn9k.nlst = 1;
 
@@ -494,6 +499,11 @@ cnxk_dmadev_copy_sg(void *dev_private, uint16_t vchan, const struct rte_dma_sge
 	header->cn9k.ptr = (uint64_t)comp_ptr;
 	STRM_INC(dpi_conf->c_desc, tail);
 
+	if (unlikely(dpi_conf->c_desc.tail == dpi_conf->c_desc.head)) {
+		STRM_DEC(dpi_conf->c_desc, tail);
+		return -ENOSPC;
+	}
+
 	/*
 	 * For inbound case, src pointers are last pointers.
 	 * For all other cases, src pointers are first pointers.
@@ -561,6 +571,11 @@ cn10k_dmadev_copy(void *dev_private, uint16_t vchan, rte_iova_t src, rte_iova_t
 	header->cn10k.ptr = (uint64_t)comp_ptr;
 	STRM_INC(dpi_conf->c_desc, tail);
 
+	if (unlikely(dpi_conf->c_desc.tail == dpi_conf->c_desc.head)) {
+		STRM_DEC(dpi_conf->c_desc, tail);
+		return -ENOSPC;
+	}
+
 	header->cn10k.nfst = 1;
 	header->cn10k.nlst = 1;
 
@@ -613,6 +628,11 @@ cn10k_dmadev_copy_sg(void *dev_private, uint16_t vchan, const struct rte_dma_sge
 	header->cn10k.ptr = (uint64_t)comp_ptr;
 	STRM_INC(dpi_conf->c_desc, tail);
 
+	if (unlikely(dpi_conf->c_desc.tail == dpi_conf->c_desc.head)) {
+		STRM_DEC(dpi_conf->c_desc, tail);
+		return -ENOSPC;
+	}
+
 	header->cn10k.nfst = nb_src & DPI_MAX_POINTER;
 	header->cn10k.nlst = nb_dst & DPI_MAX_POINTER;
 	fptr = &src[0];
@@ -695,8 +715,6 @@ cnxk_dmadev_completed_status(void *dev_private, uint16_t vchan, const uint16_t n
 	struct cnxk_dpi_compl_s *comp_ptr;
 	int cnt;
 
-	RTE_SET_USED(last_idx);
-
 	for (cnt = 0; cnt < nb_cpls; cnt++) {
 		comp_ptr = c_desc->compl_ptr[c_desc->head];
 		status[cnt] = comp_ptr->cdata;
diff --git a/drivers/dma/cnxk/cnxk_dmadev.h b/drivers/dma/cnxk/cnxk_dmadev.h
index f375143b16..9c6c898d23 100644
--- a/drivers/dma/cnxk/cnxk_dmadev.h
+++ b/drivers/dma/cnxk/cnxk_dmadev.h
@@ -9,7 +9,7 @@
 #define DPI_MAX_POINTER	     15
 #define STRM_INC(s, var)     ((s).var = ((s).var + 1) & (s).max_cnt)
 #define STRM_DEC(s, var)     ((s).var = ((s).var - 1) == -1 ? (s).max_cnt : ((s).var - 1))
-#define DPI_MAX_DESC	     1024
+#define DPI_MAX_DESC	     2048
 #define DPI_MIN_DESC	     2
 #define MAX_VCHANS_PER_QUEUE 4
 
-- 
2.25.1


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

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20230731121225.1545318-1-amitprakashs@marvell.com>
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-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-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 03/12] dma/cnxk: set dmadev to ready state Amit Prakash Shukla
2023-08-23 11:15       ` [PATCH v5 04/12] dma/cnxk: flag support for dma device Amit Prakash Shukla
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       ` Amit Prakash Shukla [this message]
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-11-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).