This is simple inuse flag which can be done with stdatomic
exchange logic.

Signed-off-by: Stephen Hemminger <[email protected]>
---
 drivers/bus/dpaa/base/qbman/qman.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/bus/dpaa/base/qbman/qman.c 
b/drivers/bus/dpaa/base/qbman/qman.c
index 5534e1846c..82a976141a 100644
--- a/drivers/bus/dpaa/base/qbman/qman.c
+++ b/drivers/bus/dpaa/base/qbman/qman.c
@@ -11,6 +11,7 @@
 #include <rte_eventdev.h>
 #include <rte_byteorder.h>
 #include <rte_dpaa_logs.h>
+#include <rte_stdatomic.h>
 #include <eal_export.h>
 #include <dpaa_bits.h>
 
@@ -683,7 +684,7 @@ qman_init_portal(struct qman_portal *portal,
 
 #define MAX_GLOBAL_PORTALS 8
 static struct qman_portal global_portals[MAX_GLOBAL_PORTALS];
-static rte_atomic16_t global_portals_used[MAX_GLOBAL_PORTALS];
+static RTE_ATOMIC(bool) global_portals_used[MAX_GLOBAL_PORTALS];
 
 struct qman_portal *
 qman_alloc_global_portal(struct qm_portal_config *q_pcfg)
@@ -691,7 +692,8 @@ qman_alloc_global_portal(struct qm_portal_config *q_pcfg)
        unsigned int i;
 
        for (i = 0; i < MAX_GLOBAL_PORTALS; i++) {
-               if (rte_atomic16_test_and_set(&global_portals_used[i])) {
+               if (!rte_atomic_exchange_explicit(&global_portals_used[i], true,
+                                                 rte_memory_order_acquire)) {
                        global_portals[i].config = q_pcfg;
                        return &global_portals[i];
                }
@@ -708,7 +710,8 @@ qman_free_global_portal(struct qman_portal *portal)
 
        for (i = 0; i < MAX_GLOBAL_PORTALS; i++) {
                if (&global_portals[i] == portal) {
-                       rte_atomic16_clear(&global_portals_used[i]);
+                       rte_atomic_store_explicit(&global_portals_used[i], 
false,
+                                                 rte_memory_order_release);
                        return 0;
                }
        }
-- 
2.53.0

Reply via email to