Skip to content

Commit

Permalink
sgi-xpc: ensure flags are updated before bte_copy
Browse files Browse the repository at this point in the history
The clearing of the msg->flags needs a barrier between it and the notify
of the channel threads that the messages are cleaned and ready for use.

Signed-off-by: Robin Holt <holt@sgi.com>
Signed-off-by: Dean Nelson <dcn@sgi.com>
Cc: <stable@kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
  • Loading branch information
Robin Holt authored and Linus Torvalds committed Jan 30, 2009
1 parent de33c8d commit 69b3bb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
9 changes: 5 additions & 4 deletions drivers/misc/sgi-xp/xpc_sn2.c
Original file line number Diff line number Diff line change
Expand Up @@ -1836,6 +1836,7 @@ xpc_process_msg_chctl_flags_sn2(struct xpc_partition *part, int ch_number)
*/
xpc_clear_remote_msgqueue_flags_sn2(ch);

smp_wmb(); /* ensure flags have been cleared before bte_copy */
ch_sn2->w_remote_GP.put = ch_sn2->remote_GP.put;

dev_dbg(xpc_chan, "w_remote_GP.put changed to %ld, partid=%d, "
Expand Down Expand Up @@ -1934,7 +1935,7 @@ xpc_get_deliverable_payload_sn2(struct xpc_channel *ch)
break;

get = ch_sn2->w_local_GP.get;
rmb(); /* guarantee that .get loads before .put */
smp_rmb(); /* guarantee that .get loads before .put */
if (get == ch_sn2->w_remote_GP.put)
break;

Expand Down Expand Up @@ -2053,7 +2054,7 @@ xpc_allocate_msg_sn2(struct xpc_channel *ch, u32 flags,
while (1) {

put = ch_sn2->w_local_GP.put;
rmb(); /* guarantee that .put loads before .get */
smp_rmb(); /* guarantee that .put loads before .get */
if (put - ch_sn2->w_remote_GP.get < ch->local_nentries) {

/* There are available message entries. We need to try
Expand Down Expand Up @@ -2186,7 +2187,7 @@ xpc_send_payload_sn2(struct xpc_channel *ch, u32 flags, void *payload,
* The preceding store of msg->flags must occur before the following
* load of local_GP->put.
*/
mb();
smp_mb();

/* see if the message is next in line to be sent, if so send it */

Expand Down Expand Up @@ -2287,7 +2288,7 @@ xpc_received_payload_sn2(struct xpc_channel *ch, void *payload)
* The preceding store of msg->flags must occur before the following
* load of local_GP->get.
*/
mb();
smp_mb();

/*
* See if this message is next in line to be acknowledged as having
Expand Down
2 changes: 1 addition & 1 deletion drivers/misc/sgi-xp/xpc_uv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@ xpc_send_payload_uv(struct xpc_channel *ch, u32 flags, void *payload,
atomic_inc(&ch->n_to_notify);

msg_slot->key = key;
wmb(); /* a non-NULL func must hit memory after the key */
smp_wmb(); /* a non-NULL func must hit memory after the key */
msg_slot->func = func;

if (ch->flags & XPC_C_DISCONNECTING) {
Expand Down

0 comments on commit 69b3bb6

Please sign in to comment.