All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC v2] Bluetooth : Fix hci_sync miss wakeup interrupt
@ 2014-10-31  5:23 chanyeol.park
  2014-11-01 21:24 ` Johan Hedberg
  0 siblings, 1 reply; 3+ messages in thread
From: chanyeol.park @ 2014-10-31  5:23 UTC (permalink / raw)
  To: linux-bluetooth

From: Chan-yeol Park <chanyeol.park@samsung.com>

__hci_cmd_sync_ev(), __hci_req_sync() could miss wake_up_interrupt from
hci_req_sync_complete() because hci_cmd_work() workquee and its reponse
could be completed before they are ready to get the signal through
add_wait_queue(), set_current_state(TASK_INTERRUPTIBLE).

Signed-off-by: Chan-yeol Park <chanyeol.park@samsung.com>
Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
---
 net/bluetooth/hci_core.c | 18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index cb05d7f..c008f1f 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1147,13 +1147,15 @@ struct sk_buff *__hci_cmd_sync_ev(struct hci_dev *hdev, u16 opcode, u32 plen,
 
 	hdev->req_status = HCI_REQ_PEND;
 
-	err = hci_req_run(&req, hci_req_sync_complete);
-	if (err < 0)
-		return ERR_PTR(err);
-
 	add_wait_queue(&hdev->req_wait_q, &wait);
 	set_current_state(TASK_INTERRUPTIBLE);
 
+	err = hci_req_run(&req, hci_req_sync_complete);
+	if (err < 0) {
+		remove_wait_queue(&hdev->req_wait_q, &wait);
+		return ERR_PTR(err);
+	}
+
 	schedule_timeout(timeout);
 
 	remove_wait_queue(&hdev->req_wait_q, &wait);
@@ -1211,10 +1213,15 @@ static int __hci_req_sync(struct hci_dev *hdev,
 
 	func(&req, opt);
 
+	add_wait_queue(&hdev->req_wait_q, &wait);
+	set_current_state(TASK_INTERRUPTIBLE);
+
 	err = hci_req_run(&req, hci_req_sync_complete);
 	if (err < 0) {
 		hdev->req_status = 0;
 
+		remove_wait_queue(&hdev->req_wait_q, &wait);
+
 		/* ENODATA means the HCI request command queue is empty.
 		 * This can happen when a request with conditionals doesn't
 		 * trigger any commands to be sent. This is normal behavior
@@ -1226,9 +1233,6 @@ static int __hci_req_sync(struct hci_dev *hdev,
 		return err;
 	}
 
-	add_wait_queue(&hdev->req_wait_q, &wait);
-	set_current_state(TASK_INTERRUPTIBLE);
-
 	schedule_timeout(timeout);
 
 	remove_wait_queue(&hdev->req_wait_q, &wait);
-- 
1.9.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [RFC v2] Bluetooth : Fix hci_sync miss wakeup interrupt
  2014-10-31  5:23 [RFC v2] Bluetooth : Fix hci_sync miss wakeup interrupt chanyeol.park
@ 2014-11-01 21:24 ` Johan Hedberg
  2014-11-03  5:21   ` Chan-yeol Park
  0 siblings, 1 reply; 3+ messages in thread
From: Johan Hedberg @ 2014-11-01 21:24 UTC (permalink / raw)
  To: chanyeol.park; +Cc: linux-bluetooth

Hi Chan-yeol,

On Fri, Oct 31, 2014, chanyeol.park@samsung.com wrote:
> __hci_cmd_sync_ev(), __hci_req_sync() could miss wake_up_interrupt from
> hci_req_sync_complete() because hci_cmd_work() workquee and its reponse
> could be completed before they are ready to get the signal through
> add_wait_queue(), set_current_state(TASK_INTERRUPTIBLE).
> 
> Signed-off-by: Chan-yeol Park <chanyeol.park@samsung.com>
> Signed-off-by: Kyungmin Park <kyungmin.park@samsung.com>
> ---
>  net/bluetooth/hci_core.c | 18 +++++++++++-------
>  1 file changed, 11 insertions(+), 7 deletions(-)

Applied to bluetooth-next. Thanks.

This fixed a really frequent hang for me of init HCI commands when
running mgmt-tester. Is it through the our user space testers that you
were seeing this issue as well? I might have seen the problem in the
past too but for some reason it started showing up really frequently
now.

Johan

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [RFC v2] Bluetooth : Fix hci_sync miss wakeup interrupt
  2014-11-01 21:24 ` Johan Hedberg
@ 2014-11-03  5:21   ` Chan-yeol Park
  0 siblings, 0 replies; 3+ messages in thread
From: Chan-yeol Park @ 2014-11-03  5:21 UTC (permalink / raw)
  To: linux-bluetooth

Hi Johan,
On 11/02/2014 06:24 AM, Johan Hedberg wrote:
> This fixed a really frequent hang for me of init HCI commands when 
> running mgmt-tester. Is it through the our user space testers that you 
> were seeing this issue as well? I might have seen the problem in the 
> past too but for some reason it started showing up really frequently 
> now. Johan 

In case of me, I've faced this bug while I execute "hciconfig hci0 down" 
and hci_dev_do_close(). and it takes about 5 second(HCI_CMD_TIMEOUT).
As you mentioned this bug is shown recently. I guess some of patches 
reveal our potential bug.

Thanks
Chanyeol




^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-11-03  5:21 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-10-31  5:23 [RFC v2] Bluetooth : Fix hci_sync miss wakeup interrupt chanyeol.park
2014-11-01 21:24 ` Johan Hedberg
2014-11-03  5:21   ` Chan-yeol Park

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.