From patchwork Mon Jul 22 16:39:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 142643 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1518845683; Mon, 22 Jul 2024 18:43:22 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9C25F40DF5; Mon, 22 Jul 2024 18:40:52 +0200 (CEST) Received: from AS8PR04CU009.outbound.protection.outlook.com (mail-westeuropeazon11011029.outbound.protection.outlook.com [52.101.70.29]) by mails.dpdk.org (Postfix) with ESMTP id 1A23440ED0 for ; Mon, 22 Jul 2024 18:40:32 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=FdLOL6kFd5MdB1CBoXyXkAfcuNKo2Zfoxqki94rO62Pq7pIO7Uj/LFLPLTHDuNXoJPenOqUdmdv8taZMMFL1Vfn3iUpL4ZaCCdU+BO2v/Ou8u2AQAlPSy/6wuEyRGdKx/sm4xteJweKWleG8LK/Uxa5UnbkM1W1riqoR2Jl3au3Nlz87XPqPB329z7DPSX1EJMuIgGdiW6liwzMmU6IXNkQ2CPYoAOxwZhb4BAPf1yxoJhigY2rCL33E4HBQde1rVvzq577u/Dswfrn11mTv17UVxRX2H7mfNEZjAC3fdbOvhBGE8nFHYp94n+9RiZ09mXPW9Az0cCJVBFdKRIN/lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=A5goVnGFKicEl3EdTB46CLBe2PT9a2uXlS4uthFw5kw=; b=rlxe9Sydd0Su2NxmvH7Mjhyt5G9EJlpXy4vzTN5elY1hb/6SnW7d5Y80Irlf7k0r+3iOcoV3pYccGYl6u9Q6seEUMPhoBTJnFSJbQEieWpsoFaBA2jYnDx1Zq+BrSFtJt4KTf96HA7QBVDb401aWvMvx73ma1abMJvt2QTyDFc3ZFmmEy9p+Jo7c45k8fn3X6DC68VjVR+Jbxae9Jw3slUn/1DPd0pDFyRzZ9yWTf8NW68XTyXQoidzjkrX2JLXPj/PoII6H9p7n7/GQxLQQ4NKXSOWg/iG5LLX4AVS1ITrrfj7tkKU95lI9eafiY9dI19Sgn6x65JvP4U2hjdPy3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=A5goVnGFKicEl3EdTB46CLBe2PT9a2uXlS4uthFw5kw=; b=oVWs31OVI1+30ONd0qnPAsjeeTy3Kj2TblHjzR4AzodmmDpHw+H6Knxg/m18Id1J148hTuVl7hTmo1b8KVLaldr3GRONLm1/sa2gkvgxfW7RdDw69E6p0o8QMRup1WYdsIWbPwFYp8YVqENyh6c6Iv4CMOY7UH6GBZ73vkVz+EI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AS8SPR01MB0024.eurprd04.prod.outlook.com (2603:10a6:20b:3d0::24) by PA1PR04MB10652.eurprd04.prod.outlook.com (2603:10a6:102:491::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.16; Mon, 22 Jul 2024 16:40:29 +0000 Received: from AS8SPR01MB0024.eurprd04.prod.outlook.com ([fe80::c634:479e:8f8a:a325]) by AS8SPR01MB0024.eurprd04.prod.outlook.com ([fe80::c634:479e:8f8a:a325%7]) with mapi id 15.20.7784.017; Mon, 22 Jul 2024 16:40:29 +0000 From: Gagandeep Singh To: dev@dpdk.org, Sachin Saxena Cc: Jun Yang Subject: [v3 24/30] dma/dpaa: improve congestion handling Date: Mon, 22 Jul 2024 22:09:24 +0530 Message-Id: <20240722163930.2171568-25-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240722163930.2171568-1-g.singh@nxp.com> References: <20240722115843.1830105-1-g.singh@nxp.com> <20240722163930.2171568-1-g.singh@nxp.com> X-ClientProxiedBy: SG3P274CA0014.SGPP274.PROD.OUTLOOK.COM (2603:1096:4:be::26) To AS8SPR01MB0024.eurprd04.prod.outlook.com (2603:10a6:20b:3d0::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8SPR01MB0024:EE_|PA1PR04MB10652:EE_ X-MS-Office365-Filtering-Correlation-Id: 17887391-d42b-4b30-a793-08dcaa6cfec8 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|52116014|376014|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: SYcw/LO+9Ps5YLhU3TGJ+8Q/WdOtcBjrIxZyEslbiJFqeiviwJV1sm9TAaQskbDH04+iWM5p6i8Ln9aqfXTCziP7FImjodqeIp8VBLcJ6E1/WWkAF3UVdBNilCaJrpJzgpb4FoWTcR/+/k7JxPrzQg0VxRPAB09h88+OmbbGZRcl+zXkdrP5zV06hFzW5HOWe9Sz+yvHI99Djjx09Vzdpr3cXnc/odTjIWBE2EZDrSvaDpt2pRymj4GoHH0YXzSl+ZpgG9xPTs8pDXfEYCGmBiDYAlbDRwfvEdE0aFfS4wQfCwaTD6XKQLoUwUpdmfYEM9FW8MRF0vr/NRheBf9gMZEdWSBF7g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TRXp+yn5FZhXHJA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8SPR01MB0024.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(52116014)(376014)(1800799024)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TWp0lmrtX6U/FDA1zMdsisghPMy8xsFECT96s7AUnnyG41S1Y0fhmvoZ5+nEP23zQS+O21y2jNaZ/i1bjjv3PkLxMtDtl1Hu6b0ugZsE49oPxC/TBOpZihpOtQi5+d+TtnJJAVLidmKPs6yvzyQFMtpJb2UhzYfwXpTcYbFXis0BVQGctl2wEGSSoE6siS2XY36RgLys90YateuRomoZ47twLE2h2EZTboS1g0lAUXZA+4HQBpmP8bZhwmIC4Dno1j06IdQxrtZInHCqBmcCMBm0fCEy7wisWxf1G/E0klWcwpPL+xf4mnx9PVyYNqj9OA3sCe61K89iYR4eY5KmIyoCI2DwqVCWY6N7ymat7cXa3tCu21WjrcWKqFJpTgsYEwKiJUVTwwCGmeETLKOQ6zqxxYqB4iHjbeRK1mp4flpU4wyUSyWl1Iu8lzDCwavW3F1EXT6pQLfJiU6DLHwajGjD2AArdIcsCE5KuCcQHb3LKk4CO5WOAWgmfuuCk1xfCGQb6e2fU2Wq6IylDgdnh3D7cNCLBco7yA992Q9PWEDxPzFQt4Zl0+V+vuD/LmBlLYpDHBqWXYJC3uQzcjkHZRy8gfQNXvo59Wz0yX4AdKq7kypv1WYmUDJSucK1gCCwNO9EN+FVbwYUQP/WM5KuqayntkWuZg9CCVdIPWyrrrEwDqlX+hGLLJTTWIdnu70u3KK611u4rrt7uIJo4NpvDq245eUCYbFE3vIsHKWMX+f9HADyKHxleUATrzl6gKQnbt5GKCAqrWKuWBcLcICn3PorKeY6vcCTlSqwM6EoiWLbQbiPRsJKhNpYVa+S1I6bWT05YmnQGbo5BNnydl4X4KyA9FrDTJwtzdAjjvWqhj5XH6xPiBLEBocMMb++8Kd7NKWAPnrjzlrN057P0vCO+b6XOv5GuAB3vy+AWXBljaNu1Bpt1RxmUhs7qCaD3Vt+M57Z95MPdnD3EvIAAcuamUzQlihAIT2BWX433OF02RCJTLVlwhKDJilhQvBT1Iwz4dDORVTBjzeb0zrQhRrmw+faZt+zmNBdZniyVBfR3WMnmTCZirggbjWyr70CjdYGIBCekUOW/t5aB+mODQ+IqZ9U7MbWnCxLZM2J5N4uXqaBLaogx6QOiSSHIATqezO+7wP91yJ5ARNZDCb3SjFRaHhLQm2/rm9QvlTpbXwbORpHtNI+ptNfW4DglAlTi99QCnGAMISWU0TPj98y8rJhFBYB+69PTy37wYP6e5v0rD2XTEE8H91W4hrNtfhgfgsKUHl7EOvyJ3FIkuQ3qavRBe32Di2peGVebVXUesY1x16rPEzCa7WnjoGVQ5eBQpBfe8asGLfomNIbEuXPFihdkms3whOB5IWzeImPyxi2IK4VEY+jo0A1p/n6iqApj3DmxB5BELH7YmyT86tBsg7D9aHDW5e9mTGVHTM6e1ZsJZJqsNiyMPXS8smSB5NNCVLOFw6viNDlyKJhFMN1Pw5dbDiQjAtKgdMIrB8zPpkSjEIfdcax3WU1MPNnuztfLvDhlPm/FfYep/tYg7bKP76iHxsx/zNzWGKwGQHjeYcIMs/lYRGsazzmsm3PoS40DGcZ X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 17887391-d42b-4b30-a793-08dcaa6cfec8 X-MS-Exchange-CrossTenant-AuthSource: AS8SPR01MB0024.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2024 16:40:28.9348 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: r3x7DpxN94E6lj9qClaCzVWodGY+pvIBYl7AJhhit/wU53b/Ia0IINIzByaMiYrv X-MS-Exchange-Transport-CrossTenantHeadersStamped: PA1PR04MB10652 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 From: Jun Yang The congestion issue occurs frequently on low speed device(PCIe). We should drain the command queue to make dma work when congestion occurs. Signed-off-by: Jun Yang --- drivers/dma/dpaa/dpaa_qdma.c | 157 +++++++++++++++++++---------------- 1 file changed, 85 insertions(+), 72 deletions(-) diff --git a/drivers/dma/dpaa/dpaa_qdma.c b/drivers/dma/dpaa/dpaa_qdma.c index de5ecc7d0b..eaa5f81f6d 100644 --- a/drivers/dma/dpaa/dpaa_qdma.c +++ b/drivers/dma/dpaa/dpaa_qdma.c @@ -535,73 +535,6 @@ fsl_qdma_reg_init(struct fsl_qdma_engine *fsl_qdma) return 0; } -static int -fsl_qdma_enqueue_desc_to_ring(struct fsl_qdma_queue *fsl_queue, - int is_burst) -{ - uint16_t i, num = fsl_queue->pending_num, idx, start; - int ret; - - num = is_burst ? fsl_queue->pending_num : 1; - - fsl_queue->desc_in_hw[fsl_queue->ci] = num; - ret = rte_ring_enqueue(fsl_queue->complete_burst, - &fsl_queue->desc_in_hw[fsl_queue->ci]); - if (ret) { - DPAA_QDMA_ERR("%s: Queue is full, try dequeue first", - __func__); - DPAA_QDMA_ERR("%s: submitted:%"PRIu64", completed:%"PRIu64"", - __func__, fsl_queue->stats.submitted, - fsl_queue->stats.completed); - return ret; - } - start = fsl_queue->pending_start; - for (i = 0; i < num; i++) { - idx = (start + i) & (fsl_queue->pending_max - 1); - ret = rte_ring_enqueue(fsl_queue->complete_desc, - &fsl_queue->pending_desc[idx]); - if (ret) { - DPAA_QDMA_ERR("Descriptors eq failed!\r\n"); - return ret; - } - } - - return 0; -} - -static int -fsl_qdma_enqueue_desc_single(struct fsl_qdma_queue *fsl_queue, - dma_addr_t dst, dma_addr_t src, size_t len) -{ - uint8_t *block = fsl_queue->block_vir; - struct fsl_qdma_comp_sg_desc *csgf_src, *csgf_dest; - struct fsl_qdma_cmpd_ft *ft; - int ret; - - ft = fsl_queue->ft[fsl_queue->ci]; - csgf_src = &ft->desc_sbuf; - csgf_dest = &ft->desc_dbuf; - qdma_desc_sge_addr_set64(csgf_src, src); - csgf_src->length = len; - csgf_src->extion = 0; - qdma_desc_sge_addr_set64(csgf_dest, dst); - csgf_dest->length = len; - csgf_dest->extion = 0; - /* This entry is the last entry. */ - csgf_dest->final = 1; - - ret = fsl_qdma_enqueue_desc_to_ring(fsl_queue, 0); - if (ret) - return ret; - fsl_queue->ci = (fsl_queue->ci + 1) & (fsl_queue->n_cq - 1); - - qdma_writel(fsl_queue->le_cqmr | FSL_QDMA_BCQMR_EI, - block + FSL_QDMA_BCQMR(fsl_queue->queue_id)); - fsl_queue->stats.submitted++; - - return 0; -} - static uint16_t dpaa_qdma_block_dequeue(struct fsl_qdma_engine *fsl_qdma, uint8_t block_id) @@ -633,7 +566,6 @@ dpaa_qdma_block_dequeue(struct fsl_qdma_engine *fsl_qdma, ret = qdma_ccdf_get_queue(&cq[start], &qid); if (ret == true) { cmd_queue = &fsl_qdma->cmd_queues[block_id][qid]; - cmd_queue->stats.completed++; ret = rte_ring_dequeue(cmd_queue->complete_burst, (void **)&dq_complete); @@ -677,6 +609,87 @@ dpaa_qdma_block_dequeue(struct fsl_qdma_engine *fsl_qdma, return count; } +static int +fsl_qdma_enqueue_desc_to_ring(struct fsl_qdma_queue *fsl_queue, + int is_burst) +{ + uint16_t i, num = fsl_queue->pending_num, idx, start, dq; + int ret, dq_cnt; + + num = is_burst ? fsl_queue->pending_num : 1; + + fsl_queue->desc_in_hw[fsl_queue->ci] = num; +eq_again: + ret = rte_ring_enqueue(fsl_queue->complete_burst, + &fsl_queue->desc_in_hw[fsl_queue->ci]); + if (ret) { + DPAA_QDMA_DP_DEBUG("%s: Queue is full, try dequeue first", + __func__); + DPAA_QDMA_DP_DEBUG("%s: submitted:%"PRIu64", completed:%"PRIu64"", + __func__, fsl_queue->stats.submitted, + fsl_queue->stats.completed); + dq_cnt = 0; +dq_again: + dq = dpaa_qdma_block_dequeue(fsl_queue->engine, + fsl_queue->block_id); + dq_cnt++; + if (dq > 0) { + goto eq_again; + } else { + if (dq_cnt < 100) + goto dq_again; + DPAA_QDMA_ERR("%s: Dq block%d failed!", + __func__, fsl_queue->block_id); + } + return ret; + } + start = fsl_queue->pending_start; + for (i = 0; i < num; i++) { + idx = (start + i) & (fsl_queue->pending_max - 1); + ret = rte_ring_enqueue(fsl_queue->complete_desc, + &fsl_queue->pending_desc[idx]); + if (ret) { + DPAA_QDMA_ERR("Descriptors eq failed!\r\n"); + return ret; + } + } + + return 0; +} + +static int +fsl_qdma_enqueue_desc_single(struct fsl_qdma_queue *fsl_queue, + dma_addr_t dst, dma_addr_t src, size_t len) +{ + uint8_t *block = fsl_queue->block_vir; + struct fsl_qdma_comp_sg_desc *csgf_src, *csgf_dest; + struct fsl_qdma_cmpd_ft *ft; + int ret; + + ft = fsl_queue->ft[fsl_queue->ci]; + csgf_src = &ft->desc_sbuf; + csgf_dest = &ft->desc_dbuf; + qdma_desc_sge_addr_set64(csgf_src, src); + csgf_src->length = len; + csgf_src->extion = 0; + qdma_desc_sge_addr_set64(csgf_dest, dst); + csgf_dest->length = len; + csgf_dest->extion = 0; + /* This entry is the last entry. */ + csgf_dest->final = 1; + + ret = fsl_qdma_enqueue_desc_to_ring(fsl_queue, 0); + if (ret) + return ret; + fsl_queue->ci = (fsl_queue->ci + 1) & (fsl_queue->n_cq - 1); + + qdma_writel(fsl_queue->le_cqmr | FSL_QDMA_BCQMR_EI, + block + FSL_QDMA_BCQMR(fsl_queue->queue_id)); + fsl_queue->stats.submitted++; + + return 0; +} + static int fsl_qdma_enqueue_overflow(struct fsl_qdma_queue *fsl_queue) { @@ -702,7 +715,7 @@ fsl_qdma_enqueue_overflow(struct fsl_qdma_queue *fsl_queue) if (likely(!overflow)) return 0; - DPAA_QDMA_ERR("TC%d/Q%d submitted(%"PRIu64")-completed(%"PRIu64") >= %d", + DPAA_QDMA_DP_DEBUG("TC%d/Q%d submitted(%"PRIu64")-completed(%"PRIu64") >= %d", fsl_queue->block_id, fsl_queue->queue_id, st->submitted, st->completed, QDMA_QUEUE_CR_WM); drain_num = 0; @@ -712,7 +725,7 @@ fsl_qdma_enqueue_overflow(struct fsl_qdma_queue *fsl_queue) fsl_queue->block_id); if (!blk_drain) { drain_num++; - if (drain_num > 100) { + if (drain_num > 1000) { DPAA_QDMA_ERR("TC%d failed drain, Q%d's %"PRIu64" bd in HW.", fsl_queue->block_id, fsl_queue->queue_id, st->submitted - st->completed); @@ -721,8 +734,8 @@ fsl_qdma_enqueue_overflow(struct fsl_qdma_queue *fsl_queue) goto drain_again; } check_num++; - if (check_num > 10) { - DPAA_QDMA_ERR("TC%d failed drain, Q%d's %"PRIu64" bd in HW.", + if (check_num > 1000) { + DPAA_QDMA_ERR("TC%d failed check, Q%d's %"PRIu64" bd in HW.", fsl_queue->block_id, fsl_queue->queue_id, st->submitted - st->completed); return -ENOSPC;