diff mbox series

Bluetooth: Call shutdown for HCI_USER_CHANNEL

Message ID 20220829195805.1.Ic8eabc8ed89a07c3d52726dd017539069faac6c4@changeid
State New
Headers show
Series Bluetooth: Call shutdown for HCI_USER_CHANNEL | expand

Commit Message

Abhishek Pandit-Subedi Aug. 30, 2022, 2:58 a.m. UTC
From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>

Some drivers depend on shutdown being called for proper operation.
There's no reason to restrict this from being called when using
HCI_USER_CHANNEL.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
---
This is easy to reproduce on QCA6174-A, which uses the hci_qca driver.
Simply open the socket, bind as userchannel and close again. It will
succeed the first time and fail the second time (because shutdown wasn't
called). A similar bug also occurs with btmtksdio (using MT7921).

Question for maintainers: What is a driver supposed to be doing during
shutdown? We should add some documentation to `struct hci_dev` to
clarify.


 net/bluetooth/hci_sync.c | 1 -
 1 file changed, 1 deletion(-)

Comments

Abhishek Pandit-Subedi Sept. 2, 2022, 12:54 a.m. UTC | #1
Please avoid merging.

After additional testing, I've found a problem with btusb->shutdown
not working for Intel controllers.

btusb_shutdown_intel uses __hci_sync_cmd(...) to send the command and
the command complete will not get captured because it is using hci
user channel. We'll need a more invasive change to remove the
userchannel flag during close so that the stack can properly clean up.


On Mon, Aug 29, 2022 at 7:58 PM Abhishek Pandit-Subedi
<abhishekpandit@google.com> wrote:
>
> From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
>
> Some drivers depend on shutdown being called for proper operation.
> There's no reason to restrict this from being called when using
> HCI_USER_CHANNEL.
>
> Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
> ---
> This is easy to reproduce on QCA6174-A, which uses the hci_qca driver.
> Simply open the socket, bind as userchannel and close again. It will
> succeed the first time and fail the second time (because shutdown wasn't
> called). A similar bug also occurs with btmtksdio (using MT7921).
>
> Question for maintainers: What is a driver supposed to be doing during
> shutdown? We should add some documentation to `struct hci_dev` to
> clarify.
>
>
>  net/bluetooth/hci_sync.c | 1 -
>  1 file changed, 1 deletion(-)
>
> diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
> index e08c0503027d..be78fd708f16 100644
> --- a/net/bluetooth/hci_sync.c
> +++ b/net/bluetooth/hci_sync.c
> @@ -4680,7 +4680,6 @@ int hci_dev_close_sync(struct hci_dev *hdev)
>         }
>
>         if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
> -           !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
>             test_bit(HCI_UP, &hdev->flags)) {
>                 /* Execute vendor specific shutdown routine */
>                 if (hdev->shutdown)
> --
> 2.37.2.672.g94769d06f0-goog
>
diff mbox series

Patch

diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index e08c0503027d..be78fd708f16 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -4680,7 +4680,6 @@  int hci_dev_close_sync(struct hci_dev *hdev)
 	}
 
 	if (!hci_dev_test_flag(hdev, HCI_UNREGISTER) &&
-	    !hci_dev_test_flag(hdev, HCI_USER_CHANNEL) &&
 	    test_bit(HCI_UP, &hdev->flags)) {
 		/* Execute vendor specific shutdown routine */
 		if (hdev->shutdown)