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 6CE3142C12; Fri, 2 Jun 2023 21:45:29 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B7BA7410D0; Fri, 2 Jun 2023 21:45:17 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 3FA134161A for ; Fri, 2 Jun 2023 21:45:13 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id 67C1220A11B7; Fri, 2 Jun 2023 12:45:12 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 67C1220A11B7 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1685735112; bh=EO8eSrUP7GplkEmhvURtiBIZZT/f3j0N26NV21a/9nY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bJsgFwQ9E8cOHTWcexhjBKakSxQf9nXFEByHp5cCitkiR7Bzhe7sM5dcTMWSdrNaJ xJQWcA4fucbofUADK5W7h44TzEQ8ErSw8o6lUd29EhP8jtNv+5UPwj7pNRRHyRq9BB Xa4Y1v6GgvpB2ZiUkD33xH/WIWZKOBukYswHYJJA= From: Tyler Retzlaff To: dev@dpdk.org, david.marchand@redhat.com Cc: Olivier Matz , Bruce Richardson , Kevin Laatz , Qiming Yang , Qi Zhang , Wenjun Wu , Tetsuya Mukawa , Honnappa.Nagarahalli@arm.com, thomas@monjalon.net, Tyler Retzlaff Subject: [PATCH v4 2/6] dma/idxd: replace rte atomics with GCC builtin atomics Date: Fri, 2 Jun 2023 12:45:03 -0700 Message-Id: <1685735107-19208-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1685735107-19208-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1685735107-19208-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Acked-by: Morten Brørup Acked-by: Bruce Richardson Acked-by: Kevin Laatz --- drivers/dma/idxd/idxd_internal.h | 3 +-- drivers/dma/idxd/idxd_pci.c | 11 ++++++----- 2 files changed, 7 insertions(+), 7 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 5e56240..3696c7f 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); + /* NOTE: review for potential ordering optimization */ + is_last_wq = (__atomic_fetch_sub(&idxd->u.pci->ref_count, 1, __ATOMIC_SEQ_CST) == 1); if (is_last_wq) { /* disable the device */ err_code = idxd_pci_dev_command(idxd, idxd_disable_dev); @@ -322,8 +322,9 @@ return ret; } qid = rte_dma_get_dev_id_by_name(qname); - max_qid = rte_atomic16_read( - &((struct idxd_dmadev *)rte_dma_fp_objs[qid].dev_private)->u.pci->ref_count); + max_qid = __atomic_load_n( + &((struct idxd_dmadev *)rte_dma_fp_objs[qid].dev_private)->u.pci->ref_count, + __ATOMIC_SEQ_CST); /* we have queue 0 done, now configure the rest of the queues */ for (qid = 1; qid < max_qid; qid++) { @@ -380,7 +381,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