aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMadhukar Pappireddy <madhukar.pappireddy@arm.com>2020-07-04 01:23:50 -0500
committerMadhukar Pappireddy <madhukar.pappireddy@arm.com>2020-07-04 01:27:38 -0500
commit986de72ace2591794f20ecce499593c6149c328e (patch)
tree39d20b7fa667cb25499839fba56cfe69afcc1fe7
parentfd7c7978cfee3138a645a2014b02562f94aef141 (diff)
downloadtf-a-tests-986de72ace2591794f20ecce499593c6149c328e.tar.gz
Add explicit barrier before sev() in tftf_send_event_common API
Consider the following scenario: If sev() gets reordered above the event->cnt+=inc operation in tftf_send_event_common() on core 0, and lets say core 1 is in wfe in tftf_wait_for_event, core 1 receives the event before the write to event->cnt from core 0 propagates to core 1. Later, core 1 wakes up, reads event->cnt, sees that it is 0 and goes back to wfe, thereby leading to hang. Signed-off-by: Madhukar Pappireddy <madhukar.pappireddy@arm.com> Change-Id: I2e8a5ab7c220b02d5b637dc7cdf3562ca73dbfdc
-rw-r--r--lib/events/events.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/lib/events/events.c b/lib/events/events.c
index 42130d5..5919d3b 100644
--- a/lib/events/events.c
+++ b/lib/events/events.c
@@ -25,6 +25,11 @@ static void send_event_common(event_t *event, unsigned int inc)
event->cnt += inc;
spin_unlock(&event->lock);
+ /*
+ * Make sure the cnt increment is observable by all CPUs
+ * before the event is sent.
+ */
+ dsbsy();
sev();
}