Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-net-next-2025-01-15' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next

Luiz Augusto von Dentz says:

====================
bluetooth-next pull request for net-next:

- btusb: Add new VID/PID 13d3/3610 for MT7922
- btusb: Add new VID/PID 13d3/3628 for MT7925
- btusb: Add MT7921e device 13d3:3576
- btusb: Add RTL8851BE device 13d3:3600
- btusb: Add ID 0x2c7c:0x0130 for Qualcomm WCN785x
- btusb: add sysfs attribute to control USB alt setting
- qca: Expand firmware-name property
- qca: Fix poor RF performance for WCN6855
- L2CAP: handle NULL sock pointer in l2cap_sock_alloc
- Allow reset via sysfs
- ISO: Allow BIG re-sync
- dt-bindings: Utilize PMU abstraction for WCN6750
- MGMT: Mark LL Privacy as stable

* tag 'for-net-next-2025-01-15' of git://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next: (23 commits)
Bluetooth: MGMT: Fix slab-use-after-free Read in mgmt_remove_adv_monitor_sync
Bluetooth: qca: Fix poor RF performance for WCN6855
Bluetooth: Allow reset via sysfs
Bluetooth: Get rid of cmd_timeout and use the reset callback
Bluetooth: Remove the cmd timeout count in btusb
Bluetooth: Use str_enable_disable-like helpers
Bluetooth: btmtk: Remove resetting mt7921 before downloading the fw
Bluetooth: L2CAP: handle NULL sock pointer in l2cap_sock_alloc
Bluetooth: btusb: Add RTL8851BE device 13d3:3600
dt-bindings: bluetooth: Utilize PMU abstraction for WCN6750
Bluetooth: btusb: Add MT7921e device 13d3:3576
Bluetooth: btrtl: check for NULL in btrtl_setup_realtek()
Bluetooth: btbcm: Fix NULL deref in btbcm_get_board_name()
Bluetooth: qca: Expand firmware-name to load specific rampatch
Bluetooth: qca: Update firmware-name to support board specific nvm
dt-bindings: net: bluetooth: qca: Expand firmware-name property
Bluetooth: btusb: Add new VID/PID 13d3/3628 for MT7925
Bluetooth: btusb: Add new VID/PID 13d3/3610 for MT7922
Bluetooth: btusb: add sysfs attribute to control USB alt setting
Bluetooth: btusb: Add ID 0x2c7c:0x0130 for Qualcomm WCN785x
...
====================

Link: https://patch.msgid.link/20250117213203.3921910-1-luiz.dentz@gmail.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

+340 -335
+4 -6
Documentation/devicetree/bindings/net/bluetooth/qualcomm-bluetooth.yaml
··· 101 101 max-speed: true 102 102 103 103 firmware-name: 104 - description: specify the name of nvm firmware to load 104 + minItems: 1 105 + items: 106 + - description: specify the name of nvm firmware to load 107 + - description: specify the name of rampatch firmware to load 105 108 106 109 local-bd-address: true 107 110 ··· 157 154 - qcom,wcn6750-bt 158 155 then: 159 156 required: 160 - - enable-gpios 161 - - swctrl-gpios 162 - - vddio-supply 163 157 - vddaon-supply 164 - - vddbtcxmx-supply 165 158 - vddrfacmn-supply 166 159 - vddrfa0p8-supply 167 160 - vddrfa1p7-supply 168 161 - vddrfa1p2-supply 169 - - vddasd-supply 170 162 - if: 171 163 properties: 172 164 compatible:
+3
drivers/bluetooth/btbcm.c
··· 553 553 554 554 /* get rid of any '/' in the compatible string */ 555 555 board_type = devm_kstrdup(dev, tmp, GFP_KERNEL); 556 + if (!board_type) 557 + return NULL; 558 + 556 559 strreplace(board_type, '/', '-'); 557 560 558 561 return board_type;
+9 -8
drivers/bluetooth/btintel.c
··· 9 9 #include <linux/module.h> 10 10 #include <linux/firmware.h> 11 11 #include <linux/regmap.h> 12 + #include <linux/string_choices.h> 12 13 #include <linux/acpi.h> 13 14 #include <acpi/acpi_bus.h> 14 15 #include <linux/unaligned.h> ··· 507 506 508 507 bt_dev_info(hdev, "Device revision is %u", version->dev_rev_id); 509 508 bt_dev_info(hdev, "Secure boot is %s", 510 - version->secure_boot ? "enabled" : "disabled"); 509 + str_enabled_disabled(version->secure_boot)); 511 510 bt_dev_info(hdev, "OTP lock is %s", 512 - version->otp_lock ? "enabled" : "disabled"); 511 + str_enabled_disabled(version->otp_lock)); 513 512 bt_dev_info(hdev, "API lock is %s", 514 - version->api_lock ? "enabled" : "disabled"); 513 + str_enabled_disabled(version->api_lock)); 515 514 bt_dev_info(hdev, "Debug lock is %s", 516 - version->debug_lock ? "enabled" : "disabled"); 515 + str_enabled_disabled(version->debug_lock)); 517 516 bt_dev_info(hdev, "Minimum firmware build %u week %u %u", 518 517 version->min_fw_build_nn, version->min_fw_build_cw, 519 518 2000 + version->min_fw_build_yy); ··· 928 927 le16_to_cpu(params->dev_revid)); 929 928 930 929 bt_dev_info(hdev, "Secure boot is %s", 931 - params->secure_boot ? "enabled" : "disabled"); 930 + str_enabled_disabled(params->secure_boot)); 932 931 933 932 bt_dev_info(hdev, "OTP lock is %s", 934 - params->otp_lock ? "enabled" : "disabled"); 933 + str_enabled_disabled(params->otp_lock)); 935 934 936 935 bt_dev_info(hdev, "API lock is %s", 937 - params->api_lock ? "enabled" : "disabled"); 936 + str_enabled_disabled(params->api_lock)); 938 937 939 938 bt_dev_info(hdev, "Debug lock is %s", 940 - params->debug_lock ? "enabled" : "disabled"); 939 + str_enabled_disabled(params->debug_lock)); 941 940 942 941 bt_dev_info(hdev, "Minimum firmware build %u week %u %u", 943 942 params->min_fw_build_nn, params->min_fw_build_cw,
+2 -1
drivers/bluetooth/btmrvl_main.c
··· 7 7 8 8 #include <linux/module.h> 9 9 #include <linux/of.h> 10 + #include <linux/string_choices.h> 10 11 #include <net/bluetooth/bluetooth.h> 11 12 #include <net/bluetooth/hci_core.h> 12 13 #include <linux/mmc/sdio_func.h> ··· 89 88 else 90 89 adapter->psmode = 0; 91 90 BT_DBG("PS Mode:%s", 92 - (adapter->psmode) ? "Enable" : "Disable"); 91 + str_enable_disable(adapter->psmode)); 93 92 } else { 94 93 BT_DBG("PS Mode command failed"); 95 94 }
+2 -2
drivers/bluetooth/btmtk.c
··· 1329 1329 fwname = FIRMWARE_MT7668; 1330 1330 break; 1331 1331 case 0x7922: 1332 - case 0x7961: 1333 1332 case 0x7925: 1334 1333 /* Reset the device to ensure it's in the initial state before 1335 1334 * downloading the firmware to ensure. ··· 1336 1337 1337 1338 if (!test_bit(BTMTK_FIRMWARE_LOADED, &btmtk_data->flags)) 1338 1339 btmtk_usb_subsys_reset(hdev, dev_id); 1339 - 1340 + fallthrough; 1341 + case 0x7961: 1340 1342 btmtk_fw_get_filename(fw_bin_name, sizeof(fw_bin_name), dev_id, 1341 1343 fw_version, fw_flavor); 1342 1344
+2 -2
drivers/bluetooth/btmtksdio.c
··· 1249 1249 return 0; 1250 1250 } 1251 1251 1252 - static void btmtksdio_cmd_timeout(struct hci_dev *hdev) 1252 + static void btmtksdio_reset(struct hci_dev *hdev) 1253 1253 { 1254 1254 struct btmtksdio_dev *bdev = hci_get_drvdata(hdev); 1255 1255 u32 status; ··· 1360 1360 1361 1361 hdev->open = btmtksdio_open; 1362 1362 hdev->close = btmtksdio_close; 1363 - hdev->cmd_timeout = btmtksdio_cmd_timeout; 1363 + hdev->reset = btmtksdio_reset; 1364 1364 hdev->flush = btmtksdio_flush; 1365 1365 hdev->setup = btmtksdio_setup; 1366 1366 hdev->shutdown = btmtksdio_shutdown;
+131 -69
drivers/bluetooth/btqca.c
··· 272 272 } 273 273 EXPORT_SYMBOL_GPL(qca_send_pre_shutdown_cmd); 274 274 275 + static bool qca_filename_has_extension(const char *filename) 276 + { 277 + const char *suffix = strrchr(filename, '.'); 278 + 279 + /* File extensions require a dot, but not as the first or last character */ 280 + if (!suffix || suffix == filename || *(suffix + 1) == '\0') 281 + return 0; 282 + 283 + /* Avoid matching directories with names that look like files with extensions */ 284 + return !strchr(suffix, '/'); 285 + } 286 + 287 + static bool qca_get_alt_nvm_file(char *filename, size_t max_size) 288 + { 289 + char fwname[64]; 290 + const char *suffix; 291 + 292 + /* nvm file name has an extension, replace with .bin */ 293 + if (qca_filename_has_extension(filename)) { 294 + suffix = strrchr(filename, '.'); 295 + strscpy(fwname, filename, suffix - filename + 1); 296 + snprintf(fwname + (suffix - filename), 297 + sizeof(fwname) - (suffix - filename), ".bin"); 298 + /* If nvm file is already the default one, return false to skip the retry. */ 299 + if (strcmp(fwname, filename) == 0) 300 + return false; 301 + 302 + snprintf(filename, max_size, "%s", fwname); 303 + return true; 304 + } 305 + return false; 306 + } 307 + 275 308 static int qca_tlv_check_data(struct hci_dev *hdev, 276 309 struct qca_fw_config *config, 277 310 u8 *fw_data, size_t fw_size, ··· 597 564 config->fwname, ret); 598 565 return ret; 599 566 } 567 + } 568 + /* If the board-specific file is missing, try loading the default 569 + * one, unless that was attempted already. 570 + */ 571 + else if (config->type == TLV_TYPE_NVM && 572 + qca_get_alt_nvm_file(config->fwname, sizeof(config->fwname))) { 573 + bt_dev_info(hdev, "QCA Downloading %s", config->fwname); 574 + ret = request_firmware(&fw, config->fwname, &hdev->dev); 575 + if (ret) { 576 + bt_dev_err(hdev, "QCA Failed to request file: %s (%d)", 577 + config->fwname, ret); 578 + return ret; 579 + } 600 580 } else { 601 581 bt_dev_err(hdev, "QCA Failed to request file: %s (%d)", 602 582 config->fwname, ret); ··· 746 700 return 0; 747 701 } 748 702 749 - static void qca_generate_hsp_nvm_name(char *fwname, size_t max_size, 703 + static void qca_get_nvm_name_by_board(char *fwname, size_t max_size, 704 + const char *stem, enum qca_btsoc_type soc_type, 750 705 struct qca_btsoc_version ver, u8 rom_ver, u16 bid) 751 706 { 752 707 const char *variant; 708 + const char *prefix; 753 709 754 - /* hsp gf chip */ 755 - if ((le32_to_cpu(ver.soc_id) & QCA_HSP_GF_SOC_MASK) == QCA_HSP_GF_SOC_ID) 756 - variant = "g"; 757 - else 758 - variant = ""; 710 + /* Set the default value to variant and prefix */ 711 + variant = ""; 712 + prefix = "b"; 759 713 760 - if (bid == 0x0) 761 - snprintf(fwname, max_size, "qca/hpnv%02x%s.bin", rom_ver, variant); 762 - else 763 - snprintf(fwname, max_size, "qca/hpnv%02x%s.%x", rom_ver, variant, bid); 764 - } 714 + if (soc_type == QCA_QCA2066) 715 + prefix = ""; 765 716 766 - static inline void qca_get_nvm_name_generic(struct qca_fw_config *cfg, 767 - const char *stem, u8 rom_ver, u16 bid) 768 - { 769 - if (bid == 0x0) 770 - snprintf(cfg->fwname, sizeof(cfg->fwname), "qca/%snv%02x.bin", stem, rom_ver); 771 - else if (bid & 0xff00) 772 - snprintf(cfg->fwname, sizeof(cfg->fwname), 773 - "qca/%snv%02x.b%x", stem, rom_ver, bid); 774 - else 775 - snprintf(cfg->fwname, sizeof(cfg->fwname), 776 - "qca/%snv%02x.b%02x", stem, rom_ver, bid); 717 + if (soc_type == QCA_WCN6855 || soc_type == QCA_QCA2066) { 718 + /* If the chip is manufactured by GlobalFoundries */ 719 + if ((le32_to_cpu(ver.soc_id) & QCA_HSP_GF_SOC_MASK) == QCA_HSP_GF_SOC_ID) 720 + variant = "g"; 721 + } 722 + 723 + if (rom_ver != 0) { 724 + if (bid == 0x0 || bid == 0xffff) 725 + snprintf(fwname, max_size, "qca/%s%02x%s.bin", stem, rom_ver, variant); 726 + else 727 + snprintf(fwname, max_size, "qca/%s%02x%s.%s%02x", stem, rom_ver, 728 + variant, prefix, bid); 729 + } else { 730 + if (bid == 0x0 || bid == 0xffff) 731 + snprintf(fwname, max_size, "qca/%s%s.bin", stem, variant); 732 + else 733 + snprintf(fwname, max_size, "qca/%s%s.%s%02x", stem, variant, prefix, bid); 734 + } 777 735 } 778 736 779 737 int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, 780 738 enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, 781 - const char *firmware_name) 739 + const char *firmware_name, const char *rampatch_name) 782 740 { 783 741 struct qca_fw_config config = {}; 784 742 int err; ··· 811 761 812 762 /* Download rampatch file */ 813 763 config.type = TLV_TYPE_PATCH; 814 - switch (soc_type) { 815 - case QCA_WCN3990: 816 - case QCA_WCN3991: 817 - case QCA_WCN3998: 818 - snprintf(config.fwname, sizeof(config.fwname), 819 - "qca/crbtfw%02x.tlv", rom_ver); 820 - break; 821 - case QCA_WCN3988: 822 - snprintf(config.fwname, sizeof(config.fwname), 823 - "qca/apbtfw%02x.tlv", rom_ver); 824 - break; 825 - case QCA_QCA2066: 826 - snprintf(config.fwname, sizeof(config.fwname), 827 - "qca/hpbtfw%02x.tlv", rom_ver); 828 - break; 829 - case QCA_QCA6390: 830 - snprintf(config.fwname, sizeof(config.fwname), 831 - "qca/htbtfw%02x.tlv", rom_ver); 832 - break; 833 - case QCA_WCN6750: 834 - /* Choose mbn file by default.If mbn file is not found 835 - * then choose tlv file 836 - */ 837 - config.type = ELF_TYPE_PATCH; 838 - snprintf(config.fwname, sizeof(config.fwname), 839 - "qca/msbtfw%02x.mbn", rom_ver); 840 - break; 841 - case QCA_WCN6855: 842 - snprintf(config.fwname, sizeof(config.fwname), 843 - "qca/hpbtfw%02x.tlv", rom_ver); 844 - break; 845 - case QCA_WCN7850: 846 - snprintf(config.fwname, sizeof(config.fwname), 847 - "qca/hmtbtfw%02x.tlv", rom_ver); 848 - break; 849 - default: 850 - snprintf(config.fwname, sizeof(config.fwname), 851 - "qca/rampatch_%08x.bin", soc_ver); 764 + if (rampatch_name) { 765 + snprintf(config.fwname, sizeof(config.fwname), "qca/%s", rampatch_name); 766 + } else { 767 + switch (soc_type) { 768 + case QCA_WCN3990: 769 + case QCA_WCN3991: 770 + case QCA_WCN3998: 771 + snprintf(config.fwname, sizeof(config.fwname), 772 + "qca/crbtfw%02x.tlv", rom_ver); 773 + break; 774 + case QCA_WCN3988: 775 + snprintf(config.fwname, sizeof(config.fwname), 776 + "qca/apbtfw%02x.tlv", rom_ver); 777 + break; 778 + case QCA_QCA2066: 779 + snprintf(config.fwname, sizeof(config.fwname), 780 + "qca/hpbtfw%02x.tlv", rom_ver); 781 + break; 782 + case QCA_QCA6390: 783 + snprintf(config.fwname, sizeof(config.fwname), 784 + "qca/htbtfw%02x.tlv", rom_ver); 785 + break; 786 + case QCA_WCN6750: 787 + /* Choose mbn file by default.If mbn file is not found 788 + * then choose tlv file 789 + */ 790 + config.type = ELF_TYPE_PATCH; 791 + snprintf(config.fwname, sizeof(config.fwname), 792 + "qca/msbtfw%02x.mbn", rom_ver); 793 + break; 794 + case QCA_WCN6855: 795 + snprintf(config.fwname, sizeof(config.fwname), 796 + "qca/hpbtfw%02x.tlv", rom_ver); 797 + break; 798 + case QCA_WCN7850: 799 + snprintf(config.fwname, sizeof(config.fwname), 800 + "qca/hmtbtfw%02x.tlv", rom_ver); 801 + break; 802 + default: 803 + snprintf(config.fwname, sizeof(config.fwname), 804 + "qca/rampatch_%08x.bin", soc_ver); 805 + } 852 806 } 853 807 854 808 err = qca_download_firmware(hdev, &config, soc_type, rom_ver); ··· 870 816 /* Download NVM configuration */ 871 817 config.type = TLV_TYPE_NVM; 872 818 if (firmware_name) { 873 - snprintf(config.fwname, sizeof(config.fwname), 874 - "qca/%s", firmware_name); 819 + /* The firmware name has an extension, use it directly */ 820 + if (qca_filename_has_extension(firmware_name)) { 821 + snprintf(config.fwname, sizeof(config.fwname), "qca/%s", firmware_name); 822 + } else { 823 + qca_read_fw_board_id(hdev, &boardid); 824 + qca_get_nvm_name_by_board(config.fwname, sizeof(config.fwname), 825 + firmware_name, soc_type, ver, 0, boardid); 826 + } 875 827 } else { 876 828 switch (soc_type) { 877 829 case QCA_WCN3990: ··· 896 836 "qca/apnv%02x.bin", rom_ver); 897 837 break; 898 838 case QCA_QCA2066: 899 - qca_generate_hsp_nvm_name(config.fwname, 900 - sizeof(config.fwname), ver, rom_ver, boardid); 839 + qca_get_nvm_name_by_board(config.fwname, 840 + sizeof(config.fwname), "hpnv", soc_type, ver, 841 + rom_ver, boardid); 901 842 break; 902 843 case QCA_QCA6390: 903 844 snprintf(config.fwname, sizeof(config.fwname), ··· 909 848 "qca/msnv%02x.bin", rom_ver); 910 849 break; 911 850 case QCA_WCN6855: 912 - snprintf(config.fwname, sizeof(config.fwname), 913 - "qca/hpnv%02x.bin", rom_ver); 851 + qca_read_fw_board_id(hdev, &boardid); 852 + qca_get_nvm_name_by_board(config.fwname, sizeof(config.fwname), 853 + "hpnv", soc_type, ver, rom_ver, boardid); 914 854 break; 915 855 case QCA_WCN7850: 916 - qca_get_nvm_name_generic(&config, "hmt", rom_ver, boardid); 856 + qca_get_nvm_name_by_board(config.fwname, sizeof(config.fwname), 857 + "hmtnv", soc_type, ver, rom_ver, boardid); 917 858 break; 918 - 919 859 default: 920 860 snprintf(config.fwname, sizeof(config.fwname), 921 861 "qca/nvm_%08x.bin", soc_ver);
+3 -2
drivers/bluetooth/btqca.h
··· 161 161 int qca_set_bdaddr_rome(struct hci_dev *hdev, const bdaddr_t *bdaddr); 162 162 int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, 163 163 enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, 164 - const char *firmware_name); 164 + const char *firmware_name, const char *rampatch_name); 165 165 int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver, 166 166 enum qca_btsoc_type); 167 167 int qca_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr); ··· 176 176 static inline int qca_uart_setup(struct hci_dev *hdev, uint8_t baudrate, 177 177 enum qca_btsoc_type soc_type, 178 178 struct qca_btsoc_version ver, 179 - const char *firmware_name) 179 + const char *firmware_name, 180 + const char *rampatch_name) 180 181 { 181 182 return -EOPNOTSUPP; 182 183 }
+3 -1
drivers/bluetooth/btrtl.c
··· 1351 1351 1352 1352 btrtl_set_quirks(hdev, btrtl_dev); 1353 1353 1354 - hci_set_hw_info(hdev, 1354 + if (btrtl_dev->ic_info) { 1355 + hci_set_hw_info(hdev, 1355 1356 "RTL lmp_subver=%u hci_rev=%u hci_ver=%u hci_bus=%u", 1356 1357 btrtl_dev->ic_info->lmp_subver, 1357 1358 btrtl_dev->ic_info->hci_rev, 1358 1359 btrtl_dev->ic_info->hci_ver, 1359 1360 btrtl_dev->ic_info->hci_bus); 1361 + } 1360 1362 1361 1363 btrtl_free(btrtl_dev); 1362 1364 return ret;
+53 -20
drivers/bluetooth/btusb.c
··· 377 377 BTUSB_WIDEBAND_SPEECH }, 378 378 { USB_DEVICE(0x13d3, 0x3623), .driver_info = BTUSB_QCA_WCN6855 | 379 379 BTUSB_WIDEBAND_SPEECH }, 380 + { USB_DEVICE(0x2c7c, 0x0130), .driver_info = BTUSB_QCA_WCN6855 | 381 + BTUSB_WIDEBAND_SPEECH }, 380 382 381 383 /* Broadcom BCM2035 */ 382 384 { USB_DEVICE(0x0a5c, 0x2009), .driver_info = BTUSB_BCM92035 }, ··· 482 480 /* Realtek 8822CU Bluetooth devices */ 483 481 { USB_DEVICE(0x13d3, 0x3549), .driver_info = BTUSB_REALTEK | 484 482 BTUSB_WIDEBAND_SPEECH }, 483 + 484 + /* Realtek 8851BE Bluetooth devices */ 485 + { USB_DEVICE(0x13d3, 0x3600), .driver_info = BTUSB_REALTEK }, 485 486 486 487 /* Realtek 8852AE Bluetooth devices */ 487 488 { USB_DEVICE(0x0bda, 0x2852), .driver_info = BTUSB_REALTEK | ··· 605 600 BTUSB_WIDEBAND_SPEECH }, 606 601 { USB_DEVICE(0x13d3, 0x3567), .driver_info = BTUSB_MEDIATEK | 607 602 BTUSB_WIDEBAND_SPEECH }, 603 + { USB_DEVICE(0x13d3, 0x3576), .driver_info = BTUSB_MEDIATEK | 604 + BTUSB_WIDEBAND_SPEECH }, 608 605 { USB_DEVICE(0x13d3, 0x3578), .driver_info = BTUSB_MEDIATEK | 609 606 BTUSB_WIDEBAND_SPEECH }, 610 607 { USB_DEVICE(0x13d3, 0x3583), .driver_info = BTUSB_MEDIATEK | ··· 616 609 617 610 /* MediaTek MT7922 Bluetooth devices */ 618 611 { USB_DEVICE(0x13d3, 0x3585), .driver_info = BTUSB_MEDIATEK | 612 + BTUSB_WIDEBAND_SPEECH }, 613 + { USB_DEVICE(0x13d3, 0x3610), .driver_info = BTUSB_MEDIATEK | 619 614 BTUSB_WIDEBAND_SPEECH }, 620 615 621 616 /* MediaTek MT7922A Bluetooth devices */ ··· 682 673 { USB_DEVICE(0x13d3, 0x3604), .driver_info = BTUSB_MEDIATEK | 683 674 BTUSB_WIDEBAND_SPEECH }, 684 675 { USB_DEVICE(0x13d3, 0x3608), .driver_info = BTUSB_MEDIATEK | 676 + BTUSB_WIDEBAND_SPEECH }, 677 + { USB_DEVICE(0x13d3, 0x3628), .driver_info = BTUSB_MEDIATEK | 685 678 BTUSB_WIDEBAND_SPEECH }, 686 679 687 680 /* Additional Realtek 8723AE Bluetooth devices */ ··· 890 879 int (*disconnect)(struct hci_dev *hdev); 891 880 892 881 int oob_wake_irq; /* irq for out-of-band wake-on-bt */ 893 - unsigned cmd_timeout_cnt; 894 882 895 883 struct qca_dump_info qca_dump; 896 884 }; ··· 916 906 usb_queue_reset_device(data->intf); 917 907 } 918 908 919 - static void btusb_intel_cmd_timeout(struct hci_dev *hdev) 909 + static void btusb_intel_reset(struct hci_dev *hdev) 920 910 { 921 911 struct btusb_data *data = hci_get_drvdata(hdev); 922 912 struct gpio_desc *reset_gpio = data->reset_gpio; 923 913 struct btintel_data *intel_data = hci_get_priv(hdev); 924 - 925 - if (++data->cmd_timeout_cnt < 5) 926 - return; 927 914 928 915 if (intel_data->acpi_reset_method) { 929 916 if (test_and_set_bit(INTEL_ACPI_RESET_ACTIVE, intel_data->flags)) { ··· 994 987 } 995 988 } 996 989 997 - static void btusb_rtl_cmd_timeout(struct hci_dev *hdev) 990 + static void btusb_rtl_reset(struct hci_dev *hdev) 998 991 { 999 992 struct btusb_data *data = hci_get_drvdata(hdev); 1000 993 struct gpio_desc *reset_gpio = data->reset_gpio; ··· 1003 996 }; 1004 997 1005 998 btusb_rtl_alloc_devcoredump(hdev, &hdr, NULL, 0); 1006 - 1007 - if (++data->cmd_timeout_cnt < 5) 1008 - return; 1009 999 1010 1000 if (!reset_gpio) { 1011 1001 btusb_reset(hdev); ··· 1038 1034 btusb_rtl_alloc_devcoredump(hdev, &hdr, NULL, 0); 1039 1035 } 1040 1036 1041 - static void btusb_qca_cmd_timeout(struct hci_dev *hdev) 1037 + static void btusb_qca_reset(struct hci_dev *hdev) 1042 1038 { 1043 1039 struct btusb_data *data = hci_get_drvdata(hdev); 1044 1040 struct gpio_desc *reset_gpio = data->reset_gpio; 1045 1041 1046 1042 if (test_bit(BTUSB_HW_SSR_ACTIVE, &data->flags)) { 1047 - bt_dev_info(hdev, "Ramdump in progress, defer cmd_timeout"); 1043 + bt_dev_info(hdev, "Ramdump in progress, defer reset"); 1048 1044 return; 1049 1045 } 1050 - 1051 - if (++data->cmd_timeout_cnt < 5) 1052 - return; 1053 1046 1054 1047 if (reset_gpio) { 1055 1048 bt_dev_err(hdev, "Reset qca device via bt_en gpio"); ··· 3646 3645 .llseek = default_llseek, 3647 3646 }; 3648 3647 3648 + static ssize_t isoc_alt_show(struct device *dev, 3649 + struct device_attribute *attr, 3650 + char *buf) 3651 + { 3652 + struct btusb_data *data = dev_get_drvdata(dev); 3653 + 3654 + return sysfs_emit(buf, "%d\n", data->isoc_altsetting); 3655 + } 3656 + 3657 + static ssize_t isoc_alt_store(struct device *dev, 3658 + struct device_attribute *attr, 3659 + const char *buf, size_t count) 3660 + { 3661 + struct btusb_data *data = dev_get_drvdata(dev); 3662 + int alt; 3663 + int ret; 3664 + 3665 + if (kstrtoint(buf, 10, &alt)) 3666 + return -EINVAL; 3667 + 3668 + ret = btusb_switch_alt_setting(data->hdev, alt); 3669 + return ret < 0 ? ret : count; 3670 + } 3671 + 3672 + static DEVICE_ATTR_RW(isoc_alt); 3673 + 3649 3674 static int btusb_probe(struct usb_interface *intf, 3650 3675 const struct usb_device_id *id) 3651 3676 { ··· 3868 3841 3869 3842 /* Transport specific configuration */ 3870 3843 hdev->send = btusb_send_frame_intel; 3871 - hdev->cmd_timeout = btusb_intel_cmd_timeout; 3844 + hdev->reset = btusb_intel_reset; 3872 3845 3873 3846 if (id->driver_info & BTUSB_INTEL_NO_WBS_SUPPORT) 3874 3847 btintel_set_flag(hdev, INTEL_ROM_LEGACY_NO_WBS_SUPPORT); ··· 3888 3861 hdev->setup = btusb_mtk_setup; 3889 3862 hdev->shutdown = btusb_mtk_shutdown; 3890 3863 hdev->manufacturer = 70; 3891 - hdev->cmd_timeout = btmtk_reset_sync; 3864 + hdev->reset = btmtk_reset_sync; 3892 3865 hdev->set_bdaddr = btmtk_set_bdaddr; 3893 3866 hdev->send = btusb_send_frame_mtk; 3894 3867 set_bit(HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN, &hdev->quirks); ··· 3920 3893 data->setup_on_usb = btusb_setup_qca; 3921 3894 hdev->shutdown = btusb_shutdown_qca; 3922 3895 hdev->set_bdaddr = btusb_set_bdaddr_ath3012; 3923 - hdev->cmd_timeout = btusb_qca_cmd_timeout; 3896 + hdev->reset = btusb_qca_reset; 3924 3897 set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); 3925 3898 btusb_check_needs_reset_resume(intf); 3926 3899 } ··· 3934 3907 data->setup_on_usb = btusb_setup_qca; 3935 3908 hdev->shutdown = btusb_shutdown_qca; 3936 3909 hdev->set_bdaddr = btusb_set_bdaddr_wcn6855; 3937 - hdev->cmd_timeout = btusb_qca_cmd_timeout; 3910 + hdev->reset = btusb_qca_reset; 3938 3911 set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks); 3939 3912 hci_set_msft_opcode(hdev, 0xFD70); 3940 3913 } ··· 3953 3926 btrtl_set_driver_name(hdev, btusb_driver.name); 3954 3927 hdev->setup = btusb_setup_realtek; 3955 3928 hdev->shutdown = btrtl_shutdown_realtek; 3956 - hdev->cmd_timeout = btusb_rtl_cmd_timeout; 3929 + hdev->reset = btusb_rtl_reset; 3957 3930 hdev->hw_error = btusb_rtl_hw_error; 3958 3931 3959 3932 /* Realtek devices need to set remote wakeup on auto-suspend */ ··· 4035 4008 data->isoc, data); 4036 4009 if (err < 0) 4037 4010 goto out_free_dev; 4011 + 4012 + err = device_create_file(&intf->dev, &dev_attr_isoc_alt); 4013 + if (err) 4014 + goto out_free_dev; 4038 4015 } 4039 4016 4040 4017 if (IS_ENABLED(CONFIG_BT_HCIBTUSB_BCM) && data->diag) { ··· 4085 4054 hdev = data->hdev; 4086 4055 usb_set_intfdata(data->intf, NULL); 4087 4056 4088 - if (data->isoc) 4057 + if (data->isoc) { 4058 + device_remove_file(&intf->dev, &dev_attr_isoc_alt); 4089 4059 usb_set_intfdata(data->isoc, NULL); 4060 + } 4090 4061 4091 4062 if (data->diag) 4092 4063 usb_set_intfdata(data->diag, NULL);
+23 -10
drivers/bluetooth/hci_qca.c
··· 31 31 #include <linux/pwrseq/consumer.h> 32 32 #include <linux/regulator/consumer.h> 33 33 #include <linux/serdev.h> 34 + #include <linux/string_choices.h> 34 35 #include <linux/mutex.h> 35 36 #include <linux/unaligned.h> 36 37 ··· 229 228 u32 init_speed; 230 229 u32 oper_speed; 231 230 bool bdaddr_property_broken; 232 - const char *firmware_name; 231 + const char *firmware_name[2]; 233 232 }; 234 233 235 234 static int qca_regulator_enable(struct qca_serdev *qcadev); ··· 259 258 if (hu->serdev) { 260 259 struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev); 261 260 262 - return qsd->firmware_name; 261 + return qsd->firmware_name[0]; 262 + } else { 263 + return NULL; 264 + } 265 + } 266 + 267 + static const char *qca_get_rampatch_name(struct hci_uart *hu) 268 + { 269 + if (hu->serdev) { 270 + struct qca_serdev *qsd = serdev_device_get_drvdata(hu->serdev); 271 + 272 + return qsd->firmware_name[1]; 263 273 } else { 264 274 return NULL; 265 275 } ··· 344 332 else 345 333 __serial_clock_off(hu->tty); 346 334 347 - BT_DBG("Vote serial clock %s(%s)", new_vote ? "true" : "false", 348 - vote ? "true" : "false"); 335 + BT_DBG("Vote serial clock %s(%s)", str_true_false(new_vote), 336 + str_true_false(vote)); 349 337 350 338 diff = jiffies_to_msecs(jiffies - qca->vote_last_jif); 351 339 ··· 1650 1638 clear_bit(QCA_HW_ERROR_EVENT, &qca->flags); 1651 1639 } 1652 1640 1653 - static void qca_cmd_timeout(struct hci_dev *hdev) 1641 + static void qca_reset(struct hci_dev *hdev) 1654 1642 { 1655 1643 struct hci_uart *hu = hci_get_drvdata(hdev); 1656 1644 struct qca_data *qca = hu->priv; ··· 1867 1855 unsigned int retries = 0; 1868 1856 enum qca_btsoc_type soc_type = qca_soc_type(hu); 1869 1857 const char *firmware_name = qca_get_firmware_name(hu); 1858 + const char *rampatch_name = qca_get_rampatch_name(hu); 1870 1859 int ret; 1871 1860 struct qca_btsoc_version ver; 1872 1861 struct qca_serdev *qcadev; ··· 1976 1963 1977 1964 /* Setup patch / NVM configurations */ 1978 1965 ret = qca_uart_setup(hdev, qca_baudrate, soc_type, ver, 1979 - firmware_name); 1966 + firmware_name, rampatch_name); 1980 1967 if (!ret) { 1981 1968 clear_bit(QCA_IBS_DISABLED, &qca->flags); 1982 1969 qca_debugfs_init(hdev); 1983 1970 hu->hdev->hw_error = qca_hw_error; 1984 - hu->hdev->cmd_timeout = qca_cmd_timeout; 1971 + hu->hdev->reset = qca_reset; 1985 1972 if (hu->serdev) { 1986 1973 if (device_can_wakeup(hu->serdev->ctrl->dev.parent)) 1987 1974 hu->hdev->wakeup = qca_wakeup; ··· 2215 2202 enum qca_btsoc_type soc_type = qca_soc_type(hu); 2216 2203 2217 2204 hu->hdev->hw_error = NULL; 2218 - hu->hdev->cmd_timeout = NULL; 2205 + hu->hdev->reset = NULL; 2219 2206 2220 2207 del_timer_sync(&qca->wake_retrans_timer); 2221 2208 del_timer_sync(&qca->tx_idle_timer); ··· 2322 2309 qcadev->serdev_hu.serdev = serdev; 2323 2310 data = device_get_match_data(&serdev->dev); 2324 2311 serdev_device_set_drvdata(serdev, qcadev); 2325 - device_property_read_string(&serdev->dev, "firmware-name", 2326 - &qcadev->firmware_name); 2312 + device_property_read_string_array(&serdev->dev, "firmware-name", 2313 + qcadev->firmware_name, ARRAY_SIZE(qcadev->firmware_name)); 2327 2314 device_property_read_u32(&serdev->dev, "max-speed", 2328 2315 &qcadev->oper_speed); 2329 2316 if (!qcadev->oper_speed)
-1
include/net/bluetooth/hci.h
··· 438 438 HCI_FORCE_BREDR_SMP, 439 439 HCI_FORCE_STATIC_ADDR, 440 440 HCI_LL_RPA_RESOLUTION, 441 - HCI_ENABLE_LL_PRIVACY, 442 441 HCI_CMD_PENDING, 443 442 HCI_FORCE_NO_MITM, 444 443 HCI_QUALITY_REPORT,
+4 -10
include/net/bluetooth/hci_core.h
··· 157 157 158 158 /* Bitmask of connection flags */ 159 159 enum hci_conn_flags { 160 - HCI_CONN_FLAG_REMOTE_WAKEUP = 1, 161 - HCI_CONN_FLAG_DEVICE_PRIVACY = 2, 160 + HCI_CONN_FLAG_REMOTE_WAKEUP = BIT(0), 161 + HCI_CONN_FLAG_DEVICE_PRIVACY = BIT(1), 162 + HCI_CONN_FLAG_ADDRESS_RESOLUTION = BIT(2), 162 163 }; 163 164 typedef u8 hci_conn_flags_t; 164 165 ··· 633 632 int (*post_init)(struct hci_dev *hdev); 634 633 int (*set_diag)(struct hci_dev *hdev, bool enable); 635 634 int (*set_bdaddr)(struct hci_dev *hdev, const bdaddr_t *bdaddr); 636 - void (*cmd_timeout)(struct hci_dev *hdev); 637 635 void (*reset)(struct hci_dev *hdev); 638 636 bool (*wakeup)(struct hci_dev *hdev); 639 637 int (*set_quality_report)(struct hci_dev *hdev, bool enable); ··· 1759 1759 int hci_bdaddr_list_del(struct list_head *list, bdaddr_t *bdaddr, u8 type); 1760 1760 int hci_bdaddr_list_del_with_irk(struct list_head *list, bdaddr_t *bdaddr, 1761 1761 u8 type); 1762 - int hci_bdaddr_list_del_with_flags(struct list_head *list, bdaddr_t *bdaddr, 1763 - u8 type); 1764 1762 void hci_bdaddr_list_clear(struct list_head *list); 1765 1763 1766 1764 struct hci_conn_params *hci_conn_params_lookup(struct hci_dev *hdev, ··· 1917 1919 1918 1920 #define ll_privacy_capable(dev) ((dev)->le_features[0] & HCI_LE_LL_PRIVACY) 1919 1921 1920 - /* Use LL Privacy based address resolution if supported */ 1921 - #define use_ll_privacy(dev) (ll_privacy_capable(dev) && \ 1922 - hci_dev_test_flag(dev, HCI_ENABLE_LL_PRIVACY)) 1923 - 1924 - #define privacy_mode_capable(dev) (use_ll_privacy(dev) && \ 1922 + #define privacy_mode_capable(dev) (ll_privacy_capable(dev) && \ 1925 1923 (hdev->commands[39] & 0x04)) 1926 1924 1927 1925 #define read_key_size_capable(dev) \
-1
include/net/bluetooth/hci_sync.h
··· 140 140 int hci_write_le_host_supported_sync(struct hci_dev *hdev, u8 le, u8 simul); 141 141 int hci_remove_ext_adv_instance_sync(struct hci_dev *hdev, u8 instance, 142 142 struct sock *sk); 143 - int hci_remove_ext_adv_instance(struct hci_dev *hdev, u8 instance); 144 143 struct sk_buff *hci_read_local_oob_data_sync(struct hci_dev *hdev, bool ext, 145 144 struct sock *sk); 146 145
+2 -22
net/bluetooth/hci_core.c
··· 1456 1456 bt_dev_err(hdev, "command tx timeout"); 1457 1457 } 1458 1458 1459 - if (hdev->cmd_timeout) 1460 - hdev->cmd_timeout(hdev); 1459 + if (hdev->reset) 1460 + hdev->reset(hdev); 1461 1461 1462 1462 atomic_set(&hdev->cmd_cnt, 1); 1463 1463 queue_work(hdev->workqueue, &hdev->cmd_work); ··· 2172 2172 } 2173 2173 2174 2174 entry = hci_bdaddr_list_lookup_with_irk(list, bdaddr, type); 2175 - if (!entry) 2176 - return -ENOENT; 2177 - 2178 - list_del(&entry->list); 2179 - kfree(entry); 2180 - 2181 - return 0; 2182 - } 2183 - 2184 - int hci_bdaddr_list_del_with_flags(struct list_head *list, bdaddr_t *bdaddr, 2185 - u8 type) 2186 - { 2187 - struct bdaddr_list_with_flags *entry; 2188 - 2189 - if (!bacmp(bdaddr, BDADDR_ANY)) { 2190 - hci_bdaddr_list_clear(list); 2191 - return 0; 2192 - } 2193 - 2194 - entry = hci_bdaddr_list_lookup_with_flags(list, bdaddr, type); 2195 2175 if (!entry) 2196 2176 return -ENOENT; 2197 2177
+30 -46
net/bluetooth/hci_sync.c
··· 1066 1066 /* If Controller supports LL Privacy use own address type is 1067 1067 * 0x03 1068 1068 */ 1069 - if (use_ll_privacy(hdev)) 1069 + if (ll_privacy_capable(hdev)) 1070 1070 *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; 1071 1071 else 1072 1072 *own_addr_type = ADDR_LE_DEV_RANDOM; ··· 1786 1786 HCI_CMD_TIMEOUT, sk); 1787 1787 } 1788 1788 1789 - static int remove_ext_adv_sync(struct hci_dev *hdev, void *data) 1790 - { 1791 - struct adv_info *adv = data; 1792 - u8 instance = 0; 1793 - 1794 - if (adv) 1795 - instance = adv->instance; 1796 - 1797 - return hci_remove_ext_adv_instance_sync(hdev, instance, NULL); 1798 - } 1799 - 1800 - int hci_remove_ext_adv_instance(struct hci_dev *hdev, u8 instance) 1801 - { 1802 - struct adv_info *adv = NULL; 1803 - 1804 - if (instance) { 1805 - adv = hci_find_adv_instance(hdev, instance); 1806 - if (!adv) 1807 - return -EINVAL; 1808 - } 1809 - 1810 - return hci_cmd_sync_queue(hdev, remove_ext_adv_sync, adv, NULL); 1811 - } 1812 - 1813 1789 int hci_le_terminate_big_sync(struct hci_dev *hdev, u8 handle, u8 reason) 1814 1790 { 1815 1791 struct hci_cp_le_term_big cp; ··· 2138 2162 2139 2163 static int hci_le_set_addr_resolution_enable_sync(struct hci_dev *hdev, u8 val) 2140 2164 { 2141 - if (!use_ll_privacy(hdev)) 2165 + if (!ll_privacy_capable(hdev)) 2142 2166 return 0; 2143 2167 2144 2168 /* If controller is not/already resolving we are done. */ ··· 2230 2254 struct hci_cp_le_del_from_resolv_list cp; 2231 2255 struct bdaddr_list_with_irk *entry; 2232 2256 2233 - if (!use_ll_privacy(hdev)) 2257 + if (!ll_privacy_capable(hdev)) 2234 2258 return 0; 2235 2259 2236 2260 /* Check if the IRK has been programmed */ ··· 2295 2319 struct bdaddr_list_with_irk *entry; 2296 2320 struct hci_conn_params *p; 2297 2321 2298 - if (!use_ll_privacy(hdev)) 2322 + if (!ll_privacy_capable(hdev)) 2299 2323 return 0; 2300 2324 2301 2325 /* Attempt to program local identity address, type and irk if params is ··· 2308 2332 hci_copy_identity_address(hdev, &cp.bdaddr, &cp.bdaddr_type); 2309 2333 memcpy(cp.peer_irk, hdev->irk, 16); 2310 2334 goto done; 2311 - } 2335 + } else if (!(params->flags & HCI_CONN_FLAG_ADDRESS_RESOLUTION)) 2336 + return 0; 2312 2337 2313 2338 irk = hci_find_irk_by_addr(hdev, &params->addr, params->addr_type); 2314 2339 if (!irk) ··· 2355 2378 { 2356 2379 struct hci_cp_le_set_privacy_mode cp; 2357 2380 struct smp_irk *irk; 2381 + 2382 + if (!ll_privacy_capable(hdev) || 2383 + !(params->flags & HCI_CONN_FLAG_ADDRESS_RESOLUTION)) 2384 + return 0; 2358 2385 2359 2386 /* If device privacy mode has already been set there is nothing to do */ 2360 2387 if (params->privacy_mode == HCI_DEVICE_PRIVACY) ··· 2408 2427 /* Select filter policy to accept all advertising */ 2409 2428 if (*num_entries >= hdev->le_accept_list_size) 2410 2429 return -ENOSPC; 2411 - 2412 - /* Accept list can not be used with RPAs */ 2413 - if (!use_ll_privacy(hdev) && 2414 - hci_find_irk_by_addr(hdev, &params->addr, params->addr_type)) 2415 - return -EINVAL; 2416 2430 2417 2431 /* Attempt to program the device in the resolving list first to avoid 2418 2432 * having to rollback in case it fails since the resolving list is ··· 2543 2567 { 2544 2568 int err; 2545 2569 2546 - if (!use_ll_privacy(hdev)) 2570 + if (!ll_privacy_capable(hdev)) 2547 2571 return 0; 2548 2572 2549 2573 if (!hci_dev_test_flag(hdev, HCI_LL_RPA_RESOLUTION)) ··· 2647 2671 * 2648 2672 * Update is done using the following sequence: 2649 2673 * 2650 - * use_ll_privacy((Disable Advertising) -> Disable Resolving List) -> 2674 + * ll_privacy_capable((Disable Advertising) -> Disable Resolving List) -> 2651 2675 * Remove Devices From Accept List -> 2652 - * (has IRK && use_ll_privacy(Remove Devices From Resolving List))-> 2676 + * (has IRK && ll_privacy_capable(Remove Devices From Resolving List))-> 2653 2677 * Add Devices to Accept List -> 2654 - * (has IRK && use_ll_privacy(Remove Devices From Resolving List)) -> 2655 - * use_ll_privacy(Enable Resolving List -> (Enable Advertising)) -> 2678 + * (has IRK && ll_privacy_capable(Remove Devices From Resolving List)) -> 2679 + * ll_privacy_capable(Enable Resolving List -> (Enable Advertising)) -> 2656 2680 * Enable Scanning 2657 2681 * 2658 2682 * In case of failure advertising shall be restored to its original state and ··· 2673 2697 /* Pause advertising if resolving list can be used as controllers 2674 2698 * cannot accept resolving list modifications while advertising. 2675 2699 */ 2676 - if (use_ll_privacy(hdev)) { 2700 + if (ll_privacy_capable(hdev)) { 2677 2701 err = hci_pause_advertising_sync(hdev); 2678 2702 if (err) { 2679 2703 bt_dev_err(hdev, "pause advertising failed: %d", err); ··· 2818 2842 bt_dev_err(hdev, "Unable to enable LL privacy: %d", err); 2819 2843 2820 2844 /* Resume advertising if it was paused */ 2821 - if (use_ll_privacy(hdev)) 2845 + if (ll_privacy_capable(hdev)) 2822 2846 hci_resume_advertising_sync(hdev); 2823 2847 2824 2848 /* Select filter policy to use accept list */ ··· 3076 3100 * If there are devices to scan: 3077 3101 * 3078 3102 * Disable Scanning -> Update Accept List -> 3079 - * use_ll_privacy((Disable Advertising) -> Disable Resolving List -> 3103 + * ll_privacy_capable((Disable Advertising) -> Disable Resolving List -> 3080 3104 * Update Resolving List -> Enable Resolving List -> (Enable Advertising)) -> 3081 3105 * Enable Scanning 3082 3106 * ··· 3430 3454 * 3431 3455 * HCI_SSP_ENABLED(Enable SSP) 3432 3456 * HCI_LE_ENABLED(Enable LE) 3433 - * HCI_LE_ENABLED(use_ll_privacy(Add local IRK to Resolving List) -> 3457 + * HCI_LE_ENABLED(ll_privacy_capable(Add local IRK to Resolving List) -> 3434 3458 * Update adv data) 3435 3459 * Enable Authentication 3436 3460 * lmp_bredr_capable(Set Fast Connectable -> Set Scan Type -> Set Class -> ··· 4204 4228 */ 4205 4229 if (use_enhanced_conn_complete(hdev)) 4206 4230 events[1] |= 0x02; /* LE Enhanced Connection Complete */ 4231 + 4232 + /* Mark Device Privacy if Privacy Mode is supported */ 4233 + if (privacy_mode_capable(hdev)) 4234 + hdev->conn_flags |= HCI_CONN_FLAG_DEVICE_PRIVACY; 4235 + 4236 + /* Mark Address Resolution if LL Privacy is supported */ 4237 + if (ll_privacy_capable(hdev)) 4238 + hdev->conn_flags |= HCI_CONN_FLAG_ADDRESS_RESOLUTION; 4207 4239 4208 4240 /* If the controller supports Extended Scanner Filter 4209 4241 * Policies, enable the corresponding event. ··· 5369 5385 } 5370 5386 5371 5387 /* Resume advertising if it was paused */ 5372 - if (use_ll_privacy(hdev)) 5388 + if (ll_privacy_capable(hdev)) 5373 5389 hci_resume_advertising_sync(hdev); 5374 5390 5375 5391 /* No further actions needed for LE-only discovery */ ··· 5881 5897 5882 5898 failed: 5883 5899 /* Resume advertising if it was paused */ 5884 - if (use_ll_privacy(hdev)) 5900 + if (ll_privacy_capable(hdev)) 5885 5901 hci_resume_advertising_sync(hdev); 5886 5902 5887 5903 /* Resume passive scanning */ ··· 6657 6673 /* If Controller supports LL Privacy use own address type is 6658 6674 * 0x03 6659 6675 */ 6660 - if (use_ll_privacy(hdev)) 6676 + if (ll_privacy_capable(hdev)) 6661 6677 *own_addr_type = ADDR_LE_DEV_RANDOM_RESOLVED; 6662 6678 else 6663 6679 *own_addr_type = ADDR_LE_DEV_RANDOM;
+19
net/bluetooth/hci_sysfs.c
··· 90 90 module_put(THIS_MODULE); 91 91 } 92 92 93 + static ssize_t reset_store(struct device *dev, struct device_attribute *attr, 94 + const char *buf, size_t count) 95 + { 96 + struct hci_dev *hdev = to_hci_dev(dev); 97 + 98 + if (hdev->reset) 99 + hdev->reset(hdev); 100 + 101 + return count; 102 + } 103 + static DEVICE_ATTR_WO(reset); 104 + 105 + static struct attribute *bt_host_attrs[] = { 106 + &dev_attr_reset.attr, 107 + NULL, 108 + }; 109 + ATTRIBUTE_GROUPS(bt_host); 110 + 93 111 static const struct device_type bt_host = { 94 112 .name = "host", 95 113 .release = bt_host_release, 114 + .groups = bt_host_groups, 96 115 }; 97 116 98 117 void hci_init_sysfs(struct hci_dev *hdev)
+36
net/bluetooth/iso.c
··· 1281 1281 1282 1282 BT_DBG("new socket %p", ch); 1283 1283 1284 + /* A Broadcast Sink might require BIG sync to be terminated 1285 + * and re-established multiple times, while keeping the same 1286 + * PA sync handle active. To allow this, once all BIS 1287 + * connections have been accepted on a PA sync parent socket, 1288 + * "reset" socket state, to allow future BIG re-sync procedures. 1289 + */ 1290 + if (test_bit(BT_SK_PA_SYNC, &iso_pi(sk)->flags)) { 1291 + /* Iterate through the list of bound BIS indices 1292 + * and clear each BIS as they are accepted by the 1293 + * user space, one by one. 1294 + */ 1295 + for (int i = 0; i < iso_pi(sk)->bc_num_bis; i++) { 1296 + if (iso_pi(sk)->bc_bis[i] > 0) { 1297 + iso_pi(sk)->bc_bis[i] = 0; 1298 + iso_pi(sk)->bc_num_bis--; 1299 + break; 1300 + } 1301 + } 1302 + 1303 + if (iso_pi(sk)->bc_num_bis == 0) { 1304 + /* Once the last BIS was accepted, reset parent 1305 + * socket parameters to mark that the listening 1306 + * process for BIS connections has been completed: 1307 + * 1308 + * 1. Reset the DEFER setup flag on the parent sk. 1309 + * 2. Clear the flag marking that the BIG create 1310 + * sync command is pending. 1311 + * 3. Transition socket state from BT_LISTEN to 1312 + * BT_CONNECTED. 1313 + */ 1314 + set_bit(BT_SK_DEFER_SETUP, &bt_sk(sk)->flags); 1315 + clear_bit(BT_SK_BIG_SYNC, &iso_pi(sk)->flags); 1316 + sk->sk_state = BT_CONNECTED; 1317 + } 1318 + } 1319 + 1284 1320 done: 1285 1321 release_sock(sk); 1286 1322 return err;
+2 -1
net/bluetooth/l2cap_sock.c
··· 1888 1888 chan = l2cap_chan_create(); 1889 1889 if (!chan) { 1890 1890 sk_free(sk); 1891 - sock->sk = NULL; 1891 + if (sock) 1892 + sock->sk = NULL; 1892 1893 return NULL; 1893 1894 } 1894 1895
+12 -133
net/bluetooth/mgmt.c
··· 4417 4417 0x96, 0x46, 0xc0, 0x42, 0xb5, 0x10, 0x1b, 0x67, 4418 4418 }; 4419 4419 4420 - /* 15c0a148-c273-11ea-b3de-0242ac130004 */ 4421 - static const u8 rpa_resolution_uuid[16] = { 4422 - 0x04, 0x00, 0x13, 0xac, 0x42, 0x02, 0xde, 0xb3, 4423 - 0xea, 0x11, 0x73, 0xc2, 0x48, 0xa1, 0xc0, 0x15, 4424 - }; 4425 - 4426 4420 /* 6fbaf188-05e0-496a-9885-d6ddfdb4e03e */ 4427 4421 static const u8 iso_socket_uuid[16] = { 4428 4422 0x3e, 0xe0, 0xb4, 0xfd, 0xdd, 0xd6, 0x85, 0x98, ··· 4463 4469 flags = 0; 4464 4470 4465 4471 memcpy(rp->features[idx].uuid, le_simultaneous_roles_uuid, 16); 4466 - rp->features[idx].flags = cpu_to_le32(flags); 4467 - idx++; 4468 - } 4469 - 4470 - if (hdev && ll_privacy_capable(hdev)) { 4471 - if (hci_dev_test_flag(hdev, HCI_ENABLE_LL_PRIVACY)) 4472 - flags = BIT(0) | BIT(1); 4473 - else 4474 - flags = BIT(1); 4475 - 4476 - memcpy(rp->features[idx].uuid, rpa_resolution_uuid, 16); 4477 4472 rp->features[idx].flags = cpu_to_le32(flags); 4478 4473 idx++; 4479 4474 } ··· 4523 4540 return status; 4524 4541 } 4525 4542 4526 - static int exp_ll_privacy_feature_changed(bool enabled, struct hci_dev *hdev, 4527 - struct sock *skip) 4528 - { 4529 - struct mgmt_ev_exp_feature_changed ev; 4530 - 4531 - memset(&ev, 0, sizeof(ev)); 4532 - memcpy(ev.uuid, rpa_resolution_uuid, 16); 4533 - ev.flags = cpu_to_le32((enabled ? BIT(0) : 0) | BIT(1)); 4534 - 4535 - // Do we need to be atomic with the conn_flags? 4536 - if (enabled && privacy_mode_capable(hdev)) 4537 - hdev->conn_flags |= HCI_CONN_FLAG_DEVICE_PRIVACY; 4538 - else 4539 - hdev->conn_flags &= ~HCI_CONN_FLAG_DEVICE_PRIVACY; 4540 - 4541 - return mgmt_limited_event(MGMT_EV_EXP_FEATURE_CHANGED, hdev, 4542 - &ev, sizeof(ev), 4543 - HCI_MGMT_EXP_FEATURE_EVENTS, skip); 4544 - 4545 - } 4546 - 4547 4543 static int exp_feature_changed(struct hci_dev *hdev, const u8 *uuid, 4548 4544 bool enabled, struct sock *skip) 4549 4545 { ··· 4562 4600 exp_feature_changed(NULL, ZERO_KEY, false, sk); 4563 4601 } 4564 4602 #endif 4565 - 4566 - if (hdev && use_ll_privacy(hdev) && !hdev_is_powered(hdev)) { 4567 - bool changed; 4568 - 4569 - changed = hci_dev_test_and_clear_flag(hdev, 4570 - HCI_ENABLE_LL_PRIVACY); 4571 - if (changed) 4572 - exp_feature_changed(hdev, rpa_resolution_uuid, false, 4573 - sk); 4574 - } 4575 4603 4576 4604 hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); 4577 4605 ··· 4664 4712 4665 4713 if (changed) 4666 4714 exp_feature_changed(hdev, mgmt_mesh_uuid, val, sk); 4667 - 4668 - return err; 4669 - } 4670 - 4671 - static int set_rpa_resolution_func(struct sock *sk, struct hci_dev *hdev, 4672 - struct mgmt_cp_set_exp_feature *cp, 4673 - u16 data_len) 4674 - { 4675 - struct mgmt_rp_set_exp_feature rp; 4676 - bool val, changed; 4677 - int err; 4678 - u32 flags; 4679 - 4680 - /* Command requires to use the controller index */ 4681 - if (!hdev) 4682 - return mgmt_cmd_status(sk, MGMT_INDEX_NONE, 4683 - MGMT_OP_SET_EXP_FEATURE, 4684 - MGMT_STATUS_INVALID_INDEX); 4685 - 4686 - /* Changes can only be made when controller is powered down */ 4687 - if (hdev_is_powered(hdev)) 4688 - return mgmt_cmd_status(sk, hdev->id, 4689 - MGMT_OP_SET_EXP_FEATURE, 4690 - MGMT_STATUS_REJECTED); 4691 - 4692 - /* Parameters are limited to a single octet */ 4693 - if (data_len != MGMT_SET_EXP_FEATURE_SIZE + 1) 4694 - return mgmt_cmd_status(sk, hdev->id, 4695 - MGMT_OP_SET_EXP_FEATURE, 4696 - MGMT_STATUS_INVALID_PARAMS); 4697 - 4698 - /* Only boolean on/off is supported */ 4699 - if (cp->param[0] != 0x00 && cp->param[0] != 0x01) 4700 - return mgmt_cmd_status(sk, hdev->id, 4701 - MGMT_OP_SET_EXP_FEATURE, 4702 - MGMT_STATUS_INVALID_PARAMS); 4703 - 4704 - val = !!cp->param[0]; 4705 - 4706 - if (val) { 4707 - changed = !hci_dev_test_and_set_flag(hdev, 4708 - HCI_ENABLE_LL_PRIVACY); 4709 - hci_dev_clear_flag(hdev, HCI_ADVERTISING); 4710 - 4711 - /* Enable LL privacy + supported settings changed */ 4712 - flags = BIT(0) | BIT(1); 4713 - } else { 4714 - changed = hci_dev_test_and_clear_flag(hdev, 4715 - HCI_ENABLE_LL_PRIVACY); 4716 - 4717 - /* Disable LL privacy + supported settings changed */ 4718 - flags = BIT(1); 4719 - } 4720 - 4721 - memcpy(rp.uuid, rpa_resolution_uuid, 16); 4722 - rp.flags = cpu_to_le32(flags); 4723 - 4724 - hci_sock_set_flag(sk, HCI_MGMT_EXP_FEATURE_EVENTS); 4725 - 4726 - err = mgmt_cmd_complete(sk, hdev->id, 4727 - MGMT_OP_SET_EXP_FEATURE, 0, 4728 - &rp, sizeof(rp)); 4729 - 4730 - if (changed) 4731 - exp_ll_privacy_feature_changed(val, hdev, sk); 4732 4715 4733 4716 return err; 4734 4717 } ··· 4919 5032 EXP_FEAT(debug_uuid, set_debug_func), 4920 5033 #endif 4921 5034 EXP_FEAT(mgmt_mesh_uuid, set_mgmt_mesh_func), 4922 - EXP_FEAT(rpa_resolution_uuid, set_rpa_resolution_func), 4923 5035 EXP_FEAT(quality_report_uuid, set_quality_report_func), 4924 5036 EXP_FEAT(offload_codecs_uuid, set_offload_codec_func), 4925 5037 EXP_FEAT(le_simultaneous_roles_uuid, set_le_simultaneous_roles_func), ··· 4946 5060 return mgmt_cmd_status(sk, hdev ? hdev->id : MGMT_INDEX_NONE, 4947 5061 MGMT_OP_SET_EXP_FEATURE, 4948 5062 MGMT_STATUS_NOT_SUPPORTED); 4949 - } 4950 - 4951 - static u32 get_params_flags(struct hci_dev *hdev, 4952 - struct hci_conn_params *params) 4953 - { 4954 - u32 flags = hdev->conn_flags; 4955 - 4956 - /* Devices using RPAs can only be programmed in the acceptlist if 4957 - * LL Privacy has been enable otherwise they cannot mark 4958 - * HCI_CONN_FLAG_REMOTE_WAKEUP. 4959 - */ 4960 - if ((flags & HCI_CONN_FLAG_REMOTE_WAKEUP) && !use_ll_privacy(hdev) && 4961 - hci_find_irk_by_addr(hdev, &params->addr, params->addr_type)) 4962 - flags &= ~HCI_CONN_FLAG_REMOTE_WAKEUP; 4963 - 4964 - return flags; 4965 5063 } 4966 5064 4967 5065 static int get_device_flags(struct sock *sk, struct hci_dev *hdev, void *data, ··· 4982 5112 if (!params) 4983 5113 goto done; 4984 5114 4985 - supported_flags = get_params_flags(hdev, params); 4986 5115 current_flags = params->flags; 4987 5116 } 4988 5117 ··· 5061 5192 goto unlock; 5062 5193 } 5063 5194 5064 - supported_flags = get_params_flags(hdev, params); 5195 + supported_flags = hdev->conn_flags; 5065 5196 5066 5197 if ((supported_flags | current_flags) != supported_flags) { 5067 5198 bt_dev_warn(hdev, "Bad flag given (0x%x) vs supported (0x%0x)", ··· 5388 5519 { 5389 5520 struct mgmt_rp_remove_adv_monitor rp; 5390 5521 struct mgmt_pending_cmd *cmd = data; 5391 - struct mgmt_cp_remove_adv_monitor *cp = cmd->param; 5522 + struct mgmt_cp_remove_adv_monitor *cp; 5523 + 5524 + if (status == -ECANCELED || 5525 + cmd != pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev)) 5526 + return; 5392 5527 5393 5528 hci_dev_lock(hdev); 5529 + 5530 + cp = cmd->param; 5394 5531 5395 5532 rp.monitor_handle = cp->monitor_handle; 5396 5533 ··· 5415 5540 static int mgmt_remove_adv_monitor_sync(struct hci_dev *hdev, void *data) 5416 5541 { 5417 5542 struct mgmt_pending_cmd *cmd = data; 5543 + 5544 + if (cmd != pending_find(MGMT_OP_REMOVE_ADV_MONITOR, hdev)) 5545 + return -ECANCELED; 5546 + 5418 5547 struct mgmt_cp_remove_adv_monitor *cp = cmd->param; 5419 5548 u16 handle = __le16_to_cpu(cp->monitor_handle); 5420 5549