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 348A642829; Thu, 23 Mar 2023 23:54:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 71EE042B7E; Thu, 23 Mar 2023 23:54:03 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 054A64111C for ; Thu, 23 Mar 2023 23:53:59 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 4ED5C20DEE45; Thu, 23 Mar 2023 15:53:59 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 4ED5C20DEE45 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679612039; bh=NzBmBBZ/5eE2h1wW5gmRrb2SHkhASTAXtcRNqJqtAOM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ou/mxvXyuGvLmZSxYOtKZDv2P7yH76qy4PpedwFUyfB469epvaMYToap7zerKo9GV XeYlj4Wilvv7ebIyc0RS1wNFE3PX5EUqjFYWaIGi03ZrJGwW0hBBUGu0fnNPzHNoiR ybyBufK4gW0KdTlD0+xRBl4VcmaHG3vMyLyA2leo= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, stephen@networkplumber.org, mb@smartsharesystems.com, Tyler Retzlaff Subject: [PATCH v3 3/7] dma/idxd: replace rte atomics with GCC builtin atomics Date: Thu, 23 Mar 2023 15:53:52 -0700 Message-Id: <1679612036-30773-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679612036-30773-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1679612036-30773-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 Replace the use of rte_atomic.h types and functions, instead use GCC supplied C++11 memory model builtins. Signed-off-by: Tyler Retzlaff --- drivers/dma/idxd/idxd_internal.h | 3 +-- drivers/dma/idxd/idxd_pci.c | 8 +++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/drivers/dma/idxd/idxd_internal.h b/drivers/dma/idxd/idxd_internal.h index 180a858..cd41777 100644 --- a/drivers/dma/idxd/idxd_internal.h +++ b/drivers/dma/idxd/idxd_internal.h @@ -7,7 +7,6 @@ #include #include -#include #include "idxd_hw_defs.h" @@ -34,7 +33,7 @@ struct idxd_pci_common { rte_spinlock_t lk; uint8_t wq_cfg_sz; - rte_atomic16_t ref_count; + uint16_t ref_count; volatile struct rte_idxd_bar0 *regs; volatile uint32_t *wq_regs_base; volatile struct rte_idxd_grpcfg *grp_regs; diff --git a/drivers/dma/idxd/idxd_pci.c b/drivers/dma/idxd/idxd_pci.c index 781fa02..2de5d15 100644 --- a/drivers/dma/idxd/idxd_pci.c +++ b/drivers/dma/idxd/idxd_pci.c @@ -6,7 +6,6 @@ #include #include #include -#include #include "idxd_internal.h" @@ -136,7 +135,9 @@ /* if this is the last WQ on the device, disable the device and free * the PCI struct */ - is_last_wq = rte_atomic16_dec_and_test(&idxd->u.pci->ref_count); + /* NOTE: review for potential ordering optimization */ + is_last_wq = __atomic_fetch_sub(&idxd->u.pci->ref_count, 1, + __ATOMIC_SEQ_CST) - 1 == 0; if (is_last_wq) { /* disable the device */ err_code = idxd_pci_dev_command(idxd, idxd_disable_dev); @@ -350,7 +351,8 @@ free(idxd.u.pci); return ret; } - rte_atomic16_inc(&idxd.u.pci->ref_count); + /* NOTE: review for potential ordering optimization */ + __atomic_fetch_add(&idxd.u.pci->ref_count, 1, __ATOMIC_SEQ_CST); } return 0; -- 1.8.3.1