aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Elo <matias.elo@nokia.com>2023-11-13 16:31:35 +0200
committerMatias Elo <matias.elo@nokia.com>2024-02-13 12:23:24 +0200
commitd41bedda01a845fb964f3401a02c1998bf3acbf3 (patch)
tree8e3d5581dc31a3d2a57bb5c62ae798ec9cc33871
parent53d82cb76a7ad94fdbb506570372ee91ab12d058 (diff)
linux-gen: wait_until: add generic 8-bit wait until function
Add architecture independent 8-bit wait until function. The ARM specific WFE loop is temporarily removed from scalable scheduler implementation. WFE support will be added back in a following commit, which adds aarch64 specific wait until functions. Signed-off-by: Matias Elo <matias.elo@nokia.com> Reviewed-by: Janne Peltonen <janne.peltonen@nokia.com>
-rw-r--r--platform/linux-generic/arch/default/odp_wait_until.h6
-rw-r--r--platform/linux-generic/odp_schedule_scalable.c29
2 files changed, 15 insertions, 20 deletions
diff --git a/platform/linux-generic/arch/default/odp_wait_until.h b/platform/linux-generic/arch/default/odp_wait_until.h
index e81031e2d..8c70ed535 100644
--- a/platform/linux-generic/arch/default/odp_wait_until.h
+++ b/platform/linux-generic/arch/default/odp_wait_until.h
@@ -28,6 +28,12 @@ static inline void _odp_wait_until_eq_u32(uint32_t *val, uint32_t expected)
odp_cpu_pause();
}
+static inline void _odp_wait_until_eq_acq_u8(uint8_t *val, uint8_t expected)
+{
+ while (__atomic_load_n(val, __ATOMIC_ACQUIRE) != expected)
+ odp_cpu_pause();
+}
+
static inline void _odp_wait_until_eq_acq_u32(uint32_t *val, uint32_t expected)
{
while (__atomic_load_n(val, __ATOMIC_ACQUIRE) != expected)
diff --git a/platform/linux-generic/odp_schedule_scalable.c b/platform/linux-generic/odp_schedule_scalable.c
index 1da55c5c3..78c9cc08f 100644
--- a/platform/linux-generic/odp_schedule_scalable.c
+++ b/platform/linux-generic/odp_schedule_scalable.c
@@ -225,13 +225,9 @@ void _odp_sched_update_enq(sched_elem_t *q, uint32_t actual)
if (odp_unlikely(ticket != TICKET_INVALID)) {
/* Wait for our turn to update schedq. */
if (odp_unlikely(__atomic_load_n(&q->qschst.cur_ticket,
- __ATOMIC_ACQUIRE) != ticket)) {
- sevl();
- while (wfe() &&
- monitor8(&q->qschst.cur_ticket,
- __ATOMIC_ACQUIRE) != ticket)
- odp_cpu_pause();
- }
+ __ATOMIC_ACQUIRE) != ticket))
+ _odp_wait_until_eq_acq_u8(&q->qschst.cur_ticket, ticket);
+
/* Enqueue at end of scheduler queue */
/* We are here because of empty-to-non-empty transition
* This means queue must be pushed to schedq if possible
@@ -368,13 +364,9 @@ sched_update_deq(sched_elem_t *q,
_ODP_ASSERT(q->qschst_type != ODP_SCHED_SYNC_ATOMIC);
/* Wait for our turn to update schedq. */
if (odp_unlikely(__atomic_load_n(&q->qschst.cur_ticket,
- __ATOMIC_ACQUIRE) != ticket)) {
- sevl();
- while (wfe() &&
- monitor8(&q->qschst.cur_ticket,
- __ATOMIC_ACQUIRE) != ticket)
- odp_cpu_pause();
- }
+ __ATOMIC_ACQUIRE) != ticket))
+ _odp_wait_until_eq_acq_u8(&q->qschst.cur_ticket, ticket);
+
/* We are here because of non-empty-to-empty transition or
* WRR budget exhausted
* This means the queue must be popped from the schedq, now or
@@ -496,12 +488,9 @@ static inline void sched_update_popd(sched_elem_t *elem)
1,
__ATOMIC_RELAXED);
if (odp_unlikely(__atomic_load_n(&elem->qschst.cur_ticket,
- __ATOMIC_ACQUIRE) != ticket)) {
- sevl();
- while (wfe() && monitor8(&elem->qschst.cur_ticket,
- __ATOMIC_ACQUIRE) != ticket)
- odp_cpu_pause();
- }
+ __ATOMIC_ACQUIRE) != ticket))
+ _odp_wait_until_eq_acq_u8(&elem->qschst.cur_ticket, ticket);
+
sched_update_popd_sc(elem);
atomic_store_release(&elem->qschst.cur_ticket, ticket + 1,
/*readonly=*/false);