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 8A5CE41EC0; Fri, 17 Mar 2023 21:20:11 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 712C542FFC; Fri, 17 Mar 2023 21:19:55 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 46ABD42FE2 for ; Fri, 17 Mar 2023 21:19:50 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 954702057678; Fri, 17 Mar 2023 13:19:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 954702057678 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679084389; bh=DP9UwxdQD76v+o+uTn1Q6EMyCDMuoNb6G15X6hlW1is=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bXGWUhuQn5M/MxSMseOvOsr7I8OGNcqScBDQ7krfvN9OJu6RsAm7roIy5IuZfNPAH ukZngYglNXnPeHk+yiiErgpOwE2zo8ePMMRhXYfvbAiMh6Y+ycjXdKcG26wPK5vdFE mm6EQv6ZZKUEq1WyYyx6unPCPHkPJG5b7jpoPYNI= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH 3/7] dma/idxd: replace rte atomics with GCC builtin atomics Date: Fri, 17 Mar 2023 13:19:44 -0700 Message-Id: <1679084388-19267-4-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-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 | 6 +++--- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/dma/idxd/idxd_internal.h b/drivers/dma/idxd/idxd_internal.h index 180a858..53a0c8e 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; + int16_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..e869d33 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,8 @@ /* 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); + 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 +350,7 @@ free(idxd.u.pci); return ret; } - rte_atomic16_inc(&idxd.u.pci->ref_count); + __atomic_fetch_add(&idxd.u.pci->ref_count, 1, __ATOMIC_SEQ_CST); } return 0; -- 1.8.3.1