Commit 5aac4937 authored by Andrea Parri's avatar Andrea Parri Committed by Marcel Holtmann

Bluetooth: Remove unnecessary smp_mb__{before,after}_atomic

The barriers are unneeded; wait_woken() and woken_wake_function()
already provide us with the required synchronization: remove them
and document that we're relying on the (implicit) synchronization
provided by wait_woken() and woken_wake_function().
Signed-off-by: default avatarAndrea Parri <andrea.parri@amarulasolutions.com>
Reviewed-by: default avatarBrian Norris <computersforpeace@gmail.com>
Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
parent 1042caa7
...@@ -489,9 +489,6 @@ static int bnep_session(void *arg) ...@@ -489,9 +489,6 @@ static int bnep_session(void *arg)
add_wait_queue(sk_sleep(sk), &wait); add_wait_queue(sk_sleep(sk), &wait);
while (1) { while (1) {
/* Ensure session->terminate is updated */
smp_mb__before_atomic();
if (atomic_read(&s->terminate)) if (atomic_read(&s->terminate))
break; break;
/* RX */ /* RX */
...@@ -512,6 +509,10 @@ static int bnep_session(void *arg) ...@@ -512,6 +509,10 @@ static int bnep_session(void *arg)
break; break;
netif_wake_queue(dev); netif_wake_queue(dev);
/*
* wait_woken() performs the necessary memory barriers
* for us; see the header comment for this primitive.
*/
wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
} }
remove_wait_queue(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
......
...@@ -288,9 +288,6 @@ static int cmtp_session(void *arg) ...@@ -288,9 +288,6 @@ static int cmtp_session(void *arg)
add_wait_queue(sk_sleep(sk), &wait); add_wait_queue(sk_sleep(sk), &wait);
while (1) { while (1) {
/* Ensure session->terminate is updated */
smp_mb__before_atomic();
if (atomic_read(&session->terminate)) if (atomic_read(&session->terminate))
break; break;
if (sk->sk_state != BT_CONNECTED) if (sk->sk_state != BT_CONNECTED)
...@@ -306,6 +303,10 @@ static int cmtp_session(void *arg) ...@@ -306,6 +303,10 @@ static int cmtp_session(void *arg)
cmtp_process_transmit(session); cmtp_process_transmit(session);
/*
* wait_woken() performs the necessary memory barriers
* for us; see the header comment for this primitive.
*/
wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
} }
remove_wait_queue(sk_sleep(sk), &wait); remove_wait_queue(sk_sleep(sk), &wait);
...@@ -431,9 +432,10 @@ int cmtp_del_connection(struct cmtp_conndel_req *req) ...@@ -431,9 +432,10 @@ int cmtp_del_connection(struct cmtp_conndel_req *req)
/* Stop session thread */ /* Stop session thread */
atomic_inc(&session->terminate); atomic_inc(&session->terminate);
/* Ensure session->terminate is updated */ /*
smp_mb__after_atomic(); * See the comment preceding the call to wait_woken()
* in cmtp_session().
*/
wake_up_interruptible(sk_sleep(session->sock->sk)); wake_up_interruptible(sk_sleep(session->sock->sk));
} else } else
err = -ENOENT; err = -ENOENT;
......
...@@ -1074,6 +1074,10 @@ static int hidp_session_start_sync(struct hidp_session *session) ...@@ -1074,6 +1074,10 @@ static int hidp_session_start_sync(struct hidp_session *session)
static void hidp_session_terminate(struct hidp_session *session) static void hidp_session_terminate(struct hidp_session *session)
{ {
atomic_inc(&session->terminate); atomic_inc(&session->terminate);
/*
* See the comment preceding the call to wait_woken()
* in hidp_session_run().
*/
wake_up_interruptible(&hidp_session_wq); wake_up_interruptible(&hidp_session_wq);
} }
...@@ -1193,8 +1197,6 @@ static void hidp_session_run(struct hidp_session *session) ...@@ -1193,8 +1197,6 @@ static void hidp_session_run(struct hidp_session *session)
* thread is woken up by ->sk_state_changed(). * thread is woken up by ->sk_state_changed().
*/ */
/* Ensure session->terminate is updated */
smp_mb__before_atomic();
if (atomic_read(&session->terminate)) if (atomic_read(&session->terminate))
break; break;
...@@ -1228,14 +1230,15 @@ static void hidp_session_run(struct hidp_session *session) ...@@ -1228,14 +1230,15 @@ static void hidp_session_run(struct hidp_session *session)
hidp_process_transmit(session, &session->ctrl_transmit, hidp_process_transmit(session, &session->ctrl_transmit,
session->ctrl_sock); session->ctrl_sock);
/*
* wait_woken() performs the necessary memory barriers
* for us; see the header comment for this primitive.
*/
wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT); wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
} }
remove_wait_queue(&hidp_session_wq, &wait); remove_wait_queue(&hidp_session_wq, &wait);
atomic_inc(&session->terminate); atomic_inc(&session->terminate);
/* Ensure session->terminate is updated */
smp_mb__after_atomic();
} }
static int hidp_session_wake_function(wait_queue_entry_t *wait, static int hidp_session_wake_function(wait_queue_entry_t *wait,
......
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