[PATCH v3 12/16] bbdev: use previous value atomic fetch operations

Tyler Retzlaff roretzla at linux.microsoft.com
Mon Mar 20 20:00:32 CET 2023


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 <roretzla at linux.microsoft.com>
Reviewed-by: Ruifeng Wang <ruifeng.wang at arm.com>
---
 lib/bbdev/rte_bbdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/bbdev/rte_bbdev.c b/lib/bbdev/rte_bbdev.c
index 1521cdb..9df0837 100644
--- a/lib/bbdev/rte_bbdev.c
+++ b/lib/bbdev/rte_bbdev.c
@@ -250,8 +250,8 @@ struct rte_bbdev *
 	}
 
 	/* clear shared BBDev Data if no process is using the device anymore */
-	if (__atomic_sub_fetch(&bbdev->data->process_cnt, 1,
-			      __ATOMIC_RELAXED) == 0)
+	if (__atomic_fetch_sub(&bbdev->data->process_cnt, 1,
+			      __ATOMIC_RELAXED) - 1 == 0)
 		memset(bbdev->data, 0, sizeof(*bbdev->data));
 
 	memset(bbdev, 0, sizeof(*bbdev));
-- 
1.8.3.1



More information about the dev mailing list