[PATCH v2 02/16] common/cnxk: use previous value atomic fetch operations
Tyler Retzlaff
roretzla at linux.microsoft.com
Wed Mar 15 22:15:31 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>
---
drivers/common/cnxk/roc_ae.c | 2 +-
drivers/common/cnxk/roc_ae_fpm_tables.c | 2 +-
drivers/common/cnxk/roc_npa.c | 2 +-
3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/common/cnxk/roc_ae.c b/drivers/common/cnxk/roc_ae.c
index 929da05..336b927 100644
--- a/drivers/common/cnxk/roc_ae.c
+++ b/drivers/common/cnxk/roc_ae.c
@@ -203,6 +203,6 @@ struct ae_ec_grp_tbl {
ec_grp = mz->addr;
/* Decrement number of devices using EC grp table */
- if (__atomic_sub_fetch(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+ if (__atomic_fetch_sub(&ec_grp->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
plt_memzone_free(mz);
}
diff --git a/drivers/common/cnxk/roc_ae_fpm_tables.c b/drivers/common/cnxk/roc_ae_fpm_tables.c
index afb2a50..f915702 100644
--- a/drivers/common/cnxk/roc_ae_fpm_tables.c
+++ b/drivers/common/cnxk/roc_ae_fpm_tables.c
@@ -1135,6 +1135,6 @@ struct ae_fpm_tbl {
fpm = (struct ae_fpm_tbl *)mz->addr;
/* Decrement number of devices using FPM table */
- if (__atomic_sub_fetch(&fpm->refcount, 1, __ATOMIC_SEQ_CST) == 0)
+ if (__atomic_fetch_sub(&fpm->refcount, 1, __ATOMIC_SEQ_CST) - 1 == 0)
plt_memzone_free(mz);
}
diff --git a/drivers/common/cnxk/roc_npa.c b/drivers/common/cnxk/roc_npa.c
index 69c3d8d..20637fb 100644
--- a/drivers/common/cnxk/roc_npa.c
+++ b/drivers/common/cnxk/roc_npa.c
@@ -946,7 +946,7 @@
return NPA_ERR_ALLOC;
/* Not the last PCI device */
- if (__atomic_sub_fetch(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) != 0)
+ if (__atomic_fetch_sub(&idev->npa_refcnt, 1, __ATOMIC_SEQ_CST) - 1 != 0)
return 0;
npa_unregister_irqs(idev->npa);
--
1.8.3.1
More information about the dev
mailing list