linux/include/net/bluetooth
Archie Pusaka 0f281a5e5b Bluetooth: Ignore HCI_ERROR_CANCELLED_BY_HOST on adv set terminated event
This event is received when the controller stops advertising,
specifically for these three reasons:
(a) Connection is successfully created (success).
(b) Timeout is reached (error).
(c) Number of advertising events is reached (error).
(*) This event is NOT generated when the host stops the advertisement.
Refer to the BT spec ver 5.3 vol 4 part E sec 7.7.65.18. Note that the
section was revised from BT spec ver 5.0 vol 2 part E sec 7.7.65.18
which was ambiguous about (*).

Some chips (e.g. RTL8822CE) send this event when the host stops the
advertisement with status = HCI_ERROR_CANCELLED_BY_HOST (due to (*)
above). This is treated as an error and the advertisement will be
removed and userspace will be informed via MGMT event.

On suspend, we are supposed to temporarily disable advertisements,
and continue advertising on resume. However, due to the behavior
above, the advertisements are removed instead.

This patch returns early if HCI_ERROR_CANCELLED_BY_HOST is received.

Btmon snippet of the unexpected behavior:
@ MGMT Command: Remove Advertising (0x003f) plen 1
        Instance: 1
< HCI Command: LE Set Extended Advertising Enable (0x08|0x0039) plen 6
        Extended advertising: Disabled (0x00)
        Number of sets: 1 (0x01)
        Entry 0
          Handle: 0x01
          Duration: 0 ms (0x00)
          Max ext adv events: 0
> HCI Event: LE Meta Event (0x3e) plen 6
      LE Advertising Set Terminated (0x12)
        Status: Operation Cancelled by Host (0x44)
        Handle: 1
        Connection handle: 0
        Number of completed extended advertising events: 5
> HCI Event: Command Complete (0x0e) plen 4
      LE Set Extended Advertising Enable (0x08|0x0039) ncmd 2
        Status: Success (0x00)

Signed-off-by: Archie Pusaka <apusaka@chromium.org>
Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
2021-11-16 15:16:30 +01:00
..
bluetooth.h Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2 2021-10-29 16:51:58 +02:00
hci_core.h Bluetooth: hci_request: Remove bg_scan_update work 2021-11-16 15:13:34 +01:00
hci_mon.h Bluetooth: monitor: Add support for ISO packets 2020-01-15 22:28:51 +01:00
hci_sock.h Bluetooth: Use only 8 bits for the HCI CMSG state flags 2020-06-12 15:10:46 +02:00
hci_sync.h Bluetooth: hci_sync: Convert MGMT_OP_SET_CONNECTABLE to use cmd_sync 2021-11-16 15:13:34 +01:00
hci.h Bluetooth: Ignore HCI_ERROR_CANCELLED_BY_HOST on adv set terminated event 2021-11-16 15:16:30 +01:00
l2cap.h Bluetooth: L2CAP: Fix not checking for maximum number of DCID 2021-03-15 21:08:33 +01:00
mgmt.h Bluetooth: use inclusive language in SMP 2021-06-26 07:12:37 +02:00
rfcomm.h Bluetooth: Replace zero-length array with flexible-array member 2020-02-28 08:30:02 +01:00
sco.h Bluetooth: Add support for BT_PKT_STATUS CMSG data for SCO connections 2020-06-12 15:08:49 +02:00