Skip to content
Permalink
Joseph-Hwang/B…
Switch branches/tags

Commits on Aug 13, 2021

  1. Bluetooth: set quality report callback for Intel

    This patch sets up set_quality_report callback for Intel to
    set and reset the debug features.
    
    Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
    Signed-off-by: Joseph Hwang <josephsih@chromium.org>
    josephsih authored and intel-lab-lkp committed Aug 13, 2021
  2. Bluetooth: Support the quality report events

    This patch allows a user space process to enable/disable the quality
    report events dynamically through the set experimental feature mgmt
    interface if CONFIG_BT_FEATURE_QUALITY_REPORT is enabled.
    
    Since the quality report feature needs to invoke the callback function
    provided by the driver, i.e., hdev->set_quality_report, a valid
    controller index is required.
    
    Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
    Signed-off-by: Joseph Hwang <josephsih@chromium.org>
    josephsih authored and intel-lab-lkp committed Aug 13, 2021
  3. Bluetooth: refactor set_exp_feature with a feature table

    This patch refactors the set_exp_feature with a feature table
    consisting of UUIDs and the corresponding callback functions.
    In this way, a new experimental feature setting function can be
    simply added with its UUID and callback function.
    
    Signed-off-by: Joseph Hwang <josephsih@chromium.org>
    josephsih authored and intel-lab-lkp committed Aug 13, 2021
  4. Bluetooth: btintel: support link statistics telemetry events

    This patch supports the link statistics telemetry events for
    intel controllers
    
    Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
    Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
    Signed-off-by: Kiran K <kiran.k@intel.com>
    Signed-off-by: Joseph Hwang <josephsih@chromium.org>
    chethantn authored and intel-lab-lkp committed Aug 13, 2021
  5. Bluetooth: btusb: disable Intel link statistics telemetry events

    To avoid the overhead on both the controller and the host, the
    Intel link statistics telemetry events are disabled by default.
    
    Reviewed-by: Miao-chen Chou <mcchou@chromium.org>
    Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
    Signed-off-by: Kiran K <kiran.k@intel.com>
    Signed-off-by: Joseph Hwang <josephsih@chromium.org>
    josephsih authored and intel-lab-lkp committed Aug 13, 2021

Commits on Aug 10, 2021

  1. Bluetooth: btusb: check conditions before enabling USB ALT 3 for WBS

    Some USB BT adapters don't satisfy the MTU requirement mentioned in
    commit e848dbd ("Bluetooth: btusb: Add support USB ALT 3 for WBS")
    and have ALT 3 setting that produces no/garbled audio. Some adapters
    with larger MTU were also reported to have problems with ALT 3.
    
    Add a flag and check it and MTU before selecting ALT 3, falling back to
    ALT 1. Enable the flag for Realtek, restoring the previous behavior for
    non-Realtek devices.
    
    Tested with USB adapters (mtu<72, no/garbled sound with ALT3, ALT1
    works) BCM20702A1 0b05:17cb, CSR8510A10 0a12:0001, and (mtu>=72, ALT3
    works) RTL8761BU 0bda:8771, Intel AX200 8087:0029 (after disabling
    ALT6). Also got reports for (mtu>=72, ALT 3 reported to produce bad
    audio) Intel 8087:0a2b.
    
    Signed-off-by: Pauli Virtanen <pav@iki.fi>
    Fixes: e848dbd ("Bluetooth: btusb: Add support USB ALT 3 for WBS")
    Tested-by: Michał Kępień <kernel@kempniu.pl>
    Tested-by: Jonathan Lampérth <jon@h4n.dev>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    pv authored and Vudentz committed Aug 10, 2021
  2. Bluetooth: fix repeated calls to sco_sock_kill

    In commit 4e1a720 ("Bluetooth: avoid killing an already killed
    socket"), a check was added to sco_sock_kill to skip killing a socket
    if the SOCK_DEAD flag was set.
    
    This was done after a trace for a use-after-free bug showed that the
    same sock pointer was being killed twice.
    
    Unfortunately, this check prevents sco_sock_kill from running on any
    socket. sco_sock_kill kills a socket only if it's zapped and orphaned,
    however sock_orphan announces that the socket is dead before detaching
    it. i.e., orphaned sockets have the SOCK_DEAD flag set.
    
    To fix this, we remove the check for SOCK_DEAD, and avoid repeated
    calls to sco_sock_kill by removing incorrect calls in:
    
    1. sco_sock_timeout. The socket should not be killed on timeout as
    further processing is expected to be done. For example,
    sco_sock_connect sets the timer then waits for the socket to be
    connected or for an error to be returned.
    
    2. sco_conn_del. This function should clean up resources for the
    connection, but the socket itself should be cleaned up in
    sco_sock_release.
    
    3. sco_sock_close. Calls to sco_sock_close in sco_sock_cleanup_listen
    and sco_sock_release are followed by sco_sock_kill. Hence the
    duplicated call should be removed.
    
    Fixes: 4e1a720 ("Bluetooth: avoid killing an already killed socket")
    Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    desmondcheongzx authored and Vudentz committed Aug 10, 2021
  3. Bluetooth: switch to lock_sock in RFCOMM

    Other than rfcomm_sk_state_change and rfcomm_connect_ind, functions in
    RFCOMM use lock_sock to lock the socket.
    
    Since bh_lock_sock and spin_lock_bh do not provide synchronization
    with lock_sock, these calls should be changed to lock_sock.
    
    This is now safe to do because packet processing is now done in a
    workqueue instead of a tasklet, so bh_lock_sock/spin_lock_bh are no
    longer necessary to synchronise between user contexts and SOFTIRQ
    processing.
    
    Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    desmondcheongzx authored and Vudentz committed Aug 10, 2021
  4. Bluetooth: serialize calls to sco_sock_{set,clear}_timer

    Currently, calls to sco_sock_set_timer are made under the locked
    socket, but this does not apply to all calls to sco_sock_clear_timer.
    
    Both sco_sock_{set,clear}_timer should be serialized by lock_sock to
    prevent unexpected concurrent clearing/setting of timers.
    
    Additionally, since sco_pi(sk)->conn is only cleared under the locked
    socket, this change allows us to avoid races between
    sco_sock_clear_timer and the call to kfree(conn) in sco_conn_del.
    
    Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    desmondcheongzx authored and Vudentz committed Aug 10, 2021
  5. Bluetooth: switch to lock_sock in SCO

    Since sco_sock_timeout is now scheduled using delayed work, it is no
    longer run in SOFTIRQ context. Hence bh_lock_sock is no longer
    necessary in SCO to synchronise between user contexts and SOFTIRQ
    processing.
    
    As such, calls to bh_lock_sock should be replaced with lock_sock to
    synchronize with other concurrent processes that use lock_sock.
    
    Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    desmondcheongzx authored and Vudentz committed Aug 10, 2021
  6. Bluetooth: avoid circular locks in sco_sock_connect

    In a future patch, calls to bh_lock_sock in sco.c should be replaced
    by lock_sock now that none of the functions are run in IRQ context.
    
    However, doing so results in a circular locking dependency:
    
    ======================================================
    WARNING: possible circular locking dependency detected
    5.14.0-rc4-syzkaller #0 Not tainted
    ------------------------------------------------------
    syz-executor.2/14867 is trying to acquire lock:
    ffff88803e3c1120 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at:
    lock_sock include/net/sock.h:1613 [inline]
    ffff88803e3c1120 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}, at:
    sco_conn_del+0x12a/0x2a0 net/bluetooth/sco.c:191
    
    but task is already holding lock:
    ffffffff8d2dc7c8 (hci_cb_list_lock){+.+.}-{3:3}, at:
    hci_disconn_cfm include/net/bluetooth/hci_core.h:1497 [inline]
    ffffffff8d2dc7c8 (hci_cb_list_lock){+.+.}-{3:3}, at:
    hci_conn_hash_flush+0xda/0x260 net/bluetooth/hci_conn.c:1608
    
    which lock already depends on the new lock.
    
    the existing dependency chain (in reverse order) is:
    
    -> #2 (hci_cb_list_lock){+.+.}-{3:3}:
           __mutex_lock_common kernel/locking/mutex.c:959 [inline]
           __mutex_lock+0x12a/0x10a0 kernel/locking/mutex.c:1104
           hci_connect_cfm include/net/bluetooth/hci_core.h:1482 [inline]
           hci_remote_features_evt net/bluetooth/hci_event.c:3263 [inline]
           hci_event_packet+0x2f4d/0x7c50 net/bluetooth/hci_event.c:6240
           hci_rx_work+0x4f8/0xd30 net/bluetooth/hci_core.c:5122
           process_one_work+0x98d/0x1630 kernel/workqueue.c:2276
           worker_thread+0x658/0x11f0 kernel/workqueue.c:2422
           kthread+0x3e5/0x4d0 kernel/kthread.c:319
           ret_from_fork+0x1f/0x30 arch/x86/entry/entry_64.S:295
    
    -> #1 (&hdev->lock){+.+.}-{3:3}:
           __mutex_lock_common kernel/locking/mutex.c:959 [inline]
           __mutex_lock+0x12a/0x10a0 kernel/locking/mutex.c:1104
           sco_connect net/bluetooth/sco.c:245 [inline]
           sco_sock_connect+0x227/0xa10 net/bluetooth/sco.c:601
           __sys_connect_file+0x155/0x1a0 net/socket.c:1879
           __sys_connect+0x161/0x190 net/socket.c:1896
           __do_sys_connect net/socket.c:1906 [inline]
           __se_sys_connect net/socket.c:1903 [inline]
           __x64_sys_connect+0x6f/0xb0 net/socket.c:1903
           do_syscall_x64 arch/x86/entry/common.c:50 [inline]
           do_syscall_64+0x35/0xb0 arch/x86/entry/common.c:80
           entry_SYSCALL_64_after_hwframe+0x44/0xae
    
    -> #0 (sk_lock-AF_BLUETOOTH-BTPROTO_SCO){+.+.}-{0:0}:
           check_prev_add kernel/locking/lockdep.c:3051 [inline]
           check_prevs_add kernel/locking/lockdep.c:3174 [inline]
           validate_chain kernel/locking/lockdep.c:3789 [inline]
           __lock_acquire+0x2a07/0x54a0 kernel/locking/lockdep.c:5015
           lock_acquire kernel/locking/lockdep.c:5625 [inline]
           lock_acquire+0x1ab/0x510 kernel/locking/lockdep.c:5590
           lock_sock_nested+0xca/0x120 net/core/sock.c:3170
           lock_sock include/net/sock.h:1613 [inline]
           sco_conn_del+0x12a/0x2a0 net/bluetooth/sco.c:191
           sco_disconn_cfm+0x71/0xb0 net/bluetooth/sco.c:1202
           hci_disconn_cfm include/net/bluetooth/hci_core.h:1500 [inline]
           hci_conn_hash_flush+0x127/0x260 net/bluetooth/hci_conn.c:1608
           hci_dev_do_close+0x528/0x1130 net/bluetooth/hci_core.c:1778
           hci_unregister_dev+0x1c0/0x5a0 net/bluetooth/hci_core.c:4015
           vhci_release+0x70/0xe0 drivers/bluetooth/hci_vhci.c:340
           __fput+0x288/0x920 fs/file_table.c:280
           task_work_run+0xdd/0x1a0 kernel/task_work.c:164
           exit_task_work include/linux/task_work.h:32 [inline]
           do_exit+0xbd4/0x2a60 kernel/exit.c:825
           do_group_exit+0x125/0x310 kernel/exit.c:922
           get_signal+0x47f/0x2160 kernel/signal.c:2808
           arch_do_signal_or_restart+0x2a9/0x1c40 arch/x86/kernel/signal.c:865
           handle_signal_work kernel/entry/common.c:148 [inline]
           exit_to_user_mode_loop kernel/entry/common.c:172 [inline]
           exit_to_user_mode_prepare+0x17d/0x290 kernel/entry/common.c:209
           __syscall_exit_to_user_mode_work kernel/entry/common.c:291 [inline]
           syscall_exit_to_user_mode+0x19/0x60 kernel/entry/common.c:302
           ret_from_fork+0x15/0x30 arch/x86/entry/entry_64.S:288
    
    other info that might help us debug this:
    
    Chain exists of:
      sk_lock-AF_BLUETOOTH-BTPROTO_SCO --> &hdev->lock --> hci_cb_list_lock
    
     Possible unsafe locking scenario:
    
           CPU0                    CPU1
           ----                    ----
      lock(hci_cb_list_lock);
                                   lock(&hdev->lock);
                                   lock(hci_cb_list_lock);
      lock(sk_lock-AF_BLUETOOTH-BTPROTO_SCO);
    
     *** DEADLOCK ***
    
    The issue is that the lock hierarchy should go from &hdev->lock -->
    hci_cb_list_lock --> sk_lock-AF_BLUETOOTH-BTPROTO_SCO. For example,
    one such call trace is:
    
      hci_dev_do_close():
        hci_dev_lock();
        hci_conn_hash_flush():
          hci_disconn_cfm():
            mutex_lock(&hci_cb_list_lock);
            sco_disconn_cfm():
            sco_conn_del():
              lock_sock(sk);
    
    However, in sco_sock_connect, we call lock_sock before calling
    hci_dev_lock inside sco_connect, thus inverting the lock hierarchy.
    
    We fix this by pulling the call to hci_dev_lock out from sco_connect.
    
    Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    desmondcheongzx authored and Vudentz committed Aug 10, 2021
  7. Bluetooth: schedule SCO timeouts with delayed_work

    struct sock.sk_timer should be used as a sock cleanup timer. However,
    SCO uses it to implement sock timeouts.
    
    This causes issues because struct sock.sk_timer's callback is run in
    an IRQ context, and the timer callback function sco_sock_timeout takes
    a spin lock on the socket. However, other functions such as
    sco_conn_del and sco_conn_ready take the spin lock with interrupts
    enabled.
    
    This inconsistent {SOFTIRQ-ON-W} -> {IN-SOFTIRQ-W} lock usage could
    lead to deadlocks as reported by Syzbot [1]:
           CPU0
           ----
      lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
      <Interrupt>
        lock(slock-AF_BLUETOOTH-BTPROTO_SCO);
    
    To fix this, we use delayed work to implement SCO sock timouts
    instead. This allows us to avoid taking the spin lock on the socket in
    an IRQ context, and corrects the misuse of struct sock.sk_timer.
    
    As a note, cancel_delayed_work is used instead of
    cancel_delayed_work_sync in sco_sock_set_timer and
    sco_sock_clear_timer to avoid a deadlock. In the future, the call to
    bh_lock_sock inside sco_sock_timeout should be changed to lock_sock to
    synchronize with other functions using lock_sock. However, since
    sco_sock_set_timer and sco_sock_clear_timer are sometimes called under
    the locked socket (in sco_connect and __sco_sock_close),
    cancel_delayed_work_sync might cause them to sleep until an
    sco_sock_timeout that has started finishes running. But
    sco_sock_timeout would also sleep until it can grab the lock_sock.
    
    Using cancel_delayed_work is fine because sco_sock_timeout does not
    change from run to run, hence there is no functional difference
    between:
    1. waiting for a timeout to finish running before scheduling another
    timeout
    2. scheduling another timeout while a timeout is running.
    
    Link: https://syzkaller.appspot.com/bug?id=9089d89de0502e120f234ca0fc8a703f7368b31e [1]
    Reported-by: syzbot+2f6d7c28bb4bf7e82060@syzkaller.appspotmail.com
    Tested-by: syzbot+2f6d7c28bb4bf7e82060@syzkaller.appspotmail.com
    Signed-off-by: Desmond Cheong Zhi Xi <desmondcheongzx@gmail.com>
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    desmondcheongzx authored and Vudentz committed Aug 10, 2021

Commits on Aug 6, 2021

  1. Bluetooth: btusb: Fix fall-through warnings

    Fix fall-through warnings:
    drivers/bluetooth/btusb.c: In function ‘btusb_recv_acl_mtk’:
    drivers/bluetooth/btusb.c:4033:3: warning:
    this statement may fall through [-Wimplicit-fallthrough=]
     4033 |   usb_disable_autosuspend(data->udev);
          |   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    drivers/bluetooth/btusb.c:4034:2: note: here
     4034 |  case 0x05ff:  /* Firmware debug logging 1 */
          |  ^~~~
    
    Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    mark-yw.chen authored and holtmann committed Aug 6, 2021

Commits on Aug 5, 2021

  1. Bluetooth: btintel: Combine setting up MSFT extension

    This patch combines the setting up MSFT extension for the legacy and TLV
    based bootloader into the common function based on hw_variant.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  2. Bluetooth: btintel: Fix the legacy bootloader returns tlv based version

    From the ThP, it supports both legacy and TLV based HCI_Intel_Read_Version
    command after downloading the operational firmware, and it causes the
    driver to choose the wrong setup routines and missing firmware/ddc file.
    
    So, as a workaround, this patch checks the fw variant from the TLV based
    version, and if the device is legacy bootloader device, the legacy
    HCI_Intel_Read_Version command is used to get the legacy version
    information and run the legacy bootloader setup with it.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  3. Bluetooth: btintel: Clean the exported function to static

    This patch changes the exported functions to static if they are no
    longer used by others.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  4. Bluetooth: btintel: Move hci quirks to setup routine

    This patch moves the hci quirks for Intel devices into the setup
    routines and cleaned up the driver flags.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  5. Bluetooth: btintel: Refactoring setup routine for bootloader devices

    This patch refactors the setup routines for legacy and TLV based
    bootloader devices to the combined setup, and move the related functions
    from btusb to btintel.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  6. Bluetooth: btintel: Add combined set_diag functions

    This patch adds a combined set_diag functions.
    It also changes the btintel_set_diag_mfg() to static since it is no
    longer used by others.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  7. Bluetooth: btintel: Fix the LED is not turning off immediately

    Some platforms have an issue with BT LED when the interface is
    down or BT radio is turned off, which takes 5 seconds to BT LED
    goes off. This command turns off the BT LED immediately.
    
    This patch sends the Intel vendor command to turn off the LED.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  8. Bluetooth: btintel: Fix the first HCI command not work with ROM device

    The some legacy ROM controllers have a bug with the first HCI command
    sent to it returning number of completed commands as zero, which would
    stall the command processing in the Bluetooth core.
    
    As a workaround, send HCI Rest command first which will reset the
    controller to fix the issue.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  9. Bluetooth: btintel: Add btintel data struct

    This patch adds a data structure for btintel for btintel object, and the
    definition of bootloder states. It also adds macros to set/test/clear
    the flags.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  10. Bluetooth: btintel: Refactoring setup routine for legacy ROM sku

    This patch refactors the setup routines for legacy ROM product into
    combined setup, and move the related functions from btusb to btintel.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  11. Bluetooth: btintel: Add combined setup and shutdown functions

    There are multiple setup and shutdown functions for Intel device and the
    setup function to be used is depends on the USB PID/VID, which makes
    difficult to maintain the code and increases the code size.
    
    This patch adds combined setup and shutdown functions to provide a
    single entry point for all Intel devices and choose the setup functions
    based on the information read with HCI_Intel_Read_Version command.
    
    Starting from TyP device, the command and response parameters for
    HCI_Intel_Read_Version command are changed even though OCF remains
    same. However, the legacy devices still can handle the command without
    error even if it has a extra parameter, so to simplify the flow,
    the new command format is used to read the version information for
    both legacy and new (tlv based) format.
    
    Also, it also adds a routine to setup the hdev callbacks in btintel.
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  12. Bluetooth: Add support hdev to allocate private data

    This patch adds support hdev to allocate extra size for private data.
    The size of private data is specified in the hdev_alloc_size(priv_size)
    and the allocated buffer can be accessed with hci_get_priv(hdev).
    
    Signed-off-by: Tedd Ho-Jeong An <tedd.an@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    tedd-an authored and holtmann committed Aug 5, 2021
  13. Bluetooth: increase BTNAMSIZ to 21 chars to fix potential buffer over…

    …flow
    
    An earlier commit replaced using batostr to using %pMR sprintf for the
    construction of session->name. Static analysis detected that this new
    method can use a total of 21 characters (including the trailing '\0')
    so we need to increase the BTNAMSIZ from 18 to 21 to fix potential
    buffer overflows.
    
    Addresses-Coverity: ("Out-of-bounds write")
    Fixes: fcb7333 ("Bluetooth: Use %pMR in sprintf/seq_printf instead of batostr")
    Signed-off-by: Colin Ian King <colin.king@canonical.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Colin Ian King authored and holtmann committed Aug 5, 2021

Commits on Aug 4, 2021

  1. Bluetooth: Add additional Bluetooth part for Realtek 8852AE

    This Realtek device has both wifi and BT components. The latter reports
    a USB ID of 04ca:4006, which is not in the table.
    
    The portion of /sys/kernel/debug/usb/devices pertaining to this device is
    
    T:  Bus=02 Lev=01 Prnt=01 Port=12 Cnt=04 Dev#=  4 Spd=12   MxCh= 0
    D:  Ver= 1.00 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
    P:  Vendor=04ca ProdID=4006 Rev= 0.00
    S:  Manufacturer=Realtek
    S:  Product=Bluetooth Radio
    S:  SerialNumber=00e04c000001
    C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=500mA
    I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
    E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
    E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
    E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
    I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
    E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
    E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
    I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
    E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
    E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
    I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
    E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
    E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
    I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
    E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
    E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
    I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
    E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
    E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
    I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
    E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
    E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
    
    Signed-off-by: Larry Finger <Larry.Finger@lwfinger.net>
    Cc: Stable <stable@vger.kernel.org>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    lwfinger authored and holtmann committed Aug 4, 2021
  2. Bluetooth: btusb: Support Bluetooth Reset for Mediatek Chip(MT7921)

    When the firmware hang or command no response, driver can reset the
    bluetooth mcu via USB to recovery it. The reset steps as follows.
    
    1. Cancel USB transfer requests before reset.
    2. It use speicific USB HW Register to reset Bluetooth MCU, at the
       same time, the USB Endpoint0 still keep alive.
    3. Poll the USB HW register until reset is completed by Endpoint0.
    4. To recovery unexpected USB state and behavior during resetting the
       Bluetooth MCU, the driver need to reset the USB device for MT7921.
    5. After the reset is completed, the Bluetooth MCU need to re-setup,
       such as download patch, power-on sequence and etc.
    
    Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
    Reviewed-by: Michael Sun <michaelfsun@google.com>
    Reviewed-by: Archie Pusaka <apusaka@chromium.org>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    mark-yw.chen authored and holtmann committed Aug 4, 2021
  3. Bluetooth: btusb: Record debug log for Mediatek Chip.

    Mediatek Bluetooth controller sends the FW log and FW dump via EP2.
    This patch creates an MTK specified callback(btusb_recv_acl_mtk) to
    replace the original one (hci_recv_frame) when an MTK controller is
    detected. The new callback will separate the firmware dump traffics
    from the ACL data to have them process separately.
    
    1. Add a new field (recv_acl) to the btusb_data struct to store
    vendor-specific ACL callback handler.
    2. Add the MTK-specific ACL callback handler (btusb_recv_acl_mtk) to
    process ACL data, debug log, and firmware dump.
    3. The debug log traces LMP/LL events and connection quality reports.
    4. The upper layer can use hci_channel_monitor to receive these
    packets.
    
    Example btmon: firmware debug log.
    1. Enable firmware debug log.
    < HCI Command: Vendor (0x3f|0x005d) plen 4
            00 00 02 02                                      ....
    > HCI Event: Command Complete (0x0e) plen 8
          Vendor (0x3f|0x005d) ncmd 1
            Status: Success (0x00)
            00 00 02 02                                      ....
    2. Diagnostic packet from controller
    = Vendor Diagnostic (len 500)
              ff 05 f0 01 fd ff 02 0e 08 01 5d fc 00 00 00 02
              02 aa aa aa cb e3 f0 15 b0 0c 5f 01 00 d1 0f 33
              01 7f 00 08 57 61 0c 00 00 00 00 00 23 37 17 00
              fd ff 00 00 29 60 ff ff b1 56 e8 00 57 40 0a 40
              39 95 f2 00 47 40 43 00 fc f0 16 00 57 61 0c 00
              00 00 00 00 23 37 17 00 fd ff 00 00 29 60 ff ff
              65 95 f2 00 57 40 0a 40 ec d3 fc 00 47 40 3b 00
              2c f1 17 00 57 61 0c 00 00 00 00 00 23 37 17 00
              fd ff 00 00 29 60 ff ff 19 d4 fc 00 57 40 76 1c
              b2 61 01 01 47 40 b3 04 0b 63 18 00 fe ff 02 01
              04 05 33 8b 9e 08 00 aa aa aa aa aa 27 38 01 02
              01 00 00 00 02 e0 10 00 20 00 20 00 2a 08 40 00
              20 00 20 08 2a 08 02 00 40 00 00 01 2e 08 40 00
              01 67 b0 c2 2e 08 3e 07 ff ff ff ff 40 08 01 00
              02 00 00 00 34 08 a3 00 00 00 00 00 34 08 a3 00
              00 00 00 00 35 08 45 01 00 00 00 00 2e 08 40 00
              01 67 b0 c2 30 35 01 02 00 00 00 00 2c 31 01 00
              02 00 00 40 2d 19 03 00 00 40 00 00 fd ff 02 0f
              04 00 01 01 04 aa aa aa aa aa aa aa 57 61 0c 00
              00 00 00 00 23 46 32 00 01 00 00 00 2f 35 00 02
              00 00 00 00 29 35 ff 02 00 22 00 00 2d 31 a6 02
              02 00 00 00 31 6c 40 00 14 63 18 1b 31 6c 40 00
              14 63 18 23 51 08 53 00 12 63 18 00 2c 35 12 01
              fe 00 00 00 2b 35 fe 02 02 00 00 00 2f 31 21 00
              00 00 02 00 75 61 01 00 4c 1b 93 00 79 61 01 00
              00 00 00 00 12 e3 63 18 20 31 86 01 74 61 68 03
              00 00 04 00 a1 73 ff 00 b9 01 00 00 a1 73 04 00
              00 00 00 00 a1 73 00 00 00 00 00 00 a1 73 00 00
              02 00 00 00 31 6c 40 00 16 63 18 0c 31 6c 40 00
              16 63 18 1c 77 61 40 00 48 33 40 00 14 e3 63 18
              40 31 86 01 00 d1 02 c5 07 23 a1 34 73 61 37 02
              02 00 00 a1
    
    Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
    Reviewed-by: Michael Sun <michaelfsun@google.com>
    Reviewed-by: Archie Pusaka <apusaka@chromium.org>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    mark-yw.chen authored and holtmann committed Aug 4, 2021
  4. Bluetooth: hci_bcm: Fix kernel doc comments

    Kernel doc validator complains about few missed parameter descriptions.
    Fill the gap by describing them.
    
    Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    andy-shev authored and holtmann committed Aug 4, 2021

Commits on Aug 3, 2021

  1. Bluetooth: Fix not generating RPA when required

    Code was checking if random_addr and hdev->rpa match without first
    checking if the RPA has not been set (BDADDR_ANY), furthermore it was
    clearing HCI_RPA_EXPIRED before the command completes and the RPA is
    actually programmed which in case of failure would leave the expired
    RPA still set.
    
    Since advertising instance have a similar problem the clearing of
    HCI_RPA_EXPIRED has been moved to hci_event.c after checking the random
    address is in fact the hdev->rap and then proceed to set the expire
    timeout.
    
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Vudentz authored and holtmann committed Aug 3, 2021
  2. Bluetooth: HCI: Add proper tracking for enable status of adv instances

    This adds a field to track if advertising instances are enabled or not
    and only clear HCI_LE_ADV flag if there is no instance left advertising.
    
    Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Vudentz authored and holtmann committed Aug 3, 2021

Commits on Aug 2, 2021

  1. Bluetooth: btusb: Enable MSFT extension for Mediatek Chip (MT7921)

    The Mdiatek MT7921(7961) support MSFT HCI extensions, we are using
    0xFD30 for VsMsftOpCode.
    
    Signed-off-by: mark-yw.chen <mark-yw.chen@mediatek.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    mark-yw.chen authored and holtmann committed Aug 2, 2021

Commits on Jul 29, 2021

  1. Bluetooth: btusb: Make the CSR clone chip force-suspend workaround mo…

    …re generic
    
    Turns out Hans de Goede completed the work I started last year trying to
    improve Chinese-clone detection of CSR controller chips. Quirk after quirk
    these Bluetooth dongles are more usable now.
    
    Even after a few BlueZ regressions; these clones are so fickle that some
    days they stop working altogether. Except on Windows, they work fine.
    
    But this force-suspend initialization quirk seems to mostly do the trick,
    after a lot of testing Bluetooth now seems to work *all* the time.
    
    The only problem is that the solution ended up being masked under a very
    stringent check; when there are probably hundreds of fake dongle
    models out there that benefit from a good reset. Make it so.
    
    Fixes: 81cac64 ("Bluetooth: Deal with USB devices that are faking CSR vendor")
    Fixes: cde1a8a ("Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth controllers")
    Fixes: d74e0ae ("Bluetooth: btusb: Fix detection of some fake CSR controllers with a bcdDevice val of 0x0134")
    Fixes: 0671c06 ("Bluetooth: btusb: Add workaround for remote-wakeup issues with Barrot 8041a02 fake CSR controllers")
    
    Cc: stable@vger.kernel.org
    Cc: Hans de Goede <hdegoede@redhat.com>
    Tested-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com>
    Signed-off-by: Ismael Ferreras Morezuelas <swyterzone@gmail.com>
    Reviewed-by: Hans de Goede <hdegoede@redhat.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    Swyter authored and holtmann committed Jul 29, 2021
  2. Bluetooth: btusb: Enable MSFT extension for Intel next generation con…

    …trollers
    
    The Intel TyphoonPeak, GarfieldPeak Bluetooth controllers
    support the Microsoft vendor extension and they are using
    0xFC1E for VsMsftOpCode.
    
    Verified on a GarfieldPeak device through bluetoothctl show
    
    Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
    Signed-off-by: Michael Sun <michaelfsun@google.com>
    Signed-off-by: Marcel Holtmann <marcel@holtmann.org>
    chethantn authored and holtmann committed Jul 29, 2021
Older