Commit 10572132 authored by Gustavo F. Padovan's avatar Gustavo F. Padovan

Bluetooth: Fix HCI_RESET command synchronization

We can't send new commands before a cmd_complete for the HCI_RESET command
shows up.
Reported-by: default avatarMikko Vinni <mmvinni@yahoo.com>
Reported-by: default avatarJustin P. Mattock <justinmattock@gmail.com>
Reported-by: default avatarEd Tomlinson <edt@aei.ca>
Signed-off-by: default avatarGustavo F. Padovan <padovan@profusion.mobi>
Tested-by: default avatarJustin P. Mattock <justinmattock@gmail.com>
Tested-by: default avatarMikko Vinni <mmvinni@yahoo.com>
Tested-by: default avatarEd Tomlinson <edt@aei.ca>
parent 23e9fde2
...@@ -84,6 +84,8 @@ enum { ...@@ -84,6 +84,8 @@ enum {
HCI_SERVICE_CACHE, HCI_SERVICE_CACHE,
HCI_LINK_KEYS, HCI_LINK_KEYS,
HCI_DEBUG_KEYS, HCI_DEBUG_KEYS,
HCI_RESET,
}; };
/* HCI ioctl defines */ /* HCI ioctl defines */
......
...@@ -186,6 +186,7 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt) ...@@ -186,6 +186,7 @@ static void hci_reset_req(struct hci_dev *hdev, unsigned long opt)
BT_DBG("%s %ld", hdev->name, opt); BT_DBG("%s %ld", hdev->name, opt);
/* Reset device */ /* Reset device */
set_bit(HCI_RESET, &hdev->flags);
hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL); hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL);
} }
...@@ -213,8 +214,10 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt) ...@@ -213,8 +214,10 @@ static void hci_init_req(struct hci_dev *hdev, unsigned long opt)
/* Mandatory initialization */ /* Mandatory initialization */
/* Reset */ /* Reset */
if (!test_bit(HCI_QUIRK_NO_RESET, &hdev->quirks)) if (!test_bit(HCI_QUIRK_NO_RESET, &hdev->quirks)) {
set_bit(HCI_RESET, &hdev->flags);
hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL); hci_send_cmd(hdev, HCI_OP_RESET, 0, NULL);
}
/* Read Local Supported Features */ /* Read Local Supported Features */
hci_send_cmd(hdev, HCI_OP_READ_LOCAL_FEATURES, 0, NULL); hci_send_cmd(hdev, HCI_OP_READ_LOCAL_FEATURES, 0, NULL);
...@@ -1074,6 +1077,7 @@ static void hci_cmd_timer(unsigned long arg) ...@@ -1074,6 +1077,7 @@ static void hci_cmd_timer(unsigned long arg)
BT_ERR("%s command tx timeout", hdev->name); BT_ERR("%s command tx timeout", hdev->name);
atomic_set(&hdev->cmd_cnt, 1); atomic_set(&hdev->cmd_cnt, 1);
clear_bit(HCI_RESET, &hdev->flags);
tasklet_schedule(&hdev->cmd_task); tasklet_schedule(&hdev->cmd_task);
} }
......
...@@ -183,6 +183,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -183,6 +183,8 @@ static void hci_cc_reset(struct hci_dev *hdev, struct sk_buff *skb)
BT_DBG("%s status 0x%x", hdev->name, status); BT_DBG("%s status 0x%x", hdev->name, status);
clear_bit(HCI_RESET, &hdev->flags);
hci_req_complete(hdev, HCI_OP_RESET, status); hci_req_complete(hdev, HCI_OP_RESET, status);
} }
...@@ -1847,7 +1849,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb) ...@@ -1847,7 +1849,7 @@ static inline void hci_cmd_status_evt(struct hci_dev *hdev, struct sk_buff *skb)
if (ev->opcode != HCI_OP_NOP) if (ev->opcode != HCI_OP_NOP)
del_timer(&hdev->cmd_timer); del_timer(&hdev->cmd_timer);
if (ev->ncmd) { if (ev->ncmd && !test_bit(HCI_RESET, &hdev->flags)) {
atomic_set(&hdev->cmd_cnt, 1); atomic_set(&hdev->cmd_cnt, 1);
if (!skb_queue_empty(&hdev->cmd_q)) if (!skb_queue_empty(&hdev->cmd_q))
tasklet_schedule(&hdev->cmd_task); tasklet_schedule(&hdev->cmd_task);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment