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 <roret...@linux.microsoft.com> Reviewed-by: Ruifeng Wang <ruifeng.w...@arm.com> --- drivers/common/mlx5/linux/mlx5_nl.c | 2 +- drivers/common/mlx5/mlx5_common_mr.c | 8 ++++---- drivers/common/mlx5/mlx5_common_utils.c | 8 ++++---- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/drivers/common/mlx5/linux/mlx5_nl.c b/drivers/common/mlx5/linux/mlx5_nl.c index 5d04857..33670bb 100644 --- a/drivers/common/mlx5/linux/mlx5_nl.c +++ b/drivers/common/mlx5/linux/mlx5_nl.c @@ -178,7 +178,7 @@ struct mlx5_nl_port_info { uint32_t atomic_sn; /* Generate Netlink sequence number. */ -#define MLX5_NL_SN_GENERATE __atomic_add_fetch(&atomic_sn, 1, __ATOMIC_RELAXED) +#define MLX5_NL_SN_GENERATE (__atomic_fetch_add(&atomic_sn, 1, __ATOMIC_RELAXED) + 1) /** * Opens a Netlink socket. diff --git a/drivers/common/mlx5/mlx5_common_mr.c b/drivers/common/mlx5/mlx5_common_mr.c index 0e1d243..037a4d8 100644 --- a/drivers/common/mlx5/mlx5_common_mr.c +++ b/drivers/common/mlx5/mlx5_common_mr.c @@ -58,8 +58,8 @@ struct mlx5_mempool_reg { if (__atomic_load_n(&buf->refcnt, __ATOMIC_RELAXED) == 1) { rte_mempool_put(buf->mp, buf); - } else if (unlikely(__atomic_sub_fetch(&buf->refcnt, 1, - __ATOMIC_RELAXED) == 0)) { + } else if (unlikely(__atomic_fetch_sub(&buf->refcnt, 1, + __ATOMIC_RELAXED) - 1 == 0)) { __atomic_store_n(&buf->refcnt, 1, __ATOMIC_RELAXED); rte_mempool_put(buf->mp, buf); } @@ -1665,8 +1665,8 @@ struct mlx5_mempool_get_extmem_data { bool ret = false; for (i = 0; i < mpr->mrs_n; i++) - ret |= __atomic_sub_fetch(&mpr->mrs[i].refcnt, 1, - __ATOMIC_RELAXED) == 0; + ret |= __atomic_fetch_sub(&mpr->mrs[i].refcnt, 1, + __ATOMIC_RELAXED) - 1 == 0; return ret; } diff --git a/drivers/common/mlx5/mlx5_common_utils.c b/drivers/common/mlx5/mlx5_common_utils.c index 58d744b..06b5b9b 100644 --- a/drivers/common/mlx5/mlx5_common_utils.c +++ b/drivers/common/mlx5/mlx5_common_utils.c @@ -81,8 +81,8 @@ struct mlx5_list * while (entry != NULL) { if (l_const->cb_match(l_const->ctx, entry, ctx) == 0) { if (reuse) { - ret = __atomic_add_fetch(&entry->ref_cnt, 1, - __ATOMIC_RELAXED) - 1; + ret = __atomic_fetch_add(&entry->ref_cnt, 1, + __ATOMIC_RELAXED); DRV_LOG(DEBUG, "mlx5 list %s entry %p ref: %u.", l_const->name, (void *)entry, entry->ref_cnt); @@ -285,7 +285,7 @@ struct mlx5_list_entry * { struct mlx5_list_entry *gentry = entry->gentry; - if (__atomic_sub_fetch(&entry->ref_cnt, 1, __ATOMIC_RELAXED) != 0) + if (__atomic_fetch_sub(&entry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0) return 1; if (entry->lcore_idx == (uint32_t)lcore_idx) { LIST_REMOVE(entry, next); @@ -303,7 +303,7 @@ struct mlx5_list_entry * l_const->name, (void *)entry); return 0; } - if (__atomic_sub_fetch(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) != 0) + if (__atomic_fetch_sub(&gentry->ref_cnt, 1, __ATOMIC_RELAXED) - 1 != 0) return 1; rte_rwlock_write_lock(&l_inconst->lock); if (likely(gentry->ref_cnt == 0)) { -- 1.8.3.1