| From 8bf079861c1f68500f4bf548b28c48c83bdcd796 Mon Sep 17 00:00:00 2001 |
| From: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> |
| Date: Mon, 8 Aug 2022 11:04:05 -0700 |
| Subject: [PATCH] FROMLIST: Bluetooth: Ignore cmd_timeout with HCI_USER_CHANNEL |
| |
| When using HCI_USER_CHANNEL, hci traffic is expected to be handled by |
| userspace entirely. However, it is still possible (and sometimes |
| desirable) to be able to send commands to the controller directly. In |
| such cases, the kernel command timeout shouldn't do any error handling. |
| |
| Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org> |
| (am from https://patchwork.kernel.org/patch/12938973/) |
| (also found at https://lore.kernel.org/r/20220808110315.1.I5a39052e33f6f3c7406f53b0304a32ccf9f340fa@changeid) |
| |
| BUG=b:233764522 |
| TEST=run `hcitool cmd 4 1` while stack is running |
| |
| Change-Id: I5a39052e33f6f3c7406f53b0304a32ccf9f340fa |
| Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/kernel/+/3831732 |
| Commit-Queue: Abhishek Pandit-Subedi <abhishekpandit@google.com> |
| Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org> |
| Reviewed-by: Sean Paul <sean@poorly.run> |
| Reviewed-by: Katherine Lai <laikatherine@chromium.org> |
| Tested-by: Abhishek Pandit-Subedi <abhishekpandit@google.com> |
| --- |
| net/bluetooth/hci_core.c | 25 ++++++++++++++++--------- |
| 1 file changed, 16 insertions(+), 9 deletions(-) |
| |
| diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c |
| index 902b7e3c2822717e88572e44d72c5fd0c40df52b..b748377012cff09f541df8ba26e7872aa8c0fa58 100644 |
| --- a/net/bluetooth/hci_core.c |
| +++ b/net/bluetooth/hci_core.c |
| @@ -1447,18 +1447,25 @@ static void hci_cmd_timeout(struct work_struct *work) |
| struct hci_dev *hdev = container_of(work, struct hci_dev, |
| cmd_timer.work); |
| |
| - if (hdev->req_skb) { |
| - u16 opcode = hci_skb_opcode(hdev->req_skb); |
| + /* Don't trigger the timeout behavior if it happens while we're in |
| + * userchannel mode. Userspace is responsible for handling any command |
| + * timeouts. |
| + */ |
| + if (!(hci_dev_test_flag(hdev, HCI_USER_CHANNEL) && |
| + test_bit(HCI_UP, &hdev->flags))) { |
| + if (hdev->req_skb) { |
| + u16 opcode = hci_skb_opcode(hdev->req_skb); |
| |
| - bt_dev_err(hdev, "command 0x%4.4x tx timeout", opcode); |
| + bt_dev_err(hdev, "command 0x%4.4x tx timeout", opcode); |
| |
| - hci_cmd_sync_cancel_sync(hdev, ETIMEDOUT); |
| - } else { |
| - bt_dev_err(hdev, "command tx timeout"); |
| - } |
| + hci_cmd_sync_cancel_sync(hdev, ETIMEDOUT); |
| + } else { |
| + bt_dev_err(hdev, "command tx timeout"); |
| + } |
| |
| - if (hdev->cmd_timeout) |
| - hdev->cmd_timeout(hdev); |
| + if (hdev->cmd_timeout) |
| + hdev->cmd_timeout(hdev); |
| + } |
| |
| atomic_set(&hdev->cmd_cnt, 1); |
| queue_work(hdev->workqueue, &hdev->cmd_work); |
| -- |
| 2.47.0.277.g8800431eea-goog |
| |