Re: [PATCH v2] Bluetooth: btusb: Fix and detect most of the Chinese Bluetooth controllers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Ismael,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on bluetooth-next/master]
[also build test WARNING on bluetooth/master v5.8-rc3 next-20200629]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use  as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Ismael-Ferreras-Morezuelas/Bluetooth-btusb-Fix-and-detect-most-of-the-Chinese-Bluetooth-controllers/20200624-083108
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: parisc-randconfig-s032-20200629 (attached as .config)
compiler: hppa-linux-gcc (GCC) 9.3.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.2-3-gfa153962-dirty
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross C= CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' ARCH=parisc 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@xxxxxxxxx>


sparse warnings: (new ones prefixed by >>)

>> drivers/bluetooth/btusb.c:1788:37: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1789:37: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:1790:49: sparse: sparse: restricted __le16 degrades to integer
   drivers/bluetooth/btusb.c:2306:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2306:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2306:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2306:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2315:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2315:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2315:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2315:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2316:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2316:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2316:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2316:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2317:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2317:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2317:25: sparse: sparse: cast to restricted __le16
   drivers/bluetooth/btusb.c:2317:25: sparse: sparse: cast to restricted __le16

vim +1788 drivers/bluetooth/btusb.c

  1718	
  1719	static int btusb_setup_csr(struct hci_dev *hdev)
  1720	{
  1721		struct btusb_data *data = hci_get_drvdata(hdev);
  1722		struct usb_device *udev = data->udev;
  1723		struct hci_rp_read_local_version *rp;
  1724		struct sk_buff *skb;
  1725	
  1726		BT_DBG("%s", hdev->name);
  1727	
  1728		skb = __hci_cmd_sync(hdev, HCI_OP_READ_LOCAL_VERSION, 0, NULL,
  1729				     HCI_INIT_TIMEOUT);
  1730		if (IS_ERR(skb)) {
  1731			int err = PTR_ERR(skb);
  1732			bt_dev_err(hdev, "CSR: Local version failed (%d)", err);
  1733			return err;
  1734		}
  1735	
  1736		if (skb->len != sizeof(struct hci_rp_read_local_version)) {
  1737			bt_dev_err(hdev, "CSR: Local version length mismatch");
  1738			kfree_skb(skb);
  1739			return -EIO;
  1740		}
  1741	
  1742		rp = (struct hci_rp_read_local_version *)skb->data;
  1743	
  1744		/* Of interest to fine-tune the logic in the future */
  1745		bt_dev_info(hdev, "CSR: New controller detected; bcdDevice=%#x, HCI manufacturer=%u, HCI rev=%#x, LMP subver=%#x",
  1746			    le16_to_cpu(udev->descriptor.bcdDevice),
  1747			    le16_to_cpu(rp->manufacturer),
  1748			    le16_to_cpu(rp->hci_rev),
  1749			    le16_to_cpu(rp->lmp_subver));
  1750	
  1751		/* Detect a wide host of Chinese controllers that rely on heavy VID/PID
  1752		 * squatting of this poor old Bluetooth 1.1 device. As if that wasn't
  1753		 * enough there are actually three classes of controllers reusing
  1754		 * the same 0A12:0001 VID/PID:
  1755		 *
  1756		 * * Old CSR Bluetooth 1.1 devices (BlueCore?):
  1757		 *   HCI_QUIRK_SIMULTANEOUS_DISCOVERY
  1758		 *   HCI_QUIRK_RESET_ON_CLOSE
  1759		 *
  1760		 * * New CSR Bluetooth devices based on CSR8510 (BlueSoleil?):
  1761		 *   HCI_QUIRK_BROKEN_STORED_LINK_KEY
  1762		 *
  1763		 * * Unbranded CSR clone:
  1764		 *   Their HCI chip uses a different manufacturer number;
  1765		 *   sourced from various vendors. Most common ones are:
  1766		 *     - Broadcom Corporation (15)
  1767		 *     - Mitel Semiconductor (16)
  1768		 *
  1769		 *   No quirks, varies depending on the real manufacturer.
  1770		 *
  1771		 * We detect actual CSR devices by checking that the HDI manufacturer code
  1772		 * is Cambridge Silicon Radio (10) and ensuring that LMP sub-version and
  1773		 * the HID values will always match. The full list of newer bcdDevices
  1774		 * is documented in the official driver .inf files.
  1775		 *
  1776		 * Because diagnosing all this has been very tricky in the past, with the
  1777		 * original bug being reported in 2013, and left unsolved until 2020, let's
  1778		 * report the chip type to potentially have a better coverage and reports.
  1779		 */
  1780		if (le16_to_cpu(rp->manufacturer) == 10 &&
  1781		    le16_to_cpu(rp->hci_rev) == le16_to_cpu(rp->lmp_subver)) {
  1782			/* Only apply the reset quirk on actual, early Bluetooth 1.1 devices
  1783			 * from CSR. Old firmware would otherwise execute USB reset
  1784			 */
  1785			if (le16_to_cpu(udev->descriptor.bcdDevice) < 0x117)
  1786				set_bit(HCI_QUIRK_RESET_ON_CLOSE, &hdev->quirks);
  1787	
> 1788			if (udev->descriptor.idVendor  == 0x0a12 &&
  1789			    udev->descriptor.idProduct == 0x0001) {
  1790				switch (udev->descriptor.bcdDevice) {
  1791				case 0x0100:
  1792				case 0x0134:
  1793				case 0x1915:
  1794				case 0x1958:
  1795				case 0x2520:
  1796				case 0x3164:
  1797				case 0x4839:
  1798				case 0x5276:
  1799				case 0x7558:
  1800				case 0x8891:
  1801					/* These newer CSR controllers have all a broken
  1802					 * stored link key handling, so just disable it.
  1803					 */
  1804					set_bit(HCI_QUIRK_BROKEN_STORED_LINK_KEY, &hdev->quirks);
  1805					bt_dev_info(hdev, "CSR: Modern CSR controller type detected");
  1806					break;
  1807				default:
  1808					/* Only apply this quirk to actual, old CSR devices */
  1809					set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &hdev->quirks);
  1810					bt_dev_info(hdev, "CSR: Old CSR controller type detected");
  1811				}
  1812			}
  1813		} else {
  1814			bt_dev_info(hdev, "CSR: Unbranded CSR clone detected; adding workaround");
  1815		}
  1816	
  1817		kfree_skb(skb);
  1818	
  1819		return 0;
  1820	}
  1821	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@xxxxxxxxxxxx

Attachment: .config.gz
Description: application/gzip


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux