From patchwork Mon Jul 22 11:58:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gagandeep Singh X-Patchwork-Id: 142597 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 64E5D45681; Mon, 22 Jul 2024 14:01:38 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FE7340662; Mon, 22 Jul 2024 13:59:48 +0200 (CEST) Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013064.outbound.protection.outlook.com [52.101.67.64]) by mails.dpdk.org (Postfix) with ESMTP id 8066740689 for ; Mon, 22 Jul 2024 13:59:47 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=bir4N9NiiwWSHe62XlsEJDWRnxcJloXkc/S3qPewEt3asSRztalsO4Vl/LbIq5zkayStWDQnqok07cA8eheG+xiUkfSVhUNg5tKEMLZC0JsGnMwaPhniyynD45reqbZAR8bnr2YTX6UWq/jHar4vnU6njMzisT+GPEhcVYBBcXrhCnRP/3AipnGGIWonYppYXIWLxkc97M2DwYoBKkDycCfwKSI6sCX0UPJMPF97PvOCwqJFdA2anCXmiS9R4RECbOv2pC7GQp+Z7DzVN+R9Vivz//rmIeUxDtnzGhnWR/VdRCrMWyjIyC7SjBG1lcmp8nYIMz/3krEpG2h30vprAg== 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=hI6TiSPKWc08lRPg153+O/RkWkagE7BTo8aWeC2MErwEKomSf2j4TkllhvwpNAD6Fc8N6ZlpW6+gONVMs8rJ53EFSx2Qkg/ivjhEJhIbmRtzxOEfx7vfSnKy84wINaHxbOAbHCziVpYOqXNy0/mjLgC9TZlFJWHPgKLYlZKI8FzLg8zUHeEbsWat7B/j5y8tXpoWrUf4KIyIdAv6l70RO+cSnVvoLUYU0nd27mfA15jhrZfwuewDauVPY19c+bZu8iCXQDdvC6Qtam1/5GrwozQ+pWKMiNOppxDGnV1Tm7/ztBhh970kIJD9Lbnv3lF0ol8uUhNfwY69SezB0j4ipw== 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=agJkdBYntiqPJrLObjvjdgPtx34Y0JMb2rEuVJWdDPEXmGT0ulWIOEgYytBVVuTd6P1CBgtG6igDHAW8I4xF3q6+lWAsy6CgclAPY1NNZGeqCl0fLptiT3ptYvjY5XJ0PjAZyts7OmIzyioNv1FGIf9m7Rdvwu4d4A4kK3U7w4Y= 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 VI1PR04MB7118.eurprd04.prod.outlook.com (2603:10a6:800:127::12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7784.20; Mon, 22 Jul 2024 11:59:46 +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 11:59:46 +0000 From: Gagandeep Singh To: dev@dpdk.org, Sachin Saxena Cc: Jun Yang Subject: [v2 24/30] dma/dpaa: improve congestion handling Date: Mon, 22 Jul 2024 17:28:37 +0530 Message-Id: <20240722115843.1830105-25-g.singh@nxp.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20240722115843.1830105-1-g.singh@nxp.com> References: <20240719100126.1150373-1-g.singh@nxp.com> <20240722115843.1830105-1-g.singh@nxp.com> X-ClientProxiedBy: SI2PR02CA0025.apcprd02.prod.outlook.com (2603:1096:4:195::21) To AS8SPR01MB0024.eurprd04.prod.outlook.com (2603:10a6:20b:3d0::24) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AS8SPR01MB0024:EE_|VI1PR04MB7118:EE_ X-MS-Office365-Filtering-Correlation-Id: 3e01bd2a-cb41-47d8-ed8f-08dcaa45c79b X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|366016|1800799024|376014|52116014|38350700014; X-Microsoft-Antispam-Message-Info: BF+Lvfzu7casMaogHtVjxXGL29Qfzpl67XSxKkjj+1Vmrb7Q6FtPpgPCXtsdprsVVOPGxDRn9hb9FDn4nH832/y4O4vWrsUj+HRoa4tIo2NNcVv2Viidn/CkyvezDqffQNjlhxNrY4p08pqLiAdfaI5QbVDhDjIAfc+DYOnl1zY935i/p41GtPFjURH0cK+MSEJKTeFR3yPiUSjvjIS6OgNiwF/6hItChuG6ilhfMMtFPIfUlC5le6jelIQtOotaeH7FrNostL5D+wbHrSezeR/Kmu+E3DIAoZ/O9Dg5XotDoapK2TY2eY+dgaK0bkBioltd0poOHPyvmEOlnm0ADe8ibCkW5p1Z0pmqJDRgHEtjhN2xI1Gou21yP3rdYtG1O9H1yes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en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AS8SPR01MB0024.eurprd04.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230040)(366016)(1800799024)(376014)(52116014)(38350700014); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: GsZ9FdOsyXbhyjxUiFln/ut4WGl3SK3ffA6bcoW7cKauAiv4xWA31YJ2l64bIW2jOZjNOuBvZbDAFlnU1xznPp81tMbuQszMTPI5j4NeBFFDvG6fwsCOPEL+s4b9JNA99/+0fcwNj8XTln4iBTdE+SJ6xpZ1M1IZrk3jC6zzg4bW1XnD//FY4ETWWa1IaGBmkhRAL926d5XPjR2YuyNtIvZ0gvDfcHdj3JArTqhizaUdhLPy0IxsvbYvMVA8uCLuhnhzWxwXil7F3OfZeum2gILEtCupgR66jE37w5hmZkUdYKNUV0HVDdJifpeX588KoLs0hyMQ2vhUVOEY8w2i1MlwijPhqsSCGoXNWfg5bUFEV4thTXEkfZo+t43rYJOyTtchZMEpW7IGh8+W3ggVeRZxVZhvN9pvunGzt5kF69NLEFpOJw9gsjJCkRD8W8bTLgXJq9St8dQsh4/Be+GKBdSmYK8E05Q6rfnJOB2VdIARULNWvYFrpJOclHmtAkvZ3lvWLM2W/bSy3xMdFNPWIXIgj8ik3y+62BFuWkkhQXnx/U2yQBYKPpAK8H8Q0YfqoNJuxmNrydmU5BCgWBOIzD1Bylq1l3xsMyded7y1TuHA8Nvp8VO9mwHjpjlhxWioK60DQOUcZELz7qtMdc3ua37UwO3Q57n7IXGOkEVP17THDktOlO2eBqaxs21oa/pJExkS3Mt1MkH+wB+EfxaXIbQiEkv3Ma+YsjSpnRuyWIxXFkaNrHE2zQU8AlTOLO/xl9vFp5i8W0+r9grGIlZKqn2gQ22VbVU/IGNcyNPaXXif46out3dFkZQo191YeGeC/Umkjp5PbnJlAEXfEaiJQHPJbo1P7pd0Qeunz1pgM3C8HJc1lJyghuoHvw2tPyYwFAY95GVUXfOnYtWKQ3bahN3Tlcl6DCgB1Z7TyTdykIk/2aa1WSC/qt7RsxX/UESe6GSRCtjiSfGGAX/V3G6xna+/EubCe2jg+kvhrk8sOFOacNDRlzBWJUhsLJvbKDAOiTAjx+/NvaGTHI9MEyt6jZZOeX9xis6fp4v8vtvAQ/YCfG4j375frJbulGFv3ik+OCVZJGSeYMt+VCGlyYsoosiZs6BIB2Sjk4LtHn+liKQcUvtqqIg2PLPpx9G7kUonvzMbjSzfAuGQoLKJa50LiHgzUNWEMedhvHvn/3ZYqbrz/KL2omULwYL9pZcNY9vmX7F5TRQK03MWlnuoOOCltxOmFQyyRR2DohaA81iUBJsvvWc5AgmhM721HF1j13YjCR2Ob4eBCKDcAH+mO8fauclQsSibCE393GqHzy0biypHF9M++vPL/XkS2VDcw6jLh7EyomtH3IhAl7ccOC2OLq97wXJMa33ZXT2S/wSC74gJsJ+orrZt9KH3SfOF9x4LiQMuNO65PeD+iqM8unYyyOfoqBjIry3RABVmSEDRgAsJqxrkDSDw/QJgwTX8L3EdSdwn+YpxQGopuKd82bcPOUkVs8BL3baPvPtafJLeJ8oRUBkYU1SFT5BV3CFxL67u+XWepKUg/iHjoQBSFIoPZR8Hu17jCCFqtfQYcRUKen59kiuVotklreYo3g6rU+1F X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3e01bd2a-cb41-47d8-ed8f-08dcaa45c79b X-MS-Exchange-CrossTenant-AuthSource: AS8SPR01MB0024.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Jul 2024 11:59:45.9675 (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: RwgjjTJHqUV0NLLVa4n8jHXDQ19MQeMg6JzZ61uK4HbyCMWsHHp1t6zMLXkT1eeh X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB7118 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;