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 5ABB341EA5; Wed, 15 Mar 2023 22:15:55 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2AD704161A; Wed, 15 Mar 2023 22:15:50 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 8F773410DD for ; Wed, 15 Mar 2023 22:15:47 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id C594B205701C; Wed, 15 Mar 2023 14:15:46 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com C594B205701C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1678914946; bh=hi8YITqo1Uqxht/1HZMWpeLbSbs5ROLyhI26l6ovbtI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ISod8gotecRaP05kKFIviajxdhGFosB1X2Gil6PM35Ik+PZWnS9SIOmZSFlthjYkX DzCk95M32oqof59CS2X0/6Bp99POtnssMvuGZBbBLdBNRLYS7DiZl4vHYUb7AjbEFL asUxsj+HUGwvclvbdq8psK9nTotVrC10AIuqCte4= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH v2 02/16] common/cnxk: use previous value atomic fetch operations Date: Wed, 15 Mar 2023 14:15:31 -0700 Message-Id: <1678914945-10638-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1678914945-10638-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1678914945-10638-1-git-send-email-roretzla@linux.microsoft.com> 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 Use __atomic_fetch_{add,and,or,sub,xor} instead of __atomic_{add,and,or,sub,xor}_fetch adding the necessary code to allow consumption of the resulting value. Signed-off-by: Tyler Retzlaff --- drivers/common/cnxk/roc_ae.c | 2 +- drivers/common/cnxk/roc_ae_fpm_tables.c | 2 +- drivers/common/cnxk/roc_npa.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/common/cnxk/roc_ae.c b/drivers/common/cnxk/roc_ae.c index 929da05..336b927 100644 --- a/drivers/common/cnxk/roc_ae.c +++ b/drivers/common/cnxk/roc_ae.c @@ -203,6 +203,6 @@ struct ae_ec_grp_tbl { ec_grp = mz->addr; /* Decrement number of devices using EC grp table */ - if (__atomic_sub_fetch(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) == 0) + if (__atomic_fetch_sub(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0) plt_memzone_free(mz); } diff --git a/drivers/common/cnxk/roc_ae_fpm_tables.c b/drivers/common/cnxk/roc_ae_fpm_tables.c index afb2a50..f915702 100644 --- a/drivers/common/cnxk/roc_ae_fpm_tables.c +++ b/drivers/common/cnxk/roc_ae_fpm_tables.c @@ -1135,6 +1135,6 @@ struct ae_fpm_tbl { fpm = (struct ae_fpm_tbl *)mz->addr; /* Decrement number of devices using FPM table */ - if (__atomic_sub_fetch(&fpm->refcount, 1, __ATOMIC_SEQ_CST) == 0) + if (__atomic_fetch_sub(&fpm->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0) plt_memzone_free(mz); } diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c index 69c3d8d..20637fb 100644 --- a/drivers/common/cnxk/roc_npa.c +++ b/drivers/common/cnxk/roc_npa.c @@ -946,7 +946,7 @@ return NPA_ERR_ALLOC; /* Not the last PCI device */ - if (__atomic_sub_fetch(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) != 0) + if (__atomic_fetch_sub(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) - 1 != 0) return 0; npa_unregister_irqs(idev->npa); -- 1.8.3.1