From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6EFBF430DF; Wed, 23 Aug 2023 13:16:33 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7B4C343265; Wed, 23 Aug 2023 13:16:21 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 0C6BA43261; Wed, 23 Aug 2023 13:16:18 +0200 (CEST) Received: from pps.filterd (m0045851.ppops.net [127.0.0.1]) by mx0b-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 37N72aS0013047; Wed, 23 Aug 2023 04:16:18 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=zx0nQJm72CgnShJic74AfV96cR47OHNtx6x7KXTfJO8=; b=G8oes8F0uhkKEILhdft1OPwGPj4IyNgUgW9YOhD4BVNXi4aX91DtNkK50PrKNgMM5IiY uZ5gWyKqjpmZvTfnEMnP4nKtQSmrUjsY/a94IGSI2Tti+aWghl7MshXDn2CgOmz1epuM 34foQMiacmI8snj7qTbTE1C8mygQKJv8X6v2ehuZzJOejJmHn2nFuzg42+D+UgKigcln 4Z6JHGCphTLx77xbQLVDX47WJM2xCQBeQMOzzClGx7u88swa4AdudYr4QhRzbr7p+N8v ujcLMD4nLZIxcnc5//nCSQwIU58SVTFo/4XDCOnueC2hupuRk9QHlClxHSnuPTng8p0t KA== Received: from dc5-exch02.marvell.com ([199.233.59.182]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3sn20ctmeg-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Wed, 23 Aug 2023 04:16:18 -0700 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Wed, 23 Aug 2023 04:16:16 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Wed, 23 Aug 2023 04:16:15 -0700 Received: from localhost.localdomain (unknown [10.28.36.157]) by maili.marvell.com (Postfix) with ESMTP id 51EFF3F708D; Wed, 23 Aug 2023 04:16:14 -0700 (PDT) From: Amit Prakash Shukla To: Vamsi Attunuru CC: , , Amit Prakash Shukla , Subject: [PATCH v5 06/12] dma/cnxk: chunk buffer failure return code Date: Wed, 23 Aug 2023 16:45:19 +0530 Message-ID: <20230823111525.3975662-6-amitprakashs@marvell.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230823111525.3975662-1-amitprakashs@marvell.com> References: <20230821174942.3165191-1-amitprakashs@marvell.com> <20230823111525.3975662-1-amitprakashs@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-GUID: HS6psNmw3ZUGwr-GR-sTT3oLH5C0xfFL X-Proofpoint-ORIG-GUID: HS6psNmw3ZUGwr-GR-sTT3oLH5C0xfFL X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.267,Aquarius:18.0.957,Hydra:6.0.601,FMLib:17.11.176.26 definitions=2023-08-23_06,2023-08-22_01,2023-05-22_02 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org On chunk buffer alloc failure, ENOMEM is returned. As per DMA spec ENOSPC shall be returned on failure to allocate memory. This changeset fixes the same. Fixes: b56f1e2dad38 ("dma/cnxk: add channel operations") Cc: stable@dpdk.org Signed-off-by: Amit Prakash Shukla --- 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 | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/drivers/dma/cnxk/cnxk_dmadev.c b/drivers/dma/cnxk/cnxk_dmadev.c index 0db74b454d..aa6f6c710c 100644 --- a/drivers/dma/cnxk/cnxk_dmadev.c +++ b/drivers/dma/cnxk/cnxk_dmadev.c @@ -257,8 +257,7 @@ __dpi_queue_write(struct roc_dpi *dpi, uint64_t *cmds, int cmd_count) { uint64_t *ptr = dpi->chunk_base; - if ((cmd_count < DPI_MIN_CMD_SIZE) || (cmd_count > DPI_MAX_CMD_SIZE) || - cmds == NULL) + if ((cmd_count < DPI_MIN_CMD_SIZE) || (cmd_count > DPI_MAX_CMD_SIZE) || cmds == NULL) return -EINVAL; /* @@ -274,11 +273,15 @@ __dpi_queue_write(struct roc_dpi *dpi, uint64_t *cmds, int cmd_count) int count; uint64_t *new_buff = dpi->chunk_next; - dpi->chunk_next = - (void *)roc_npa_aura_op_alloc(dpi->aura_handle, 0); + dpi->chunk_next = (void *)roc_npa_aura_op_alloc(dpi->aura_handle, 0); if (!dpi->chunk_next) { - plt_err("Failed to alloc next buffer from NPA"); - return -ENOMEM; + plt_dp_dbg("Failed to alloc next buffer from NPA"); + + /* NPA failed to allocate a buffer. Restoring chunk_next + * to its original address. + */ + dpi->chunk_next = new_buff; + return -ENOSPC; } /* @@ -312,13 +315,17 @@ __dpi_queue_write(struct roc_dpi *dpi, uint64_t *cmds, int cmd_count) /* queue index may be greater than pool size */ if (dpi->chunk_head >= dpi->pool_size_m1) { new_buff = dpi->chunk_next; - dpi->chunk_next = - (void *)roc_npa_aura_op_alloc(dpi->aura_handle, - 0); + dpi->chunk_next = (void *)roc_npa_aura_op_alloc(dpi->aura_handle, 0); if (!dpi->chunk_next) { - plt_err("Failed to alloc next buffer from NPA"); - return -ENOMEM; + plt_dp_dbg("Failed to alloc next buffer from NPA"); + + /* NPA failed to allocate a buffer. Restoring chunk_next + * to its original address. + */ + dpi->chunk_next = new_buff; + return -ENOSPC; } + /* Write next buffer address */ *ptr = (uint64_t)new_buff; dpi->chunk_base = new_buff; -- 2.25.1