Add additional checks while performing RTE_EVENT_OP_RELEASE to
ensure that there are no pending SWTAGs and FLUSHEs in flight.

Signed-off-by: Pavan Nikhilesh <pbhagavat...@marvell.com>
---
 drivers/event/cnxk/cn10k_eventdev.c |  4 +---
 drivers/event/cnxk/cn10k_worker.c   |  8 ++++++--
 drivers/event/cnxk/cn9k_eventdev.c  |  4 +---
 drivers/event/cnxk/cn9k_worker.c    | 16 ++++++++++++----
 drivers/event/cnxk/cn9k_worker.h    |  3 +--
 drivers/event/cnxk/cnxk_worker.h    | 17 ++++++++++++++---
 6 files changed, 35 insertions(+), 17 deletions(-)

diff --git a/drivers/event/cnxk/cn10k_eventdev.c 
b/drivers/event/cnxk/cn10k_eventdev.c
index 9b4d2895ec..2fa2cd31c2 100644
--- a/drivers/event/cnxk/cn10k_eventdev.c
+++ b/drivers/event/cnxk/cn10k_eventdev.c
@@ -137,9 +137,7 @@ cn10k_sso_hws_flush_events(void *hws, uint8_t queue_id, 
uintptr_t base,
                if (fn != NULL && ev.u64 != 0)
                        fn(arg, ev);
                if (ev.sched_type != SSO_TT_EMPTY)
-                       cnxk_sso_hws_swtag_flush(
-                               ws->base + SSOW_LF_GWS_WQE0,
-                               ws->base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
+                       cnxk_sso_hws_swtag_flush(ws->base);
                do {
                        val = plt_read64(ws->base + SSOW_LF_GWS_PENDSTATE);
                } while (val & BIT_ULL(56));
diff --git a/drivers/event/cnxk/cn10k_worker.c 
b/drivers/event/cnxk/cn10k_worker.c
index 975a22336a..0d99b4c5e5 100644
--- a/drivers/event/cnxk/cn10k_worker.c
+++ b/drivers/event/cnxk/cn10k_worker.c
@@ -18,8 +18,12 @@ cn10k_sso_hws_enq(void *port, const struct rte_event *ev)
                cn10k_sso_hws_forward_event(ws, ev);
                break;
        case RTE_EVENT_OP_RELEASE:
-               cnxk_sso_hws_swtag_flush(ws->base + SSOW_LF_GWS_WQE0,
-                                        ws->base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
+               if (ws->swtag_req) {
+                       cnxk_sso_hws_desched(ev->u64, ws->base);
+                       ws->swtag_req = 0;
+                       break;
+               }
+               cnxk_sso_hws_swtag_flush(ws->base);
                break;
        default:
                return 0;
diff --git a/drivers/event/cnxk/cn9k_eventdev.c 
b/drivers/event/cnxk/cn9k_eventdev.c
index 4bba477dd1..41bbe3cb22 100644
--- a/drivers/event/cnxk/cn9k_eventdev.c
+++ b/drivers/event/cnxk/cn9k_eventdev.c
@@ -156,9 +156,7 @@ cn9k_sso_hws_flush_events(void *hws, uint8_t queue_id, 
uintptr_t base,
                if (fn != NULL && ev.u64 != 0)
                        fn(arg, ev);
                if (ev.sched_type != SSO_TT_EMPTY)
-                       cnxk_sso_hws_swtag_flush(
-                               ws_base + SSOW_LF_GWS_TAG,
-                               ws_base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
+                       cnxk_sso_hws_swtag_flush(ws_base);
                do {
                        val = plt_read64(ws_base + SSOW_LF_GWS_PENDSTATE);
                } while (val & BIT_ULL(56));
diff --git a/drivers/event/cnxk/cn9k_worker.c b/drivers/event/cnxk/cn9k_worker.c
index a981bc986f..41dbe6cafb 100644
--- a/drivers/event/cnxk/cn9k_worker.c
+++ b/drivers/event/cnxk/cn9k_worker.c
@@ -19,8 +19,12 @@ cn9k_sso_hws_enq(void *port, const struct rte_event *ev)
                cn9k_sso_hws_forward_event(ws, ev);
                break;
        case RTE_EVENT_OP_RELEASE:
-               cnxk_sso_hws_swtag_flush(ws->base + SSOW_LF_GWS_TAG,
-                                        ws->base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
+               if (ws->swtag_req) {
+                       cnxk_sso_hws_desched(ev->u64, ws->base);
+                       ws->swtag_req = 0;
+                       break;
+               }
+               cnxk_sso_hws_swtag_flush(ws->base);
                break;
        default:
                return 0;
@@ -78,8 +82,12 @@ cn9k_sso_hws_dual_enq(void *port, const struct rte_event *ev)
                cn9k_sso_hws_dual_forward_event(dws, base, ev);
                break;
        case RTE_EVENT_OP_RELEASE:
-               cnxk_sso_hws_swtag_flush(base + SSOW_LF_GWS_TAG,
-                                        base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
+               if (dws->swtag_req) {
+                       cnxk_sso_hws_desched(ev->u64, base);
+                       dws->swtag_req = 0;
+                       break;
+               }
+               cnxk_sso_hws_swtag_flush(base);
                break;
        default:
                return 0;
diff --git a/drivers/event/cnxk/cn9k_worker.h b/drivers/event/cnxk/cn9k_worker.h
index 917d1e0b40..88eb4e9cf9 100644
--- a/drivers/event/cnxk/cn9k_worker.h
+++ b/drivers/event/cnxk/cn9k_worker.h
@@ -841,8 +841,7 @@ cn9k_sso_hws_event_tx(uint64_t base, struct rte_event *ev, 
uint64_t *cmd,
                        return 1;
        }
 
-       cnxk_sso_hws_swtag_flush(base + SSOW_LF_GWS_TAG,
-                                base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
+       cnxk_sso_hws_swtag_flush(base);
 
        return 1;
 }
diff --git a/drivers/event/cnxk/cnxk_worker.h b/drivers/event/cnxk/cnxk_worker.h
index 7de03f3fbb..5e5e96b1ec 100644
--- a/drivers/event/cnxk/cnxk_worker.h
+++ b/drivers/event/cnxk/cnxk_worker.h
@@ -45,11 +45,15 @@ cnxk_sso_hws_swtag_untag(uintptr_t swtag_untag_op)
 }
 
 static __rte_always_inline void
-cnxk_sso_hws_swtag_flush(uint64_t tag_op, uint64_t flush_op)
+cnxk_sso_hws_swtag_flush(uint64_t base)
 {
-       if (CNXK_TT_FROM_TAG(plt_read64(tag_op)) == SSO_TT_EMPTY)
+       /* Ensure that there is no previous flush is pending. */
+       while (plt_read64(base + SSOW_LF_GWS_PENDSTATE) & BIT_ULL(56))
+               ;
+       if (CNXK_TT_FROM_TAG(plt_read64(base + SSOW_LF_GWS_TAG)) ==
+           SSO_TT_EMPTY)
                return;
-       plt_write64(0, flush_op);
+       plt_write64(0, base + SSOW_LF_GWS_OP_SWTAG_FLUSH);
 }
 
 static __rte_always_inline uint64_t
@@ -78,4 +82,11 @@ cnxk_sso_hws_swtag_wait(uintptr_t tag_op)
        return swtp;
 }
 
+static __rte_always_inline void
+cnxk_sso_hws_desched(uint64_t u64, uint64_t base)
+{
+       plt_write64(u64, base + SSOW_LF_GWS_OP_UPD_WQP_GRP1);
+       plt_write64(0, base + SSOW_LF_GWS_OP_DESCHED);
+}
+
 #endif
-- 
2.35.1

Reply via email to