diff mbox series

Bluetooth: hci_h5: btrtl: Add quirk for keep power during suspend/resume for specific devices

Message ID 20210315085840.4424-1-hildawu@realtek.com
State New
Headers show
Series Bluetooth: hci_h5: btrtl: Add quirk for keep power during suspend/resume for specific devices | expand

Commit Message

Hilda Wu March 15, 2021, 8:58 a.m. UTC
From: hildawu <hildawu@realtek.com>

RTL8822C devices support BT wakeup Host. Add a quirk for these specific
devices did not power off during suspend and resume.
By this change, if the Host support that received BT device signal then
it can be wakeup.

Signed-off-by: hildawu <hildawu@realtek.com>
---
 drivers/bluetooth/btrtl.c   | 36 ------------------------------------
 drivers/bluetooth/btrtl.h   | 35 +++++++++++++++++++++++++++++++++++
 drivers/bluetooth/hci_h5.c  | 35 ++++++++++++++++++++++++-----------
 include/net/bluetooth/hci.h |  9 +++++++++
 4 files changed, 68 insertions(+), 47 deletions(-)

Comments

kernel test robot March 15, 2021, 9:46 p.m. UTC | #1
Hi,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on bluetooth-next/master]
[also build test ERROR on net-next/master net/master v5.12-rc3 next-20210315]
[cannot apply to sparc-next/master]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/hildawu-realtek-com/Bluetooth-hci_h5-btrtl-Add-quirk-for-keep-power-during-suspend-resume-for-specific-devices/20210315-170101
base:   https://git.kernel.org/pub/scm/linux/kernel/git/bluetooth/bluetooth-next.git master
config: powerpc64-randconfig-r016-20210315 (attached as .config)
compiler: clang version 13.0.0 (https://github.com/llvm/llvm-project a28facba1ccdc957f386b7753f4958307f1bfde8)
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # install powerpc64 cross compiling tool for clang build
        # apt-get install binutils-powerpc64-linux-gnu
        # https://github.com/0day-ci/linux/commit/c97383d88c50364f4451a74ac4d3ad7b3605c20b
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review hildawu-realtek-com/Bluetooth-hci_h5-btrtl-Add-quirk-for-keep-power-during-suspend-resume-for-specific-devices/20210315-170101
        git checkout c97383d88c50364f4451a74ac4d3ad7b3605c20b
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=powerpc64 

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

All errors (new ones prefixed by >>):

   In file included from drivers/bluetooth/btrtl.c:11:
   In file included from include/linux/usb.h:16:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:45:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(insw, (unsigned long p, void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:33:1: note: expanded from here
   __do_insw
   ^
   arch/powerpc/include/asm/io.h:557:56: note: expanded from macro '__do_insw'
   #define __do_insw(p, b, n)      readsw((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
                                          ~~~~~~~~~~~~~~~~~~~~~^
   In file included from drivers/bluetooth/btrtl.c:11:
   In file included from include/linux/usb.h:16:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:47:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(insl, (unsigned long p, void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:35:1: note: expanded from here
   __do_insl
   ^
   arch/powerpc/include/asm/io.h:558:56: note: expanded from macro '__do_insl'
   #define __do_insl(p, b, n)      readsl((PCI_IO_ADDR)_IO_BASE+(p), (b), (n))
                                          ~~~~~~~~~~~~~~~~~~~~~^
   In file included from drivers/bluetooth/btrtl.c:11:
   In file included from include/linux/usb.h:16:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:49:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsb, (unsigned long p, const void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:37:1: note: expanded from here
   __do_outsb
   ^
   arch/powerpc/include/asm/io.h:559:58: note: expanded from macro '__do_outsb'
   #define __do_outsb(p, b, n)     writesb((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
                                           ~~~~~~~~~~~~~~~~~~~~~^
   In file included from drivers/bluetooth/btrtl.c:11:
   In file included from include/linux/usb.h:16:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:51:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsw, (unsigned long p, const void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:39:1: note: expanded from here
   __do_outsw
   ^
   arch/powerpc/include/asm/io.h:560:58: note: expanded from macro '__do_outsw'
   #define __do_outsw(p, b, n)     writesw((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
                                           ~~~~~~~~~~~~~~~~~~~~~^
   In file included from drivers/bluetooth/btrtl.c:11:
   In file included from include/linux/usb.h:16:
   In file included from include/linux/interrupt.h:11:
   In file included from include/linux/hardirq.h:10:
   In file included from arch/powerpc/include/asm/hardirq.h:6:
   In file included from include/linux/irq.h:20:
   In file included from include/linux/io.h:13:
   In file included from arch/powerpc/include/asm/io.h:619:
   arch/powerpc/include/asm/io-defs.h:53:1: warning: performing pointer arithmetic on a null pointer has undefined behavior [-Wnull-pointer-arithmetic]
   DEF_PCI_AC_NORET(outsl, (unsigned long p, const void *b, unsigned long c),
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
   arch/powerpc/include/asm/io.h:616:3: note: expanded from macro 'DEF_PCI_AC_NORET'
                   __do_##name al;                                 \
                   ^~~~~~~~~~~~~~
   <scratch space>:41:1: note: expanded from here
   __do_outsl
   ^
   arch/powerpc/include/asm/io.h:561:58: note: expanded from macro '__do_outsl'
   #define __do_outsl(p, b, n)     writesl((PCI_IO_ADDR)_IO_BASE+(p),(b),(n))
                                           ~~~~~~~~~~~~~~~~~~~~~^
>> drivers/bluetooth/btrtl.c:556:14: error: no member named 'drop_fw' in 'struct btrtl_device_info'
                   btrtl_dev->drop_fw = true;
                   ~~~~~~~~~  ^
   drivers/bluetooth/btrtl.c:558:17: error: no member named 'drop_fw' in 'struct btrtl_device_info'
           if (btrtl_dev->drop_fw) {
               ~~~~~~~~~  ^
   12 warnings and 2 errors generated.


vim +556 drivers/bluetooth/btrtl.c

26503ad25de8c7 Martin Blumenstingl 2018-08-02  519  
1cc194caaffbe0 Hans de Goede       2018-08-02  520  struct btrtl_device_info *btrtl_initialize(struct hci_dev *hdev,
1cc194caaffbe0 Hans de Goede       2018-08-02  521  					   const char *postfix)
db33c77dddc2ed Carlo Caione        2015-05-14  522  {
26503ad25de8c7 Martin Blumenstingl 2018-08-02  523  	struct btrtl_device_info *btrtl_dev;
db33c77dddc2ed Carlo Caione        2015-05-14  524  	struct sk_buff *skb;
db33c77dddc2ed Carlo Caione        2015-05-14  525  	struct hci_rp_read_local_version *resp;
1cc194caaffbe0 Hans de Goede       2018-08-02  526  	char cfg_name[40];
907f84990924bf Alex Lu             2018-02-11  527  	u16 hci_rev, lmp_subver;
c50903e3ee1b55 Martin Blumenstingl 2018-08-02  528  	u8 hci_ver;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  529  	int ret;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  530  	u16 opcode;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  531  	u8 cmd[2];
26503ad25de8c7 Martin Blumenstingl 2018-08-02  532  
26503ad25de8c7 Martin Blumenstingl 2018-08-02  533  	btrtl_dev = kzalloc(sizeof(*btrtl_dev), GFP_KERNEL);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  534  	if (!btrtl_dev) {
26503ad25de8c7 Martin Blumenstingl 2018-08-02  535  		ret = -ENOMEM;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  536  		goto err_alloc;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  537  	}
db33c77dddc2ed Carlo Caione        2015-05-14  538  
db33c77dddc2ed Carlo Caione        2015-05-14  539  	skb = btrtl_read_local_version(hdev);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  540  	if (IS_ERR(skb)) {
26503ad25de8c7 Martin Blumenstingl 2018-08-02  541  		ret = PTR_ERR(skb);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  542  		goto err_free;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  543  	}
db33c77dddc2ed Carlo Caione        2015-05-14  544  
db33c77dddc2ed Carlo Caione        2015-05-14  545  	resp = (struct hci_rp_read_local_version *)skb->data;
f1300c0340872d Alex Lu             2019-08-31  546  	rtl_dev_info(hdev, "examining hci_ver=%02x hci_rev=%04x lmp_ver=%02x lmp_subver=%04x",
2064ee332e4c1b Marcel Holtmann     2017-10-30  547  		     resp->hci_ver, resp->hci_rev,
db33c77dddc2ed Carlo Caione        2015-05-14  548  		     resp->lmp_ver, resp->lmp_subver);
db33c77dddc2ed Carlo Caione        2015-05-14  549  
c50903e3ee1b55 Martin Blumenstingl 2018-08-02  550  	hci_ver = resp->hci_ver;
907f84990924bf Alex Lu             2018-02-11  551  	hci_rev = le16_to_cpu(resp->hci_rev);
db33c77dddc2ed Carlo Caione        2015-05-14  552  	lmp_subver = le16_to_cpu(resp->lmp_subver);
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  553  
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  554  	if (resp->hci_ver == 0x8 && le16_to_cpu(resp->hci_rev) == 0x826c &&
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  555  	    resp->lmp_ver == 0x8 && le16_to_cpu(resp->lmp_subver) == 0xa99e)
1996d9cad6ad48 Kai-Heng Feng       2020-10-26 @556  		btrtl_dev->drop_fw = true;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  557  
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  558  	if (btrtl_dev->drop_fw) {
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  559  		opcode = hci_opcode_pack(0x3f, 0x66);
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  560  		cmd[0] = opcode & 0xff;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  561  		cmd[1] = opcode >> 8;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  562  
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  563  		skb = bt_skb_alloc(sizeof(cmd), GFP_KERNEL);
f5e8e215869eed Colin Ian King      2020-11-10  564  		if (!skb)
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  565  			goto out_free;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  566  
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  567  		skb_put_data(skb, cmd, sizeof(cmd));
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  568  		hci_skb_pkt_type(skb) = HCI_COMMAND_PKT;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  569  
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  570  		hdev->send(hdev, skb);
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  571  
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  572  		/* Ensure the above vendor command is sent to controller and
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  573  		 * process has done.
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  574  		 */
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  575  		msleep(200);
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  576  
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  577  		/* Read the local version again. Expect to have the vanilla
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  578  		 * version as cold boot.
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  579  		 */
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  580  		skb = btrtl_read_local_version(hdev);
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  581  		if (IS_ERR(skb)) {
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  582  			ret = PTR_ERR(skb);
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  583  			goto err_free;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  584  		}
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  585  
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  586  		resp = (struct hci_rp_read_local_version *)skb->data;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  587  		rtl_dev_info(hdev, "examining hci_ver=%02x hci_rev=%04x lmp_ver=%02x lmp_subver=%04x",
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  588  			     resp->hci_ver, resp->hci_rev,
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  589  			     resp->lmp_ver, resp->lmp_subver);
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  590  
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  591  		hci_ver = resp->hci_ver;
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  592  		hci_rev = le16_to_cpu(resp->hci_rev);
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  593  		lmp_subver = le16_to_cpu(resp->lmp_subver);
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  594  	}
1996d9cad6ad48 Kai-Heng Feng       2020-10-26  595  out_free:
db33c77dddc2ed Carlo Caione        2015-05-14  596  	kfree_skb(skb);
db33c77dddc2ed Carlo Caione        2015-05-14  597  
c50903e3ee1b55 Martin Blumenstingl 2018-08-02  598  	btrtl_dev->ic_info = btrtl_match_ic(lmp_subver, hci_rev, hci_ver,
c50903e3ee1b55 Martin Blumenstingl 2018-08-02  599  					    hdev->bus);
c50903e3ee1b55 Martin Blumenstingl 2018-08-02  600  
26503ad25de8c7 Martin Blumenstingl 2018-08-02  601  	if (!btrtl_dev->ic_info) {
d182215d2fb9e5 Alex Lu             2019-08-31  602  		rtl_dev_info(hdev, "unknown IC info, lmp subver %04x, hci rev %04x, hci ver %04x",
c50903e3ee1b55 Martin Blumenstingl 2018-08-02  603  			    lmp_subver, hci_rev, hci_ver);
00df214b1faae5 Kai-Heng Feng       2019-01-27  604  		return btrtl_dev;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  605  	}
26503ad25de8c7 Martin Blumenstingl 2018-08-02  606  
26503ad25de8c7 Martin Blumenstingl 2018-08-02  607  	if (btrtl_dev->ic_info->has_rom_version) {
26503ad25de8c7 Martin Blumenstingl 2018-08-02  608  		ret = rtl_read_rom_version(hdev, &btrtl_dev->rom_version);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  609  		if (ret)
26503ad25de8c7 Martin Blumenstingl 2018-08-02  610  			goto err_free;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  611  	}
26503ad25de8c7 Martin Blumenstingl 2018-08-02  612  
26503ad25de8c7 Martin Blumenstingl 2018-08-02  613  	btrtl_dev->fw_len = rtl_load_file(hdev, btrtl_dev->ic_info->fw_name,
26503ad25de8c7 Martin Blumenstingl 2018-08-02  614  					  &btrtl_dev->fw_data);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  615  	if (btrtl_dev->fw_len < 0) {
f1300c0340872d Alex Lu             2019-08-31  616  		rtl_dev_err(hdev, "firmware file %s not found",
26503ad25de8c7 Martin Blumenstingl 2018-08-02  617  			    btrtl_dev->ic_info->fw_name);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  618  		ret = btrtl_dev->fw_len;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  619  		goto err_free;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  620  	}
26503ad25de8c7 Martin Blumenstingl 2018-08-02  621  
26503ad25de8c7 Martin Blumenstingl 2018-08-02  622  	if (btrtl_dev->ic_info->cfg_name) {
1cc194caaffbe0 Hans de Goede       2018-08-02  623  		if (postfix) {
1cc194caaffbe0 Hans de Goede       2018-08-02  624  			snprintf(cfg_name, sizeof(cfg_name), "%s-%s.bin",
1cc194caaffbe0 Hans de Goede       2018-08-02  625  				 btrtl_dev->ic_info->cfg_name, postfix);
1cc194caaffbe0 Hans de Goede       2018-08-02  626  		} else {
1cc194caaffbe0 Hans de Goede       2018-08-02  627  			snprintf(cfg_name, sizeof(cfg_name), "%s.bin",
1cc194caaffbe0 Hans de Goede       2018-08-02  628  				 btrtl_dev->ic_info->cfg_name);
1cc194caaffbe0 Hans de Goede       2018-08-02  629  		}
1cc194caaffbe0 Hans de Goede       2018-08-02  630  		btrtl_dev->cfg_len = rtl_load_file(hdev, cfg_name,
26503ad25de8c7 Martin Blumenstingl 2018-08-02  631  						   &btrtl_dev->cfg_data);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  632  		if (btrtl_dev->ic_info->config_needed &&
26503ad25de8c7 Martin Blumenstingl 2018-08-02  633  		    btrtl_dev->cfg_len <= 0) {
f1300c0340872d Alex Lu             2019-08-31  634  			rtl_dev_err(hdev, "mandatory config file %s not found",
26503ad25de8c7 Martin Blumenstingl 2018-08-02  635  				    btrtl_dev->ic_info->cfg_name);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  636  			ret = btrtl_dev->cfg_len;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  637  			goto err_free;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  638  		}
26503ad25de8c7 Martin Blumenstingl 2018-08-02  639  	}
26503ad25de8c7 Martin Blumenstingl 2018-08-02  640  
673fae14f24052 Miao-chen Chou      2020-12-17  641  	/* RTL8822CE supports the Microsoft vendor extension and uses 0xFCF0
673fae14f24052 Miao-chen Chou      2020-12-17  642  	 * for VsMsftOpCode.
673fae14f24052 Miao-chen Chou      2020-12-17  643  	 */
673fae14f24052 Miao-chen Chou      2020-12-17  644  	if (lmp_subver == RTL_ROM_LMP_8822B)
673fae14f24052 Miao-chen Chou      2020-12-17  645  		hci_set_msft_opcode(hdev, 0xFCF0);
673fae14f24052 Miao-chen Chou      2020-12-17  646  
26503ad25de8c7 Martin Blumenstingl 2018-08-02  647  	return btrtl_dev;
26503ad25de8c7 Martin Blumenstingl 2018-08-02  648  
26503ad25de8c7 Martin Blumenstingl 2018-08-02  649  err_free:
26503ad25de8c7 Martin Blumenstingl 2018-08-02  650  	btrtl_free(btrtl_dev);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  651  err_alloc:
26503ad25de8c7 Martin Blumenstingl 2018-08-02  652  	return ERR_PTR(ret);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  653  }
26503ad25de8c7 Martin Blumenstingl 2018-08-02  654  EXPORT_SYMBOL_GPL(btrtl_initialize);
26503ad25de8c7 Martin Blumenstingl 2018-08-02  655  

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

Patch

diff --git a/drivers/bluetooth/btrtl.c b/drivers/bluetooth/btrtl.c
index e7fe5fb22753..94d1e7885aee 100644
--- a/drivers/bluetooth/btrtl.c
+++ b/drivers/bluetooth/btrtl.c
@@ -38,42 +38,6 @@ 
 	.hci_ver = (hciv), \
 	.hci_bus = (bus)
 
-enum btrtl_chip_id {
-	CHIP_ID_8723A,
-	CHIP_ID_8723B,
-	CHIP_ID_8821A,
-	CHIP_ID_8761A,
-	CHIP_ID_8822B = 8,
-	CHIP_ID_8723D,
-	CHIP_ID_8821C,
-	CHIP_ID_8822C = 13,
-	CHIP_ID_8761B,
-	CHIP_ID_8852A = 18,
-};
-
-struct id_table {
-	__u16 match_flags;
-	__u16 lmp_subver;
-	__u16 hci_rev;
-	__u8 hci_ver;
-	__u8 hci_bus;
-	bool config_needed;
-	bool has_rom_version;
-	char *fw_name;
-	char *cfg_name;
-};
-
-struct btrtl_device_info {
-	const struct id_table *ic_info;
-	u8 rom_version;
-	u8 *fw_data;
-	int fw_len;
-	u8 *cfg_data;
-	int cfg_len;
-	bool drop_fw;
-	int project_id;
-};
-
 static const struct id_table ic_id_table[] = {
 	/* 8723A */
 	{ IC_INFO(RTL_ROM_LMP_8723A, 0xb, 0x6, HCI_USB),
diff --git a/drivers/bluetooth/btrtl.h b/drivers/bluetooth/btrtl.h
index 2a582682136d..0fa38c116762 100644
--- a/drivers/bluetooth/btrtl.h
+++ b/drivers/bluetooth/btrtl.h
@@ -12,6 +12,41 @@ 
 #define rtl_dev_info(dev, fmt, ...) bt_dev_info(dev, "RTL: " fmt, ##__VA_ARGS__)
 #define rtl_dev_dbg(dev, fmt, ...) bt_dev_dbg(dev, "RTL: " fmt, ##__VA_ARGS__)
 
+enum btrtl_chip_id {
+	CHIP_ID_8723A,
+	CHIP_ID_8723B,
+	CHIP_ID_8821A,
+	CHIP_ID_8761A,
+	CHIP_ID_8822B = 8,
+	CHIP_ID_8723D,
+	CHIP_ID_8821C,
+	CHIP_ID_8822C = 13,
+	CHIP_ID_8761B,
+	CHIP_ID_8852A = 18,
+};
+
+struct id_table {
+	__u16 match_flags;
+	__u16 lmp_subver;
+	__u16 hci_rev;
+	__u8 hci_ver;
+	__u8 hci_bus;
+	bool config_needed;
+	bool has_rom_version;
+	char *fw_name;
+	char *cfg_name;
+};
+
+struct btrtl_device_info {
+	const struct id_table *ic_info;
+	u8 rom_version;
+	u8 *fw_data;
+	int fw_len;
+	u8 *cfg_data;
+	int cfg_len;
+	int project_id;
+};
+
 struct btrtl_device_info;
 
 struct rtl_download_cmd {
diff --git a/drivers/bluetooth/hci_h5.c b/drivers/bluetooth/hci_h5.c
index 27e96681d583..1ca4ff89ea14 100644
--- a/drivers/bluetooth/hci_h5.c
+++ b/drivers/bluetooth/hci_h5.c
@@ -909,7 +909,15 @@  static int h5_btrtl_setup(struct h5 *h5)
 	/* Enable controller to do both LE scan and BR/EDR inquiry
 	 * simultaneously.
 	 */
-	set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
+	switch (btrtl_dev->project_id) {
+	case CHIP_ID_8822C:
+	case CHIP_ID_8852A:
+		set_bit(HCI_QUIRK_SIMULTANEOUS_DISCOVERY, &h5->hu->hdev->quirks);
+		set_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks);
+		break;
+	default:
+		break;
+	}
 
 out_free:
 	btrtl_free(btrtl_dev);
@@ -945,8 +953,11 @@  static void h5_btrtl_close(struct h5 *h5)
 static int h5_btrtl_suspend(struct h5 *h5)
 {
 	serdev_device_set_flow_control(h5->hu->serdev, false);
-	gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
-	gpiod_set_value_cansleep(h5->enable_gpio, 0);
+
+	if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
+		gpiod_set_value_cansleep(h5->device_wake_gpio, 0);
+		gpiod_set_value_cansleep(h5->enable_gpio, 0);
+	}
 	return 0;
 }
 
@@ -972,17 +983,19 @@  static void h5_btrtl_reprobe_worker(struct work_struct *work)
 
 static int h5_btrtl_resume(struct h5 *h5)
 {
-	struct h5_btrtl_reprobe *reprobe;
+	if (!test_bit(HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED, &h5->hu->hdev->quirks)) {
+		struct h5_btrtl_reprobe *reprobe;
 
-	reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
-	if (!reprobe)
-		return -ENOMEM;
+		reprobe = kzalloc(sizeof(*reprobe), GFP_KERNEL);
+		if (!reprobe)
+			return -ENOMEM;
 
-	__module_get(THIS_MODULE);
+		__module_get(THIS_MODULE);
 
-	INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
-	reprobe->dev = get_device(&h5->hu->serdev->dev);
-	queue_work(system_long_wq, &reprobe->work);
+		INIT_WORK(&reprobe->work, h5_btrtl_reprobe_worker);
+		reprobe->dev = get_device(&h5->hu->serdev->dev);
+		queue_work(system_long_wq, &reprobe->work);
+	}
 	return 0;
 }
 
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index ba2f439bc04d..2e88381b4a58 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -246,6 +246,15 @@  enum {
 	 * HCI after resume.
 	 */
 	HCI_QUIRK_NO_SUSPEND_NOTIFIER,
+
+	/* When this quirk is set, the controller does not power off
+	 * during suspend and resume. This mechanism lets BT devices wake
+	 * the Host up if the Host and chips support.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_DEVICES_WAKEUP_SUPPORTED,
 };
 
 /* HCI device flags */