From patchwork Tue Apr 11 07:21:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ashwin Sekhar T K X-Patchwork-Id: 125897 X-Patchwork-Delegate: jerinj@marvell.com 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 A2E9442919; Tue, 11 Apr 2023 09:22:01 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A66B40DFD; Tue, 11 Apr 2023 09:22:01 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0b-0016f401.pphosted.com [67.231.156.173]) by mails.dpdk.org (Postfix) with ESMTP id 61FE640A8B for ; Tue, 11 Apr 2023 09:21:59 +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 33B6QaEi004955 for ; Tue, 11 Apr 2023 00:21:58 -0700 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=XHpMPeUEOxsf+Ls05owxshd0n2NwLEfQp+3oEDm257w=; b=i3X7WVfzXdxDPOuKQkEapc5q6o/i2qPMSLgR3tXJtUyxBPq/BOCPSkTpX3hSMcM3Q2wI dA+zumvn+K2GQm6IQf/unC89LOEChHN4QWQ0criT9nvstNNTGUG1NPYzbmL+gZMEZMm2 lQjIvyqU8KVkORO1aRVAKLgL6bP6es1oxevQ9oLqeCLY0uOwV+RIudeLDS8iCZvC6zou TOn/dQ6KKMkjxM91CW1f+NA81146H69ah5U6XNJ4Y5sl9jaUYLAoBz0XI9oZqM3/Bq3D AiXiZ4wBTXaLbSKT3FWIwywUuzzvoNBCcI0pv0W3FhxOk2M+vNxDR90M3s2Qvq3VBeQ0 fA== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0b-0016f401.pphosted.com (PPS) with ESMTPS id 3purfs8rvc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT) for ; Tue, 11 Apr 2023 00:21:58 -0700 Received: from DC5-EXCH02.marvell.com (10.69.176.39) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.48; Tue, 11 Apr 2023 00:21:56 -0700 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH02.marvell.com (10.69.176.39) with Microsoft SMTP Server id 15.0.1497.48 via Frontend Transport; Tue, 11 Apr 2023 00:21:56 -0700 Received: from localhost.localdomain (unknown [10.28.36.142]) by maili.marvell.com (Postfix) with ESMTP id ED5DC3F70A3; Tue, 11 Apr 2023 00:21:48 -0700 (PDT) From: Ashwin Sekhar T K To: , Nithin Dabilpuram , Kiran Kumar K , Sunil Kumar Kori , Satha Rao , Ashwin Sekhar T K , "Pavan Nikhilesh" CC: , , , , Subject: [PATCH] mempool/cnxk: avoid indefinite wait when counting batch alloc pointers Date: Tue, 11 Apr 2023 12:51:46 +0530 Message-ID: <20230411072146.1124802-1-asekhar@marvell.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Proofpoint-ORIG-GUID: GCbca0QK67Ft84_GabHVFh3bYJQ3enD9 X-Proofpoint-GUID: GCbca0QK67Ft84_GabHVFh3bYJQ3enD9 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.942,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-04-11_04,2023-04-06_03,2023-02-09_01 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 Avoid waiting indefinitely when counting batch alloc pointers by adding a wait timeout. Signed-off-by: Ashwin Sekhar T K --- drivers/common/cnxk/roc_npa.h | 15 +++++++++------ drivers/mempool/cnxk/cn10k_mempool_ops.c | 3 ++- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/drivers/common/cnxk/roc_npa.h b/drivers/common/cnxk/roc_npa.h index dd588b0322..1ef3ecc08a 100644 --- a/drivers/common/cnxk/roc_npa.h +++ b/drivers/common/cnxk/roc_npa.h @@ -241,19 +241,23 @@ roc_npa_aura_batch_alloc_issue(uint64_t aura_handle, uint64_t *buf, } static inline void -roc_npa_batch_alloc_wait(uint64_t *cache_line) +roc_npa_batch_alloc_wait(uint64_t *cache_line, unsigned int wait_us) { + const uint64_t ticks = (uint64_t)wait_us * plt_tsc_hz() / (uint64_t)1E6; + const uint64_t start = plt_tsc_cycles(); + /* Batch alloc status code is updated in bits [5:6] of the first word * of the 128 byte cache line. */ while (((__atomic_load_n(cache_line, __ATOMIC_RELAXED) >> 5) & 0x3) == ALLOC_CCODE_INVAL) - ; + if (wait_us && (plt_tsc_cycles() - start) >= ticks) + break; } static inline unsigned int roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num, - unsigned int do_wait) + unsigned int wait_us) { unsigned int count, i; @@ -267,8 +271,7 @@ roc_npa_aura_batch_alloc_count(uint64_t *aligned_buf, unsigned int num, status = (struct npa_batch_alloc_status_s *)&aligned_buf[i]; - if (do_wait) - roc_npa_batch_alloc_wait(&aligned_buf[i]); + roc_npa_batch_alloc_wait(&aligned_buf[i], wait_us); count += status->count; } @@ -293,7 +296,7 @@ roc_npa_aura_batch_alloc_extract(uint64_t *buf, uint64_t *aligned_buf, status = (struct npa_batch_alloc_status_s *)&aligned_buf[i]; - roc_npa_batch_alloc_wait(&aligned_buf[i]); + roc_npa_batch_alloc_wait(&aligned_buf[i], 0); line_count = status->count; diff --git a/drivers/mempool/cnxk/cn10k_mempool_ops.c b/drivers/mempool/cnxk/cn10k_mempool_ops.c index ba826f0f01..ff0015d8de 100644 --- a/drivers/mempool/cnxk/cn10k_mempool_ops.c +++ b/drivers/mempool/cnxk/cn10k_mempool_ops.c @@ -9,6 +9,7 @@ #define BATCH_ALLOC_SZ ROC_CN10K_NPA_BATCH_ALLOC_MAX_PTRS #define BATCH_OP_DATA_TABLE_MZ_NAME "batch_op_data_table_mz" +#define BATCH_ALLOC_WAIT_US 5 enum batch_op_status { BATCH_ALLOC_OP_NOT_ISSUED = 0, @@ -178,7 +179,7 @@ cn10k_mempool_get_count(const struct rte_mempool *mp) if (mem->status == BATCH_ALLOC_OP_ISSUED) count += roc_npa_aura_batch_alloc_count( - mem->objs, BATCH_ALLOC_SZ, 1); + mem->objs, BATCH_ALLOC_SZ, BATCH_ALLOC_WAIT_US); if (mem->status == BATCH_ALLOC_OP_DONE) count += mem->sz;