From patchwork Tue Jun 6 21:45:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Tyler Retzlaff X-Patchwork-Id: 128232 X-Patchwork-Delegate: david.marchand@redhat.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 AD0AC42C44; Tue, 6 Jun 2023 23:46:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9853142D38; Tue, 6 Jun 2023 23:45:55 +0200 (CEST) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id DA74341153 for ; Tue, 6 Jun 2023 23:45:49 +0200 (CEST) Received: by linux.microsoft.com (Postfix, from userid 1086) id E92C820BE499; Tue, 6 Jun 2023 14:45:48 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com E92C820BE499 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1686087948; bh=EO8eSrUP7GplkEmhvURtiBIZZT/f3j0N26NV21a/9nY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=mOsZUJs7N/VsYGsG6RP7VxnyL+AbkZc+wXBWURGE485dNLFxT9hX5vzcNschBqx/g dREjMGh2xVpJ0JoWhQGwdt7XIF++utJ+E+aYs43yV28ZE6wpuhzqMgkDj1iebpjxqO rTeCiaBSiBBYueJJ38XZohTIRrn5ecPj+upQOv0I= 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 v5 2/6] dma/idxd: replace rte atomics with GCC builtin atomics Date: Tue, 6 Jun 2023 14:45:43 -0700 Message-Id: <1686087947-15471-3-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1686087947-15471-1-git-send-email-roretzla@linux.microsoft.com> References: <1679084388-19267-1-git-send-email-roretzla@linux.microsoft.com> <1686087947-15471-1-git-send-email-roretzla@linux.microsoft.com> MIME-Version: 1.0 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;