1. 26 11月, 2021 4 次提交
  2. 25 11月, 2021 1 次提交
  3. 16 11月, 2021 4 次提交
    • A
      Bluetooth: Attempt to clear HCI_LE_ADV on adv set terminated error event · 1f9d5657
      Archie Pusaka 提交于
      We should clear the flag if the adv instance removed due to receiving
      this error status is the last one we have.
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: NMiao-chen Chou <mcchou@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      1f9d5657
    • A
      Bluetooth: Ignore HCI_ERROR_CANCELLED_BY_HOST on adv set terminated event · 0f281a5e
      Archie Pusaka 提交于
      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: NArchie Pusaka <apusaka@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      0f281a5e
    • J
      Bluetooth: fix uninitialized variables notify_evt · a27c519a
      Jackie Liu 提交于
      Coverity Scan report:
      
      [...]
      *** CID 1493985:  Uninitialized variables  (UNINIT)
      /net/bluetooth/hci_event.c: 4535 in hci_sync_conn_complete_evt()
      4529
      4530     	/* Notify only in case of SCO over HCI transport data path which
      4531     	 * is zero and non-zero value shall be non-HCI transport data path
      4532     	 */
      4533     	if (conn->codec.data_path == 0) {
      4534     		if (hdev->notify)
      >>>     CID 1493985:  Uninitialized variables  (UNINIT)
      >>>     Using uninitialized value "notify_evt" when calling "*hdev->notify".
      4535     			hdev->notify(hdev, notify_evt);
      4536     	}
      4537
      4538     	hci_connect_cfm(conn, ev->status);
      4539     	if (ev->status)
      4540     		hci_conn_del(conn);
      [...]
      
      Although only btusb uses air_mode, and he only handles HCI_NOTIFY_ENABLE_SCO_CVSD
      and HCI_NOTIFY_ENABLE_SCO_TRANSP, there is still a very small chance that
      ev->air_mode is not equal to 0x2 and 0x3, but notify_evt is initialized to
      HCI_NOTIFY_ENABLE_SCO_CVSD or HCI_NOTIFY_ENABLE_SCO_TRANSP. the context is
      maybe not correct.
      
      Let us directly use the required function instead of re-initializing it,
      so as to restore the original logic and make the code more correct.
      
      Addresses-Coverity: ("Uninitialized variables")
      Fixes: f4f9fa0c ("Bluetooth: Allow usb to auto-suspend when SCO use	non-HCI transport")
      Suggested-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NJackie Liu <liuyun01@kylinos.cn>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      a27c519a
    • P
      Bluetooth: stop proccessing malicious adv data · 3a56ef71
      Pavel Skripkin 提交于
      Syzbot reported slab-out-of-bounds read in hci_le_adv_report_evt(). The
      problem was in missing validaion check.
      
      We should check if data is not malicious and we can read next data block.
      If we won't check ptr validness, code can read a way beyond skb->end and
      it can cause problems, of course.
      
      Fixes: e95beb41 ("Bluetooth: hci_le_adv_report_evt code refactoring")
      Reported-and-tested-by: syzbot+e3fcb9c4f3c2a931dc40@syzkaller.appspotmail.com
      Signed-off-by: NPavel Skripkin <paskripkin@gmail.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      3a56ef71
  4. 29 10月, 2021 7 次提交
    • L
      Bluetooth: hci_sync: Rework hci_suspend_notifier · 182ee45d
      Luiz Augusto von Dentz 提交于
      This makes hci_suspend_notifier use the hci_*_sync which can be
      executed synchronously which is allowed in the suspend_notifier and
      simplifies a lot of the handling since the status of each command can
      be checked inline so no other work need to be scheduled thus can be
      performed without using of a state machine.
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      182ee45d
    • B
      Bluetooth: hci_sync: Convert MGMT_OP_SSP · 3244845c
      Brian Gix 提交于
      mgmt-tester paths:
      Set SSP on - Success 2
      Set Device ID - SSP off and Power on
      Signed-off-by: NBrian Gix <brian.gix@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      3244845c
    • L
      Bluetooth: hci_sync: Convert MGMT_OP_START_DISCOVERY · abfeea47
      Luiz Augusto von Dentz 提交于
      This make use of hci_cmd_sync_queue for MGMT_OP_START_DISCOVERY,
      MGMT_OP_START_SERVICE_DISCOVERY and MGMT_OP_STOP_DISCOVERY to use
      hci_cmd_sync_queue so they no longer depend on hdev->discov_update work
      to send any commands.
      
      Tested with:
      
      tools/mgmt-tester -s "Start Discovery"
      
      Test Summary
      ------------
      Start Discovery - Not powered 1                      Passed
      Start Discovery - Invalid parameters 1               Passed
      Start Discovery - Not supported 1                    Passed
      Start Discovery - Success 1                          Passed
      Start Discovery - Success 2                          Passed
      Start Discovery - Power Off 1                        Passed
      Start Discovery BREDR LE - (Ext Scan Enable)         Passed
      Start Discovery LE - (Ext Scan Enable)               Passed
      Start Discovery LE - (Ext Scan Param)                Passed
      Start Discovery - (2m, Scan Param)                   Passed
      Start Discovery - (coded, Scan Param)                Passed
      Start Discovery - (1m, 2m, coded, Scan Param)        Passed
      LL Privacy - Start Discovery 1 (Disable RL)          Passed
      LL Privacy - Start Discovery 2 (Disable RL)          Passed
      Total: 14, Passed: 14 (100.0%), Failed: 0, Not Run: 0
      
      tools/mgmt-tester -s "Start Service"
      
      Test Summary
      ------------
      Start Service Discovery - Not powered 1              Passed
      Start Service Discovery - Invalid parameters 1       Passed
      Start Service Discovery - Not supported 1            Passed
      Start Service Discovery - Success 1                  Passed
      Start Service Discovery - Success 2                  Passed
      Total: 5, Passed: 5 (100.0%), Failed: 0, Not Run: 0
      
      tools/mgmt-tester -s "Stop Discovery"
      
      Test Summary
      ------------
      Stop Discovery - Success 1                           Passed
      Stop Discovery - BR/EDR (Inquiry) Success 1          Passed
      Stop Discovery - Rejected 1                          Passed
      Stop Discovery - Invalid parameters 1                Passed
      Stop Discovery - (Ext Scan Disable)                  Passed
      Total: 5, Passed: 5 (100.0%), Failed: 0, Not Run: 0
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      abfeea47
    • L
      Bluetooth: hci_sync: Rework background scan · 5bee2fd6
      Luiz Augusto von Dentz 提交于
      This replaces the use of hci_update_background_scan with
      hci_update_passive_scan which runs from cmd_work_sync and deal properly
      with resolving list when LL privacy is enabled.
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      5bee2fd6
    • L
      Bluetooth: hci_sync: Enable advertising when LL privacy is enabled · ad383c2c
      Luiz Augusto von Dentz 提交于
      This enables advertising when LL privacy is enabled and changes the
      command sequence when resolving list is updated to also account for when
      advertising is enabled using the following sequence:
      
      If there are devices to scan:
      
      Disable Scanning -> Update Accept List ->
      use_ll_privacy((Disable Advertising) -> Disable Resolving List ->
      Update Resolving List -> Enable Resolving List -> (Enable Advertising)) ->
      Enable Scanning
      
      Otherwise:
      
      Disable Scanning
      
      Errors during the Update Accept List stage are handled gracefully by
      restoring any previous state (e.g. advertising) and disabling the use of
      accept list as either accept list or resolving list could not be
      updated.
      
      Tested with:
      
      mgmt-tester -s "LL Privacy"
      
      Test Summary
      ------------
      LL Privacy - Add Device 1 (Add to WL)                Passed
      LL Privacy - Add Device 2 (Add to RL)                Passed
      LL Privacy - Add Device 3 (Enable RL)                Passed
      LL Privacy - Add Device 4 (2 Devices to WL)          Passed
      LL Privacy - Add Device 5 (2 Devices to RL)          Passed
      LL Privacy - Add Device 6 (RL is full)               Passed
      LL Privacy - Add Device 7 (WL is full)               Passed
      LL Privacy - Add Device 8 (Disable Adv)              Passed
      LL Privacy - Add Device 9 (Multi Adv)                Passed
      LL Privacy - Add Device 10 (Multi Dev and Multi Adv) Passed
      LL Privacy - Remove Device 1 (Remove from WL)        Passed
      LL Privacy - Remove Device 2 (Remove from RL)        Passed
      LL Privacy - Remove Device 3 (Disable RL)            Passed
      LL Privacy - Remove Device 4 (Disable Adv)           Passed
      LL Privacy - Remove Device 5 (Multi Adv)             Passed
      LL Privacy - Start Discovery 1 (Disable RL)          Passed
      LL Privacy - Start Discovery 2 (Disable RL)          Passed
      Total: 18, Passed: 18 (100.0%), Failed: 0, Not Run: 0
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      ad383c2c
    • L
      Bluetooth: hci_sync: Make use of hci_cmd_sync_queue set 2 · cba6b758
      Luiz Augusto von Dentz 提交于
      This make use of hci_cmd_sync_queue for the following MGMT commands:
      
      Add Advertising
      Remove Advertising
      Add Extended Advertising Parameters
      Add Extended Advertising Data
      
      mgmt-tester -s "Add Advertising"
      
      Test Summary
      ------------
      Add Advertising - Failure: LE off                    Passed
      Add Advertising - Invalid Params 1 (AD too long)     Passed
      Add Advertising - Invalid Params 2 (Malformed len)   Passed
      Add Advertising - Invalid Params 3 (Malformed len)   Passed
      Add Advertising - Invalid Params 4 (Malformed len)   Passed
      Add Advertising - Invalid Params 5 (AD too long)     Passed
      Add Advertising - Invalid Params 6 (ScRsp too long)  Passed
      Add Advertising - Invalid Params 7 (Malformed len)   Passed
      Add Advertising - Invalid Params 8 (Malformed len)   Passed
      Add Advertising - Invalid Params 9 (Malformed len)   Passed
      Add Advertising - Invalid Params 10 (ScRsp too long) Passed
      Add Advertising - Rejected (Timeout, !Powered)       Passed
      Add Advertising - Success 1 (Powered, Add Adv Inst)  Passed
      Add Advertising - Success 2 (!Powered, Add Adv Inst) Passed
      Add Advertising - Success 3 (!Powered, Adv Enable)   Passed
      Add Advertising - Success 4 (Set Adv on override)    Passed
      Add Advertising - Success 5 (Set Adv off override)   Passed
      Add Advertising - Success 6 (Scan Rsp Dta, Adv ok)   Passed
      Add Advertising - Success 7 (Scan Rsp Dta, Scan ok)  Passed
      Add Advertising - Success 8 (Connectable Flag)       Passed
      Add Advertising - Success 9 (General Discov Flag)    Passed
      Add Advertising - Success 10 (Limited Discov Flag)   Passed
      Add Advertising - Success 11 (Managed Flags)         Passed
      Add Advertising - Success 12 (TX Power Flag)         Passed
      Add Advertising - Success 13 (ADV_SCAN_IND)          Passed
      Add Advertising - Success 14 (ADV_NONCONN_IND)       Passed
      Add Advertising - Success 15 (ADV_IND)               Passed
      Add Advertising - Success 16 (Connectable -> on)     Passed
      Add Advertising - Success 17 (Connectable -> off)    Passed
      Add Advertising - Success 18 (Power -> off, Remove)  Passed
      Add Advertising - Success 19 (Power -> off, Keep)    Passed
      Add Advertising - Success 20 (Add Adv override)      Passed
      Add Advertising - Success 21 (Timeout expires)       Passed
      Add Advertising - Success 22 (LE -> off, Remove)     Passed
      Add Advertising - Success (Empty ScRsp)              Passed
      Add Advertising - Success (ScRsp only)               Passed
      Add Advertising - Invalid Params (ScRsp too long)    Passed
      Add Advertising - Success (ScRsp appear)             Passed
      Add Advertising - Invalid Params (ScRsp appear long) Passed
      Add Advertising - Success (Appear is null)           Passed
      Add Advertising - Success (Name is null)             Passed
      Add Advertising - Success (Complete name)            Passed
      Add Advertising - Success (Shortened name)           Passed
      Add Advertising - Success (Short name)               Passed
      Add Advertising - Success (Name + data)              Passed
      Add Advertising - Invalid Params (Name + data)       Passed
      Add Advertising - Success (Name+data+appear)         Passed
      Total: 47, Passed: 47 (100.0%), Failed: 0, Not Run: 0
      Overall execution time: 2.17 seconds
      
      mgmt-tester -s "Remove Advertising"
      
      Test Summary
      ------------
      Remove Advertising - Invalid Params 1                Passed
      Remove Advertising - Success 1                       Passed
      Remove Advertising - Success 2                       Passed
      Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
      Overall execution time: 0.0585 seconds
      
      mgmt-tester -s "Ext Adv MGMT Params"
      
      Test Summary:
      ------------
      Ext Adv MGMT Params - Unpowered                      Passed
      Ext Adv MGMT Params - Invalid parameters             Passed
      Ext Adv MGMT Params - Success                        Passed
      Ext Adv MGMT Params - (5.0) Success                  Passed
      Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0
      Overall execution time: 0.0746 seconds
      
      mgmt-tester -s "Ext Adv MGMT -"
      
      Test Summary
      ------------
      Ext Adv MGMT - Data set without Params               Passed
      Ext Adv MGMT - AD Data (5.0) Invalid parameters      Passed
      Ext Adv MGMT - AD Data (5.0) Success                 Passed
      Ext Adv MGMT - AD Scan Response (5.0) Success        Passed
      Total: 4, Passed: 4 (100.0%), Failed: 0, Not Run: 0
      Overall execution time: 0.0805 seconds
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      cba6b758
    • A
      Bluetooth: Fix removing adv when processing cmd complete · 2128939f
      Archie Pusaka 提交于
      If we remove one instance of adv using Set Extended Adv Enable, there
      is a possibility of issue occurs when processing the Command Complete
      event. Especially, the adv_info might not be found since we already
      remove it in hci_req_clear_adv_instance() -> hci_remove_adv_instance().
      If that's the case, we will mistakenly proceed to remove all adv
      instances instead of just one single instance.
      
      This patch fixes the issue by checking the content of the HCI command
      instead of checking whether the adv_info is found.
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: NSonny Sasaka <sonnysasaka@chromium.org>
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      2128939f
  5. 06 10月, 2021 1 次提交
    • L
      Bluetooth: Fix handling of SUSPEND_DISCONNECTING · 83775456
      Luiz Augusto von Dentz 提交于
      When SUSPEND_DISCONNECTING bit is set that means Disconnect is pending
      but the code was evaluating if the list is empty before calling
      hci_conn_del which does the actual cleanup and remove the connection
      from the list thus the bit is never cleared causing the suspend
      procedure to always timeout when there are connections to be
      disconnected:
      
      Suspend/Resume - Success 5 (Pairing - Legacy) - waiting done
        Set the system into Suspend via force_suspend
      = mgmt-tester: Suspend/Resume - Success 5 (Pairing -..   17:03:13.200458
      = mgmt-tester: Set the system into Suspend via force_suspend    17:03:13.205812
      < HCI Command: Write Scan E.. (0x03|0x001a) plen 1  #122 [hci0] 17:03:13.213561
              Scan enable: No Scans (0x00)
      > HCI Event: Command Complete (0x0e) plen 4         #123 [hci0] 17:03:13.214710
            Write Scan Enable (0x03|0x001a) ncmd 1
              Status: Success (0x00)
      < HCI Command: Disconnect (0x01|0x0006) plen 3      #124 [hci0] 17:03:13.215830
              Handle: 42
              Reason: Remote Device Terminated due to Power Off (0x15)
      > HCI Event: Command Status (0x0f) plen 4           #125 [hci0] 17:03:13.216602
            Disconnect (0x01|0x0006) ncmd 1
              Status: Success (0x00)
      > HCI Event: Disconnect Complete (0x05) plen 4      #126 [hci0] 17:03:13.217342
              Status: Success (0x00)
              Handle: 42
              Reason: Remote Device Terminated due to Power Off (0x15)
      @ MGMT Event: Device Disconn.. (0x000c) plen 8  {0x0002} [hci0] 17:03:13.217688
              BR/EDR Address: 00:AA:01:01:00:00 (Intel Corporation)
              Reason: Connection terminated by local host for suspend (0x05)
      @ MGMT Event: Device Disconn.. (0x000c) plen 8  {0x0001} [hci0] 17:03:13.217688
              BR/EDR Address: 00:AA:01:01:00:00 (Intel Corporation)
              Reason: Connection terminated by local host for suspend (0x05)
      Suspend/Resume - Success 5 (Pairing - Legacy) - test timed out
      = mgmt-tester: Suspend/Resume - Success 5 (Pairing -..   17:03:13.939317
      Suspend/Resume - Success 5 (Pairing - Legacy) - teardown
      = mgmt-tester: Suspend/Resume - Success 5 (Pairing -..   17:03:13.947267
      [   13.284291] Bluetooth: hci0: Timed out waiting for suspend events
      [   13.287324] Bluetooth: hci0: Suspend timeout bit: 6
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      83775456
  6. 21 9月, 2021 1 次提交
  7. 08 9月, 2021 2 次提交
  8. 31 8月, 2021 2 次提交
  9. 30 8月, 2021 1 次提交
  10. 17 8月, 2021 1 次提交
    • K
      Bluetooth: Fix race condition in handling NOP command · ecb71f25
      Kiran K 提交于
      For NOP command, need to cancel work scheduled on cmd_timer,
      on receiving command status or commmand complete event.
      
      Below use case might lead to race condition multiple when NOP
      commands are queued sequentially:
      
      hci_cmd_work() {
         if (atomic_read(&hdev->cmd_cnt) {
                  .
                  .
                  .
            atomic_dec(&hdev->cmd_cnt);
            hci_send_frame(hdev,...);
            schedule_delayed_work(&hdev->cmd_timer,...);
         }
      }
      
      On receiving event for first NOP, the work scheduled on hdev->cmd_timer
      is not cancelled and second NOP is dequeued and sent to controller.
      
      While waiting for an event for second NOP command, work scheduled on
      cmd_timer for the first NOP can get scheduled, resulting in sending third
      NOP command (sending back to back NOP commands). This might
      cause issues at controller side (like memory overrun, controller going
      unresponsive) resulting in hci tx timeouts, hardware errors etc.
      
      The fix to this issue is to cancel the delayed work scheduled on
      cmd_timer on receiving command status or command complete event for
      NOP command (this patch handles NOP command same as any other SIG
      command).
      Signed-off-by: NKiran K <kiran.k@intel.com>
      Reviewed-by: NChethan T N <chethan.tumkur.narayan@intel.com>
      Reviewed-by: NSrivatsa Ravishankar <ravishankar.srivatsa@intel.com>
      Acked-by: NManish Mandlik <mmandlik@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      ecb71f25
  11. 16 8月, 2021 2 次提交
  12. 04 8月, 2021 2 次提交
  13. 29 7月, 2021 1 次提交
  14. 26 6月, 2021 11 次提交
    • L
      Bluetooth: Fix handling of HCI_LE_Advertising_Set_Terminated event · 23837a6d
      Luiz Augusto von Dentz 提交于
      Error status of this event means that it has ended due reasons other
      than a connection:
      
       'If advertising has terminated as a result of the advertising duration
       elapsing, the Status parameter shall be set to the error code
       Advertising Timeout (0x3C).'
      
       'If advertising has terminated because the
       Max_Extended_Advertising_Events was reached, the Status parameter
       shall be set to the error code Limit Reached (0x43).'
      
      Fixes: acf0aeae ("Bluetooth: Handle ADv set terminated event")
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      23837a6d
    • A
      Bluetooth: use inclusive language when filtering devices · 3d4f9c00
      Archie Pusaka 提交于
      This patch replaces some non-inclusive terms based on the appropriate
      language mapping table compiled by the Bluetooth SIG:
      https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf
      
      Specifically, these terms are replaced:
      blacklist -> reject list
      whitelist -> accept list
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: NMiao-chen Chou <mcchou@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      3d4f9c00
    • A
      Bluetooth: use inclusive language when tracking connections · 39bc74ca
      Archie Pusaka 提交于
      This patch replaces some non-inclusive terms based on the appropriate
      language mapping table compiled by the Bluetooth SIG:
      https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf
      
      Specifically, these terms are replaced:
      master -> central
      slave  -> peripheral
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: NMiao-chen Chou <mcchou@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      39bc74ca
    • A
      Bluetooth: use inclusive language in HCI role comments · 74be523c
      Archie Pusaka 提交于
      This patch replaces some non-inclusive terms based on the appropriate
      language mapping table compiled by the Bluetooth SIG:
      https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf
      
      Specifically, these terms are replaced:
      master -> initiator (for smp) or central (everything else)
      slave  -> responder (for smp) or peripheral (everything else)
      
      The #define preprocessor terms are unchanged for now to not disturb
      dependent APIs.
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      74be523c
    • A
      Bluetooth: use inclusive language in comments · 67ffb185
      Archie Pusaka 提交于
      This patch replaces some non-inclusive terms based on the appropriate
      language mapping table compiled by the Bluetooth SIG:
      https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf
      
      Specifically, these terms are replaced:
      slave       -> peripheral
      blacklisted -> blocked
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: NMiao-chen Chou <mcchou@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      67ffb185
    • A
      Bluetooth: use inclusive language in HCI LE features · ef365da1
      Archie Pusaka 提交于
      This patch replaces some non-inclusive terms based on the appropriate
      language mapping table compiled by the Bluetooth SIG:
      https://specificationrefs.bluetooth.com/language-mapping/Appropriate_Language_Mapping_Table.pdf
      
      Specifically, these terms are replaced:
      master -> central
      slave  -> peripheral
      Signed-off-by: NArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: NMiao-chen Chou <mcchou@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      ef365da1
    • S
      Bluetooth: Translate additional address type during le_conn_comp · 79699a70
      Sathish Narasimman 提交于
      When using controller based address resolution, then the destination
      address type during le_conn_complete uses 0x02 & 0x03 if controller
      resolves the destination address(RPA).
      These address types need to be converted back into either 0x00 0r 0x01
      Signed-off-by: NSathish Narasimman <sathish.narasimman@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      79699a70
    • S
      Bluetooth: Remove spurious error message · 1c58e933
      Szymon Janc 提交于
      Even with rate limited reporting this is very spammy and since
      it is remote device that is providing bogus data there is no
      need to report this as error.
      
      Since real_len variable was used only to allow conditional error
      message it is now also removed.
      
      [72454.143336] bt_err_ratelimited: 10 callbacks suppressed
      [72454.143337] Bluetooth: hci0: advertising data len corrected
      [72454.296314] Bluetooth: hci0: advertising data len corrected
      [72454.892329] Bluetooth: hci0: advertising data len corrected
      [72455.051319] Bluetooth: hci0: advertising data len corrected
      [72455.357326] Bluetooth: hci0: advertising data len corrected
      [72455.663295] Bluetooth: hci0: advertising data len corrected
      [72455.787278] Bluetooth: hci0: advertising data len corrected
      [72455.942278] Bluetooth: hci0: advertising data len corrected
      [72456.094276] Bluetooth: hci0: advertising data len corrected
      [72456.249137] Bluetooth: hci0: advertising data len corrected
      [72459.416333] bt_err_ratelimited: 13 callbacks suppressed
      [72459.416334] Bluetooth: hci0: advertising data len corrected
      [72459.721334] Bluetooth: hci0: advertising data len corrected
      [72460.011317] Bluetooth: hci0: advertising data len corrected
      [72460.327171] Bluetooth: hci0: advertising data len corrected
      [72460.638294] Bluetooth: hci0: advertising data len corrected
      [72460.946350] Bluetooth: hci0: advertising data len corrected
      [72461.225320] Bluetooth: hci0: advertising data len corrected
      [72461.690322] Bluetooth: hci0: advertising data len corrected
      [72462.118318] Bluetooth: hci0: advertising data len corrected
      [72462.427319] Bluetooth: hci0: advertising data len corrected
      [72464.546319] bt_err_ratelimited: 7 callbacks suppressed
      [72464.546319] Bluetooth: hci0: advertising data len corrected
      [72464.857318] Bluetooth: hci0: advertising data len corrected
      [72465.163332] Bluetooth: hci0: advertising data len corrected
      [72465.278331] Bluetooth: hci0: advertising data len corrected
      [72465.432323] Bluetooth: hci0: advertising data len corrected
      [72465.891334] Bluetooth: hci0: advertising data len corrected
      [72466.045334] Bluetooth: hci0: advertising data len corrected
      [72466.197321] Bluetooth: hci0: advertising data len corrected
      [72466.340318] Bluetooth: hci0: advertising data len corrected
      [72466.498335] Bluetooth: hci0: advertising data len corrected
      [72469.803299] bt_err_ratelimited: 10 callbacks suppressed
      Signed-off-by: NSzymon Janc <szymon.janc@codecoup.pl>
      Fixes: https://bugzilla.kernel.org/show_bug.cgi?id=203753
      Cc: stable@vger.kernel.org
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      1c58e933
    • K
      Bluetooth: Fix alt settings for incoming SCO with transparent coding format · 06d213d8
      Kiran K 提交于
      For incoming SCO connection with transparent coding format, alt setting
      of CVSD is getting applied instead of Transparent.
      
      Before fix:
      < HCI Command: Accept Synchron.. (0x01|0x0029) plen 21  #2196 [hci0] 321.342548
              Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
              Transmit bandwidth: 8000
              Receive bandwidth: 8000
              Max latency: 13
              Setting: 0x0003
                Input Coding: Linear
                Input Data Format: 1's complement
                Input Sample Size: 8-bit
                # of bits padding at MSB: 0
                Air Coding Format: Transparent Data
              Retransmission effort: Optimize for link quality (0x02)
              Packet type: 0x003f
                HV1 may be used
                HV2 may be used
                HV3 may be used
                EV3 may be used
                EV4 may be used
                EV5 may be used
      > HCI Event: Command Status (0x0f) plen 4               #2197 [hci0] 321.343585
            Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
              Status: Success (0x00)
      > HCI Event: Synchronous Connect Comp.. (0x2c) plen 17  #2198 [hci0] 321.351666
              Status: Success (0x00)
              Handle: 257
              Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
              Link type: eSCO (0x02)
              Transmission interval: 0x0c
              Retransmission window: 0x04
              RX packet length: 60
              TX packet length: 60
              Air mode: Transparent (0x03)
      ........
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2336 [hci0] 321.383655
      < SCO Data TX: Handle 257 flags 0x00 dlen 60            #2337 [hci0] 321.389558
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2338 [hci0] 321.393615
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2339 [hci0] 321.393618
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2340 [hci0] 321.393618
      < SCO Data TX: Handle 257 flags 0x00 dlen 60            #2341 [hci0] 321.397070
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2342 [hci0] 321.403622
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2343 [hci0] 321.403625
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2344 [hci0] 321.403625
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2345 [hci0] 321.403625
      < SCO Data TX: Handle 257 flags 0x00 dlen 60            #2346 [hci0] 321.404569
      < SCO Data TX: Handle 257 flags 0x00 dlen 60            #2347 [hci0] 321.412091
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2348 [hci0] 321.413626
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2349 [hci0] 321.413630
      > SCO Data RX: Handle 257 flags 0x00 dlen 48            #2350 [hci0] 321.413630
      < SCO Data TX: Handle 257 flags 0x00 dlen 60            #2351 [hci0] 321.419674
      
      After fix:
      
      < HCI Command: Accept Synchronou.. (0x01|0x0029) plen 21  #309 [hci0] 49.439693
              Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
              Transmit bandwidth: 8000
              Receive bandwidth: 8000
              Max latency: 13
              Setting: 0x0003
                Input Coding: Linear
                Input Data Format: 1's complement
                Input Sample Size: 8-bit
                # of bits padding at MSB: 0
                Air Coding Format: Transparent Data
              Retransmission effort: Optimize for link quality (0x02)
              Packet type: 0x003f
                HV1 may be used
                HV2 may be used
                HV3 may be used
                EV3 may be used
                EV4 may be used
                EV5 may be used
      > HCI Event: Command Status (0x0f) plen 4                 #310 [hci0] 49.440308
            Accept Synchronous Connection Request (0x01|0x0029) ncmd 1
              Status: Success (0x00)
      > HCI Event: Synchronous Connect Complete (0x2c) plen 17  #311 [hci0] 49.449308
              Status: Success (0x00)
              Handle: 257
              Address: 1C:CC:D6:E2:EA:80 (Xiaomi Communications Co Ltd)
              Link type: eSCO (0x02)
              Transmission interval: 0x0c
              Retransmission window: 0x04
              RX packet length: 60
              TX packet length: 60
              Air mode: Transparent (0x03)
      < SCO Data TX: Handle 257 flags 0x00 dlen 60              #312 [hci0] 49.450421
      < SCO Data TX: Handle 257 flags 0x00 dlen 60              #313 [hci0] 49.457927
      > HCI Event: Max Slots Change (0x1b) plen 3               #314 [hci0] 49.460345
              Handle: 256
              Max slots: 5
      < SCO Data TX: Handle 257 flags 0x00 dlen 60              #315 [hci0] 49.465453
      > SCO Data RX: Handle 257 flags 0x00 dlen 60              #316 [hci0] 49.470502
      > SCO Data RX: Handle 257 flags 0x00 dlen 60              #317 [hci0] 49.470519
      < SCO Data TX: Handle 257 flags 0x00 dlen 60              #318 [hci0] 49.472996
      > SCO Data RX: Handle 257 flags 0x00 dlen 60              #319 [hci0] 49.480412
      < SCO Data TX: Handle 257 flags 0x00 dlen 60              #320 [hci0] 49.480492
      < SCO Data TX: Handle 257 flags 0x00 dlen 60              #321 [hci0] 49.487989
      > SCO Data RX: Handle 257 flags 0x00 dlen 60              #322 [hci0] 49.490303
      < SCO Data TX: Handle 257 flags 0x00 dlen 60              #323 [hci0] 49.495496
      > SCO Data RX: Handle 257 flags 0x00 dlen 60              #324 [hci0] 49.500304
      > SCO Data RX: Handle 257 flags 0x00 dlen 60              #325 [hci0] 49.500311
      Signed-off-by: NKiran K <kiran.k@intel.com>
      Signed-off-by: NLokendra Singh <lokendra.singh@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      06d213d8
    • M
      Bluetooth: Add ncmd=0 recovery handling · de75cd0d
      Manish Mandlik 提交于
      During command status or command complete event, the controller may set
      ncmd=0 indicating that it is not accepting any more commands. In such a
      case, host holds off sending any more commands to the controller. If the
      controller doesn't recover from such condition, host will wait forever,
      until the user decides that the Bluetooth is broken and may power cycles
      the Bluetooth.
      
      This patch triggers the hardware error to reset the controller and
      driver when it gets into such state as there is no other wat out.
      Reviewed-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Signed-off-by: NManish Mandlik <mmandlik@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      de75cd0d
    • Y
      Bluetooth: Return whether a connection is outbound · 1c6ed31b
      Yu Liu 提交于
      When an MGMT_EV_DEVICE_CONNECTED event is reported back to the user
      space we will set the flags to tell if the established connection is
      outbound or not. This is useful for the user space to log better metrics
      and error messages.
      Reviewed-by: NMiao-chen Chou <mcchou@chromium.org>
      Reviewed-by: NAlain Michaud <alainm@chromium.org>
      Signed-off-by: NYu Liu <yudiliu@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      1c6ed31b