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 95BB2427E5; Mon, 20 Mar 2023 20:01:35 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C135A42D0C; Mon, 20 Mar 2023 20:01:10 +0100 (CET) Received: from linux.microsoft.com (linux.microsoft.com [13.77.154.182]) by mails.dpdk.org (Postfix) with ESMTP id 444EF410D0 for ; Mon, 20 Mar 2023 20:01:03 +0100 (CET) Received: by linux.microsoft.com (Postfix, from userid 1086) id 2B57120FB40F; Mon, 20 Mar 2023 12:01:01 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 2B57120FB40F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1679338862; bh=fAPptoENiYpaSsjEfJQYA6MmcY92Ro6MWRnZgaHlVzs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=pvvi58G3h6ABMf0EnH1EmYQFlSiAT8JXrvQ8IN7AAD6RAbQHYrJzJqdVorS/v7/Ku TQBEggwyGFGO7j7meM8O1ayUlZx0huazR1zt8KYl9aFUJHr/owK+1R9ZCxS6nK1ZeL AhTslu0r+sKXWuBnqQdNdER6eSx3UlSwNluM6bm8= From: Tyler Retzlaff To: dev@dpdk.org Cc: Honnappa.Nagarahalli@arm.com, Ruifeng.Wang@arm.com, thomas@monjalon.net, pbhagavatula@marvell.com, ndabilpuram@marvell.com, Tyler Retzlaff Subject: [PATCH v3 08/16] net/iavf: use previous value atomic fetch operations Date: Mon, 20 Mar 2023 12:00:28 -0700 Message-Id: <1679338836-21321-9-git-send-email-roretzla@linux.microsoft.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1679338836-21321-1-git-send-email-roretzla@linux.microsoft.com> References: <1678486530-20688-1-git-send-email-roretzla@linux.microsoft.com> <1679338836-21321-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 Reviewed-by: Ruifeng Wang --- drivers/net/iavf/iavf_vchnl.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/iavf/iavf_vchnl.c b/drivers/net/iavf/iavf_vchnl.c index 9adaadb..51d4fc7 100644 --- a/drivers/net/iavf/iavf_vchnl.c +++ b/drivers/net/iavf/iavf_vchnl.c @@ -120,7 +120,7 @@ struct iavf_event_handler { { struct iavf_event_handler *handler = &event_handler; - if (__atomic_add_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 1) + if (__atomic_fetch_add(&handler->ndev, 1, __ATOMIC_RELAXED) + 1 != 1) return 0; #if defined(RTE_EXEC_ENV_IS_WINDOWS) && RTE_EXEC_ENV_IS_WINDOWS != 0 int err = _pipe(handler->fd, MAX_EVENT_PENDING, O_BINARY); @@ -149,7 +149,7 @@ struct iavf_event_handler { { struct iavf_event_handler *handler = &event_handler; - if (__atomic_sub_fetch(&handler->ndev, 1, __ATOMIC_RELAXED) != 0) + if (__atomic_fetch_sub(&handler->ndev, 1, __ATOMIC_RELAXED) - 1 != 0) return; int unused = pthread_cancel(handler->tid); @@ -533,8 +533,8 @@ struct iavf_event_handler { /* read message and it's expected one */ if (msg_opc == vf->pend_cmd) { uint32_t cmd_count = - __atomic_sub_fetch(&vf->pend_cmd_count, - 1, __ATOMIC_RELAXED); + __atomic_fetch_sub(&vf->pend_cmd_count, + 1, __ATOMIC_RELAXED) - 1; if (cmd_count == 0) _notify_cmd(vf, msg_ret); } else { -- 1.8.3.1