linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897
@ 2021-09-17 12:27 Jonas Dreßler
  2021-09-17 12:30 ` Pali Rohár
                   ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jonas Dreßler @ 2021-09-17 12:27 UTC (permalink / raw)
  To: Amitkumar Karwar, Ganapathi Bhat, Xinming Hu, Kalle Valo,
	David S. Miller, Jakub Kicinski, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz
  Cc: Jonas Dreßler, Tsuchiya Yuto, linux-wireless,
	linux-bluetooth, linux-kernel, Maximilian Luz, Andy Shevchenko,
	Pali Rohár

The Marvell 88W8897 combined wifi and bluetooth card (pcie+usb version)
is used in a lot of Microsoft Surface devices, and all those devices
suffer from very low 2.4GHz wifi connection speeds while bluetooth is
enabled. The reason for that is that the default passive scanning
interval for Bluetooth Low Energy devices is quite high on Linux
(interval of 60 msec and scan window of 30 msec, see le_scan_interval
and le_scan_window in hci_core.c), and the Marvell chip is known for its
bad bt+wifi coexisting performance.

So decrease that passive scan interval and make the scan window shorter
on this particular device to allow for spending more time transmitting
wifi signals: The new scan interval is 250 msec (0x190 * 0.625 msec) and
the new scan window is 6.25 msec (0xa * 0.625 msec).

This change has a very large impact on the 2.4GHz wifi speeds and gets
it up to performance comparable with the Windows driver, which seems to
apply a similar quirk.

The scan interval and scan window length were tested and found to work
very well with a bunch of Bluetooth Low Energy devices, including the
Surface Pen, a Bluetooth Speaker and two modern Bluetooth headphones.
All devices were discovered immediately after turning them on. Even
lower values were also tested, but these introduced longer delays until
devices get discovered.

Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
---
 drivers/bluetooth/btusb.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 60d2fce59a71..05b11179c839 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -59,6 +59,7 @@ static struct usb_driver btusb_driver;
 #define BTUSB_WIDEBAND_SPEECH	0x400000
 #define BTUSB_VALID_LE_STATES   0x800000
 #define BTUSB_QCA_WCN6855	0x1000000
+#define BTUSB_LOWER_LESCAN_INTERVAL	0x2000000
 #define BTUSB_INTEL_BROKEN_INITIAL_NCMD 0x4000000
 
 static const struct usb_device_id btusb_table[] = {
@@ -356,6 +357,7 @@ static const struct usb_device_id blacklist_table[] = {
 	{ USB_DEVICE(0x1286, 0x2044), .driver_info = BTUSB_MARVELL },
 	{ USB_DEVICE(0x1286, 0x2046), .driver_info = BTUSB_MARVELL },
 	{ USB_DEVICE(0x1286, 0x204e), .driver_info = BTUSB_MARVELL },
+	{ USB_DEVICE(0x1286, 0x204c), .driver_info = BTUSB_LOWER_LESCAN_INTERVAL },
 
 	/* Intel Bluetooth devices */
 	{ USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED },
@@ -3813,6 +3815,19 @@ static int btusb_probe(struct usb_interface *intf,
 	if (id->driver_info & BTUSB_MARVELL)
 		hdev->set_bdaddr = btusb_set_bdaddr_marvell;
 
+	/* The Marvell 88W8897 combined wifi and bluetooth card is known for
+	 * very bad bt+wifi coexisting performance.
+	 *
+	 * Decrease the passive BT Low Energy scan interval a bit
+	 * (0x0190 * 0.625 msec = 250 msec) and make the scan window shorter
+	 * (0x000a * 0,625 msec = 6.25 msec). This allows for significantly
+	 * higher wifi throughput while passively scanning for BT LE devices.
+	 */
+	if (id->driver_info & BTUSB_LOWER_LESCAN_INTERVAL) {
+		hdev->le_scan_interval = 0x0190;
+		hdev->le_scan_window = 0x000a;
+	}
+
 	if (IS_ENABLED(CONFIG_BT_HCIBTUSB_MTK) &&
 	    (id->driver_info & BTUSB_MEDIATEK)) {
 		hdev->setup = btusb_mtk_setup;
-- 
2.31.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897
  2021-09-17 12:27 [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897 Jonas Dreßler
@ 2021-09-17 12:30 ` Pali Rohár
  2021-09-17 12:36   ` Jonas Dreßler
  2021-09-17 12:35 ` Marcel Holtmann
  2021-09-17 13:18 ` bluez.test.bot
  2 siblings, 1 reply; 8+ messages in thread
From: Pali Rohár @ 2021-09-17 12:30 UTC (permalink / raw)
  To: Jonas Dreßler
  Cc: Amitkumar Karwar, Ganapathi Bhat, Xinming Hu, Kalle Valo,
	David S. Miller, Jakub Kicinski, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz, Tsuchiya Yuto, linux-wireless,
	linux-bluetooth, linux-kernel, Maximilian Luz, Andy Shevchenko

On Friday 17 September 2021 14:27:18 Jonas Dreßler wrote:
> The Marvell 88W8897 combined wifi and bluetooth card (pcie+usb version)
> is used in a lot of Microsoft Surface devices, and all those devices
> suffer from very low 2.4GHz wifi connection speeds while bluetooth is
> enabled.

Hello! Do you know if this issue is specific only to this one Marvell
88W8897 chip or if this issue affects also other Marvell wifi+bt combo
chips?

> The reason for that is that the default passive scanning
> interval for Bluetooth Low Energy devices is quite high on Linux
> (interval of 60 msec and scan window of 30 msec, see le_scan_interval
> and le_scan_window in hci_core.c), and the Marvell chip is known for its
> bad bt+wifi coexisting performance.
> 
> So decrease that passive scan interval and make the scan window shorter
> on this particular device to allow for spending more time transmitting
> wifi signals: The new scan interval is 250 msec (0x190 * 0.625 msec) and
> the new scan window is 6.25 msec (0xa * 0.625 msec).
> 
> This change has a very large impact on the 2.4GHz wifi speeds and gets
> it up to performance comparable with the Windows driver, which seems to
> apply a similar quirk.
> 
> The scan interval and scan window length were tested and found to work
> very well with a bunch of Bluetooth Low Energy devices, including the
> Surface Pen, a Bluetooth Speaker and two modern Bluetooth headphones.
> All devices were discovered immediately after turning them on. Even
> lower values were also tested, but these introduced longer delays until
> devices get discovered.
> 
> Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
> ---
>  drivers/bluetooth/btusb.c | 15 +++++++++++++++
>  1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 60d2fce59a71..05b11179c839 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver;
>  #define BTUSB_WIDEBAND_SPEECH	0x400000
>  #define BTUSB_VALID_LE_STATES   0x800000
>  #define BTUSB_QCA_WCN6855	0x1000000
> +#define BTUSB_LOWER_LESCAN_INTERVAL	0x2000000
>  #define BTUSB_INTEL_BROKEN_INITIAL_NCMD 0x4000000
>  
>  static const struct usb_device_id btusb_table[] = {
> @@ -356,6 +357,7 @@ static const struct usb_device_id blacklist_table[] = {
>  	{ USB_DEVICE(0x1286, 0x2044), .driver_info = BTUSB_MARVELL },
>  	{ USB_DEVICE(0x1286, 0x2046), .driver_info = BTUSB_MARVELL },
>  	{ USB_DEVICE(0x1286, 0x204e), .driver_info = BTUSB_MARVELL },
> +	{ USB_DEVICE(0x1286, 0x204c), .driver_info = BTUSB_LOWER_LESCAN_INTERVAL },
>  
>  	/* Intel Bluetooth devices */
>  	{ USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED },
> @@ -3813,6 +3815,19 @@ static int btusb_probe(struct usb_interface *intf,
>  	if (id->driver_info & BTUSB_MARVELL)
>  		hdev->set_bdaddr = btusb_set_bdaddr_marvell;
>  
> +	/* The Marvell 88W8897 combined wifi and bluetooth card is known for
> +	 * very bad bt+wifi coexisting performance.
> +	 *
> +	 * Decrease the passive BT Low Energy scan interval a bit
> +	 * (0x0190 * 0.625 msec = 250 msec) and make the scan window shorter
> +	 * (0x000a * 0,625 msec = 6.25 msec). This allows for significantly
> +	 * higher wifi throughput while passively scanning for BT LE devices.
> +	 */
> +	if (id->driver_info & BTUSB_LOWER_LESCAN_INTERVAL) {
> +		hdev->le_scan_interval = 0x0190;
> +		hdev->le_scan_window = 0x000a;
> +	}
> +
>  	if (IS_ENABLED(CONFIG_BT_HCIBTUSB_MTK) &&
>  	    (id->driver_info & BTUSB_MEDIATEK)) {
>  		hdev->setup = btusb_mtk_setup;
> -- 
> 2.31.1
> 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897
  2021-09-17 12:27 [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897 Jonas Dreßler
  2021-09-17 12:30 ` Pali Rohár
@ 2021-09-17 12:35 ` Marcel Holtmann
  2021-09-17 12:41   ` Jonas Dreßler
  2021-09-17 13:18 ` bluez.test.bot
  2 siblings, 1 reply; 8+ messages in thread
From: Marcel Holtmann @ 2021-09-17 12:35 UTC (permalink / raw)
  To: Jonas Dreßler
  Cc: Amitkumar Karwar, Ganapathi Bhat, Xinming Hu, Kalle Valo,
	David S. Miller, Jakub Kicinski, Johan Hedberg,
	Luiz Augusto von Dentz, Tsuchiya Yuto, linux-wireless,
	linux-bluetooth, open list, Maximilian Luz, Andy Shevchenko,
	Pali Rohár

Hi Jonas,

> The Marvell 88W8897 combined wifi and bluetooth card (pcie+usb version)
> is used in a lot of Microsoft Surface devices, and all those devices
> suffer from very low 2.4GHz wifi connection speeds while bluetooth is
> enabled. The reason for that is that the default passive scanning
> interval for Bluetooth Low Energy devices is quite high on Linux
> (interval of 60 msec and scan window of 30 msec, see le_scan_interval
> and le_scan_window in hci_core.c), and the Marvell chip is known for its
> bad bt+wifi coexisting performance.
> 
> So decrease that passive scan interval and make the scan window shorter
> on this particular device to allow for spending more time transmitting
> wifi signals: The new scan interval is 250 msec (0x190 * 0.625 msec) and
> the new scan window is 6.25 msec (0xa * 0.625 msec).
> 
> This change has a very large impact on the 2.4GHz wifi speeds and gets
> it up to performance comparable with the Windows driver, which seems to
> apply a similar quirk.
> 
> The scan interval and scan window length were tested and found to work
> very well with a bunch of Bluetooth Low Energy devices, including the
> Surface Pen, a Bluetooth Speaker and two modern Bluetooth headphones.
> All devices were discovered immediately after turning them on. Even
> lower values were also tested, but these introduced longer delays until
> devices get discovered.
> 
> Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
> ---
> drivers/bluetooth/btusb.c | 15 +++++++++++++++
> 1 file changed, 15 insertions(+)
> 
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 60d2fce59a71..05b11179c839 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver;
> #define BTUSB_WIDEBAND_SPEECH	0x400000
> #define BTUSB_VALID_LE_STATES   0x800000
> #define BTUSB_QCA_WCN6855	0x1000000
> +#define BTUSB_LOWER_LESCAN_INTERVAL	0x2000000
> #define BTUSB_INTEL_BROKEN_INITIAL_NCMD 0x4000000
> 
> static const struct usb_device_id btusb_table[] = {
> @@ -356,6 +357,7 @@ static const struct usb_device_id blacklist_table[] = {
> 	{ USB_DEVICE(0x1286, 0x2044), .driver_info = BTUSB_MARVELL },
> 	{ USB_DEVICE(0x1286, 0x2046), .driver_info = BTUSB_MARVELL },
> 	{ USB_DEVICE(0x1286, 0x204e), .driver_info = BTUSB_MARVELL },
> +	{ USB_DEVICE(0x1286, 0x204c), .driver_info = BTUSB_LOWER_LESCAN_INTERVAL },
> 
> 	/* Intel Bluetooth devices */
> 	{ USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED },
> @@ -3813,6 +3815,19 @@ static int btusb_probe(struct usb_interface *intf,
> 	if (id->driver_info & BTUSB_MARVELL)
> 		hdev->set_bdaddr = btusb_set_bdaddr_marvell;
> 
> +	/* The Marvell 88W8897 combined wifi and bluetooth card is known for
> +	 * very bad bt+wifi coexisting performance.
> +	 *
> +	 * Decrease the passive BT Low Energy scan interval a bit
> +	 * (0x0190 * 0.625 msec = 250 msec) and make the scan window shorter
> +	 * (0x000a * 0,625 msec = 6.25 msec). This allows for significantly
> +	 * higher wifi throughput while passively scanning for BT LE devices.
> +	 */
> +	if (id->driver_info & BTUSB_LOWER_LESCAN_INTERVAL) {
> +		hdev->le_scan_interval = 0x0190;
> +		hdev->le_scan_window = 0x000a;
> +	}
> +

you can not do it this way. Modifying hci_dev internals from within the driver is not acceptable.

Regards

Marcel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897
  2021-09-17 12:30 ` Pali Rohár
@ 2021-09-17 12:36   ` Jonas Dreßler
  0 siblings, 0 replies; 8+ messages in thread
From: Jonas Dreßler @ 2021-09-17 12:36 UTC (permalink / raw)
  To: Pali Rohár
  Cc: Amitkumar Karwar, Ganapathi Bhat, Xinming Hu, Kalle Valo,
	David S. Miller, Jakub Kicinski, Marcel Holtmann, Johan Hedberg,
	Luiz Augusto von Dentz, Tsuchiya Yuto, linux-wireless,
	linux-bluetooth, linux-kernel, Maximilian Luz, Andy Shevchenko

On 9/17/21 2:30 PM, Pali Rohár wrote:
> On Friday 17 September 2021 14:27:18 Jonas Dreßler wrote:
>> The Marvell 88W8897 combined wifi and bluetooth card (pcie+usb version)
>> is used in a lot of Microsoft Surface devices, and all those devices
>> suffer from very low 2.4GHz wifi connection speeds while bluetooth is
>> enabled.
> 
> Hello! Do you know if this issue is specific only to this one Marvell
> 88W8897 chip or if this issue affects also other Marvell wifi+bt combo
> chips?

Hi! No idea, good question, but I don't own any other devices with 
Marvell chips. Maybe it's even safe to apply it to all Bluetooth 
devices, I guess less scanning load is good for everyone (as long as it 
doesn't impact the scanning results of course, so that would need testing).

> 
>> The reason for that is that the default passive scanning
>> interval for Bluetooth Low Energy devices is quite high on Linux
>> (interval of 60 msec and scan window of 30 msec, see le_scan_interval
>> and le_scan_window in hci_core.c), and the Marvell chip is known for its
>> bad bt+wifi coexisting performance.
>>
>> So decrease that passive scan interval and make the scan window shorter
>> on this particular device to allow for spending more time transmitting
>> wifi signals: The new scan interval is 250 msec (0x190 * 0.625 msec) and
>> the new scan window is 6.25 msec (0xa * 0.625 msec).
>>
>> This change has a very large impact on the 2.4GHz wifi speeds and gets
>> it up to performance comparable with the Windows driver, which seems to
>> apply a similar quirk.
>>
>> The scan interval and scan window length were tested and found to work
>> very well with a bunch of Bluetooth Low Energy devices, including the
>> Surface Pen, a Bluetooth Speaker and two modern Bluetooth headphones.
>> All devices were discovered immediately after turning them on. Even
>> lower values were also tested, but these introduced longer delays until
>> devices get discovered.
>>
>> Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
>> ---
>>   drivers/bluetooth/btusb.c | 15 +++++++++++++++
>>   1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
>> index 60d2fce59a71..05b11179c839 100644
>> --- a/drivers/bluetooth/btusb.c
>> +++ b/drivers/bluetooth/btusb.c
>> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver;
>>   #define BTUSB_WIDEBAND_SPEECH	0x400000
>>   #define BTUSB_VALID_LE_STATES   0x800000
>>   #define BTUSB_QCA_WCN6855	0x1000000
>> +#define BTUSB_LOWER_LESCAN_INTERVAL	0x2000000
>>   #define BTUSB_INTEL_BROKEN_INITIAL_NCMD 0x4000000
>>   
>>   static const struct usb_device_id btusb_table[] = {
>> @@ -356,6 +357,7 @@ static const struct usb_device_id blacklist_table[] = {
>>   	{ USB_DEVICE(0x1286, 0x2044), .driver_info = BTUSB_MARVELL },
>>   	{ USB_DEVICE(0x1286, 0x2046), .driver_info = BTUSB_MARVELL },
>>   	{ USB_DEVICE(0x1286, 0x204e), .driver_info = BTUSB_MARVELL },
>> +	{ USB_DEVICE(0x1286, 0x204c), .driver_info = BTUSB_LOWER_LESCAN_INTERVAL },
>>   
>>   	/* Intel Bluetooth devices */
>>   	{ USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED },
>> @@ -3813,6 +3815,19 @@ static int btusb_probe(struct usb_interface *intf,
>>   	if (id->driver_info & BTUSB_MARVELL)
>>   		hdev->set_bdaddr = btusb_set_bdaddr_marvell;
>>   
>> +	/* The Marvell 88W8897 combined wifi and bluetooth card is known for
>> +	 * very bad bt+wifi coexisting performance.
>> +	 *
>> +	 * Decrease the passive BT Low Energy scan interval a bit
>> +	 * (0x0190 * 0.625 msec = 250 msec) and make the scan window shorter
>> +	 * (0x000a * 0,625 msec = 6.25 msec). This allows for significantly
>> +	 * higher wifi throughput while passively scanning for BT LE devices.
>> +	 */
>> +	if (id->driver_info & BTUSB_LOWER_LESCAN_INTERVAL) {
>> +		hdev->le_scan_interval = 0x0190;
>> +		hdev->le_scan_window = 0x000a;
>> +	}
>> +
>>   	if (IS_ENABLED(CONFIG_BT_HCIBTUSB_MTK) &&
>>   	    (id->driver_info & BTUSB_MEDIATEK)) {
>>   		hdev->setup = btusb_mtk_setup;
>> -- 
>> 2.31.1
>>


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897
  2021-09-17 12:35 ` Marcel Holtmann
@ 2021-09-17 12:41   ` Jonas Dreßler
  2021-09-17 13:18     ` Marcel Holtmann
  0 siblings, 1 reply; 8+ messages in thread
From: Jonas Dreßler @ 2021-09-17 12:41 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Amitkumar Karwar, Ganapathi Bhat, Xinming Hu, Kalle Valo,
	David S. Miller, Jakub Kicinski, Johan Hedberg,
	Luiz Augusto von Dentz, Tsuchiya Yuto, linux-wireless,
	linux-bluetooth, open list, Maximilian Luz, Andy Shevchenko,
	Pali Rohár

On 9/17/21 2:35 PM, Marcel Holtmann wrote:
> Hi Jonas,
> 
>> The Marvell 88W8897 combined wifi and bluetooth card (pcie+usb version)
>> is used in a lot of Microsoft Surface devices, and all those devices
>> suffer from very low 2.4GHz wifi connection speeds while bluetooth is
>> enabled. The reason for that is that the default passive scanning
>> interval for Bluetooth Low Energy devices is quite high on Linux
>> (interval of 60 msec and scan window of 30 msec, see le_scan_interval
>> and le_scan_window in hci_core.c), and the Marvell chip is known for its
>> bad bt+wifi coexisting performance.
>>
>> So decrease that passive scan interval and make the scan window shorter
>> on this particular device to allow for spending more time transmitting
>> wifi signals: The new scan interval is 250 msec (0x190 * 0.625 msec) and
>> the new scan window is 6.25 msec (0xa * 0.625 msec).
>>
>> This change has a very large impact on the 2.4GHz wifi speeds and gets
>> it up to performance comparable with the Windows driver, which seems to
>> apply a similar quirk.
>>
>> The scan interval and scan window length were tested and found to work
>> very well with a bunch of Bluetooth Low Energy devices, including the
>> Surface Pen, a Bluetooth Speaker and two modern Bluetooth headphones.
>> All devices were discovered immediately after turning them on. Even
>> lower values were also tested, but these introduced longer delays until
>> devices get discovered.
>>
>> Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
>> ---
>> drivers/bluetooth/btusb.c | 15 +++++++++++++++
>> 1 file changed, 15 insertions(+)
>>
>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
>> index 60d2fce59a71..05b11179c839 100644
>> --- a/drivers/bluetooth/btusb.c
>> +++ b/drivers/bluetooth/btusb.c
>> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver;
>> #define BTUSB_WIDEBAND_SPEECH	0x400000
>> #define BTUSB_VALID_LE_STATES   0x800000
>> #define BTUSB_QCA_WCN6855	0x1000000
>> +#define BTUSB_LOWER_LESCAN_INTERVAL	0x2000000
>> #define BTUSB_INTEL_BROKEN_INITIAL_NCMD 0x4000000
>>
>> static const struct usb_device_id btusb_table[] = {
>> @@ -356,6 +357,7 @@ static const struct usb_device_id blacklist_table[] = {
>> 	{ USB_DEVICE(0x1286, 0x2044), .driver_info = BTUSB_MARVELL },
>> 	{ USB_DEVICE(0x1286, 0x2046), .driver_info = BTUSB_MARVELL },
>> 	{ USB_DEVICE(0x1286, 0x204e), .driver_info = BTUSB_MARVELL },
>> +	{ USB_DEVICE(0x1286, 0x204c), .driver_info = BTUSB_LOWER_LESCAN_INTERVAL },
>>
>> 	/* Intel Bluetooth devices */
>> 	{ USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED },
>> @@ -3813,6 +3815,19 @@ static int btusb_probe(struct usb_interface *intf,
>> 	if (id->driver_info & BTUSB_MARVELL)
>> 		hdev->set_bdaddr = btusb_set_bdaddr_marvell;
>>
>> +	/* The Marvell 88W8897 combined wifi and bluetooth card is known for
>> +	 * very bad bt+wifi coexisting performance.
>> +	 *
>> +	 * Decrease the passive BT Low Energy scan interval a bit
>> +	 * (0x0190 * 0.625 msec = 250 msec) and make the scan window shorter
>> +	 * (0x000a * 0,625 msec = 6.25 msec). This allows for significantly
>> +	 * higher wifi throughput while passively scanning for BT LE devices.
>> +	 */
>> +	if (id->driver_info & BTUSB_LOWER_LESCAN_INTERVAL) {
>> +		hdev->le_scan_interval = 0x0190;
>> +		hdev->le_scan_window = 0x000a;
>> +	}
>> +
> 
> you can not do it this way. Modifying hci_dev internals from within the driver is not acceptable.
> 
> Regards
> 
> Marcel
> 

Hi Marcel,

hmm okay, it seems to me that the intention of your commit 
bef64738e3fb87eabc6fbeededad0c44ea173384 was to allow configuring it on 
a per controller basis, also btusb changes a bunch of other hci_dev 
properties? Given that we also have to match by usb-id, I don't think 
there's another place to do that other than the usb driver, or is there?

Jonas

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897
  2021-09-17 12:41   ` Jonas Dreßler
@ 2021-09-17 13:18     ` Marcel Holtmann
  2021-09-17 13:32       ` Jonas Dreßler
  0 siblings, 1 reply; 8+ messages in thread
From: Marcel Holtmann @ 2021-09-17 13:18 UTC (permalink / raw)
  To: Jonas Dreßler
  Cc: Amitkumar Karwar, Ganapathi Bhat, Xinming Hu, Kalle Valo,
	David S. Miller, Jakub Kicinski, Johan Hedberg,
	Luiz Augusto von Dentz, Tsuchiya Yuto, linux-wireless,
	linux-bluetooth, open list, Maximilian Luz, Andy Shevchenko,
	Pali Rohár

Hi Jonas,

>>> The Marvell 88W8897 combined wifi and bluetooth card (pcie+usb version)
>>> is used in a lot of Microsoft Surface devices, and all those devices
>>> suffer from very low 2.4GHz wifi connection speeds while bluetooth is
>>> enabled. The reason for that is that the default passive scanning
>>> interval for Bluetooth Low Energy devices is quite high on Linux
>>> (interval of 60 msec and scan window of 30 msec, see le_scan_interval
>>> and le_scan_window in hci_core.c), and the Marvell chip is known for its
>>> bad bt+wifi coexisting performance.
>>> 
>>> So decrease that passive scan interval and make the scan window shorter
>>> on this particular device to allow for spending more time transmitting
>>> wifi signals: The new scan interval is 250 msec (0x190 * 0.625 msec) and
>>> the new scan window is 6.25 msec (0xa * 0.625 msec).
>>> 
>>> This change has a very large impact on the 2.4GHz wifi speeds and gets
>>> it up to performance comparable with the Windows driver, which seems to
>>> apply a similar quirk.
>>> 
>>> The scan interval and scan window length were tested and found to work
>>> very well with a bunch of Bluetooth Low Energy devices, including the
>>> Surface Pen, a Bluetooth Speaker and two modern Bluetooth headphones.
>>> All devices were discovered immediately after turning them on. Even
>>> lower values were also tested, but these introduced longer delays until
>>> devices get discovered.
>>> 
>>> Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
>>> ---
>>> drivers/bluetooth/btusb.c | 15 +++++++++++++++
>>> 1 file changed, 15 insertions(+)
>>> 
>>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
>>> index 60d2fce59a71..05b11179c839 100644
>>> --- a/drivers/bluetooth/btusb.c
>>> +++ b/drivers/bluetooth/btusb.c
>>> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver;
>>> #define BTUSB_WIDEBAND_SPEECH	0x400000
>>> #define BTUSB_VALID_LE_STATES   0x800000
>>> #define BTUSB_QCA_WCN6855	0x1000000
>>> +#define BTUSB_LOWER_LESCAN_INTERVAL	0x2000000
>>> #define BTUSB_INTEL_BROKEN_INITIAL_NCMD 0x4000000
>>> 
>>> static const struct usb_device_id btusb_table[] = {
>>> @@ -356,6 +357,7 @@ static const struct usb_device_id blacklist_table[] = {
>>> 	{ USB_DEVICE(0x1286, 0x2044), .driver_info = BTUSB_MARVELL },
>>> 	{ USB_DEVICE(0x1286, 0x2046), .driver_info = BTUSB_MARVELL },
>>> 	{ USB_DEVICE(0x1286, 0x204e), .driver_info = BTUSB_MARVELL },
>>> +	{ USB_DEVICE(0x1286, 0x204c), .driver_info = BTUSB_LOWER_LESCAN_INTERVAL },
>>> 
>>> 	/* Intel Bluetooth devices */
>>> 	{ USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED },
>>> @@ -3813,6 +3815,19 @@ static int btusb_probe(struct usb_interface *intf,
>>> 	if (id->driver_info & BTUSB_MARVELL)
>>> 		hdev->set_bdaddr = btusb_set_bdaddr_marvell;
>>> 
>>> +	/* The Marvell 88W8897 combined wifi and bluetooth card is known for
>>> +	 * very bad bt+wifi coexisting performance.
>>> +	 *
>>> +	 * Decrease the passive BT Low Energy scan interval a bit
>>> +	 * (0x0190 * 0.625 msec = 250 msec) and make the scan window shorter
>>> +	 * (0x000a * 0,625 msec = 6.25 msec). This allows for significantly
>>> +	 * higher wifi throughput while passively scanning for BT LE devices.
>>> +	 */
>>> +	if (id->driver_info & BTUSB_LOWER_LESCAN_INTERVAL) {
>>> +		hdev->le_scan_interval = 0x0190;
>>> +		hdev->le_scan_window = 0x000a;
>>> +	}
>>> +
>> you can not do it this way. Modifying hci_dev internals from within the driver is not acceptable.
>> Regards
>> Marcel
> 
> 
> hmm okay, it seems to me that the intention of your commit bef64738e3fb87eabc6fbeededad0c44ea173384 was to allow configuring it on a per controller basis, also btusb changes a bunch of other hci_dev properties? Given that we also have to match by usb-id, I don't think there's another place to do that other than the usb driver, or is there?

you can change most defaults via mgmt commands.

The things the a driver should set in hci_dev is really limited and it only affects its ability to run as a transport driver. It shouldn’t deal with anything that is actually HCI upper layer operation.

Regards

Marcel


^ permalink raw reply	[flat|nested] 8+ messages in thread

* RE: Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897
  2021-09-17 12:27 [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897 Jonas Dreßler
  2021-09-17 12:30 ` Pali Rohár
  2021-09-17 12:35 ` Marcel Holtmann
@ 2021-09-17 13:18 ` bluez.test.bot
  2 siblings, 0 replies; 8+ messages in thread
From: bluez.test.bot @ 2021-09-17 13:18 UTC (permalink / raw)
  To: linux-bluetooth, verdre

[-- Attachment #1: Type: text/plain, Size: 1216 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=548839

---Test result---

Test Summary:
CheckPatch                    PASS      1.37 seconds
GitLint                       FAIL      0.91 seconds
BuildKernel                   PASS      527.07 seconds
TestRunner: Setup             PASS      349.19 seconds
TestRunner: l2cap-tester      PASS      2.85 seconds
TestRunner: bnep-tester       PASS      2.27 seconds
TestRunner: mgmt-tester       PASS      31.43 seconds
TestRunner: rfcomm-tester     PASS      2.39 seconds
TestRunner: sco-tester        PASS      2.47 seconds
TestRunner: smp-tester        PASS      2.47 seconds
TestRunner: userchan-tester   PASS      2.31 seconds

Details
##############################
Test: GitLint - FAIL - 0.91 seconds
Run gitlint with rule in .gitlint
Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897
2: B4 Second line is not empty: "is used in a lot of Microsoft Surface devices, and all those devices"




---
Regards,
Linux Bluetooth


[-- Attachment #2: l2cap-tester.log --]
[-- Type: application/octet-stream, Size: 51568 bytes --]

[-- Attachment #3: bnep-tester.log --]
[-- Type: application/octet-stream, Size: 3935 bytes --]

[-- Attachment #4: mgmt-tester.log --]
[-- Type: application/octet-stream, Size: 626843 bytes --]

[-- Attachment #5: rfcomm-tester.log --]
[-- Type: application/octet-stream, Size: 14791 bytes --]

[-- Attachment #6: sco-tester.log --]
[-- Type: application/octet-stream, Size: 13045 bytes --]

[-- Attachment #7: smp-tester.log --]
[-- Type: application/octet-stream, Size: 11859 bytes --]

[-- Attachment #8: userchan-tester.log --]
[-- Type: application/octet-stream, Size: 6516 bytes --]

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897
  2021-09-17 13:18     ` Marcel Holtmann
@ 2021-09-17 13:32       ` Jonas Dreßler
  0 siblings, 0 replies; 8+ messages in thread
From: Jonas Dreßler @ 2021-09-17 13:32 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Amitkumar Karwar, Ganapathi Bhat, Xinming Hu, Kalle Valo,
	David S. Miller, Jakub Kicinski, Johan Hedberg,
	Luiz Augusto von Dentz, Tsuchiya Yuto, linux-wireless,
	linux-bluetooth, open list, Maximilian Luz, Andy Shevchenko,
	Pali Rohár

On 9/17/21 3:18 PM, Marcel Holtmann wrote:
> Hi Jonas,
> 
>>>> The Marvell 88W8897 combined wifi and bluetooth card (pcie+usb version)
>>>> is used in a lot of Microsoft Surface devices, and all those devices
>>>> suffer from very low 2.4GHz wifi connection speeds while bluetooth is
>>>> enabled. The reason for that is that the default passive scanning
>>>> interval for Bluetooth Low Energy devices is quite high on Linux
>>>> (interval of 60 msec and scan window of 30 msec, see le_scan_interval
>>>> and le_scan_window in hci_core.c), and the Marvell chip is known for its
>>>> bad bt+wifi coexisting performance.
>>>>
>>>> So decrease that passive scan interval and make the scan window shorter
>>>> on this particular device to allow for spending more time transmitting
>>>> wifi signals: The new scan interval is 250 msec (0x190 * 0.625 msec) and
>>>> the new scan window is 6.25 msec (0xa * 0.625 msec).
>>>>
>>>> This change has a very large impact on the 2.4GHz wifi speeds and gets
>>>> it up to performance comparable with the Windows driver, which seems to
>>>> apply a similar quirk.
>>>>
>>>> The scan interval and scan window length were tested and found to work
>>>> very well with a bunch of Bluetooth Low Energy devices, including the
>>>> Surface Pen, a Bluetooth Speaker and two modern Bluetooth headphones.
>>>> All devices were discovered immediately after turning them on. Even
>>>> lower values were also tested, but these introduced longer delays until
>>>> devices get discovered.
>>>>
>>>> Signed-off-by: Jonas Dreßler <verdre@v0yd.nl>
>>>> ---
>>>> drivers/bluetooth/btusb.c | 15 +++++++++++++++
>>>> 1 file changed, 15 insertions(+)
>>>>
>>>> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
>>>> index 60d2fce59a71..05b11179c839 100644
>>>> --- a/drivers/bluetooth/btusb.c
>>>> +++ b/drivers/bluetooth/btusb.c
>>>> @@ -59,6 +59,7 @@ static struct usb_driver btusb_driver;
>>>> #define BTUSB_WIDEBAND_SPEECH	0x400000
>>>> #define BTUSB_VALID_LE_STATES   0x800000
>>>> #define BTUSB_QCA_WCN6855	0x1000000
>>>> +#define BTUSB_LOWER_LESCAN_INTERVAL	0x2000000
>>>> #define BTUSB_INTEL_BROKEN_INITIAL_NCMD 0x4000000
>>>>
>>>> static const struct usb_device_id btusb_table[] = {
>>>> @@ -356,6 +357,7 @@ static const struct usb_device_id blacklist_table[] = {
>>>> 	{ USB_DEVICE(0x1286, 0x2044), .driver_info = BTUSB_MARVELL },
>>>> 	{ USB_DEVICE(0x1286, 0x2046), .driver_info = BTUSB_MARVELL },
>>>> 	{ USB_DEVICE(0x1286, 0x204e), .driver_info = BTUSB_MARVELL },
>>>> +	{ USB_DEVICE(0x1286, 0x204c), .driver_info = BTUSB_LOWER_LESCAN_INTERVAL },
>>>>
>>>> 	/* Intel Bluetooth devices */
>>>> 	{ USB_DEVICE(0x8087, 0x0025), .driver_info = BTUSB_INTEL_COMBINED },
>>>> @@ -3813,6 +3815,19 @@ static int btusb_probe(struct usb_interface *intf,
>>>> 	if (id->driver_info & BTUSB_MARVELL)
>>>> 		hdev->set_bdaddr = btusb_set_bdaddr_marvell;
>>>>
>>>> +	/* The Marvell 88W8897 combined wifi and bluetooth card is known for
>>>> +	 * very bad bt+wifi coexisting performance.
>>>> +	 *
>>>> +	 * Decrease the passive BT Low Energy scan interval a bit
>>>> +	 * (0x0190 * 0.625 msec = 250 msec) and make the scan window shorter
>>>> +	 * (0x000a * 0,625 msec = 6.25 msec). This allows for significantly
>>>> +	 * higher wifi throughput while passively scanning for BT LE devices.
>>>> +	 */
>>>> +	if (id->driver_info & BTUSB_LOWER_LESCAN_INTERVAL) {
>>>> +		hdev->le_scan_interval = 0x0190;
>>>> +		hdev->le_scan_window = 0x000a;
>>>> +	}
>>>> +
>>> you can not do it this way. Modifying hci_dev internals from within the driver is not acceptable.
>>> Regards
>>> Marcel
>>
>>
>> hmm okay, it seems to me that the intention of your commit bef64738e3fb87eabc6fbeededad0c44ea173384 was to allow configuring it on a per controller basis, also btusb changes a bunch of other hci_dev properties? Given that we also have to match by usb-id, I don't think there's another place to do that other than the usb driver, or is there?
> 
> you can change most defaults via mgmt commands.
> 
> The things the a driver should set in hci_dev is really limited and it only affects its ability to run as a transport driver. It shouldn’t deal with anything that is actually HCI upper layer operation.
> 
> Regards
> 
> Marcel
> 

Hmm, having users of this wifi chip run a script at boot doesn't sound 
great to me, or can you point me to somewhere in bluez where I could put 
a device-specific quirk for this? IMHO this is a real bug with the 
hardware that needs to be quirked somewhere, note that this is not a 
minor performance improvement, this bumps wifi 2.4ghz speeds up from 800 
KB/s to >5 MB/s.

Other than that, there's also the possibility of changing the 
kernel-wide defaults, but as mentioned in my other answer, I don't have 
enough hardware laying around to test that at all.

Jonas

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2021-09-17 13:32 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-17 12:27 [PATCH] Bluetooth: btusb: Lower passive lescan interval on Marvell 88W8897 Jonas Dreßler
2021-09-17 12:30 ` Pali Rohár
2021-09-17 12:36   ` Jonas Dreßler
2021-09-17 12:35 ` Marcel Holtmann
2021-09-17 12:41   ` Jonas Dreßler
2021-09-17 13:18     ` Marcel Holtmann
2021-09-17 13:32       ` Jonas Dreßler
2021-09-17 13:18 ` bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).