diff options
author | Marcel Holtmann <marcel@holtmann.org> | 2015-01-28 14:09:55 -0500 |
---|---|---|
committer | Marcel Holtmann <marcel@holtmann.org> | 2015-01-28 15:26:24 -0500 |
commit | c7741d16a57cbf97eebe53f27e8216b1ff20e20c (patch) | |
tree | 8956a07a75e67675e8c3613708183a852b9e0559 /net/bluetooth | |
parent | 5c912495b7a8ab6adae877979abfffba4340e06c (diff) |
Bluetooth: Perform a power cycle when receiving hardware error event
When receiving a HCI Hardware Error event, the controller should be
assumed to be non-functional until issuing a HCI Reset command.
The Bluetooth hardware errors are vendor specific and so add a
new hdev->hw_error callback that drivers can provide to run extra
code to handle the hardware error.
After completing the vendor specific error handling perform a full
reset of the Bluetooth stack by closing and re-opening the transport.
Based-on-patch-by: Johan Hedberg <johan.hedberg@intel.com>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
Diffstat (limited to 'net/bluetooth')
-rw-r--r-- | net/bluetooth/hci_core.c | 21 | ||||
-rw-r--r-- | net/bluetooth/hci_event.c | 4 |
2 files changed, 24 insertions, 1 deletions
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index d4c9152474a9..79693a9ef4eb 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
@@ -2151,6 +2151,26 @@ static void hci_power_off(struct work_struct *work) | |||
2151 | smp_unregister(hdev); | 2151 | smp_unregister(hdev); |
2152 | } | 2152 | } |
2153 | 2153 | ||
2154 | static void hci_error_reset(struct work_struct *work) | ||
2155 | { | ||
2156 | struct hci_dev *hdev = container_of(work, struct hci_dev, error_reset); | ||
2157 | |||
2158 | BT_DBG("%s", hdev->name); | ||
2159 | |||
2160 | if (hdev->hw_error) | ||
2161 | hdev->hw_error(hdev, hdev->hw_error_code); | ||
2162 | else | ||
2163 | BT_ERR("%s hardware error 0x%2.2x", hdev->name, | ||
2164 | hdev->hw_error_code); | ||
2165 | |||
2166 | if (hci_dev_do_close(hdev)) | ||
2167 | return; | ||
2168 | |||
2169 | smp_unregister(hdev); | ||
2170 | |||
2171 | hci_dev_do_open(hdev); | ||
2172 | } | ||
2173 | |||
2154 | static void hci_discov_off(struct work_struct *work) | 2174 | static void hci_discov_off(struct work_struct *work) |
2155 | { | 2175 | { |
2156 | struct hci_dev *hdev; | 2176 | struct hci_dev *hdev; |
@@ -2943,6 +2963,7 @@ struct hci_dev *hci_alloc_dev(void) | |||
2943 | INIT_WORK(&hdev->cmd_work, hci_cmd_work); | 2963 | INIT_WORK(&hdev->cmd_work, hci_cmd_work); |
2944 | INIT_WORK(&hdev->tx_work, hci_tx_work); | 2964 | INIT_WORK(&hdev->tx_work, hci_tx_work); |
2945 | INIT_WORK(&hdev->power_on, hci_power_on); | 2965 | INIT_WORK(&hdev->power_on, hci_power_on); |
2966 | INIT_WORK(&hdev->error_reset, hci_error_reset); | ||
2946 | 2967 | ||
2947 | INIT_DELAYED_WORK(&hdev->power_off, hci_power_off); | 2968 | INIT_DELAYED_WORK(&hdev->power_off, hci_power_off); |
2948 | INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off); | 2969 | INIT_DELAYED_WORK(&hdev->discov_off, hci_discov_off); |
diff --git a/net/bluetooth/hci_event.c b/net/bluetooth/hci_event.c index 4175470ff48e..a72a5f50728d 100644 --- a/net/bluetooth/hci_event.c +++ b/net/bluetooth/hci_event.c | |||
@@ -3100,7 +3100,9 @@ static void hci_hardware_error_evt(struct hci_dev *hdev, struct sk_buff *skb) | |||
3100 | { | 3100 | { |
3101 | struct hci_ev_hardware_error *ev = (void *) skb->data; | 3101 | struct hci_ev_hardware_error *ev = (void *) skb->data; |
3102 | 3102 | ||
3103 | BT_ERR("%s hardware error 0x%2.2x", hdev->name, ev->code); | 3103 | hdev->hw_error_code = ev->code; |
3104 | |||
3105 | queue_work(hdev->req_workqueue, &hdev->error_reset); | ||
3104 | } | 3106 | } |
3105 | 3107 | ||
3106 | static void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb) | 3108 | static void hci_role_change_evt(struct hci_dev *hdev, struct sk_buff *skb) |