1. 08 Feb, 2021 1 commit
    • Hui Wang's avatar
      Bluetooth: btusb: Some Qualcomm Bluetooth adapters stop working · 234f414e
      Hui Wang authored
      This issue starts from linux-5.10-rc1, I reproduced this issue on my
      Dell Inspiron 7447 with BT adapter 0cf3:e005, the kernel will print
      out: "Bluetooth: hci0: don't support firmware rome 0x31010000", and
      someone else also reported the similar issue to bugzilla #211571.
      
      I found this is a regression introduced by 'commit b40f58b9
      ("Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support"), the
      patch assumed that if high ROM version is not zero, it is an adapter
      on WCN6855, but many old adapters don't need to load rampatch or nvm,
      and they have non-zero high ROM version.
      
      To fix it, let the driver match the rom_version in the
      qca_devices_table first, if there is no entry matched, check the
      high ROM version, if it is not zero, we assume this adapter is ready
      to work and no need to load rampatch and nvm like previously.
      
      BugLink: https://bugzilla.kernel.org/show_bug.cgi?id=211571
      Fixes: b40f58b9 ("Bluetooth: btusb: Add Qualcomm Bluetooth SoC WCN6855 support")
      Signed-off-by: default avatarHui Wang <hui.wang@canonical.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      234f414e
  2. 04 Feb, 2021 2 commits
    • Arnd Bergmann's avatar
      Bluetooth: btusb: fix excessive stack usage · 10888140
      Arnd Bergmann authored
      Enlarging the size of 'struct btmtk_hci_wmt_cmd' makes it no longer
      fit on the kernel stack, as seen from this compiler warning:
      
      drivers/bluetooth/btusb.c:3365:12: error: stack frame size of 1036 bytes in function 'btusb_mtk_hci_wmt_sync' [-Werror,-Wframe-larger-than=]
      
      Change the function to dynamically allocate the buffer instead.
      As there are other sleeping functions called from the same location,
      using GFP_KERNEL should be fine here, and the runtime overhead should
      not matter as this is rarely called.
      
      Unfortunately, I could not figure out why the message size is
      increased in the previous patch. Using dynamic allocation means
      any size is possible now, but there is still a range check that
      limits the total size (including the five-byte header) to 255
      bytes, so whatever was intended there is now undone.
      
      Fixes: 48c13301 ("Bluetooth: btusb: Fine-tune mt7663 mechanism.")
      Signed-off-by: default avatarArnd Bergmann <arnd@arndb.de>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      10888140
    • Ye Bin's avatar
      Bluetooth: btusb: remove set but not used variable in btusb_mtk_setup_firmware_79xx · 8564baa3
      Ye Bin authored
      Fix follow warning:
      drivers/bluetooth/btusb.c:3479:9: warning: variable ‘fw_size’ set but not used [-Wunused-but-set-variable]
        size_t fw_size;
               ^~~~~~~
      drivers/bluetooth/btusb.c:3473:29: warning: variable ‘patchhdr’ set but not used [-Wunused-but-set-variable]
        struct btmtk_patch_header *patchhdr = NULL;
                                   ^~~~~~~~
      Reported-by: default avatarHulk Robot <hulkci@huawei.com>
      Signed-off-by: default avatarYe Bin <yebin10@huawei.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      8564baa3
  3. 03 Feb, 2021 3 commits
    • Jupeng Zhong's avatar
      Bluetooth: btusb: Fix typo and correct the log print · a297f565
      Jupeng Zhong authored
      Change "deivice" to "device"
      
      Correct "Unsupported support hardware variant (%08x)" to
      "Unsupported hardware variant (%08x)"
      Signed-off-by: default avatarJupeng Zhong <zhongjupeng@yulong.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      a297f565
    • Hui Wang's avatar
      Bluetooth: btusb: Fix the autosuspend enable and disable · 7bd9fb05
      Hui Wang authored
      I tried to disable the autosuspend on btusb through the module
      parameter enable_autosuspend, this parameter is set to N, but the usb
      bluetooth device is still runtime suspended.
      $ cat /sys/module/btusb/parameters/enable_autosuspend
      N
      $ cat /sys/bus/usb/devices/3-10/power/runtime_status
      suspended
      $ cat /sys/bus/usb/devices/3-10/power/runtime_suspended_time
      65187
      
      We already set ".supports_autosuspend = 1" in the usb_driver, this
      device will be set autosuspend enabled by usb core, we don't need
      to call usb_enable_autosuspend() in the btusb_probe(). Instead if
      users set the parameter enable_autosuspend to N, we need to call
      usb_disable_autosuspend() in the btusb_probe(). After this change
      and set the parameter to N, we could see the device is not runtime
      suspended anymore.
      $ cat /sys/module/btusb/parameters/enable_autosuspend
      N
      $ cat /sys/bus/usb/devices/3-10/power/runtime_status
      active
      $ cat /sys/bus/usb/devices/3-10/power/runtime_suspended_time
      0
      
      And if we disable the autosuspend in the btusb_probe(), we need to
      enable the autosuspend in the disconnect(), this could guarantee
      that the device could be runtime suspended after we rmmod the btusb.
      Signed-off-by: default avatarHui Wang <hui.wang@canonical.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      7bd9fb05
    • Howard Chung's avatar
      Bluetooth: Fix crash in mgmt_add_adv_patterns_monitor_complete · b1810feb
      Howard Chung authored
      If hci_add_adv_monitor is a pending command(e.g. forward to
      msft_add_monitor_pattern), it is possible that
      mgmt_add_adv_patterns_monitor_complete gets called before
      cmd->user_data gets set, which will cause a crash when we
      try to get the moniter handle through cmd->user_data in
      mgmt_add_adv_patterns_monitor_complete.
      
      This moves the cmd->user_data assignment earlier than
      hci_add_adv_monitor.
      
      RIP: 0010:mgmt_add_adv_patterns_monitor_complete+0x82/0x187 [bluetooth]
      Code: 1e bf 03 00 00 00 be 52 00 00 00 4c 89 ea e8 9e
      e4 02 00 49 89 c6 48 85 c0 0f 84 06 01 00 00 48 89 5d b8 4c 89 fb 4d 8b
      7e 30 <41> 0f b7 47 18 66 89 45 c0 45 84 e4 75 5a 4d 8b 56 28 48 8d 4d
      c8
      RSP: 0018:ffffae81807dbcb8 EFLAGS: 00010286
      RAX: ffff91c4bdf723c0 RBX: 0000000000000000 RCX: ffff91c4e5da5b80
      RDX: ffff91c405680000 RSI: 0000000000000052 RDI: ffff91c49d654c00
      RBP: ffffae81807dbd00 R08: ffff91c49fb157e0 R09: ffff91c49fb157e0
      R10: 000000000002a4f0 R11: ffffffffc0819cfd R12: 0000000000000000
      R13: ffff91c405680000 R14: ffff91c4bdf723c0 R15: 0000000000000000
      FS:  0000000000000000(0000) GS:ffff91c4ea300000(0000)
      knlGS:0000000000000000
      CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
      CR2: 0000000000000018 CR3: 0000000133612002 CR4:
      00000000003606e0
      Call Trace:
       ? msft_le_monitor_advertisement_cb+0x111/0x141
      [bluetooth]
       hci_event_packet+0x425e/0x631c [bluetooth]
       ? printk+0x59/0x73
       ? __switch_to_asm+0x41/0x70
       ?
      msft_le_set_advertisement_filter_enable_cb+0xa6/0xa6 [bluetooth]
       ? bt_dbg+0xb4/0xbb [bluetooth]
       ? __switch_to_asm+0x41/0x70
       hci_rx_work+0x101/0x319 [bluetooth]
       process_one_work+0x257/0x506
       worker_thread+0x10d/0x284
       kthread+0x14c/0x154
       ? process_one_work+0x506/0x506
       ? kthread_blkcg+0x2c/0x2c
       ret_from_fork+0x1f/0x40
      Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
      Reviewed-by: default avatarManish Mandlik <mmandlik@chromium.org>
      Reviewed-by: default avatarArchie Pusaka <apusaka@chromium.org>
      Signed-off-by: default avatarHoward Chung <howardchung@google.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      b1810feb
  4. 02 Feb, 2021 5 commits
    • Jupeng Zhong's avatar
      Bluetooth: btusb: Fix memory leak in btusb_mtk_wmt_recv · de71a6cb
      Jupeng Zhong authored
      In btusb_mtk_wmt_recv if skb_clone fails, the alocated skb should be
      released.
      
      Omit the labels “err_out” and “err_free_skb” in this function
      implementation so that the desired exception handling code
      would be directly specified in the affected if branches.
      
      Fixes: a1c49c43 ("btusb: Add protocol support for MediaTek MT7668U USB devices")
      Signed-off-by: default avatarJupeng Zhong <zhongjupeng@yulong.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      de71a6cb
    • Gopal Tiwari's avatar
      Bluetooth: Fix null pointer dereference in amp_read_loc_assoc_final_data · e8bd76ed
      Gopal Tiwari authored
      kernel panic trace looks like:
      
       #5 [ffffb9e08698fc80] do_page_fault at ffffffffb666e0d7
       #6 [ffffb9e08698fcb0] page_fault at ffffffffb70010fe
          [exception RIP: amp_read_loc_assoc_final_data+63]
          RIP: ffffffffc06ab54f  RSP: ffffb9e08698fd68  RFLAGS: 00010246
          RAX: 0000000000000000  RBX: ffff8c8845a5a000  RCX: 0000000000000004
          RDX: 0000000000000000  RSI: ffff8c8b9153d000  RDI: ffff8c8845a5a000
          RBP: ffffb9e08698fe40   R8: 00000000000330e0   R9: ffffffffc0675c94
          R10: ffffb9e08698fe58  R11: 0000000000000001  R12: ffff8c8b9cbf6200
          R13: 0000000000000000  R14: 0000000000000000  R15: ffff8c8b2026da0b
          ORIG_RAX: ffffffffffffffff  CS: 0010  SS: 0018
       #7 [ffffb9e08698fda8] hci_event_packet at ffffffffc0676904 [bluetooth]
       #8 [ffffb9e08698fe50] hci_rx_work at ffffffffc06629ac [bluetooth]
       #9 [ffffb9e08698fe98] process_one_work at ffffffffb66f95e7
      
      hcon->amp_mgr seems NULL triggered kernel panic in following line inside
      function amp_read_loc_assoc_final_data
      
              set_bit(READ_LOC_AMP_ASSOC_FINAL, &mgr->state);
      
      Fixed by checking NULL for mgr.
      Signed-off-by: default avatarGopal Tiwari <gtiwari@redhat.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      e8bd76ed
    • Mark Chen's avatar
      Bluetooth: btusb: Add protocol support for MediaTek MT7921U USB devices · fc342c4d
      Mark Chen authored
      There is mt7921 firmware download mechanism
      
      1. Read Chip id from MT7921.
      
      2. Download firmware by endpoint 0, it's the same mechanism with
      mt7663/mt7668.
         (it's medaitek specific header format for downloading firmware.)
      
      3. Enabling Bluetooth function.
      
      The information in /sys/kernel/debug/usb/devices about the MT7921U
      Bluetooth device is listed as the below.
      
        T:  Bus=01 Lev=01 Prnt=01 Port=00 Cnt=01 Dev#= 40 Spd=480  MxCh= 0
        D:  Ver= 2.10 Cls=ef(misc ) Sub=02 Prot=01 MxPS=64 #Cfgs=  1
        P:  Vendor=0e8d ProdID=7961 Rev= 1.00
        S:  Manufacturer=MediaTek Inc.
        S:  Product=Wireless_Device
        S:  SerialNumber=000000000
        C:* #Ifs= 3 Cfg#= 1 Atr=e0 MxPwr=100mA
        A:  FirstIf#= 0 IfCount= 3 Cls=e0(wlcon) Sub=01 Prot=01
        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=125us
        E:  Ad=82(I) Atr=02(Bulk) MxPS= 512 Ivl=0ms
        E:  Ad=02(O) Atr=02(Bulk) MxPS= 512 Ivl=0ms
        I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
        E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
        E:  Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
        E:  Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
        E:  Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
        E:  Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
        E:  Ad=03(O) 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=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
        E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
        I:  If#= 1 Alt= 6 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
        E:  Ad=83(I) Atr=01(Isoc) MxPS=  63 Ivl=1ms
        E:  Ad=03(O) Atr=01(Isoc) MxPS=  63 Ivl=1ms
        I:* If#= 2 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
        E:  Ad=8a(I) Atr=03(Int.) MxPS=  64 Ivl=125us
        E:  Ad=0a(O) Atr=03(Int.) MxPS=  64 Ivl=125us
        I:  If#= 2 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=(none)
        E:  Ad=8a(I) Atr=03(Int.) MxPS= 512 Ivl=125us
        E:  Ad=0a(O) Atr=03(Int.) MxPS= 512 Ivl=125us
      Signed-off-by: default avatarMark Chen <Mark-YW.Chen@mediatek.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      fc342c4d
    • Mark Chen's avatar
      Bluetooth: btusb: Fine-tune mt7663 mechanism. · 48c13301
      Mark Chen authored
      Fine-tune read register for mt7663/mt7921.
      For mediatek chip spcific wmt protocol, we add more delay to send EP0
      In-Token.
      Signed-off-by: default avatarMark Chen <Mark-YW.Chen@mediatek.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      48c13301
    • Venkata Lakshmi Narayana Gubba's avatar
      Bluetooth: hci_qca: check for SSR triggered flag while suspend · 1bb0c663
      Venkata Lakshmi Narayana Gubba authored
      QCA_IBS_DISABLED flag will be set after memorydump started from
      controller.Currently qca_suspend() is waiting for SSR to complete
      based on flag QCA_IBS_DISABLED.Added to check for QCA_SSR_TRIGGERED
      flag too.
      
      Fixes: 2be43aba ("Bluetooth: hci_qca: Wait for timeout during suspend")
      Signed-off-by: default avatarVenkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      1bb0c663
  5. 01 Feb, 2021 1 commit
  6. 29 Jan, 2021 4 commits
  7. 25 Jan, 2021 14 commits
    • Bastien Nocera's avatar
      Bluetooth: L2CAP: Try harder to accept device not knowing options · 98d2c3e1
      Bastien Nocera authored
      The current implementation of L2CAP options negotiation will continue
      the negotiation when a device responds with L2CAP_CONF_UNACCEPT ("unaccepted
      options"), but not when the device replies with L2CAP_CONF_UNKNOWN ("unknown
      options").
      
      Trying to continue the negotiation without ERTM support will allow
      Bluetooth-capable XBox One controllers (notably models 1708 and 1797)
      to connect.
      
      btmon before patch:
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                            #64 [hci0] 59.182702
            L2CAP: Connection Response (0x03) ident 2 len 8
              Destination CID: 64
              Source CID: 64
              Result: Connection successful (0x0000)
              Status: No further information available (0x0000)
      < ACL Data TX: Handle 256 flags 0x00 dlen 23                            #65 [hci0] 59.182744
            L2CAP: Configure Request (0x04) ident 3 len 15
              Destination CID: 64
              Flags: 0x0000
              Option: Retransmission and Flow Control (0x04) [mandatory]
                Mode: Basic (0x00)
                TX window size: 0
                Max transmit: 0
                Retransmission timeout: 0
                Monitor timeout: 0
                Maximum PDU size: 0
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                            #66 [hci0] 59.183948
            L2CAP: Configure Request (0x04) ident 1 len 8
              Destination CID: 64
              Flags: 0x0000
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1480
      < ACL Data TX: Handle 256 flags 0x00 dlen 18                            #67 [hci0] 59.183994
            L2CAP: Configure Response (0x05) ident 1 len 10
              Source CID: 64
              Flags: 0x0000
              Result: Success (0x0000)
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1480
      > ACL Data RX: Handle 256 flags 0x02 dlen 15                            #69 [hci0] 59.187676
            L2CAP: Configure Response (0x05) ident 3 len 7
              Source CID: 64
              Flags: 0x0000
              Result: Failure - unknown options (0x0003)
              04                                               .
      < ACL Data TX: Handle 256 flags 0x00 dlen 12                            #70 [hci0] 59.187722
            L2CAP: Disconnection Request (0x06) ident 4 len 4
              Destination CID: 64
              Source CID: 64
      > ACL Data RX: Handle 256 flags 0x02 dlen 12                            #73 [hci0] 59.192714
            L2CAP: Disconnection Response (0x07) ident 4 len 4
              Destination CID: 64
              Source CID: 64
      
      btmon after patch:
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                          #248 [hci0] 103.502970
            L2CAP: Connection Response (0x03) ident 5 len 8
              Destination CID: 65
              Source CID: 65
              Result: Connection pending (0x0001)
              Status: No further information available (0x0000)
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                          #249 [hci0] 103.504184
            L2CAP: Connection Response (0x03) ident 5 len 8
              Destination CID: 65
              Source CID: 65
              Result: Connection successful (0x0000)
              Status: No further information available (0x0000)
      < ACL Data TX: Handle 256 flags 0x00 dlen 23                          #250 [hci0] 103.504398
            L2CAP: Configure Request (0x04) ident 6 len 15
              Destination CID: 65
              Flags: 0x0000
              Option: Retransmission and Flow Control (0x04) [mandatory]
                Mode: Basic (0x00)
                TX window size: 0
                Max transmit: 0
                Retransmission timeout: 0
                Monitor timeout: 0
                Maximum PDU size: 0
      > ACL Data RX: Handle 256 flags 0x02 dlen 16                          #251 [hci0] 103.505472
            L2CAP: Configure Request (0x04) ident 3 len 8
              Destination CID: 65
              Flags: 0x0000
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1480
      < ACL Data TX: Handle 256 flags 0x00 dlen 18                          #252 [hci0] 103.505689
            L2CAP: Configure Response (0x05) ident 3 len 10
              Source CID: 65
              Flags: 0x0000
              Result: Success (0x0000)
              Option: Maximum Transmission Unit (0x01) [mandatory]
                MTU: 1480
      > ACL Data RX: Handle 256 flags 0x02 dlen 15                          #254 [hci0] 103.509165
            L2CAP: Configure Response (0x05) ident 6 len 7
              Source CID: 65
              Flags: 0x0000
              Result: Failure - unknown options (0x0003)
              04                                               .
      < ACL Data TX: Handle 256 flags 0x00 dlen 12                          #255 [hci0] 103.509426
            L2CAP: Configure Request (0x04) ident 7 len 4
              Destination CID: 65
              Flags: 0x0000
      < ACL Data TX: Handle 256 flags 0x00 dlen 12                          #257 [hci0] 103.511870
            L2CAP: Connection Request (0x02) ident 8 len 4
              PSM: 1 (0x0001)
              Source CID: 66
      > ACL Data RX: Handle 256 flags 0x02 dlen 14                          #259 [hci0] 103.514121
            L2CAP: Configure Response (0x05) ident 7 len 6
              Source CID: 65
              Flags: 0x0000
              Result: Success (0x0000)
      Signed-off-by: default avatarFlorian Dollinger <dollinger.florian@gmx.de>
      Co-developed-by: default avatarFlorian Dollinger <dollinger.florian@gmx.de>
      Reviewed-by: default avatarLuiz Augusto Von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      98d2c3e1
    • Luiz Augusto von Dentz's avatar
      Bluetooth: L2CAP: Fix handling fragmented length · 4d7ea8ee
      Luiz Augusto von Dentz authored
      Bluetooth Core Specification v5.2, Vol. 3, Part A, section 1.4, table
      1.1:
      
       'Start Fragments always either begin with the first octet of the Basic
        L2CAP header of a PDU or they have a length of zero (see [Vol 2] Part
        B, Section 6.6.2).'
      
      Apparently this was changed by the following errata:
      
      https://www.bluetooth.org/tse/errata_view.cfm?errata_id=10216Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      4d7ea8ee
    • Vamshi K Sthambamkadi's avatar
      Bluetooth: btusb: fix memory leak on suspend and resume · 5ff20cbe
      Vamshi K Sthambamkadi authored
      kmemleak report:
      unreferenced object 0xffff9b1127f00500 (size 208):
        comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
        hex dump (first 32 bytes):
          00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
          00 60 ed 05 11 9b ff ff 00 00 00 00 00 00 00 00  .`..............
        backtrace:
          [<000000006ab3fd59>] kmem_cache_alloc_node+0x17a/0x480
          [<0000000051a5f6f9>] __alloc_skb+0x5b/0x1d0
          [<0000000037e2d252>] hci_prepare_cmd+0x32/0xc0 [bluetooth]
          [<0000000010b586d5>] hci_req_add_ev+0x84/0xe0 [bluetooth]
          [<00000000d2deb520>] hci_req_clear_event_filter+0x42/0x70 [bluetooth]
          [<00000000f864bd8c>] hci_req_prepare_suspend+0x84/0x470 [bluetooth]
          [<000000001deb2cc4>] hci_prepare_suspend+0x31/0x40 [bluetooth]
          [<000000002677dd79>] process_one_work+0x209/0x3b0
          [<00000000aaa62b07>] worker_thread+0x34/0x400
          [<00000000826d176c>] kthread+0x126/0x140
          [<000000002305e558>] ret_from_fork+0x22/0x30
      unreferenced object 0xffff9b1125c6ee00 (size 512):
        comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
        hex dump (first 32 bytes):
          04 00 00 00 0d 00 00 00 05 0c 01 00 11 9b ff ff  ................
          00 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00  ................
        backtrace:
          [<000000009f07c0cc>] slab_post_alloc_hook+0x59/0x270
          [<0000000049431dc2>] __kmalloc_node_track_caller+0x15f/0x330
          [<00000000027a42f6>] __kmalloc_reserve.isra.70+0x31/0x90
          [<00000000e8e3e76a>] __alloc_skb+0x87/0x1d0
          [<0000000037e2d252>] hci_prepare_cmd+0x32/0xc0 [bluetooth]
          [<0000000010b586d5>] hci_req_add_ev+0x84/0xe0 [bluetooth]
          [<00000000d2deb520>] hci_req_clear_event_filter+0x42/0x70 [bluetooth]
          [<00000000f864bd8c>] hci_req_prepare_suspend+0x84/0x470 [bluetooth]
          [<000000001deb2cc4>] hci_prepare_suspend+0x31/0x40 [bluetooth]
          [<000000002677dd79>] process_one_work+0x209/0x3b0
          [<00000000aaa62b07>] worker_thread+0x34/0x400
          [<00000000826d176c>] kthread+0x126/0x140
          [<000000002305e558>] ret_from_fork+0x22/0x30
      unreferenced object 0xffff9b112b395788 (size 8):
        comm "kworker/u17:2", pid 500, jiffies 4294937470 (age 580.136s)
        hex dump (first 8 bytes):
          20 00 00 00 00 00 04 00                           .......
        backtrace:
          [<0000000052dc28d2>] kmem_cache_alloc_trace+0x15e/0x460
          [<0000000046147591>] alloc_ctrl_urb+0x52/0xe0 [btusb]
          [<00000000a2ed3e9e>] btusb_send_frame+0x91/0x100 [btusb]
          [<000000001e66030e>] hci_send_frame+0x7e/0xf0 [bluetooth]
          [<00000000bf6b7269>] hci_cmd_work+0xc5/0x130 [bluetooth]
          [<000000002677dd79>] process_one_work+0x209/0x3b0
          [<00000000aaa62b07>] worker_thread+0x34/0x400
          [<00000000826d176c>] kthread+0x126/0x140
          [<000000002305e558>] ret_from_fork+0x22/0x30
      
      In pm sleep-resume context, while the btusb device rebinds, it enters
      hci_unregister_dev(), whilst there is a possibility of hdev receiving
      PM_POST_SUSPEND suspend_notifier event, leading to generation of msg
      frames. When hci_unregister_dev() completes, i.e. hdev context is
      destroyed/freed, those intermittently sent msg frames cause memory
      leak.
      
      BUG details:
      Below is stack trace of thread that enters hci_unregister_dev(), marks
      the hdev flag HCI_UNREGISTER to 1, and then goes onto to wait on notifier
      lock - refer unregister_pm_notifier().
      
        hci_unregister_dev+0xa5/0x320 [bluetoot]
        btusb_disconnect+0x68/0x150 [btusb]
        usb_unbind_interface+0x77/0x250
        ? kernfs_remove_by_name_ns+0x75/0xa0
        device_release_driver_internal+0xfe/0x1
        device_release_driver+0x12/0x20
        bus_remove_device+0xe1/0x150
        device_del+0x192/0x3e0
        ? usb_remove_ep_devs+0x1f/0x30
        usb_disable_device+0x92/0x1b0
        usb_disconnect+0xc2/0x270
        hub_event+0x9f6/0x15d0
        ? rpm_idle+0x23/0x360
        ? rpm_idle+0x26b/0x360
        process_one_work+0x209/0x3b0
        worker_thread+0x34/0x400
        ? process_one_work+0x3b0/0x3b0
        kthread+0x126/0x140
        ? kthread_park+0x90/0x90
        ret_from_fork+0x22/0x30
      
      Below is stack trace of thread executing hci_suspend_notifier() which
      processes the PM_POST_SUSPEND event, while the unbinding thread is
      waiting on lock.
      
        hci_suspend_notifier.cold.39+0x5/0x2b [bluetooth]
        blocking_notifier_call_chain+0x69/0x90
        pm_notifier_call_chain+0x1a/0x20
        pm_suspend.cold.9+0x334/0x352
        state_store+0x84/0xf0
        kobj_attr_store+0x12/0x20
        sysfs_kf_write+0x3b/0x40
        kernfs_fop_write+0xda/0x1c0
        vfs_write+0xbb/0x250
        ksys_write+0x61/0xe0
        __x64_sys_write+0x1a/0x20
        do_syscall_64+0x37/0x80
        entry_SYSCALL_64_after_hwframe+0x44/0xa9
      
      Fix hci_suspend_notifer(), not to act on events when flag HCI_UNREGISTER
      is set.
      Signed-off-by: default avatarVamshi K Sthambamkadi <vamshi.k.sthambamkadi@gmail.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      5ff20cbe
    • Geert Uytterhoeven's avatar
      dt-bindings: net: btusb: DT fix s/interrupt-name/interrupt-names/ · f2889889
      Geert Uytterhoeven authored
      The standard DT property name is "interrupt-names".
      
      Fixes: fd913ef7 ("Bluetooth: btusb: Add out-of-band wakeup support")
      Signed-off-by: default avatarGeert Uytterhoeven <geert+renesas@glider.be>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Reviewed-by: default avatarBrian Norris <briannorris@chromium.org>
      Acked-by: default avatarRajat Jain <rajatja@google.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      f2889889
    • Pan Bian's avatar
      Bluetooth: Put HCI device if inquiry procedure interrupts · 28a758c8
      Pan Bian authored
      Jump to the label done to decrement the reference count of HCI device
      hdev on path that the Inquiry procedure is interrupted.
      
      Fixes: 3e13fa1e ("Bluetooth: Fix hci_inquiry ioctl usage")
      Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      28a758c8
    • Pan Bian's avatar
      Bluetooth: drop HCI device reference before return · 5a3ef03a
      Pan Bian authored
      Call hci_dev_put() to decrement reference count of HCI device hdev if
      fails to duplicate memory.
      
      Fixes: 0b26ab9d ("Bluetooth: AMP: Handle Accept phylink command status evt")
      Signed-off-by: default avatarPan Bian <bianpan2016@163.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      5a3ef03a
    • Howard Chung's avatar
      Bluetooth: disable advertisement filters during suspend · bf6a4e30
      Howard Chung authored
      This adds logic to disable and reenable advertisement filters during
      suspend and resume. After this patch, we would only receive packets from
      devices in allow list during suspend.
      Signed-off-by: default avatarHoward Chung <howardchung@google.com>
      Reviewed-by: default avatarAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      bf6a4e30
    • Archie Pusaka's avatar
      Bluetooth: advmon offload MSFT interleave scanning integration · 58ceb1e6
      Archie Pusaka authored
      When MSFT extension is supported, we don't have to interleave the scan
      as we could just do allowlist scan.
      Signed-off-by: default avatarArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      58ceb1e6
    • Archie Pusaka's avatar
      Bluetooth: advmon offload MSFT handle filter enablement · 394566bf
      Archie Pusaka authored
      Implements the feature to disable/enable the filter used for
      advertising monitor on MSFT controller, effectively have the same
      effect as "remove all monitors" and "add all previously removed
      monitors".
      
      This feature would be needed when suspending, where we would not want
      to get packets from anything outside the allowlist. Note that the
      integration with the suspending part is not included in this patch.
      Signed-off-by: default avatarArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
      Reviewed-by: default avatarYun-Hao Chung <howardchung@google.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      394566bf
    • Archie Pusaka's avatar
      Bluetooth: advmon offload MSFT handle controller reset · 4a37682c
      Archie Pusaka authored
      When the controller is powered off, the registered advertising monitor
      is removed from the controller. This patch handles the re-registration
      of those monitors when the power is on.
      Signed-off-by: default avatarArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
      Reviewed-by: default avatarYun-Hao Chung <howardchung@google.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      4a37682c
    • Archie Pusaka's avatar
      Bluetooth: advmon offload MSFT remove monitor · 66bd095a
      Archie Pusaka authored
      Implements the monitor removal functionality for advertising monitor
      offloading to MSFT controllers. Supply handle = 0 to remove all
      monitors.
      Signed-off-by: default avatarArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
      Reviewed-by: default avatarYun-Hao Chung <howardchung@google.com>
      Reported-by: default avatarkernel test robot <lkp@intel.com>
      Reported-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      66bd095a
    • Archie Pusaka's avatar
      Bluetooth: advmon offload MSFT add monitor · a2a4dedf
      Archie Pusaka authored
      Enables advertising monitor offloading to the controller, if MSFT
      extension is supported. The kernel won't adjust the monitor parameters
      to match what the controller supports - that is the user space's
      responsibility.
      
      This patch only manages the addition of monitors. Monitor removal is
      going to be handled by another patch.
      Signed-off-by: default avatarArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: default avatarManish Mandlik <mmandlik@chromium.org>
      Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
      Reviewed-by: default avatarYun-Hao Chung <howardchung@google.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      a2a4dedf
    • Archie Pusaka's avatar
      Bluetooth: advmon offload MSFT add rssi support · b4a221ea
      Archie Pusaka authored
      MSFT needs rssi parameter for monitoring advertisement packet,
      therefore we should supply them from mgmt. This adds a new opcode
      to add advertisement monitor with rssi parameters.
      Signed-off-by: default avatarArchie Pusaka <apusaka@chromium.org>
      Reviewed-by: default avatarManish Mandlik <mmandlik@chromium.org>
      Reviewed-by: default avatarMiao-chen Chou <mcchou@chromium.org>
      Reviewed-by: default avatarYun-Hao Chung <howardchung@google.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      b4a221ea
    • Claire Chang's avatar
      Bluetooth: hci_h5: Set HCI_QUIRK_SIMULTANEOUS_DISCOVERY for btrtl · 7f9f2c3f
      Claire Chang authored
      Realtek Bluetooth controllers can do both LE scan and BR/EDR inquiry
      at once, need to set HCI_QUIRK_SIMULTANEOUS_DISCOVERY quirk.
      Signed-off-by: default avatarClaire Chang <tientzu@chromium.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      7f9f2c3f
  8. 06 Jan, 2021 6 commits
  9. 27 Dec, 2020 1 commit
  10. 22 Dec, 2020 1 commit
  11. 21 Dec, 2020 1 commit
  12. 18 Dec, 2020 1 commit
    • Sonny Sasaka's avatar
      Bluetooth: Cancel Inquiry before Create Connection · 89e65975
      Sonny Sasaka authored
      Many controllers do not allow HCI Create Connection while it is doing
      Inquiry. This patch adds Inquiry Cancel before Create Connection in this
      case to allow the controller to do Create Connection. User space will be
      aware of this Inquiry cancellation and they may issue another discovery
      request afterwards.
      
      Sample Command Disallowed response of HCI Create Connection:
      < HCI Command: Inquiry (0x01|0x0001) plen 5
              Access code: 0x9e8b33 (General Inquiry)
              Length: 10.24s (0x08)
              Num responses: 0
      > HCI Event: Command Status (0x0f) plen 4
            Inquiry (0x01|0x0001) ncmd 2
              Status: Success (0x00)
      < HCI Command: Create Connection (0x01|0x0005) plen 13
              Address: XX:XX:XX:XX:XX:XX
              Packet type: 0xcc18
              Page scan repetition mode: R2 (0x02)
              Page scan mode: Mandatory (0x00)
              Clock offset: 0x0000
              Role switch: Allow slave (0x01)
      > HCI Event: Command Status (0x0f) plen 4
            Create Connection (0x01|0x0005) ncmd 1
              Status: Success (0x00)
      > HCI Event: Connect Complete (0x03) plen 11
              Status: Command Disallowed (0x0c)
              Handle: 65535
              Address: XX:XX:XX:XX:XX:XX
              Link type: ACL (0x01)
              Encryption: Disabled (0x00)
      Reviewed-by: default avatarAbhishek Pandit-Subedi <abhishekpandit@chromium.org>
      Reviewed-by: default avatarAlain Michaud <alainm@chromium.org>
      Signed-off-by: default avatarSonny Sasaka <sonnysasaka@chromium.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      89e65975