1. 29 10月, 2021 4 次提交
    • L
      Bluetooth: hci_sync: Convert MGMT_SET_POWERED · cf75ad8b
      Luiz Augusto von Dentz 提交于
      This make use of hci_cmd_sync_queue when MGMT_SET_POWERED is used so all
      commands are run within hdev->cmd_sync_work instead of
      hdev->power_on_work and hdev->power_off_work.
      
      In addition to that the power on sequence now takes into account if
      local IRK needs to be programmed in the resolving list.
      
      Tested with:
      
      tools/mgmt-tester -s "Set powered"
      
      Test Summary
      ------------
      Set powered on - Success                             Passed
      Set powered on - Invalid parameters 1                Passed
      Set powered on - Invalid parameters 2                Passed
      Set powered on - Invalid parameters 3                Passed
      Set powered on - Invalid index                       Passed
      Set powered on - Privacy and Advertising             Passed
      Set powered off - Success                            Passed
      Set powered off - Class of Device                    Passed
      Set powered off - Invalid parameters 1               Passed
      Set powered off - Invalid parameters 2               Passed
      Set powered off - Invalid parameters 3               Passed
      Total: 11, Passed: 11 (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>
      cf75ad8b
    • 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 1 · 161510cc
      Luiz Augusto von Dentz 提交于
      This make use of hci_cmd_sync_queue for the following MGMT commands:
      
      Set Device Class
      Set Device ID
      Add UUID
      Remove UUID
      
      tools/mgmt-tester -s "Set Device Class"
      
      Test Summary
      ------------
      Set Device Class - Success 1                         Passed
      Set Device Class - Success 2                         Passed
      Set Device Class - Invalid parameters 1              Passed
      Total: 3, Passed: 3 (100.0%), Failed: 0, Not Run: 0
      Overall execution time: 0.0599 seconds
      
      tools/mgmt-tester -s "Set Device ID"
      
      Test Summary
      ------------
      Set Device ID - Success 1                            Passed
      Set Device ID - Success 2                            Passed
      Set Device ID - Disable                              Passed
      Set Device ID - Power off and Power on               Passed
      Set Device ID - SSP off and Power on                 Passed
      Set Device ID - Invalid Parameter                    Passed
      Total: 6, Passed: 6 (100.0%), Failed: 0, Not Run: 0
      Overall execution time: 0.107 seconds
      
      tools/mgmt-tester -s "Add UUID"
      
      Test Summary
      ------------
      Add UUID - UUID-16 1                                 Passed
      Add UUID - UUID-16 multiple 1                        Passed
      Add UUID - UUID-16 partial 1                         Passed
      Add UUID - UUID-32 1                                 Passed
      Add UUID - UUID-32 multiple 1                        Passed
      Add UUID - UUID-32 partial 1                         Passed
      Add UUID - UUID-128 1                                Passed
      Add UUID - UUID-128 multiple 1                       Passed
      Add UUID - UUID-128 partial 1                        Passed
      Add UUID - UUID mix                                  Passed
      Total: 10, Passed: 10 (100.0%), Failed: 0, Not Run: 0
      Overall execution time: 0.198 seconds
      
      tools/mgmt-tester -s "Remove UUID"
      
      Test Summary
      ------------
      Remove UUID - Success 1                              Passed
      Remove UUID - All UUID - Success 2                   Passed
      Remove UUID - Power Off - Success 3                  Passed
      Remove UUID - Power Off and On - Success 4           Passed
      Remove UUID - Not Exist - Invalid Params 1           Passed
      Total: 5, Passed: 5 (100.0%), Failed: 0, Not Run: 0
      Overall execution time: 0.0908 seconds
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      161510cc
    • M
      Bluetooth: Add helper for serialized HCI command execution · 6a98e383
      Marcel Holtmann 提交于
      The usage of __hci_cmd_sync() within the hdev->setup() callback allows for
      a nice and simple serialized execution of HCI commands. More importantly
      it allows for result processing before issueing the next command.
      
      With the current usage of hci_req_run() it is possible to batch up
      commands and execute them, but it is impossible to react to their
      results or errors.
      
      This is an attempt to generalize the hdev->setup() handling and provide
      a simple way of running multiple HCI commands from a single function
      context.
      
      There are multiple struct work that are decdicated to certain tasks
      already used right now. It is add a lot of bloat to hci_dev struct and
      extra handling code. So it might be possible to put all of these behind
      a common HCI command infrastructure and just execute the HCI commands
      from the same work context in a serialized fashion.
      
      For example updating the white list and resolving list can be done now
      without having to know the list size ahead of time. Also preparing for
      suspend or resume shouldn't require a state machine anymore. There are
      other tasks that should be simplified as well.
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      Signed-off-by: NLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      6a98e383
  2. 28 9月, 2021 1 次提交
    • M
      Bluetooth: Fix Advertisement Monitor Suspend/Resume · ce81843b
      Manish Mandlik 提交于
      During system suspend, advertisement monitoring is disabled by setting
      the HCI_VS_MSFT_LE_Set_Advertisement_Filter_Enable to False. This
      disables the monitoring during suspend, however, if the controller is
      monitoring a device, it sends HCI_VS_MSFT_LE_Monitor_Device_Event to
      indicate that the monitoring has been stopped for that particular
      device. This event may occur after suspend depending on the
      low_threshold_timeout and peer device advertisement frequency, which
      causes early wake up.
      
      Right way to disable the monitoring for suspend is by removing all the
      monitors before suspend and re-monitor after resume to ensure no events
      are received during suspend. This patch fixes this suspend/resume issue.
      
      Following tests are performed:
      - Add monitors before suspend and make sure DeviceFound gets triggered
      - Suspend the system and verify that all monitors are removed by kernel
        but not Released by bluetoothd
      - Wake up and verify that all monitors are added again and DeviceFound
        gets triggered
      Signed-off-by: NManish Mandlik <mmandlik@google.com>
      Reviewed-by: NArchie Pusaka <apusaka@google.com>
      Reviewed-by: NMiao-chen Chou <mcchou@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      ce81843b
  3. 21 9月, 2021 1 次提交
  4. 08 9月, 2021 1 次提交
  5. 04 8月, 2021 1 次提交
  6. 26 6月, 2021 4 次提交
  7. 23 4月, 2021 1 次提交
    • L
      bluetooth: eliminate the potential race condition when removing the HCI controller · e2cb6b89
      Lin Ma 提交于
      There is a possible race condition vulnerability between issuing a HCI
      command and removing the cont.  Specifically, functions hci_req_sync()
      and hci_dev_do_close() can race each other like below:
      
      thread-A in hci_req_sync()      |   thread-B in hci_dev_do_close()
                                      |   hci_req_sync_lock(hdev);
      test_bit(HCI_UP, &hdev->flags); |
      ...                             |   test_and_clear_bit(HCI_UP, &hdev->flags)
      hci_req_sync_lock(hdev);        |
                                      |
      In this commit we alter the sequence in function hci_req_sync(). Hence,
      the thread-A cannot issue th.
      Signed-off-by: NLin Ma <linma@zju.edu.cn>
      Cc: Marcel Holtmann <marcel@holtmann.org>
      Fixes: 7c6a329e ("[Bluetooth] Fix regression from using default link policy")
      Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
      e2cb6b89
  8. 06 4月, 2021 2 次提交
  9. 02 4月, 2021 2 次提交
  10. 16 3月, 2021 1 次提交
    • S
      Bluetooth: Cancel le_scan_restart work when stopping discovery · c06632a4
      Sonny Sasaka 提交于
      Not cancelling it has caused a bug where passive background scanning is
      disabled out of the blue, preventing BLE keyboards/mice to reconnect.
      Here is how it happens:
      After hci_req_stop_discovery, there is still le_scan_restart_work
      scheduled. Invocation of le_scan_restart_work causes a harmful
      le_scan_disable_work to be scheduled. This le_scan_disable_work will
      eventually disable passive scanning when the timer fires.
      
      Sample btmon trace:
      
      < HCI Command: LE Set Scan Parameters (0x08|0x000b) plen 7
              Type: Passive (0x00)
              Interval: 367.500 msec (0x024c)
              Window: 37.500 msec (0x003c)
              Own address type: Public (0x00)
              Filter policy: Accept all advertisement (0x00)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Scan Parameters (0x08|0x000b) ncmd 1
              Status: Success (0x00)
      < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
              Scanning: Enabled (0x01)
              Filter duplicates: Disabled (0x00)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Scan Enable (0x08|0x000c) ncmd 2
              Status: Success (0x00)
      ...
      < HCI Command: LE Set Scan Enable (0x08|0x000c) plen 2
              Scanning: Disabled (0x00)
              Filter duplicates: Disabled (0x00)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Scan Enable (0x08|0x000c) ncmd 2
              Status: Success (0x00)
      // Background scanning is not working here onwards.
      Reviewed-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Signed-off-by: NSonny Sasaka <sonnysasaka@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      c06632a4
  11. 04 3月, 2021 2 次提交
  12. 25 1月, 2021 2 次提交
  13. 19 12月, 2020 1 次提交
  14. 07 12月, 2020 8 次提交
  15. 11 11月, 2020 1 次提交
  16. 09 11月, 2020 2 次提交
  17. 25 9月, 2020 1 次提交
  18. 20 9月, 2020 1 次提交
  19. 15 9月, 2020 1 次提交
    • D
      Bluetooth: pause/resume advertising around suspend · 53274477
      Daniel Winkler 提交于
      Currently, the controller will continue advertising when the system
      enters suspend. This patch makes sure that all advertising instances are
      paused when entering suspend, and resumed when suspend exits.
      
      The Advertising and Suspend/Resume test suites were both run on this
      change on 4.19 kernel with both hardware offloaded multi-advertising and
      software rotated multi-advertising. In addition, a new test was added
      that performs the following steps:
      * Register 3 advertisements via bluez RegisterAdvertisement
      * Verify reception of all advertisements by remote peer
      * Enter suspend on DUT
      * Verify failure to receive all advertisements by remote peer
      * Exit suspend on DUT
      * Verify reception of all advertisements by remote peer
      Signed-off-by: NDaniel Winkler <danielwinkler@google.com>
      Reviewed-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      53274477
  20. 13 9月, 2020 1 次提交
    • A
      Bluetooth: Set ext scan response only when it exists · 6baf8a6a
      Abhishek Pandit-Subedi 提交于
      Only set extended scan response only when it exists. Otherwise, clear
      the scan response data.
      
      Per the core spec v5.2, Vol 4, Part E, 7.8.55
      
      If the advertising set is non-scannable and the Host uses this command
      other than to discard existing data, the Controller shall return the
      error code Invalid HCI Command Parameters (0x12).
      
      On WCN3991, the controller correctly responds with Invalid Parameters
      when this is sent.  That error causes __hci_req_hci_power_on to fail
      with -EINVAL and LE devices can't connect because background scanning
      isn't configured.
      
      Here is an hci trace of where this issue occurs during power on:
      
      < HCI Command: LE Set Extended Advertising Parameters (0x08|0x0036) plen 25
              Handle: 0x00
              Properties: 0x0010
                Use legacy advertising PDUs: ADV_NONCONN_IND
              Min advertising interval: 181.250 msec (0x0122)
              Max advertising interval: 181.250 msec (0x0122)
              Channel map: 37, 38, 39 (0x07)
              Own address type: Random (0x01)
              Peer address type: Public (0x00)
              Peer address: 00:00:00:00:00:00 (OUI 00-00-00)
              Filter policy: Allow Scan Request from Any, Allow Connect...
              TX power: 127 dbm (0x7f)
              Primary PHY: LE 1M (0x01)
              Secondary max skip: 0x00
              Secondary PHY: LE 1M (0x01)
              SID: 0x00
              Scan request notifications: Disabled (0x00)
      > HCI Event: Command Complete (0x0e) plen 5
            LE Set Extended Advertising Parameters (0x08|0x0036) ncmd 1
              Status: Success (0x00)
              TX power (selected): 9 dbm (0x09)
      < HCI Command: LE Set Advertising Set Random Address (0x08|0x0035) plen 7
              Advertising handle: 0x00
              Advertising random address: 08:FD:55:ED:22:28 (OUI 08-FD-55)
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Advertising Set Random Address (0x08|0x0035) ncmd
              Status: Success (0x00)
      < HCI Command: LE Set Extended Scan Response Data (0x08|0x0038) plen 35
              Handle: 0x00
              Operation: Complete scan response data (0x03)
              Fragment preference: Minimize fragmentation (0x01)
              Data length: 0x0d
              Name (short): Chromebook
      > HCI Event: Command Complete (0x0e) plen 4
            LE Set Extended Scan Response Data (0x08|0x0038) ncmd 1
              Status: Invalid HCI Command Parameters (0x12)
      Signed-off-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Reviewed-by: NDaniel Winkler <danielwinkler@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      6baf8a6a
  21. 31 7月, 2020 1 次提交
    • A
      Bluetooth: use the proper scan params when conn is pending · 9a9373ff
      Alain Michaud 提交于
      When an LE connection is requested and an RPA update is needed via
      hci_connect_le_scan, the default scanning parameters are used rather
      than the connect parameters.  This leads to significant delays in the
      connection establishment process when using lower duty cycle scanning
      parameters.
      
      The patch simply looks at the pended connection list when trying to
      determine which scanning parameters should be used.
      
      Before:
      < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8
                                  #378 [hci0] 1659.247156
              Own address type: Public (0x00)
              Filter policy: Ignore not in white list (0x01)
              PHYs: 0x01
              Entry 0: LE 1M
                Type: Passive (0x00)
                Interval: 367.500 msec (0x024c)
                Window: 37.500 msec (0x003c)
      
      After:
      < HCI Command: LE Set Extended Scan Parameters (0x08|0x0041) plen 8
                                     #39 [hci0] 7.422109
              Own address type: Public (0x00)
              Filter policy: Ignore not in white list (0x01)
              PHYs: 0x01
              Entry 0: LE 1M
                Type: Passive (0x00)
                Interval: 60.000 msec (0x0060)
                Window: 60.000 msec (0x0060)
      Signed-off-by: NAlain Michaud <alainm@chromium.org>
      Reviewed-by: NAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Reviewed-by: NYu Liu <yudiliu@google.com>
      Signed-off-by: NMarcel Holtmann <marcel@holtmann.org>
      9a9373ff
  22. 30 7月, 2020 1 次提交