All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: Simplify request cleanup code
@ 2015-11-12 13:15 Johan Hedberg
  2015-11-12 14:46 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: Johan Hedberg @ 2015-11-12 13:15 UTC (permalink / raw)
  To: linux-bluetooth

From: Johan Hedberg <johan.hedberg@intel.com>

The hci_req_sync_cancel() is just as much related to the request
cleanup as hci_request_cancel_all() is. Just move the former into the
latter and do the cleanup from a single place in hci_dev_do_close().
The important thing is to avoid deadlocks by holding the req_sync
lock: previously hci_request_cancel_all was done right after releasing
the lock and with this patch it's right before taking it.

Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
---
 net/bluetooth/hci_core.c    | 4 +---
 net/bluetooth/hci_request.c | 2 ++
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index fb618d6bcded..63fd31d7b27a 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -1523,7 +1523,7 @@ int hci_dev_do_close(struct hci_dev *hdev)
 
 	cancel_delayed_work(&hdev->power_off);
 
-	hci_req_sync_cancel(hdev, ENODEV);
+	hci_request_cancel_all(hdev);
 	hci_req_sync_lock(hdev);
 
 	if (!test_and_clear_bit(HCI_UP, &hdev->flags)) {
@@ -1625,8 +1625,6 @@ int hci_dev_do_close(struct hci_dev *hdev)
 
 	hci_req_sync_unlock(hdev);
 
-	hci_request_cancel_all(hdev);
-
 	hci_dev_put(hdev);
 	return 0;
 }
diff --git a/net/bluetooth/hci_request.c b/net/bluetooth/hci_request.c
index e8345d8106b5..76bd912be9fe 100644
--- a/net/bluetooth/hci_request.c
+++ b/net/bluetooth/hci_request.c
@@ -1270,6 +1270,8 @@ void hci_request_setup(struct hci_dev *hdev)
 
 void hci_request_cancel_all(struct hci_dev *hdev)
 {
+	hci_req_sync_cancel(hdev, ENODEV);
+
 	cancel_work_sync(&hdev->discov_update);
 	cancel_work_sync(&hdev->bg_scan_update);
 	cancel_delayed_work_sync(&hdev->le_scan_disable);
-- 
2.5.0


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

* Re: [PATCH] Bluetooth: Simplify request cleanup code
  2015-11-12 13:15 [PATCH] Bluetooth: Simplify request cleanup code Johan Hedberg
@ 2015-11-12 14:46 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2015-11-12 14:46 UTC (permalink / raw)
  To: Johan Hedberg; +Cc: linux-bluetooth

Hi Johan,

> The hci_req_sync_cancel() is just as much related to the request
> cleanup as hci_request_cancel_all() is. Just move the former into the
> latter and do the cleanup from a single place in hci_dev_do_close().
> The important thing is to avoid deadlocks by holding the req_sync
> lock: previously hci_request_cancel_all was done right after releasing
> the lock and with this patch it's right before taking it.
> 
> Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
> ---
> net/bluetooth/hci_core.c    | 4 +---
> net/bluetooth/hci_request.c | 2 ++
> 2 files changed, 3 insertions(+), 3 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

end of thread, other threads:[~2015-11-12 14:46 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-12 13:15 [PATCH] Bluetooth: Simplify request cleanup code Johan Hedberg
2015-11-12 14:46 ` Marcel Holtmann

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.