Commit f6c99d86 authored by Phil Elwell's avatar Phil Elwell Committed by Greg Kroah-Hartman

staging: vchiq_arm: Add missing memory barrier comments

One of points on the TODO list was to comment the memory barriers.
This patch addresses the missing ones in order to help reviewers.

Link: https://github.com/raspberrypi/linux/pull/5066Signed-off-by: default avatarPhil Elwell <phil@raspberrypi.com>
Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20220624163902.6913-1-stefan.wahren@i2se.comSigned-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent acde2522
...@@ -602,6 +602,10 @@ static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state * ...@@ -602,6 +602,10 @@ static struct vchiq_arm_state *vchiq_platform_get_arm_state(struct vchiq_state *
void void
remote_event_signal(struct remote_event *event) remote_event_signal(struct remote_event *event)
{ {
/*
* Ensure that all writes to shared data structures have completed
* before signalling the peer.
*/
wmb(); wmb();
event->fired = 1; event->fired = 1;
......
...@@ -528,6 +528,7 @@ remote_event_wait(wait_queue_head_t *wq, struct remote_event *event) ...@@ -528,6 +528,7 @@ remote_event_wait(wait_queue_head_t *wq, struct remote_event *event)
return 0; return 0;
} }
event->armed = 0; event->armed = 0;
/* Ensure that the peer sees that we are not waiting (armed == 0). */
wmb(); wmb();
} }
...@@ -650,6 +651,7 @@ request_poll(struct vchiq_state *state, struct vchiq_service *service, ...@@ -650,6 +651,7 @@ request_poll(struct vchiq_state *state, struct vchiq_service *service,
skip_service: skip_service:
state->poll_needed = 1; state->poll_needed = 1;
/* Ensure the slot handler thread sees the poll_needed flag. */
wmb(); wmb();
/* ... and ensure the slot handler runs. */ /* ... and ensure the slot handler runs. */
...@@ -1156,6 +1158,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service, ...@@ -1156,6 +1158,7 @@ queue_message_sync(struct vchiq_state *state, struct vchiq_service *service,
remote_event_wait(&state->sync_release_event, &local->sync_release); remote_event_wait(&state->sync_release_event, &local->sync_release);
/* Ensure that reads don't overtake the remote_event_wait. */
rmb(); rmb();
header = (struct vchiq_header *)SLOT_DATA_FROM_INDEX(state, header = (struct vchiq_header *)SLOT_DATA_FROM_INDEX(state,
...@@ -1959,6 +1962,7 @@ slot_handler_func(void *v) ...@@ -1959,6 +1962,7 @@ slot_handler_func(void *v)
DEBUG_TRACE(SLOT_HANDLER_LINE); DEBUG_TRACE(SLOT_HANDLER_LINE);
remote_event_wait(&state->trigger_event, &local->trigger); remote_event_wait(&state->trigger_event, &local->trigger);
/* Ensure that reads don't overtake the remote_event_wait. */
rmb(); rmb();
DEBUG_TRACE(SLOT_HANDLER_LINE); DEBUG_TRACE(SLOT_HANDLER_LINE);
...@@ -2021,6 +2025,7 @@ sync_func(void *v) ...@@ -2021,6 +2025,7 @@ sync_func(void *v)
remote_event_wait(&state->sync_trigger_event, &local->sync_trigger); remote_event_wait(&state->sync_trigger_event, &local->sync_trigger);
/* Ensure that reads don't overtake the remote_event_wait. */
rmb(); rmb();
msgid = header->msgid; msgid = header->msgid;
...@@ -3081,6 +3086,10 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned ...@@ -3081,6 +3086,10 @@ enum vchiq_status vchiq_bulk_transfer(struct vchiq_instance *instance, unsigned
if (vchiq_prepare_bulk_data(instance, bulk, offset, uoffset, size, dir)) if (vchiq_prepare_bulk_data(instance, bulk, offset, uoffset, size, dir))
goto unlock_error_exit; goto unlock_error_exit;
/*
* Ensure that the bulk data record is visible to the peer
* before proceeding.
*/
wmb(); wmb();
vchiq_log_info(vchiq_core_log_level, "%d: bt (%d->%d) %cx %x@%pad %pK", vchiq_log_info(vchiq_core_log_level, "%d: bt (%d->%d) %cx %x@%pad %pK",
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment