From: Jeffy Chen <jeffy.chen@rock-chips.com>
To: linux-bluetooth@vger.kernel.org
Cc: Brian Norris <briannorris@chromium.org>,
Douglas Anderson <dianders@chromium.org>,
Jeffy Chen <jeffy.chen@rock-chips.com>,
Johan Hedberg <johan.hedberg@gmail.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
"David S. Miller" <davem@davemloft.net>,
Marcel Holtmann <marcel@holtmann.org>,
Gustavo Padovan <gustavo@padovan.org>
Subject: [PATCH] Bluetooth: hidp: might sleep error in hidp_session_thread
Date: Fri, 20 Jan 2017 21:52:08 +0800 [thread overview]
Message-ID: <1484920328-20522-1-git-send-email-jeffy.chen@rock-chips.com> (raw)
[ 39.044329] do not call blocking ops when !TASK_RUNNING; state=1 set
at [<ffffffbffc290358>] hidp_session_thread+0x110/0x568 [hidp]
...
[ 40.159664] Call trace:
[ 40.162122] [<ffffffc00024ae08>] __might_sleep+0x64/0x90
[ 40.167443] [<ffffffc00080568c>] lock_sock_nested+0x30/0x78
[ 40.173047] [<ffffffbffc1b3ca0>] l2cap_sock_sendmsg+0x90/0xf0
[bluetooth]
[ 40.179842] [<ffffffc0008012c4>] sock_sendmsg+0x4c/0x68
[ 40.185072] [<ffffffc000801414>] kernel_sendmsg+0x54/0x68
[ 40.190477] [<ffffffbffc28f4d0>] hidp_send_frame+0x78/0xa0 [hidp]
[ 40.196574] [<ffffffbffc28f53c>] hidp_process_transmit+0x44/0x98
[hidp]
[ 40.203191] [<ffffffbffc2905ac>] hidp_session_thread+0x364/0x568
[hidp]
Following (https://lwn.net/Articles/628628/).
Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com>
---
net/bluetooth/hidp/core.c | 15 +++++++++------
1 file changed, 9 insertions(+), 6 deletions(-)
diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index 0bec458..bfd3fb8 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -1180,7 +1180,9 @@ static void hidp_session_run(struct hidp_session *session)
struct sock *ctrl_sk = session->ctrl_sock->sk;
struct sock *intr_sk = session->intr_sock->sk;
struct sk_buff *skb;
+ DEFINE_WAIT_FUNC(wait, woken_wake_function);
+ add_wait_queue(sk_sleep(intr_sk), &wait);
for (;;) {
/*
* This thread can be woken up two ways:
@@ -1188,12 +1190,10 @@ static void hidp_session_run(struct hidp_session *session)
* session->terminate flag and wakes this thread up.
* - Via modifying the socket state of ctrl/intr_sock. This
* thread is woken up by ->sk_state_changed().
- *
- * Note: set_current_state() performs any necessary
- * memory-barriers for us.
*/
- set_current_state(TASK_INTERRUPTIBLE);
+ /* Ensure session->terminate is updated */
+ smp_mb__before_atomic();
if (atomic_read(&session->terminate))
break;
@@ -1227,11 +1227,14 @@ static void hidp_session_run(struct hidp_session *session)
hidp_process_transmit(session, &session->ctrl_transmit,
session->ctrl_sock);
- schedule();
+ wait_woken(&wait, TASK_INTERRUPTIBLE, MAX_SCHEDULE_TIMEOUT);
}
+ remove_wait_queue(sk_sleep(intr_sk), &wait);
atomic_inc(&session->terminate);
- set_current_state(TASK_RUNNING);
+
+ /* Ensure session->terminate is updated */
+ smp_mb__after_atomic();
}
/*
--
2.1.4
next reply other threads:[~2017-01-20 13:52 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 13:52 Jeffy Chen [this message]
2017-01-24 2:31 ` [PATCH] Bluetooth: hidp: might sleep error in hidp_session_thread Brian Norris
2017-01-24 7:29 ` jeffy
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1484920328-20522-1-git-send-email-jeffy.chen@rock-chips.com \
--to=jeffy.chen@rock-chips.com \
--cc=briannorris@chromium.org \
--cc=davem@davemloft.net \
--cc=dianders@chromium.org \
--cc=gustavo@padovan.org \
--cc=johan.hedberg@gmail.com \
--cc=linux-bluetooth@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcel@holtmann.org \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).