[PATCH v4 25/27] vdpa/ifc: replace rte_atomic32 with stdatomic
Stephen Hemminger
stephen at networkplumber.org
Wed May 27 01:24:15 CEST 2026
Last in-tree caller of rte_atomic32_*(), blocking deprecation of the
rte_atomicNN_*() family.
Replace rte_atomic32_read/set() with rte_atomic_load_explicit() and
rte_atomic_store_explicit() on the started, dev_attached, and running
flags. Narrow them to bool (only ever hold 0/1) and group with the
existing bools to reduce padding in struct ifcvf_internal.
Signed-off-by: Stephen Hemminger <stephen at networkplumber.org>
---
drivers/vdpa/ifc/ifcvf_vdpa.c | 37 ++++++++++++++++++-----------------
1 file changed, 19 insertions(+), 18 deletions(-)
diff --git a/drivers/vdpa/ifc/ifcvf_vdpa.c b/drivers/vdpa/ifc/ifcvf_vdpa.c
index f319d455ba..e5da11a2ba 100644
--- a/drivers/vdpa/ifc/ifcvf_vdpa.c
+++ b/drivers/vdpa/ifc/ifcvf_vdpa.c
@@ -25,6 +25,7 @@
#include <rte_log.h>
#include <rte_kvargs.h>
#include <rte_devargs.h>
+#include <rte_stdatomic.h>
#include "base/ifcvf.h"
@@ -68,10 +69,10 @@ struct ifcvf_internal {
struct rte_vdpa_device *vdev;
uint16_t max_queues;
uint64_t features;
- rte_atomic32_t started;
- rte_atomic32_t dev_attached;
- rte_atomic32_t running;
rte_spinlock_t lock;
+ RTE_ATOMIC(bool) started;
+ RTE_ATOMIC(bool) dev_attached;
+ RTE_ATOMIC(bool) running;
bool sw_lm;
bool sw_fallback_running;
/* mediated vring for sw fallback */
@@ -712,9 +713,9 @@ update_datapath(struct ifcvf_internal *internal)
rte_spinlock_lock(&internal->lock);
- if (!rte_atomic32_read(&internal->running) &&
- (rte_atomic32_read(&internal->started) &&
- rte_atomic32_read(&internal->dev_attached))) {
+ if (!rte_atomic_load_explicit(&internal->running, rte_memory_order_seq_cst) &&
+ (rte_atomic_load_explicit(&internal->started, rte_memory_order_seq_cst) &&
+ rte_atomic_load_explicit(&internal->dev_attached, rte_memory_order_seq_cst))) {
ret = ifcvf_dma_map(internal, true);
if (ret)
goto err;
@@ -735,10 +736,10 @@ update_datapath(struct ifcvf_internal *internal)
if (ret)
goto err;
- rte_atomic32_set(&internal->running, 1);
- } else if (rte_atomic32_read(&internal->running) &&
- (!rte_atomic32_read(&internal->started) ||
- !rte_atomic32_read(&internal->dev_attached))) {
+ rte_atomic_store_explicit(&internal->running, true, rte_memory_order_seq_cst);
+ } else if (rte_atomic_load_explicit(&internal->running, rte_memory_order_seq_cst) &&
+ (!rte_atomic_load_explicit(&internal->started, rte_memory_order_seq_cst) ||
+ !rte_atomic_load_explicit(&internal->dev_attached, rte_memory_order_seq_cst))) {
unset_intr_relay(internal);
ret = unset_notify_relay(internal);
@@ -755,7 +756,7 @@ update_datapath(struct ifcvf_internal *internal)
if (ret)
goto err;
- rte_atomic32_set(&internal->running, 0);
+ rte_atomic_store_explicit(&internal->running, false, rte_memory_order_seq_cst);
}
rte_spinlock_unlock(&internal->lock);
@@ -1058,7 +1059,7 @@ ifcvf_sw_fallback_switchover(struct ifcvf_internal *internal)
vdpa_disable_vfio_intr(internal);
- rte_atomic32_set(&internal->running, 0);
+ rte_atomic_store_explicit(&internal->running, false, rte_memory_order_seq_cst);
ret = rte_vhost_host_notifier_ctrl(vid, RTE_VHOST_QUEUE_ALL, false);
if (ret && ret != -ENOTSUP)
@@ -1113,11 +1114,11 @@ ifcvf_dev_config(int vid)
internal = list->internal;
internal->vid = vid;
- rte_atomic32_set(&internal->dev_attached, 1);
+ rte_atomic_store_explicit(&internal->dev_attached, true, rte_memory_order_seq_cst);
if (update_datapath(internal) < 0) {
DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
vdev->device->name);
- rte_atomic32_set(&internal->dev_attached, 0);
+ rte_atomic_store_explicit(&internal->dev_attached, false, rte_memory_order_seq_cst);
return -1;
}
@@ -1166,7 +1167,7 @@ ifcvf_dev_close(int vid)
internal->sw_fallback_running = false;
} else {
- rte_atomic32_set(&internal->dev_attached, 0);
+ rte_atomic_store_explicit(&internal->dev_attached, false, rte_memory_order_seq_cst);
if (update_datapath(internal) < 0) {
DRV_LOG(ERR, "failed to update datapath for vDPA device %s",
vdev->device->name);
@@ -1782,10 +1783,10 @@ ifcvf_pci_probe(struct rte_pci_driver *pci_drv __rte_unused,
goto error;
}
- rte_atomic32_set(&internal->started, 1);
+ rte_atomic_store_explicit(&internal->started, true, rte_memory_order_seq_cst);
if (update_datapath(internal) < 0) {
DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
- rte_atomic32_set(&internal->started, 0);
+ rte_atomic_store_explicit(&internal->started, false, rte_memory_order_seq_cst);
rte_vdpa_unregister_device(internal->vdev);
pthread_mutex_lock(&internal_list_lock);
TAILQ_REMOVE(&internal_list, list, next);
@@ -1819,7 +1820,7 @@ ifcvf_pci_remove(struct rte_pci_device *pci_dev)
}
internal = list->internal;
- rte_atomic32_set(&internal->started, 0);
+ rte_atomic_store_explicit(&internal->started, false, rte_memory_order_seq_cst);
if (update_datapath(internal) < 0)
DRV_LOG(ERR, "failed to update datapath %s", pci_dev->name);
--
2.53.0
More information about the dev
mailing list