stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/6] Bluetooth: add quirk disabling LE Read Transmit Power
       [not found]                         ` <D9375D91-1062-4265-9DE9-C7CF2B705F3F@live.com>
@ 2021-11-29  7:22                           ` Aditya Garg
  2021-11-29  7:27                             ` [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019) Aditya Garg
  2021-11-29  7:32                             ` [PATCH 1/6] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
  0 siblings, 2 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:22 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Marcel Holtmann, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <redecorating@protonmail.com>

Some devices have a bug causing them to not work if they query LE tx power on startup. Thus we add a quirk in order to not query it and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Tested-by: Aditya Garg <gargaditya08@live.com>
---
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_core.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
 		}
 
-		if (hdev->commands[38] & 0x80) {
+		if (hdev->commands[38] & 0x80 &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
 			/* Read LE Min/Max Tx Power*/
 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
 				    0, NULL);


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

* [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019)
  2021-11-29  7:22                           ` [PATCH 1/6] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
@ 2021-11-29  7:27                             ` Aditya Garg
  2021-11-29  7:28                               ` [PATCH 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020) Aditya Garg
                                                 ` (2 more replies)
  2021-11-29  7:32                             ` [PATCH 1/6] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
  1 sibling, 3 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:27 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Marcel Holtmann, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Bluetooth on Apple MacBook Pro 16,1 is unable to start due to LE Min/Max Tx Power being queried on startup. Add a DMI based quirk so that it is disabled.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Tested-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/bluetooth/btbcm.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..c1b0ca63880a68 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,9 +344,23 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		/* Match for Apple MacBook Pro 16,1 which needs
+		 * Read LE Min/Max Tx Power to be disabled.
+		 */
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
+	const struct dmi_system_id *dmi_id;
 
 	/* Read Verbose Config Version Info */
 	skb = btbcm_read_verbose_config(hdev);
@@ -362,6 +377,11 @@ static int btbcm_read_info(struct hci_dev *hdev)
 
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
+
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	dmi_id = dmi_first_match(disable_broken_read_transmit_power);
+	if (dmi_id)
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
 
 	return 0;
 }


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

* [PATCH 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020)
  2021-11-29  7:27                             ` [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019) Aditya Garg
@ 2021-11-29  7:28                               ` Aditya Garg
  2021-11-29  7:30                                 ` [PATCH 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019) Aditya Garg
  2021-11-29  7:45                                 ` [PATCH v2 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020) Aditya Garg
  2021-11-29  7:44                               ` [PATCH v2 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019) Aditya Garg
  2021-11-29  8:08                               ` [PATCH " Marcel Holtmann
  2 siblings, 2 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:28 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Marcel Holtmann, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Bluetooth on Apple MacBook Pro 16,2 is unable to start due to LE Min/Max Tx Power being queried on startup. Add a DMI based quirk so that it is disabled.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/bluetooth/btbcm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index c1b0ca63880a6..ab7b754855d8a 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -354,6 +354,15 @@ static const struct dmi_system_id disable_broken_read_transmit_power[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
 		},
 	},
+	{
+		/* Match for Apple MacBook Pro 16,2 which needs
+		 * Read LE Min/Max Tx Power to be disabled.
+		 */
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
 	{ }
 };
 


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

* [PATCH 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019)
  2021-11-29  7:28                               ` [PATCH 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020) Aditya Garg
@ 2021-11-29  7:30                                 ` Aditya Garg
  2021-11-29  7:31                                   ` [PATCH 5/6] btbcm: disable read tx power for iMac 20,1 (Retina 5K, 27-inch, 2020) Aditya Garg
  2021-11-29  7:46                                   ` [PATCH v2 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019) Aditya Garg
  2021-11-29  7:45                                 ` [PATCH v2 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020) Aditya Garg
  1 sibling, 2 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:30 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Marcel Holtmann, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Bluetooth on Apple MacBook Pro 16,4 is unable to start due to LE Min/Max Tx Power being queried on startup. Add a DMI based quirk so that it is disabled.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/bluetooth/btbcm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index 348a4afa0774e..88214b453b0ce 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -363,6 +363,15 @@ static const struct dmi_system_id disable_broken_read_transmit_power[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
 		},
 	},
+	{
+		/* Match for Apple MacBook Pro 16,4 which needs
+		 * Read LE Min/Max Tx Power to be disabled.
+		 */
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
 	{ }
 };
 


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

* [PATCH 5/6] btbcm: disable read tx power for iMac 20,1 (Retina 5K, 27-inch, 2020)
  2021-11-29  7:30                                 ` [PATCH 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019) Aditya Garg
@ 2021-11-29  7:31                                   ` Aditya Garg
  2021-11-29  7:32                                     ` [PATCH 6/6] btbcm: disable read tx power for iMac 20,2 " Aditya Garg
  2021-11-29  7:46                                   ` [PATCH v2 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019) Aditya Garg
  1 sibling, 1 reply; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:31 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Marcel Holtmann, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Bluetooth on Apple iMac 20,1 is unable to start due to LE Min/Max Tx Power being queried on startup. Add a DMI based quirk so that it is disabled.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/bluetooth/btbcm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index 88214b453b0ce..15c5be927c659 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -372,6 +372,15 @@ static const struct dmi_system_id disable_broken_read_transmit_power[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
 		},
 	},
+	{
+		/* Match for Apple iMac 20,1 which needs
+		 * Read LE Min/Max Tx Power to be disabled.
+		 */
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
 	{ }
 };
 


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

* [PATCH 6/6] btbcm: disable read tx power for iMac 20,2 (Retina 5K, 27-inch, 2020)
  2021-11-29  7:31                                   ` [PATCH 5/6] btbcm: disable read tx power for iMac 20,1 (Retina 5K, 27-inch, 2020) Aditya Garg
@ 2021-11-29  7:32                                     ` Aditya Garg
  0 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:32 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Marcel Holtmann, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Bluetooth on Apple iMac 20,2 is unable to start due to LE Min/Max Tx Power being queried on startup. Add a DMI based quirk so that it is disabled.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/bluetooth/btbcm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index 15c5be927c659..601337b5a5130 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -381,6 +381,15 @@ static const struct dmi_system_id disable_broken_read_transmit_power[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
 		},
 	},
+	{
+		/* Match for Apple iMac 20,2 which needs
+		 * Read LE Min/Max Tx Power to be disabled.
+		 */
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
 	{ }
 };
 


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

* Re: [PATCH 1/6] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  7:22                           ` [PATCH 1/6] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
  2021-11-29  7:27                             ` [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019) Aditya Garg
@ 2021-11-29  7:32                             ` Greg KH
  2021-11-29  7:42                               ` [PATCH v2 " Aditya Garg
  1 sibling, 1 reply; 54+ messages in thread
From: Greg KH @ 2021-11-29  7:32 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Thorsten Leemhuis, Marcel Holtmann, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

On Mon, Nov 29, 2021 at 07:22:27AM +0000, Aditya Garg wrote:
> From: Aditya Garg <redecorating@protonmail.com>
> 
> Some devices have a bug causing them to not work if they query LE tx power on startup. Thus we add a quirk in order to not query it and default min/max tx power values to HCI_TX_POWER_INVALID.

Please wrap your changelog text at 72 columns, like your editor asked
you to :)

> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> Tested-by: Aditya Garg <gargaditya08@live.com>

Tested-by: is implicit for patches you create yourself, so no need to
add it again :)


> ---
>  include/net/bluetooth/hci.h | 9 +++++++++
>  net/bluetooth/hci_core.c    | 3 ++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
> +	 *
> +	 * This quirk can be set before hci_register_dev is called or
> +	 * during the hdev->setup vendor callback.
> +	 */
> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
>  };
>  
>  /* HCI device flags */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 8d33aa64846b1c..434c6878fe9640 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
>  			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
>  		}
>  
> -		if (hdev->commands[38] & 0x80) {
> +		if (hdev->commands[38] & 0x80 &&
> +		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {

Did you run checkpatch on this patch?  Please indent properly.

thanks,

greg k-h

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

* [PATCH v2 1/6] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  7:32                             ` [PATCH 1/6] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
@ 2021-11-29  7:42                               ` Aditya Garg
  2021-11-29  7:47                                 ` Greg KH
                                                   ` (2 more replies)
  0 siblings, 3 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:42 UTC (permalink / raw)
  To: Greg KH
  Cc: Thorsten Leemhuis, Marcel Holtmann, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query LE tx power on startup. Thus we add a 
quirk in order to not query it and default min/max tx power values to HCI_TX_POWER_INVALID.

v2: Wrap the changeling at 72 columns, correct email and remove tested by.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_core.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
 		}
 
-		if (hdev->commands[38] & 0x80) {
+		if (hdev->commands[38] & 0x80 &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
 			/* Read LE Min/Max Tx Power*/
 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
 				    0, NULL);


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

* [PATCH v2 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019)
  2021-11-29  7:27                             ` [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019) Aditya Garg
  2021-11-29  7:28                               ` [PATCH 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020) Aditya Garg
@ 2021-11-29  7:44                               ` Aditya Garg
  2021-11-29  8:08                               ` [PATCH " Marcel Holtmann
  2 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:44 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Marcel Holtmann, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Bluetooth on Apple MacBook Pro 16,1 is unable to start due to LE Min/Max Tx Power being queried on 
startup. Add a DMI based quirk so that it is disabled.

v2: Wrap the changeling at 72 columns and remove tested by.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/bluetooth/btbcm.c | 20 ++++++++++++++++++++
 1 file changed, 20 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..c1b0ca63880a68 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,9 +344,23 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		/* Match for Apple MacBook Pro 16,1 which needs
+		 * Read LE Min/Max Tx Power to be disabled.
+		 */
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
+	const struct dmi_system_id *dmi_id;
 
 	/* Read Verbose Config Version Info */
 	skb = btbcm_read_verbose_config(hdev);
@@ -362,6 +377,11 @@ static int btbcm_read_info(struct hci_dev *hdev)
 
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
+
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	dmi_id = dmi_first_match(disable_broken_read_transmit_power);
+	if (dmi_id)
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
 
 	return 0;
 }


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

* [PATCH v2 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020)
  2021-11-29  7:28                               ` [PATCH 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020) Aditya Garg
  2021-11-29  7:30                                 ` [PATCH 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019) Aditya Garg
@ 2021-11-29  7:45                                 ` Aditya Garg
  1 sibling, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:45 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Marcel Holtmann, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Bluetooth on Apple MacBook Pro 16,2 is unable to start due to LE Min/Max Tx Power being queried on 
startup. Add a DMI based quirk so that it is disabled.

v2: Wrap changelog in 72 columns

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/bluetooth/btbcm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index c1b0ca63880a6..ab7b754855d8a 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -354,6 +354,15 @@ static const struct dmi_system_id disable_broken_read_transmit_power[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
 		},
 	},
+	{
+		/* Match for Apple MacBook Pro 16,2 which needs
+		 * Read LE Min/Max Tx Power to be disabled.
+		 */
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
 	{ }
 };
 


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

* [PATCH v2 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019)
  2021-11-29  7:30                                 ` [PATCH 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019) Aditya Garg
  2021-11-29  7:31                                   ` [PATCH 5/6] btbcm: disable read tx power for iMac 20,1 (Retina 5K, 27-inch, 2020) Aditya Garg
@ 2021-11-29  7:46                                   ` Aditya Garg
  1 sibling, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:46 UTC (permalink / raw)
  To: Thorsten Leemhuis
  Cc: Marcel Holtmann, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Bluetooth on Apple MacBook Pro 16,4 is unable to start due to LE Min/Max Tx Power being queried on 
startup. Add a DMI based quirk so that it is disabled.

v2: Wrap changelog in 72 columns.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/bluetooth/btbcm.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index 348a4afa0774e..88214b453b0ce 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -363,6 +363,15 @@ static const struct dmi_system_id disable_broken_read_transmit_power[] = {
 			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
 		},
 	},
+	{
+		/* Match for Apple MacBook Pro 16,4 which needs
+		 * Read LE Min/Max Tx Power to be disabled.
+		 */
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
 	{ }
 };
 


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

* Re: [PATCH v2 1/6] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  7:42                               ` [PATCH v2 " Aditya Garg
@ 2021-11-29  7:47                                 ` Greg KH
  2021-11-29  7:49                                   ` Aditya Garg
  2021-11-29  7:47                                 ` Greg KH
  2021-11-29  8:05                                 ` Marcel Holtmann
  2 siblings, 1 reply; 54+ messages in thread
From: Greg KH @ 2021-11-29  7:47 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Thorsten Leemhuis, Marcel Holtmann, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

On Mon, Nov 29, 2021 at 07:42:39AM +0000, Aditya Garg wrote:
> From: Aditya Garg <gargaditya08@live.com>
> 
> Some devices have a bug causing them to not work if they query LE tx power on startup. Thus we add a 
> quirk in order to not query it and default min/max tx power values to HCI_TX_POWER_INVALID.
> 
> v2: Wrap the changeling at 72 columns, correct email and remove tested by.

These lines are not wrapped at 72 columns :(

Also the changes line goes below the --- line, as documented in the
kernel documentation on how to submit a patch.

thanks,

greg k-h

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

* Re: [PATCH v2 1/6] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  7:42                               ` [PATCH v2 " Aditya Garg
  2021-11-29  7:47                                 ` Greg KH
@ 2021-11-29  7:47                                 ` Greg KH
  2021-11-29  8:05                                 ` Marcel Holtmann
  2 siblings, 0 replies; 54+ messages in thread
From: Greg KH @ 2021-11-29  7:47 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Thorsten Leemhuis, Marcel Holtmann, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

On Mon, Nov 29, 2021 at 07:42:39AM +0000, Aditya Garg wrote:
> From: Aditya Garg <gargaditya08@live.com>
> 
> Some devices have a bug causing them to not work if they query LE tx power on startup. Thus we add a 
> quirk in order to not query it and default min/max tx power values to HCI_TX_POWER_INVALID.
> 
> v2: Wrap the changeling at 72 columns, correct email and remove tested by.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> ---
>  include/net/bluetooth/hci.h | 9 +++++++++
>  net/bluetooth/hci_core.c    | 3 ++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
> +	 *
> +	 * This quirk can be set before hci_register_dev is called or
> +	 * during the hdev->setup vendor callback.
> +	 */
> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
>  };
>  
>  /* HCI device flags */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 8d33aa64846b1c..434c6878fe9640 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
>  			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
>  		}
>  
> -		if (hdev->commands[38] & 0x80) {
> +		if (hdev->commands[38] & 0x80 &&
> +		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {

You did not fix this formatting?  Why not?

thanks,

greg k-h

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

* Re: [PATCH v2 1/6] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  7:47                                 ` Greg KH
@ 2021-11-29  7:49                                   ` Aditya Garg
  0 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  7:49 UTC (permalink / raw)
  To: Greg KH
  Cc: Thorsten Leemhuis, Marcel Holtmann, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable



> On 29-Nov-2021, at 1:17 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> On Mon, Nov 29, 2021 at 07:42:39AM +0000, Aditya Garg wrote:
>> From: Aditya Garg <gargaditya08@live.com>
>> 
>> Some devices have a bug causing them to not work if they query LE tx power on startup. Thus we add a 
>> quirk in order to not query it and default min/max tx power values to HCI_TX_POWER_INVALID.
>> 
>> v2: Wrap the changeling at 72 columns, correct email and remove tested by.
> 
> These lines are not wrapped at 72 columns :(
If I am not wrong, you mean that there should be 72 characters in one line right?
> 
> Also the changes line goes below the --- line, as documented in the
> kernel documentation on how to submit a patch.
> 
> thanks,
> 
> greg k-h


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

* Re: [PATCH v2 1/6] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  7:42                               ` [PATCH v2 " Aditya Garg
  2021-11-29  7:47                                 ` Greg KH
  2021-11-29  7:47                                 ` Greg KH
@ 2021-11-29  8:05                                 ` Marcel Holtmann
  2021-11-29  8:32                                   ` [PATCH v3 1/2] " Aditya Garg
  2 siblings, 1 reply; 54+ messages in thread
From: Marcel Holtmann @ 2021-11-29  8:05 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

Hi Aditya,

> Some devices have a bug causing them to not work if they query LE tx power on startup. Thus we add a 
> quirk in order to not query it and default min/max tx power values to HCI_TX_POWER_INVALID.
> 
> v2: Wrap the changeling at 72 columns, correct email and remove tested by.

that part is for the reviewer and needs to go after ---. Otherwise please break
at 72 characters.

> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> ---
> include/net/bluetooth/hci.h | 9 +++++++++
> net/bluetooth/hci_core.c    | 3 ++-
> 2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
> +	 *
> +	 * This quirk can be set before hci_register_dev is called or
> +	 * during the hdev->setup vendor callback.
> +	 */
> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
> };
> 
> /* HCI device flags */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 8d33aa64846b1c..434c6878fe9640 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
> 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
> 		}
> 
> -		if (hdev->commands[38] & 0x80) {
> +		if (hdev->commands[38] & 0x80 &&
> +		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {

	if ((hdev->commands[38] & 0x80) &&
	    !test_bit(HCI_QUIRK_.., &hdev->quirks)) {

> 			/* Read LE Min/Max Tx Power*/
> 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
> 				    0, NULL);
> 

Regards

Marcel


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

* Re: [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019)
  2021-11-29  7:27                             ` [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019) Aditya Garg
  2021-11-29  7:28                               ` [PATCH 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020) Aditya Garg
  2021-11-29  7:44                               ` [PATCH v2 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019) Aditya Garg
@ 2021-11-29  8:08                               ` Marcel Holtmann
  2021-11-29  8:11                                 ` Aditya Garg
  2 siblings, 1 reply; 54+ messages in thread
From: Marcel Holtmann @ 2021-11-29  8:08 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

Hi Aditya,

> Bluetooth on Apple MacBook Pro 16,1 is unable to start due to LE Min/Max Tx Power being queried on startup. Add a DMI based quirk so that it is disabled.

list all the MacBooks that you found problematic right now. We add the
initial as a large batch instead of all individual.

> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> Tested-by: Aditya Garg <gargaditya08@live.com>
> ---
> drivers/bluetooth/btbcm.c | 20 ++++++++++++++++++++
> 1 file changed, 20 insertions(+)
> 
> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
> index e4182acee488c5..c1b0ca63880a68 100644
> --- a/drivers/bluetooth/btbcm.c
> +++ b/drivers/bluetooth/btbcm.c
> @@ -8,6 +8,7 @@
> 
> #include <linux/module.h>
> #include <linux/firmware.h>
> +#include <linux/dmi.h>
> #include <asm/unaligned.h>
> 
> #include <net/bluetooth/bluetooth.h>
> @@ -343,9 +344,23 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
> 	return skb;
> }
> 
> +static const struct dmi_system_id disable_broken_read_transmit_power[] = {
> +	{
> +		/* Match for Apple MacBook Pro 16,1 which needs
> +		 * Read LE Min/Max Tx Power to be disabled.
> +		 */

Actually leave the comment out. You are not adding any value that isn’t
already in the variable name or the DMI. It is just repeating the obvious.

> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
> +		},
> +	},
> +	{ }
> +};
> +
> static int btbcm_read_info(struct hci_dev *hdev)
> {
> 	struct sk_buff *skb;
> +	const struct dmi_system_id *dmi_id;
> 
> 	/* Read Verbose Config Version Info */
> 	skb = btbcm_read_verbose_config(hdev);
> @@ -362,6 +377,11 @@ static int btbcm_read_info(struct hci_dev *hdev)
> 
> 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
> 	kfree_skb(skb);
> +
> +	/* Read DMI and disable broken Read LE Min/Max Tx Power */
> +	dmi_id = dmi_first_match(disable_broken_read_transmit_power);
> +	if (dmi_id)
> +		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);

	if (dmi_first_match(..))
		set_bit(.., &hdev->quirks);

There is really no need to have a variable for this.

Regards

Marcel


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

* Re: [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019)
  2021-11-29  8:08                               ` [PATCH " Marcel Holtmann
@ 2021-11-29  8:11                                 ` Aditya Garg
  2021-11-29  8:22                                   ` Marcel Holtmann
  0 siblings, 1 reply; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  8:11 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable



> On 29-Nov-2021, at 1:38 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> 
> Hi Aditya,
> 
>> Bluetooth on Apple MacBook Pro 16,1 is unable to start due to LE Min/Max Tx Power being queried on startup. Add a DMI based quirk so that it is disabled.
> 
> list all the MacBooks that you found problematic right now. We add the
> initial as a large batch instead of all individual.
> 
>> 
>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>> Tested-by: Aditya Garg <gargaditya08@live.com>
>> ---
>> drivers/bluetooth/btbcm.c | 20 ++++++++++++++++++++
>> 1 file changed, 20 insertions(+)
>> 
>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>> index e4182acee488c5..c1b0ca63880a68 100644
>> --- a/drivers/bluetooth/btbcm.c
>> +++ b/drivers/bluetooth/btbcm.c
>> @@ -8,6 +8,7 @@
>> 
>> #include <linux/module.h>
>> #include <linux/firmware.h>
>> +#include <linux/dmi.h>
>> #include <asm/unaligned.h>
>> 
>> #include <net/bluetooth/bluetooth.h>
>> @@ -343,9 +344,23 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
>> 	return skb;
>> }
>> 
>> +static const struct dmi_system_id disable_broken_read_transmit_power[] = {
>> +	{
>> +		/* Match for Apple MacBook Pro 16,1 which needs
>> +		 * Read LE Min/Max Tx Power to be disabled.
>> +		 */
> 
> Actually leave the comment out. You are not adding any value that isn’t
> already in the variable name or the DMI. It is just repeating the obvious.
Alright, I prepare the patches into a single one
> 
>> +		 .matches = {
>> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
>> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
>> +		},
>> +	},
>> +	{ }
>> +};
>> +
>> static int btbcm_read_info(struct hci_dev *hdev)
>> {
>> 	struct sk_buff *skb;
>> +	const struct dmi_system_id *dmi_id;
>> 
>> 	/* Read Verbose Config Version Info */
>> 	skb = btbcm_read_verbose_config(hdev);
>> @@ -362,6 +377,11 @@ static int btbcm_read_info(struct hci_dev *hdev)
>> 
>> 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
>> 	kfree_skb(skb);
>> +
>> +	/* Read DMI and disable broken Read LE Min/Max Tx Power */
>> +	dmi_id = dmi_first_match(disable_broken_read_transmit_power);
>> +	if (dmi_id)
>> +		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
> 
> 	if (dmi_first_match(..))
> 		set_bit(.., &hdev->quirks);
> 
> There is really no need to have a variable for this.
Fine, Ill correct this
> 
> Regards
> 
> Marcel
> 


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

* Re: [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019)
  2021-11-29  8:11                                 ` Aditya Garg
@ 2021-11-29  8:22                                   ` Marcel Holtmann
  2021-11-29  8:42                                     ` Aditya Garg
  0 siblings, 1 reply; 54+ messages in thread
From: Marcel Holtmann @ 2021-11-29  8:22 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

Hi Aditya,

>>> Bluetooth on Apple MacBook Pro 16,1 is unable to start due to LE Min/Max Tx Power being queried on startup. Add a DMI based quirk so that it is disabled.
>> 
>> list all the MacBooks that you found problematic right now. We add the
>> initial as a large batch instead of all individual.
>> 
>>> 
>>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>>> Tested-by: Aditya Garg <gargaditya08@live.com>
>>> ---
>>> drivers/bluetooth/btbcm.c | 20 ++++++++++++++++++++
>>> 1 file changed, 20 insertions(+)
>>> 
>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>> index e4182acee488c5..c1b0ca63880a68 100644
>>> --- a/drivers/bluetooth/btbcm.c
>>> +++ b/drivers/bluetooth/btbcm.c
>>> @@ -8,6 +8,7 @@
>>> 
>>> #include <linux/module.h>
>>> #include <linux/firmware.h>
>>> +#include <linux/dmi.h>
>>> #include <asm/unaligned.h>
>>> 
>>> #include <net/bluetooth/bluetooth.h>
>>> @@ -343,9 +344,23 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
>>> 	return skb;
>>> }
>>> 
>>> +static const struct dmi_system_id disable_broken_read_transmit_power[] = {
>>> +	{
>>> +		/* Match for Apple MacBook Pro 16,1 which needs
>>> +		 * Read LE Min/Max Tx Power to be disabled.
>>> +		 */
>> 
>> Actually leave the comment out. You are not adding any value that isn’t
>> already in the variable name or the DMI. It is just repeating the obvious.
> Alright, I prepare the patches into a single one

two patches, one for adding the quirk to the core and one for adjusting the driver.

Regards

Marcel


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

* Re: [PATCH v3 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  8:05                                 ` Marcel Holtmann
@ 2021-11-29  8:32                                   ` Aditya Garg
  2021-11-29  8:35                                     ` [PATCH v3 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
                                                       ` (3 more replies)
  0 siblings, 4 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  8:32 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_core.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
 		}
 
-		if (hdev->commands[38] & 0x80) {
+		if (hdev->commands[38] & 0x80 &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
 			/* Read LE Min/Max Tx Power*/
 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
 				    0, NULL);


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

* [PATCH v3 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-29  8:32                                   ` [PATCH v3 1/2] " Aditya Garg
@ 2021-11-29  8:35                                     ` Aditya Garg
  2021-11-29  8:50                                       ` [PATCH v3 resend " Aditya Garg
  2021-11-29  8:47                                     ` [PATCH v3 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
                                                       ` (2 subsequent siblings)
  3 siblings, 1 reply; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  8:35 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
 drivers/bluetooth/btbcm.c | 40 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..40f7c9c5cf0a5a 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,9 +344,44 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
+	const struct dmi_system_id *dmi_id;
 
 	/* Read Verbose Config Version Info */
 	skb = btbcm_read_verbose_config(hdev);
@@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
 
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
 	return 0;
 }
 


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

* Re: [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019)
  2021-11-29  8:22                                   ` Marcel Holtmann
@ 2021-11-29  8:42                                     ` Aditya Garg
  0 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  8:42 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler, Greg KH,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable



> On 29-Nov-2021, at 1:52 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> 
> Hi Aditya,
> 
>>>> Bluetooth on Apple MacBook Pro 16,1 is unable to start due to LE Min/Max Tx Power being queried on startup. Add a DMI based quirk so that it is disabled.
>>> 
>>> list all the MacBooks that you found problematic right now. We add the
>>> initial as a large batch instead of all individual.
>>> 
>>>> 
>>>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>>>> Tested-by: Aditya Garg <gargaditya08@live.com>
>>>> ---
>>>> drivers/bluetooth/btbcm.c | 20 ++++++++++++++++++++
>>>> 1 file changed, 20 insertions(+)
>>>> 
>>>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>>>> index e4182acee488c5..c1b0ca63880a68 100644
>>>> --- a/drivers/bluetooth/btbcm.c
>>>> +++ b/drivers/bluetooth/btbcm.c
>>>> @@ -8,6 +8,7 @@
>>>> 
>>>> #include <linux/module.h>
>>>> #include <linux/firmware.h>
>>>> +#include <linux/dmi.h>
>>>> #include <asm/unaligned.h>
>>>> 
>>>> #include <net/bluetooth/bluetooth.h>
>>>> @@ -343,9 +344,23 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
>>>> 	return skb;
>>>> }
>>>> 
>>>> +static const struct dmi_system_id disable_broken_read_transmit_power[] = {
>>>> +	{
>>>> +		/* Match for Apple MacBook Pro 16,1 which needs
>>>> +		 * Read LE Min/Max Tx Power to be disabled.
>>>> +		 */
>>> 
>>> Actually leave the comment out. You are not adding any value that isn’t
>>> already in the variable name or the DMI. It is just repeating the obvious.
>> Alright, I prepare the patches into a single one
> 
> two patches, one for adding the quirk to the core and one for adjusting the driver.
Sent
> 
> Regards
> 
> Marcel
> 


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

* [PATCH v3 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  8:32                                   ` [PATCH v3 1/2] " Aditya Garg
  2021-11-29  8:35                                     ` [PATCH v3 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
@ 2021-11-29  8:47                                     ` Aditya Garg
  2021-11-29  9:03                                       ` [PATCH v4 " Aditya Garg
  2021-11-29  8:52                                     ` [PATCH v3 " Thorsten Leemhuis
  2021-11-29 11:02                                     ` Marcel Holtmann
  3 siblings, 1 reply; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  8:47 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
include/net/bluetooth/hci.h | 9 +++++++++
net/bluetooth/hci_core.c    | 3 ++-
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
};

/* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
		}

-		if (hdev->commands[38] & 0x80) {
+		if (hdev->commands[38] & 0x80 &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
			/* Read LE Min/Max Tx Power*/
			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
				    0, NULL);

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

* [PATCH v3 resend 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-29  8:35                                     ` [PATCH v3 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
@ 2021-11-29  8:50                                       ` Aditya Garg
  2021-11-29  9:05                                         ` [PATCH v4 " Aditya Garg
  2021-11-29 11:03                                         ` [PATCH v3 resend " Marcel Holtmann
  0 siblings, 2 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  8:50 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
---
drivers/bluetooth/btbcm.c | 40 +++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..40f7c9c5cf0a5a 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@

#include <linux/module.h>
#include <linux/firmware.h>
+#include <linux/dmi.h>
#include <asm/unaligned.h>

#include <net/bluetooth/bluetooth.h>
@@ -343,9 +344,44 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
	return skb;
}

+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
static int btbcm_read_info(struct hci_dev *hdev)
{
	struct sk_buff *skb;
+	const struct dmi_system_id *dmi_id;

	/* Read Verbose Config Version Info */
	skb = btbcm_read_verbose_config(hdev);
@@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
	kfree_skb(skb);

+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
	return 0;
}

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

* Re: [PATCH v3 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  8:32                                   ` [PATCH v3 1/2] " Aditya Garg
  2021-11-29  8:35                                     ` [PATCH v3 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
  2021-11-29  8:47                                     ` [PATCH v3 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
@ 2021-11-29  8:52                                     ` Thorsten Leemhuis
  2021-11-29 11:02                                     ` Marcel Holtmann
  3 siblings, 0 replies; 54+ messages in thread
From: Thorsten Leemhuis @ 2021-11-29  8:52 UTC (permalink / raw)
  To: Aditya Garg, Marcel Holtmann
  Cc: Greg KH, Orlando Chamberlain, Daniel Winkler, Johan Hedberg,
	linux-bluetooth, linux-kernel, Luiz Augusto von Dentz,
	regressions, sonnysasaka, stable

Hi! Great to see progress for this regression.

On 29.11.21 09:32, Aditya Garg wrote:
> From: Aditya Garg <gargaditya08@live.com>
> 
> Some devices have a bug causing them to not work if they query 
> LE tx power on startup. Thus we add a quirk in order to not query it 
> and default min/max tx power values to HCI_TX_POWER_INVALID.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> ---

FWIW: In case you need to send an improved patch, could you please add
this after your 'Signed-off-by:' (see at (¹) below for the reasoning):

Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")

And if the patch is already good to go: could the subsystem maintainer
please add it when applying? See (¹) for the reasoning.

Ciao, Thorsten, your Linux kernel regression tracker.


(¹) Long story: The commit message would benefit from a link to the
regression report, for reasons explained in
Documentation/process/submitting-patches.rst. To quote:

```
If related discussions or any other background information behind the
change can be found on the web, add 'Link:' tags pointing to it. In case
your patch fixes a bug, for example, add a tag with a URL referencing
the report in the mailing list archives or a bug tracker;
```

This concept is old, but the text was reworked recently to make this use
case for the Link: tag clearer. For details see:
https://git.kernel.org/linus/1f57bd42b77c

Yes, that "Link:" is not really crucial; but it's good to have if
someone needs to look into the backstory of this change sometime in the
future. But I care for a different reason. I'm tracking this regression
(and others) with regzbot, my Linux kernel regression tracking bot. This
bot will notice if a patch with a Link: tag to a tracked regression gets
posted and record that, which allowed anyone looking into the regression
to quickly gasp the current status from regzbot's webui
(https://linux-regtracking.leemhuis.info/regzbot ) or its reports. The
bot will also notice if a commit with a Link: tag to a regression report
is applied by Linus and then automatically mark the regression as
resolved then.

IOW: this tag makes my life a regression tracker a lot easier, as I
otherwise have to tell regzbot manually when the fix lands. :-/


P.S.: As a Linux kernel regression tracker I'm getting a lot of reports
on my table. I can only look briefly into most of them. Unfortunately
therefore I sometimes will get things wrong or miss something important.
I hope that's not the case here; if you think it is, don't hesitate to
tell me about it in a public reply. That's in everyone's interest, as
what I wrote above might be misleading to everyone reading this; any
suggestion I gave they thus might sent someone reading this down the
wrong rabbit hole, which none of us wants.

BTW, I have no personal interest in this issue, which is tracked using
regzbot, my Linux kernel regression tracking bot
(https://linux-regtracking.leemhuis.info/regzbot/). I'm only posting
this mail to get things rolling again and hence don't need to be CC on
all further activities wrt to this regression.

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

* [PATCH v4 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  8:47                                     ` [PATCH v3 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
@ 2021-11-29  9:03                                       ` Aditya Garg
  2021-11-29  9:24                                         ` [PATCH v5 " Aditya Garg
  0 siblings, 1 reply; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  9:03 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
include/net/bluetooth/hci.h | 9 +++++++++
net/bluetooth/hci_core.c    | 3 ++-
2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
};

/* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
		}

-		if (hdev->commands[38] & 0x80) {
+		if (hdev->commands[38] & 0x80 &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
			/* Read LE Min/Max Tx Power*/
			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
				    0, NULL);

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

* [PATCH v4 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-29  8:50                                       ` [PATCH v3 resend " Aditya Garg
@ 2021-11-29  9:05                                         ` Aditya Garg
  2021-11-29  9:25                                           ` [PATCH v5 " Aditya Garg
  2021-11-29 11:03                                         ` [PATCH v3 resend " Marcel Holtmann
  1 sibling, 1 reply; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  9:05 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
drivers/bluetooth/btbcm.c | 40 +++++++++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..40f7c9c5cf0a5a 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@

#include <linux/module.h>
#include <linux/firmware.h>
+#include <linux/dmi.h>
#include <asm/unaligned.h>

#include <net/bluetooth/bluetooth.h>
@@ -343,9 +344,44 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
	return skb;
}

+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
static int btbcm_read_info(struct hci_dev *hdev)
{
	struct sk_buff *skb;
+	const struct dmi_system_id *dmi_id;

	/* Read Verbose Config Version Info */
	skb = btbcm_read_verbose_config(hdev);
@@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
	kfree_skb(skb);

+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
	return 0;
}

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

* [PATCH v5 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  9:03                                       ` [PATCH v4 " Aditya Garg
@ 2021-11-29  9:24                                         ` Aditya Garg
  2021-11-29 13:59                                           ` [PATCH v6 " Aditya Garg
  0 siblings, 1 reply; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  9:24 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_core.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
 		}
 
-		if (hdev->commands[38] & 0x80) {
+		if (hdev->commands[38] & 0x80 &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
 			/* Read LE Min/Max Tx Power*/
 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
 				    0, NULL);


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

* [PATCH v5 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-29  9:05                                         ` [PATCH v4 " Aditya Garg
@ 2021-11-29  9:25                                           ` Aditya Garg
  0 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29  9:25 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
 drivers/bluetooth/btbcm.c | 40 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..40f7c9c5cf0a5a 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,9 +344,44 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
+	const struct dmi_system_id *dmi_id;
 
 	/* Read Verbose Config Version Info */
 	skb = btbcm_read_verbose_config(hdev);
@@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
 
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
 	return 0;
 }
 


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

* Re: [PATCH v3 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  8:32                                   ` [PATCH v3 1/2] " Aditya Garg
                                                       ` (2 preceding siblings ...)
  2021-11-29  8:52                                     ` [PATCH v3 " Thorsten Leemhuis
@ 2021-11-29 11:02                                     ` Marcel Holtmann
  3 siblings, 0 replies; 54+ messages in thread
From: Marcel Holtmann @ 2021-11-29 11:02 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

Hi Aditya,

> Some devices have a bug causing them to not work if they query 
> LE tx power on startup. Thus we add a quirk in order to not query it 
> and default min/max tx power values to HCI_TX_POWER_INVALID.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> ---
> include/net/bluetooth/hci.h | 9 +++++++++
> net/bluetooth/hci_core.c    | 3 ++-
> 2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
> +	 *
> +	 * This quirk can be set before hci_register_dev is called or
> +	 * during the hdev->setup vendor callback.
> +	 */
> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
> };
> 
> /* HCI device flags */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 8d33aa64846b1c..434c6878fe9640 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
> 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
> 		}
> 
> -		if (hdev->commands[38] & 0x80) {
> +		if (hdev->commands[38] & 0x80 &&
> +		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {

		if ((hdev->commands[38] && 0x80) &&
		    !test_bit(HCI_QUIRK_.., &hdev->quirks)) {

> 			/* Read LE Min/Max Tx Power*/
> 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
> 				    0, NULL);
> 

Regards

Marcel


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

* Re: [PATCH v3 resend 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-29  8:50                                       ` [PATCH v3 resend " Aditya Garg
  2021-11-29  9:05                                         ` [PATCH v4 " Aditya Garg
@ 2021-11-29 11:03                                         ` Marcel Holtmann
  2021-11-29 12:01                                           ` Aditya Garg
  1 sibling, 1 reply; 54+ messages in thread
From: Marcel Holtmann @ 2021-11-29 11:03 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

Hi Aditya,

> Some Macs with the T2 security chip had Bluetooth not working.
> To fix it we add DMI based quirks to disable querying of LE Tx power.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> ---
> drivers/bluetooth/btbcm.c | 40 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
> 
> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
> index e4182acee488c5..40f7c9c5cf0a5a 100644
> --- a/drivers/bluetooth/btbcm.c
> +++ b/drivers/bluetooth/btbcm.c
> @@ -8,6 +8,7 @@
> 
> #include <linux/module.h>
> #include <linux/firmware.h>
> +#include <linux/dmi.h>
> #include <asm/unaligned.h>
> 
> #include <net/bluetooth/bluetooth.h>
> @@ -343,9 +344,44 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
> 	return skb;
> }
> 
> +static const struct dmi_system_id disable_broken_read_transmit_power[] = {
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
> +		},
> +	},
> +	{ }
> +};
> +
> static int btbcm_read_info(struct hci_dev *hdev)
> {
> 	struct sk_buff *skb;
> +	const struct dmi_system_id *dmi_id;

this variable is not needed.

> 
> 	/* Read Verbose Config Version Info */
> 	skb = btbcm_read_verbose_config(hdev);
> @@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
> 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
> 	kfree_skb(skb);
> 
> +	/* Read DMI and disable broken Read LE Min/Max Tx Power */
> +	if (dmi_first_match(disable_broken_read_transmit_power))
> +		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
> +
> 	return 0;
> }

Regards

Marcel


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

* Re: [PATCH v3 resend 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-29 11:03                                         ` [PATCH v3 resend " Marcel Holtmann
@ 2021-11-29 12:01                                           ` Aditya Garg
  0 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29 12:01 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable



> On 29-Nov-2021, at 4:33 PM, Marcel Holtmann <marcel@holtmann.org> wrote:
> 
> Hi Aditya,
> 
>> Some Macs with the T2 security chip had Bluetooth not working.
>> To fix it we add DMI based quirks to disable querying of LE Tx power.
>> 
>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>> ---
>> drivers/bluetooth/btbcm.c | 40 +++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 40 insertions(+)
>> 
>> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
>> index e4182acee488c5..40f7c9c5cf0a5a 100644
>> --- a/drivers/bluetooth/btbcm.c
>> +++ b/drivers/bluetooth/btbcm.c
>> @@ -8,6 +8,7 @@
>> 
>> #include <linux/module.h>
>> #include <linux/firmware.h>
>> +#include <linux/dmi.h>
>> #include <asm/unaligned.h>
>> 
>> #include <net/bluetooth/bluetooth.h>
>> @@ -343,9 +344,44 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
>> 	return skb;
>> }
>> 
>> +static const struct dmi_system_id disable_broken_read_transmit_power[] = {
>> +	{
>> +		 .matches = {
>> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
>> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
>> +		},
>> +	},
>> +	{
>> +		 .matches = {
>> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
>> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
>> +		},
>> +	},
>> +	{
>> +		 .matches = {
>> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
>> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
>> +		},
>> +	},
>> +	{
>> +		 .matches = {
>> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
>> +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
>> +		},
>> +	},
>> +	{
>> +		 .matches = {
>> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
>> +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
>> +		},
>> +	},
>> +	{ }
>> +};
>> +
>> static int btbcm_read_info(struct hci_dev *hdev)
>> {
>> 	struct sk_buff *skb;
>> +	const struct dmi_system_id *dmi_id;
> 
> this variable is not needed.
You want me to replace const struct dmi_system_id *dmi_id; with const struct dmi_system_id or remove it altogether.

>> 
>> 	/* Read Verbose Config Version Info */
>> 	skb = btbcm_read_verbose_config(hdev);
>> @@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
>> 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
>> 	kfree_skb(skb);
>> 
>> +	/* Read DMI and disable broken Read LE Min/Max Tx Power */
>> +	if (dmi_first_match(disable_broken_read_transmit_power))
>> +		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
>> +
>> 	return 0;
>> }
> 
> Regards
> 
> Marcel
> 


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

* [PATCH v6 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29  9:24                                         ` [PATCH v5 " Aditya Garg
@ 2021-11-29 13:59                                           ` Aditya Garg
  2021-11-29 14:00                                             ` [PATCH v6 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
  2021-11-30 11:38                                             ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
  0 siblings, 2 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29 13:59 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_core.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
 		}
 
-		if (hdev->commands[38] & 0x80) {
+		if ((hdev->commands[38] & 0x80) &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
 			/* Read LE Min/Max Tx Power*/
 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
 				    0, NULL);


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

* [PATCH v6 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-29 13:59                                           ` [PATCH v6 " Aditya Garg
@ 2021-11-29 14:00                                             ` Aditya Garg
  2021-11-30  8:45                                               ` Aditya Garg
  2021-11-30 10:28                                               ` Orlando Chamberlain
  2021-11-30 11:38                                             ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
  1 sibling, 2 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-29 14:00 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
 drivers/bluetooth/btbcm.c | 40 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 40 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..40f7c9c5cf0a5a 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,9 +344,44 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
+	const struct dmi_system_id;
 
 	/* Read Verbose Config Version Info */
 	skb = btbcm_read_verbose_config(hdev);
@@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
 
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
 	return 0;
 }
 


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

* Re: [PATCH v6 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-29 14:00                                             ` [PATCH v6 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
@ 2021-11-30  8:45                                               ` Aditya Garg
  2021-11-30  8:54                                                 ` Greg KH
  2021-11-30 10:28                                               ` Orlando Chamberlain
  1 sibling, 1 reply; 54+ messages in thread
From: Aditya Garg @ 2021-11-30  8:45 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable



> On 29-Nov-2021, at 7:30 PM, Aditya Garg <gargaditya08@live.com> wrote:
> 
> From: Aditya Garg <gargaditya08@live.com>
> 
> Some Macs with the T2 security chip had Bluetooth not working.
> To fix it we add DMI based quirks to disable querying of LE Tx power.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
> Link:
> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
> ---
> drivers/bluetooth/btbcm.c | 40 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 40 insertions(+)
> 
> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
> index e4182acee488c5..40f7c9c5cf0a5a 100644
> --- a/drivers/bluetooth/btbcm.c
> +++ b/drivers/bluetooth/btbcm.c
> @@ -8,6 +8,7 @@
> 
> #include <linux/module.h>
> #include <linux/firmware.h>
> +#include <linux/dmi.h>
> #include <asm/unaligned.h>
> 
> #include <net/bluetooth/bluetooth.h>
> @@ -343,9 +344,44 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
> 	return skb;
> }
> 
> +static const struct dmi_system_id disable_broken_read_transmit_power[] = {
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
> +		},
> +	},
> +	{ }
> +};
> +
> static int btbcm_read_info(struct hci_dev *hdev)
> {
> 	struct sk_buff *skb;
> +	const struct dmi_system_id;
> 
> 	/* Read Verbose Config Version Info */
> 	skb = btbcm_read_verbose_config(hdev);
> @@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
> 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
> 	kfree_skb(skb);
> 
> +	/* Read DMI and disable broken Read LE Min/Max Tx Power */
> +	if (dmi_first_match(disable_broken_read_transmit_power))
> +		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
> +
> 	return 0;
> }
> 
May I know whether this is fine or not.
> 


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

* Re: [PATCH v6 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-30  8:45                                               ` Aditya Garg
@ 2021-11-30  8:54                                                 ` Greg KH
  0 siblings, 0 replies; 54+ messages in thread
From: Greg KH @ 2021-11-30  8:54 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Marcel Holtmann, Thorsten Leemhuis, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

On Tue, Nov 30, 2021 at 08:45:44AM +0000, Aditya Garg wrote:
> 
> 
> > On 29-Nov-2021, at 7:30 PM, Aditya Garg <gargaditya08@live.com> wrote:
> > 
> > From: Aditya Garg <gargaditya08@live.com>
> > 
> > Some Macs with the T2 security chip had Bluetooth not working.
> > To fix it we add DMI based quirks to disable querying of LE Tx power.
> > 
> > Signed-off-by: Aditya Garg <gargaditya08@live.com>
> > Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
> > Link:
> > https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
> > Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
> > ---
> > drivers/bluetooth/btbcm.c | 40 +++++++++++++++++++++++++++++++++++++++
> > 1 file changed, 40 insertions(+)
> > 
> > diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
> > index e4182acee488c5..40f7c9c5cf0a5a 100644
> > --- a/drivers/bluetooth/btbcm.c
> > +++ b/drivers/bluetooth/btbcm.c
> > @@ -8,6 +8,7 @@
> > 
> > #include <linux/module.h>
> > #include <linux/firmware.h>
> > +#include <linux/dmi.h>
> > #include <asm/unaligned.h>
> > 
> > #include <net/bluetooth/bluetooth.h>
> > @@ -343,9 +344,44 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
> > 	return skb;
> > }
> > 
> > +static const struct dmi_system_id disable_broken_read_transmit_power[] = {
> > +	{
> > +		 .matches = {
> > +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> > +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
> > +		},
> > +	},
> > +	{
> > +		 .matches = {
> > +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> > +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
> > +		},
> > +	},
> > +	{
> > +		 .matches = {
> > +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> > +			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
> > +		},
> > +	},
> > +	{
> > +		 .matches = {
> > +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> > +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
> > +		},
> > +	},
> > +	{
> > +		 .matches = {
> > +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> > +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
> > +		},
> > +	},
> > +	{ }
> > +};
> > +
> > static int btbcm_read_info(struct hci_dev *hdev)
> > {
> > 	struct sk_buff *skb;
> > +	const struct dmi_system_id;
> > 
> > 	/* Read Verbose Config Version Info */
> > 	skb = btbcm_read_verbose_config(hdev);
> > @@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
> > 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
> > 	kfree_skb(skb);
> > 
> > +	/* Read DMI and disable broken Read LE Min/Max Tx Power */
> > +	if (dmi_first_match(disable_broken_read_transmit_power))
> > +		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
> > +
> > 	return 0;
> > }
> > 
> May I know whether this is fine or not.

Please realize that maintainers have lots and lots of patches to review.
If after 2 weeks of no response, it is fine to resend the patch again.

If you wish to help out with the maintainer's review load, please feel
free to review patches on the relevant mailing list to help lighten that
load such that your patch can be reviewed quicker.

thanks,

greg k-h

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

* Re: [PATCH v6 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-29 14:00                                             ` [PATCH v6 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
  2021-11-30  8:45                                               ` Aditya Garg
@ 2021-11-30 10:28                                               ` Orlando Chamberlain
  1 sibling, 0 replies; 54+ messages in thread
From: Orlando Chamberlain @ 2021-11-30 10:28 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Marcel Holtmann, Daniel Winkler, Johan Hedberg, linux-bluetooth,
	linux-kernel, Luiz Augusto von Dentz, regressions, sonnysasaka,
	stable

On Tue, 30 Nov 2021 01:00:43 +1100
"Aditya Garg" <gargaditya08@live.com> wrote:
> From: Aditya Garg <gargaditya08@live.com>
> 
> Some Macs with the T2 security chip had Bluetooth not working.
> To fix it we add DMI based quirks to disable querying of LE Tx power.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
> Link:
> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
> ---

It's hard to tell what the differences between versions of this patch
are. This spot here after the "---" is often used for a change log
(e.g. "v5->v6: Made change X and change Y"), so it would be useful to
have that if you can add one in future patches. I think someone may have
mentioned this earlier.

>  drivers/bluetooth/btbcm.c | 40
> +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40
> insertions(+)
> 
> diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
> index e4182acee488c5..40f7c9c5cf0a5a 100644
> --- a/drivers/bluetooth/btbcm.c
> +++ b/drivers/bluetooth/btbcm.c
> @@ -8,6 +8,7 @@
> 
>  #include <linux/module.h>
>  #include <linux/firmware.h>
> +#include <linux/dmi.h>
>  #include <asm/unaligned.h>
> 
>  #include <net/bluetooth/bluetooth.h>
> @@ -343,9 +344,44 @@ static struct sk_buff
> *btbcm_read_usb_product(struct hci_dev *hdev) return skb;
>  }
> 
> +static const struct dmi_system_id
> disable_broken_read_transmit_power[] = {
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME,
> "MacBookPro16,1"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME,
> "MacBookPro16,2"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME,
> "MacBookPro16,4"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
> +		},
> +	},
> +	{
> +		 .matches = {
> +			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
> +			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
> +		},
> +	},
> +	{ }
> +};
> +
>  static int btbcm_read_info(struct hci_dev *hdev)
>  {
>  	struct sk_buff *skb;
> +	const struct dmi_system_id;

This line seems to produce a compiler warning:

drivers/bluetooth/btbcm.c: In function ‘btbcm_read_info’:
drivers/bluetooth/btbcm.c:384:22: warning: empty declaration with type
qualifier does not redeclare  tag
  384 |         const struct dmi_system_id;
      |                      ^~~~~~~~~~~~~

I think Marcel mentioned this line could be removed.

The two patches make Bluetooth work on my MacBookPro16,1, with and without
that line.

Tested-by: Orlando Chamberlain <redecorating@protonmail.com>

> 
>  	/* Read Verbose Config Version Info */
>  	skb = btbcm_read_verbose_config(hdev);
> @@ -363,6 +399,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
>  	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
>  	kfree_skb(skb);
> 
> +	/* Read DMI and disable broken Read LE Min/Max Tx Power */
> +	if (dmi_first_match(disable_broken_read_transmit_power))
> +		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
> &hdev->quirks); +
>  	return 0;
>  }
> 
> 

-- 

Thanks,

Orlando


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

* [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-29 13:59                                           ` [PATCH v6 " Aditya Garg
  2021-11-29 14:00                                             ` [PATCH v6 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
@ 2021-11-30 11:38                                             ` Aditya Garg
  2021-11-30 11:40                                               ` [PATCH v7 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
                                                                 ` (2 more replies)
  1 sibling, 3 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-30 11:38 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
v7 :- Added Tested-by.
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_core.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
 		}
 
-		if (hdev->commands[38] & 0x80) {
+		if ((hdev->commands[38] & 0x80) &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
 			/* Read LE Min/Max Tx Power*/
 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
 				    0, NULL);


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

* [PATCH v7 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-30 11:38                                             ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
@ 2021-11-30 11:40                                               ` Aditya Garg
  2021-11-30 11:41                                               ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
  2021-11-30 11:48                                               ` [PATCH v7 resend " Aditya Garg
  2 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-30 11:40 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
v7 :- Removed unused variable and added Tested-by.
 drivers/bluetooth/btbcm.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..07fabaa5aa2979 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,6 +344,40 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
@@ -363,6 +398,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
 
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
 	return 0;
 }
 


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

* Re: [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-30 11:38                                             ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
  2021-11-30 11:40                                               ` [PATCH v7 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
@ 2021-11-30 11:41                                               ` Greg KH
  2021-11-30 11:50                                                 ` Aditya Garg
  2021-11-30 11:48                                               ` [PATCH v7 resend " Aditya Garg
  2 siblings, 1 reply; 54+ messages in thread
From: Greg KH @ 2021-11-30 11:41 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Marcel Holtmann, Thorsten Leemhuis, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

On Tue, Nov 30, 2021 at 11:38:58AM +0000, Aditya Garg wrote:
> From: Aditya Garg <gargaditya08@live.com>
> 
> Some devices have a bug causing them to not work if they query 
> LE tx power on startup. Thus we add a quirk in order to not query it 
> and default min/max tx power values to HCI_TX_POWER_INVALID.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
> Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
> Link:
> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
> ---
> v7 :- Added Tested-by.
>  include/net/bluetooth/hci.h | 9 +++++++++
>  net/bluetooth/hci_core.c    | 3 ++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
> +	 *
> +	 * This quirk can be set before hci_register_dev is called or
> +	 * during the hdev->setup vendor callback.
> +	 */
> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
>  };
>  
>  /* HCI device flags */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 8d33aa64846b1c..434c6878fe9640 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
>  			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
>  		}
>  
> -		if (hdev->commands[38] & 0x80) {
> +		if ((hdev->commands[38] & 0x80) &&
> +		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {

This line is still not properly formatted.

Please always use scripts/checkpatch.pl to find issues like this.

thanks,

greg k-h

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

* [PATCH v7 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-30 11:38                                             ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
  2021-11-30 11:40                                               ` [PATCH v7 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
  2021-11-30 11:41                                               ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
@ 2021-11-30 11:48                                               ` Aditya Garg
  2021-11-30 11:49                                                 ` [PATCH v7 resend 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
                                                                   ` (2 more replies)
  2 siblings, 3 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-30 11:48 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
v7 :- Added Tested-by.
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_core.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
 		}
 
-		if (hdev->commands[38] & 0x80) {
+		if ((hdev->commands[38] & 0x80) &&
+		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
 			/* Read LE Min/Max Tx Power*/
 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
 				    0, NULL);


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

* [PATCH v7 resend 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-30 11:48                                               ` [PATCH v7 resend " Aditya Garg
@ 2021-11-30 11:49                                                 ` Aditya Garg
  2021-11-30 12:03                                                 ` [PATCH v7 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
  2021-11-30 12:53                                                 ` [PATCH v8 " Aditya Garg
  2 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-30 11:49 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
v7 :- Removed unused variable and added Tested-by.
 drivers/bluetooth/btbcm.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..07fabaa5aa2979 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,6 +344,40 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
@@ -363,6 +398,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
 
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
 	return 0;
 }
 


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

* Re: [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-30 11:41                                               ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
@ 2021-11-30 11:50                                                 ` Aditya Garg
  0 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-30 11:50 UTC (permalink / raw)
  To: Greg KH
  Cc: Marcel Holtmann, Thorsten Leemhuis, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable



> On 30-Nov-2021, at 5:11 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> On Tue, Nov 30, 2021 at 11:38:58AM +0000, Aditya Garg wrote:
>> From: Aditya Garg <gargaditya08@live.com>
>> 
>> Some devices have a bug causing them to not work if they query 
>> LE tx power on startup. Thus we add a quirk in order to not query it 
>> and default min/max tx power values to HCI_TX_POWER_INVALID.
>> 
>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
>> Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
>> Link:
>> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
>> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
>> ---
>> v7 :- Added Tested-by.
>> include/net/bluetooth/hci.h | 9 +++++++++
>> net/bluetooth/hci_core.c    | 3 ++-
>> 2 files changed, 11 insertions(+), 1 deletion(-)
>> 
>> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
>> index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
>> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
>> +	 *
>> +	 * This quirk can be set before hci_register_dev is called or
>> +	 * during the hdev->setup vendor callback.
>> +	 */
>> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
>> };
>> 
>> /* HCI device flags */
>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>> index 8d33aa64846b1c..434c6878fe9640 100644
>> --- a/net/bluetooth/hci_core.c
>> +++ b/net/bluetooth/hci_core.c
>> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
>> 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
>> 		}
>> 
>> -		if (hdev->commands[38] & 0x80) {
>> +		if ((hdev->commands[38] & 0x80) &&
>> +		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
> 
> This line is still not properly formatted.
I hope its fine in the resent patch. I sent the patch as HTML by mistake.
> 
> Please always use scripts/checkpatch.pl to find issues like this.
> 
> thanks,
> 
> greg k-h


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

* Re: [PATCH v7 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-30 11:48                                               ` [PATCH v7 resend " Aditya Garg
  2021-11-30 11:49                                                 ` [PATCH v7 resend 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
@ 2021-11-30 12:03                                                 ` Greg KH
  2021-11-30 12:53                                                   ` Aditya Garg
  2021-11-30 12:53                                                 ` [PATCH v8 " Aditya Garg
  2 siblings, 1 reply; 54+ messages in thread
From: Greg KH @ 2021-11-30 12:03 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Marcel Holtmann, Thorsten Leemhuis, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

On Tue, Nov 30, 2021 at 11:48:25AM +0000, Aditya Garg wrote:
> From: Aditya Garg <gargaditya08@live.com>
> 
> Some devices have a bug causing them to not work if they query 
> LE tx power on startup. Thus we add a quirk in order to not query it 
> and default min/max tx power values to HCI_TX_POWER_INVALID.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
> Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
> Link:
> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
> ---
> v7 :- Added Tested-by.
>  include/net/bluetooth/hci.h | 9 +++++++++
>  net/bluetooth/hci_core.c    | 3 ++-
>  2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
> +	 *
> +	 * This quirk can be set before hci_register_dev is called or
> +	 * during the hdev->setup vendor callback.
> +	 */
> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
>  };
>  
>  /* HCI device flags */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 8d33aa64846b1c..434c6878fe9640 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
>  			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
>  		}
>  
> -		if (hdev->commands[38] & 0x80) {
> +		if ((hdev->commands[38] & 0x80) &&
> +		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {

I am getting tired of saying this, but PLEASE use scripts/checkpatch.pl
before you send out your patches.

If you had done so, you would see the following output in it:

CHECK: Alignment should match open parenthesis
#49: FILE: net/bluetooth/hci_core.c:623:
+	        if ((hdev->commands[38] & 0x80) &&
+	        !test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {


Please fix.


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

* Re: [PATCH v7 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-30 12:03                                                 ` [PATCH v7 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
@ 2021-11-30 12:53                                                   ` Aditya Garg
  0 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-30 12:53 UTC (permalink / raw)
  To: Greg KH
  Cc: Marcel Holtmann, Thorsten Leemhuis, Orlando Chamberlain,
	Daniel Winkler, Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable



> On 30-Nov-2021, at 5:33 PM, Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> On Tue, Nov 30, 2021 at 11:48:25AM +0000, Aditya Garg wrote:
>> From: Aditya Garg <gargaditya08@live.com>
>> 
>> Some devices have a bug causing them to not work if they query 
>> LE tx power on startup. Thus we add a quirk in order to not query it 
>> and default min/max tx power values to HCI_TX_POWER_INVALID.
>> 
>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
>> Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
>> Link:
>> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
>> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
>> ---
>> v7 :- Added Tested-by.
>> include/net/bluetooth/hci.h | 9 +++++++++
>> net/bluetooth/hci_core.c    | 3 ++-
>> 2 files changed, 11 insertions(+), 1 deletion(-)
>> 
>> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
>> index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
>> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
>> +	 *
>> +	 * This quirk can be set before hci_register_dev is called or
>> +	 * during the hdev->setup vendor callback.
>> +	 */
>> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
>> };
>> 
>> /* HCI device flags */
>> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
>> index 8d33aa64846b1c..434c6878fe9640 100644
>> --- a/net/bluetooth/hci_core.c
>> +++ b/net/bluetooth/hci_core.c
>> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
>> 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
>> 		}
>> 
>> -		if (hdev->commands[38] & 0x80) {
>> +		if ((hdev->commands[38] & 0x80) &&
>> +		!test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
> 
> I am getting tired of saying this, but PLEASE use scripts/checkpatch.pl
> before you send out your patches.
Sorry for offending you. The thing is that I am inexperienced in the field of submitting patches upstream. v8 shouldn't disappoint you.
> 
> If you had done so, you would see the following output in it:
> 
> CHECK: Alignment should match open parenthesis
> #49: FILE: net/bluetooth/hci_core.c:623:
> +	        if ((hdev->commands[38] & 0x80) &&
> +	        !test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
> 
> 
> Please fix.


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

* [PATCH v8 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-30 11:48                                               ` [PATCH v7 resend " Aditya Garg
  2021-11-30 11:49                                                 ` [PATCH v7 resend 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
  2021-11-30 12:03                                                 ` [PATCH v7 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
@ 2021-11-30 12:53                                                 ` Aditya Garg
  2021-11-30 12:54                                                   ` [PATCH v8 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
                                                                     ` (2 more replies)
  2 siblings, 3 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-30 12:53 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
v7 :- Added Tested-by.
v8 :- Fix checkpatch error.
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_core.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
index 8d33aa64846b1c..434c6878fe9640 100644
--- a/net/bluetooth/hci_core.c
+++ b/net/bluetooth/hci_core.c
@@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
 		}
 
-		if (hdev->commands[38] & 0x80) {
+		if ((hdev->commands[38] & 0x80) &&
+		    !test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
 			/* Read LE Min/Max Tx Power*/
 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
 				    0, NULL);


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

* [PATCH v8 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-11-30 12:53                                                 ` [PATCH v8 " Aditya Garg
@ 2021-11-30 12:54                                                   ` Aditya Garg
  2021-12-01  7:25                                                   ` [PATCH v8 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Marcel Holtmann
  2021-12-02 10:15                                                   ` [PATCH v9 " Aditya Garg
  2 siblings, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-11-30 12:54 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
---
v7 :- Removed unused variable and added Tested-by.
v8 :- No change.
 drivers/bluetooth/btbcm.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..07fabaa5aa2979 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,6 +344,40 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
@@ -363,6 +398,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
 
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
 	return 0;
 }
 


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

* Re: [PATCH v8 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-30 12:53                                                 ` [PATCH v8 " Aditya Garg
  2021-11-30 12:54                                                   ` [PATCH v8 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
@ 2021-12-01  7:25                                                   ` Marcel Holtmann
  2021-12-02 10:15                                                   ` [PATCH v9 " Aditya Garg
  2 siblings, 0 replies; 54+ messages in thread
From: Marcel Holtmann @ 2021-12-01  7:25 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

Hi Aditya,

> Some devices have a bug causing them to not work if they query 
> LE tx power on startup. Thus we add a quirk in order to not query it 
> and default min/max tx power values to HCI_TX_POWER_INVALID.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
> Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
> Link:
> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
> ---
> v7 :- Added Tested-by.
> v8 :- Fix checkpatch error.
> include/net/bluetooth/hci.h | 9 +++++++++
> net/bluetooth/hci_core.c    | 3 ++-
> 2 files changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 63065bc01b766c..383342efcdc464 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, LE tx power is not queried on startup
> +	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
> +	 *
> +	 * This quirk can be set before hci_register_dev is called or
> +	 * during the hdev->setup vendor callback.
> +	 */
> +	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
> };
> 
> /* HCI device flags */
> diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c
> index 8d33aa64846b1c..434c6878fe9640 100644
> --- a/net/bluetooth/hci_core.c
> +++ b/net/bluetooth/hci_core.c
> @@ -619,7 +619,8 @@ static int hci_init3_req(struct hci_request *req, unsigned long opt)
> 			hci_req_add(req, HCI_OP_LE_READ_ADV_TX_POWER, 0, NULL);
> 		}
> 
> -		if (hdev->commands[38] & 0x80) {
> +		if ((hdev->commands[38] & 0x80) &&
> +		    !test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks)) {
> 			/* Read LE Min/Max Tx Power*/
> 			hci_req_add(req, HCI_OP_LE_READ_TRANSMIT_POWER,
> 				    0, NULL);
> 

while patch and indentation look good now, it doesn’t actually apply
cleanly against bluetooth-next tree. So you need to re-spin it.

Regards

Marcel


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

* [PATCH v9 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-11-30 12:53                                                 ` [PATCH v8 " Aditya Garg
  2021-11-30 12:54                                                   ` [PATCH v8 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
  2021-12-01  7:25                                                   ` [PATCH v8 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Marcel Holtmann
@ 2021-12-02 10:15                                                   ` Aditya Garg
  2021-12-02 10:16                                                     ` [PATCH v9 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
  2021-12-02 12:41                                                     ` [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
  2 siblings, 2 replies; 54+ messages in thread
From: Aditya Garg @ 2021-12-02 10:15 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query 
LE tx power on startup. Thus we add a quirk in order to not query it 
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
Cc: stable@vger.kernel.org
---
v7 :- Added Tested-by.
v8 :- Fix checkpatch error.
v9 :- Remake patch for Bluetooth-next tree and add Cc: stable@vger.kernel.org
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_sync.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 0d2a92168..c4959cf9a 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index ad86caf41..52e6b5dae 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -3283,7 +3283,8 @@ static int hci_le_read_adv_tx_power_sync(struct hci_dev *hdev)
 /* Read LE Min/Max Tx Power*/
 static int hci_le_read_tx_power_sync(struct hci_dev *hdev)
 {
-	if (!(hdev->commands[38] & 0x80))
+	if (!(hdev->commands[38] & 0x80) ||
+	    test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks))
 		return 0;
 
 	return __hci_cmd_sync_status(hdev, HCI_OP_LE_READ_TRANSMIT_POWER,
-- 
2.25.1



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

* [PATCH v9 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip
  2021-12-02 10:15                                                   ` [PATCH v9 " Aditya Garg
@ 2021-12-02 10:16                                                     ` Aditya Garg
  2021-12-02 12:41                                                     ` [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
  1 sibling, 0 replies; 54+ messages in thread
From: Aditya Garg @ 2021-12-02 10:16 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
Cc: stable@vger.kernel.org
---
v7 :- Removed unused variable and added Tested-by.
v8 :- No change.
v9 :- Add Cc: stable@vger.kernel.org
 drivers/bluetooth/btbcm.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..07fabaa5aa2979 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,6 +344,40 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
@@ -363,6 +398,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
 
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
 	return 0;
 }
 


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

* [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-12-02 10:15                                                   ` [PATCH v9 " Aditya Garg
  2021-12-02 10:16                                                     ` [PATCH v9 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
@ 2021-12-02 12:41                                                     ` Aditya Garg
  2021-12-02 12:42                                                       ` [PATCH v10 2/2] btbcm: disable read tx power for some Macs with the T2 Security chip Aditya Garg
  2021-12-03 21:28                                                       ` [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Marcel Holtmann
  1 sibling, 2 replies; 54+ messages in thread
From: Aditya Garg @ 2021-12-02 12:41 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some devices have a bug causing them to not work if they query
LE tx power on startup. Thus we add a quirk in order to not query it
and default min/max tx power values to HCI_TX_POWER_INVALID.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
Cc: stable@vger.kernel.org
---
v7 :- Added Tested-by.
v8 :- Fix checkpatch error.
v9 :- Remake patch for Bluetooth-next tree and add Cc: stable@vger.kernel.org
v10 :- Fix gitlint
 include/net/bluetooth/hci.h | 9 +++++++++
 net/bluetooth/hci_sync.c    | 3 ++-
 2 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 0d2a92168..c4959cf9a 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, LE tx power is not queried on startup
+	 * and the min/max tx power values default to HCI_TX_POWER_INVALID.
+	 *
+	 * This quirk can be set before hci_register_dev is called or
+	 * during the hdev->setup vendor callback.
+	 */
+	HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index ad86caf41..52e6b5dae 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -3283,7 +3283,8 @@ static int hci_le_read_adv_tx_power_sync(struct hci_dev *hdev)
 /* Read LE Min/Max Tx Power*/
 static int hci_le_read_tx_power_sync(struct hci_dev *hdev)
 {
-	if (!(hdev->commands[38] & 0x80))
+	if (!(hdev->commands[38] & 0x80) ||
+	    test_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks))
 		return 0;
 
 	return __hci_cmd_sync_status(hdev, HCI_OP_LE_READ_TRANSMIT_POWER,
-- 
2.25.1



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

* [PATCH v10 2/2] btbcm: disable read tx power for some Macs with the T2 Security chip
  2021-12-02 12:41                                                     ` [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
@ 2021-12-02 12:42                                                       ` Aditya Garg
  2021-12-03 21:28                                                         ` Marcel Holtmann
  2021-12-03 21:28                                                       ` [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Marcel Holtmann
  1 sibling, 1 reply; 54+ messages in thread
From: Aditya Garg @ 2021-12-02 12:42 UTC (permalink / raw)
  To: Marcel Holtmann
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

From: Aditya Garg <gargaditya08@live.com>

Some Macs with the T2 security chip had Bluetooth not working.
To fix it we add DMI based quirks to disable querying of LE Tx power.

Signed-off-by: Aditya Garg <gargaditya08@live.com>
Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
Link:
https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
Cc: stable@vger.kernel.org
---
v7 :- Removed unused variable and added Tested-by.
v8 :- No change.
v9 :- Add Cc: stable@vger.kernel.org
v10 :- Fix gitlint
 drivers/bluetooth/btbcm.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/drivers/bluetooth/btbcm.c b/drivers/bluetooth/btbcm.c
index e4182acee488c5..07fabaa5aa2979 100644
--- a/drivers/bluetooth/btbcm.c
+++ b/drivers/bluetooth/btbcm.c
@@ -8,6 +8,7 @@
 
 #include <linux/module.h>
 #include <linux/firmware.h>
+#include <linux/dmi.h>
 #include <asm/unaligned.h>
 
 #include <net/bluetooth/bluetooth.h>
@@ -343,6 +344,40 @@ static struct sk_buff *btbcm_read_usb_product(struct hci_dev *hdev)
 	return skb;
 }
 
+static const struct dmi_system_id disable_broken_read_transmit_power[] = {
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,2"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "MacBookPro16,4"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,1"),
+		},
+	},
+	{
+		 .matches = {
+			DMI_MATCH(DMI_BOARD_VENDOR, "Apple Inc."),
+			DMI_MATCH(DMI_PRODUCT_NAME, "iMac20,2"),
+		},
+	},
+	{ }
+};
+
 static int btbcm_read_info(struct hci_dev *hdev)
 {
 	struct sk_buff *skb;
@@ -363,6 +398,10 @@ static int btbcm_read_info(struct hci_dev *hdev)
 	bt_dev_info(hdev, "BCM: features 0x%2.2x", skb->data[1]);
 	kfree_skb(skb);
 
+	/* Read DMI and disable broken Read LE Min/Max Tx Power */
+	if (dmi_first_match(disable_broken_read_transmit_power))
+		set_bit(HCI_QUIRK_BROKEN_READ_TRANSMIT_POWER, &hdev->quirks);
+
 	return 0;
 }
 


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

* Re: [PATCH v10 2/2] btbcm: disable read tx power for some Macs with the T2 Security chip
  2021-12-02 12:42                                                       ` [PATCH v10 2/2] btbcm: disable read tx power for some Macs with the T2 Security chip Aditya Garg
@ 2021-12-03 21:28                                                         ` Marcel Holtmann
  2021-12-21 13:44                                                           ` Thorsten Leemhuis
  0 siblings, 1 reply; 54+ messages in thread
From: Marcel Holtmann @ 2021-12-03 21:28 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

Hi Aditya,

> Some Macs with the T2 security chip had Bluetooth not working.
> To fix it we add DMI based quirks to disable querying of LE Tx power.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
> Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
> Link:
> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
> Cc: stable@vger.kernel.org
> ---
> v7 :- Removed unused variable and added Tested-by.
> v8 :- No change.
> v9 :- Add Cc: stable@vger.kernel.org
> v10 :- Fix gitlint
> drivers/bluetooth/btbcm.c | 39 +++++++++++++++++++++++++++++++++++++++
> 1 file changed, 39 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

* Re: [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power
  2021-12-02 12:41                                                     ` [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
  2021-12-02 12:42                                                       ` [PATCH v10 2/2] btbcm: disable read tx power for some Macs with the T2 Security chip Aditya Garg
@ 2021-12-03 21:28                                                       ` Marcel Holtmann
  1 sibling, 0 replies; 54+ messages in thread
From: Marcel Holtmann @ 2021-12-03 21:28 UTC (permalink / raw)
  To: Aditya Garg
  Cc: Greg KH, Thorsten Leemhuis, Orlando Chamberlain, Daniel Winkler,
	Johan Hedberg, linux-bluetooth, linux-kernel,
	Luiz Augusto von Dentz, regressions, sonnysasaka, stable

Hi Aditya,

> Some devices have a bug causing them to not work if they query
> LE tx power on startup. Thus we add a quirk in order to not query it
> and default min/max tx power values to HCI_TX_POWER_INVALID.
> 
> Signed-off-by: Aditya Garg <gargaditya08@live.com>
> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
> Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
> Link:
> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")
> Cc: stable@vger.kernel.org
> ---
> v7 :- Added Tested-by.
> v8 :- Fix checkpatch error.
> v9 :- Remake patch for Bluetooth-next tree and add Cc: stable@vger.kernel.org
> v10 :- Fix gitlint
> include/net/bluetooth/hci.h | 9 +++++++++
> net/bluetooth/hci_sync.c    | 3 ++-
> 2 files changed, 11 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

* Re: [PATCH v10 2/2] btbcm: disable read tx power for some Macs with the T2 Security chip
  2021-12-03 21:28                                                         ` Marcel Holtmann
@ 2021-12-21 13:44                                                           ` Thorsten Leemhuis
  0 siblings, 0 replies; 54+ messages in thread
From: Thorsten Leemhuis @ 2021-12-21 13:44 UTC (permalink / raw)
  To: Marcel Holtmann, Aditya Garg
  Cc: Greg KH, Orlando Chamberlain, Daniel Winkler, Johan Hedberg,
	linux-bluetooth, linux-kernel, Luiz Augusto von Dentz,
	regressions, sonnysasaka, stable

Hi, this once again is your Linux kernel regression tracker speaking.

On 03.12.21 22:28, Marcel Holtmann wrote:

>> Some Macs with the T2 security chip had Bluetooth not working.
>> To fix it we add DMI based quirks to disable querying of LE Tx power.
>>
>> Signed-off-by: Aditya Garg <gargaditya08@live.com>
>> Reported-by: Orlando Chamberlain <redecorating@protonmail.com>
>> Tested-by: Orlando Chamberlain <redecorating@protonmail.com>
>> Link:
>> https://lore.kernel.org/r/4970a940-211b-25d6-edab-21a815313954@protonmail.com
>> Fixes: 7c395ea521e6 ("Bluetooth: Query LE tx power on startup")

If anyone wonders: this was for v5.11-rc1.

>> Cc: stable@vger.kernel.org
>> ---
>> v7 :- Removed unused variable and added Tested-by.
>> v8 :- No change.
>> v9 :- Add Cc: stable@vger.kernel.org
>> v10 :- Fix gitlint
>> drivers/bluetooth/btbcm.c | 39 +++++++++++++++++++++++++++++++++++++++
>> 1 file changed, 39 insertions(+)
> 
> patch has been applied to bluetooth-next tree.
And there are these two pages now for 19 days. What's the hold-up? Or do
you consider the changes to dangerous to merge now?

Sure, it's not a recent regression, so it might not look that urgent.
But it OTOH affects everyone that can't go back to v5.10 (the newest
Longterm kernel without the regression) -- for example if a user needs a
post-v5.10 feature or upgrades to a distro with a newer kernel.

That's why this fix (unless you considerer it to dangerous) IMHO should
be merged rather sooner than later and and not wait for the merge window
of v5.17. Another aspect against waiting for the next merge window: it
contributes to piling up a large number of changes that need to be
backported to stable and longterm kernels once v5.17-rc1 is out,
resulting in stable and longterm releases with a huge pile of changes:
https://lwn.net/Articles/863505/

Ciao, Thorsten

#regzbot poke

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

end of thread, other threads:[~2021-12-21 13:44 UTC | newest]

Thread overview: 54+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20211001083412.3078-1-redecorating@protonmail.com>
     [not found] ` <YYePw07y2DzEPSBR@kroah.com>
     [not found]   ` <70a875d0-7162-d149-dbc1-c2f5e1a8e701@leemhuis.info>
     [not found]     ` <20211116090128.17546-1-redecorating@protonmail.com>
     [not found]       ` <e75bf933-9b93-89d2-d73f-f85af65093c8@leemhuis.info>
     [not found]         ` <3B8E16FA-97BF-40E5-9149-BBC3E2A245FE@live.com>
     [not found]           ` <YZSuWHB6YCtGclLs@kroah.com>
     [not found]             ` <52DEDC31-EEB2-4F39-905F-D5E3F2BBD6C0@live.com>
     [not found]               ` <8919a36b-e485-500a-2722-529ffa0d2598@leemhuis.info>
     [not found]                 ` <20211117124717.12352-1-redecorating@protonmail.com>
     [not found]                   ` <F8D12EA8-4B37-4887-998E-DC0EBE60E730@holtmann.org>
     [not found]                     ` <40550C00-4EE5-480F-AFD4-A2ACA01F9DBB@live.com>
     [not found]                       ` <332a19f1-30f0-7058-ac18-c21cf78759bb@leemhuis.info>
     [not found]                         ` <D9375D91-1062-4265-9DE9-C7CF2B705F3F@live.com>
2021-11-29  7:22                           ` [PATCH 1/6] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
2021-11-29  7:27                             ` [PATCH 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019) Aditya Garg
2021-11-29  7:28                               ` [PATCH 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020) Aditya Garg
2021-11-29  7:30                                 ` [PATCH 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019) Aditya Garg
2021-11-29  7:31                                   ` [PATCH 5/6] btbcm: disable read tx power for iMac 20,1 (Retina 5K, 27-inch, 2020) Aditya Garg
2021-11-29  7:32                                     ` [PATCH 6/6] btbcm: disable read tx power for iMac 20,2 " Aditya Garg
2021-11-29  7:46                                   ` [PATCH v2 4/6] btbcm: disable read tx power for MacBook Pro 16,4 (16 inch, 2019) Aditya Garg
2021-11-29  7:45                                 ` [PATCH v2 3/6] btbcm: disable read tx power for MacBook Pro 16,2 (13 inch - 4 Thunderbolt Ports, 2020) Aditya Garg
2021-11-29  7:44                               ` [PATCH v2 2/6] btbcm: disable read tx power for MacBook Pro 16,1 (16 inch, 2019) Aditya Garg
2021-11-29  8:08                               ` [PATCH " Marcel Holtmann
2021-11-29  8:11                                 ` Aditya Garg
2021-11-29  8:22                                   ` Marcel Holtmann
2021-11-29  8:42                                     ` Aditya Garg
2021-11-29  7:32                             ` [PATCH 1/6] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
2021-11-29  7:42                               ` [PATCH v2 " Aditya Garg
2021-11-29  7:47                                 ` Greg KH
2021-11-29  7:49                                   ` Aditya Garg
2021-11-29  7:47                                 ` Greg KH
2021-11-29  8:05                                 ` Marcel Holtmann
2021-11-29  8:32                                   ` [PATCH v3 1/2] " Aditya Garg
2021-11-29  8:35                                     ` [PATCH v3 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
2021-11-29  8:50                                       ` [PATCH v3 resend " Aditya Garg
2021-11-29  9:05                                         ` [PATCH v4 " Aditya Garg
2021-11-29  9:25                                           ` [PATCH v5 " Aditya Garg
2021-11-29 11:03                                         ` [PATCH v3 resend " Marcel Holtmann
2021-11-29 12:01                                           ` Aditya Garg
2021-11-29  8:47                                     ` [PATCH v3 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
2021-11-29  9:03                                       ` [PATCH v4 " Aditya Garg
2021-11-29  9:24                                         ` [PATCH v5 " Aditya Garg
2021-11-29 13:59                                           ` [PATCH v6 " Aditya Garg
2021-11-29 14:00                                             ` [PATCH v6 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
2021-11-30  8:45                                               ` Aditya Garg
2021-11-30  8:54                                                 ` Greg KH
2021-11-30 10:28                                               ` Orlando Chamberlain
2021-11-30 11:38                                             ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
2021-11-30 11:40                                               ` [PATCH v7 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
2021-11-30 11:41                                               ` [PATCH v7 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
2021-11-30 11:50                                                 ` Aditya Garg
2021-11-30 11:48                                               ` [PATCH v7 resend " Aditya Garg
2021-11-30 11:49                                                 ` [PATCH v7 resend 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
2021-11-30 12:03                                                 ` [PATCH v7 resend 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Greg KH
2021-11-30 12:53                                                   ` Aditya Garg
2021-11-30 12:53                                                 ` [PATCH v8 " Aditya Garg
2021-11-30 12:54                                                   ` [PATCH v8 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
2021-12-01  7:25                                                   ` [PATCH v8 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Marcel Holtmann
2021-12-02 10:15                                                   ` [PATCH v9 " Aditya Garg
2021-12-02 10:16                                                     ` [PATCH v9 2/2] btbcm: disable read tx power for affected Macs with the T2 Security chip Aditya Garg
2021-12-02 12:41                                                     ` [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Aditya Garg
2021-12-02 12:42                                                       ` [PATCH v10 2/2] btbcm: disable read tx power for some Macs with the T2 Security chip Aditya Garg
2021-12-03 21:28                                                         ` Marcel Holtmann
2021-12-21 13:44                                                           ` Thorsten Leemhuis
2021-12-03 21:28                                                       ` [PATCH v10 1/2] Bluetooth: add quirk disabling LE Read Transmit Power Marcel Holtmann
2021-11-29  8:52                                     ` [PATCH v3 " Thorsten Leemhuis
2021-11-29 11:02                                     ` Marcel Holtmann

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).