diff mbox series

bluetooth: btusb: Fix regression in the initialization of fake Bluetooth controllers

Message ID 20250219215352.15605-1-nishiyama.pedro@gmail.com
State New
Headers show
Series bluetooth: btusb: Fix regression in the initialization of fake Bluetooth controllers | expand

Commit Message

Pedro Nishiyama Feb. 19, 2025, 9:53 p.m. UTC
Set HCI_OP_READ_VOICE_SETTING and HCI_OP_READ_PAGE_SCAN_TYPE as broken.
These features are falsely reported as supported.

https://bugzilla.kernel.org/show_bug.cgi?id=60824

Signed-off-by: Pedro Nishiyama <nishiyama.pedro@gmail.com>
---
 drivers/bluetooth/btusb.c   |  2 ++
 include/net/bluetooth/hci.h | 16 ++++++++++++++++
 net/bluetooth/hci_sync.c    |  6 ++++++
 3 files changed, 24 insertions(+)

Comments

Luiz Augusto von Dentz Feb. 20, 2025, 4:25 p.m. UTC | #1
Hi Pedro,

On Wed, Feb 19, 2025 at 4:54 PM Pedro Nishiyama
<nishiyama.pedro@gmail.com> wrote:
>
> Set HCI_OP_READ_VOICE_SETTING and HCI_OP_READ_PAGE_SCAN_TYPE as broken.
> These features are falsely reported as supported.
>
> https://bugzilla.kernel.org/show_bug.cgi?id=60824

If it is a regression it needs the Fixes tag of the change when the
regression was introduced in order to determine if it should be
backported, etc.

> Signed-off-by: Pedro Nishiyama <nishiyama.pedro@gmail.com>
> ---
>  drivers/bluetooth/btusb.c   |  2 ++
>  include/net/bluetooth/hci.h | 16 ++++++++++++++++
>  net/bluetooth/hci_sync.c    |  6 ++++++
>  3 files changed, 24 insertions(+)
>
> diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
> index 90966dfbd278..43403b0cb5cc 100644
> --- a/drivers/bluetooth/btusb.c
> +++ b/drivers/bluetooth/btusb.c
> @@ -2435,6 +2435,8 @@ static int btusb_setup_csr(struct hci_dev *hdev)
>                 set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks);
>                 set_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks);
>                 set_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks);
> +               set_bit(HCI_QUIRK_BROKEN_READ_VOICE_SETTING, &hdev->quirks);
> +               set_bit(HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE, &hdev->quirks);

Can you please split the driver specific changes from the quirks?

>                 /* Clear the reset quirk since this is not an actual
>                  * early Bluetooth 1.1 device from CSR.
> diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
> index 0d51970d809f..b99818df8ee7 100644
> --- a/include/net/bluetooth/hci.h
> +++ b/include/net/bluetooth/hci.h
> @@ -354,6 +354,22 @@ enum {
>          * during the hdev->setup vendor callback.
>          */
>         HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY,
> +
> +       /* When this quirk is set, the HCI_OP_READ_VOICE_SETTING command is
> +        * skipped. This is required for a subset of the CSR controller clones
> +        * which erroneously claim to support it.
> +        *
> +        * This quirk must be set before hci_register_dev is called.
> +        */
> +       HCI_QUIRK_BROKEN_READ_VOICE_SETTING,
> +
> +       /* When this quirk is set, the HCI_OP_READ_PAGE_SCAN_TYPE command is
> +        * skipped. This is required for a subset of the CSR controller clones
> +        * which erroneously claim to support it.
> +        *
> +        * This quirk must be set before hci_register_dev is called.
> +        */
> +       HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE,
>  };
>
>  /* HCI device flags */
> diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
> index dd770ef5ec36..e76012956020 100644
> --- a/net/bluetooth/hci_sync.c
> +++ b/net/bluetooth/hci_sync.c
> @@ -3696,6 +3696,9 @@ static int hci_read_local_name_sync(struct hci_dev *hdev)
>  /* Read Voice Setting */
>  static int hci_read_voice_setting_sync(struct hci_dev *hdev)
>  {
> +       if (test_bit(HCI_QUIRK_BROKEN_READ_VOICE_SETTING, &hdev->quirks))
> +               return 0;
> +
>         return __hci_cmd_sync_status(hdev, HCI_OP_READ_VOICE_SETTING,
>                                      0, NULL, HCI_CMD_TIMEOUT);
>  }
> @@ -4132,6 +4135,9 @@ static int hci_read_page_scan_type_sync(struct hci_dev *hdev)
>         if (!(hdev->commands[13] & 0x01))
>                 return 0;
>
> +       if (test_bit(HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE, &hdev->quirks))
> +               return 0;
> +
>         return __hci_cmd_sync_status(hdev, HCI_OP_READ_PAGE_SCAN_TYPE,
>                                      0, NULL, HCI_CMD_TIMEOUT);
>  }
> --
> 2.48.1
>
diff mbox series

Patch

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 90966dfbd278..43403b0cb5cc 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2435,6 +2435,8 @@  static int btusb_setup_csr(struct hci_dev *hdev)
 		set_bit(HCI_QUIRK_BROKEN_ERR_DATA_REPORTING, &hdev->quirks);
 		set_bit(HCI_QUIRK_BROKEN_FILTER_CLEAR_ALL, &hdev->quirks);
 		set_bit(HCI_QUIRK_NO_SUSPEND_NOTIFIER, &hdev->quirks);
+		set_bit(HCI_QUIRK_BROKEN_READ_VOICE_SETTING, &hdev->quirks);
+		set_bit(HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE, &hdev->quirks);
 
 		/* Clear the reset quirk since this is not an actual
 		 * early Bluetooth 1.1 device from CSR.
diff --git a/include/net/bluetooth/hci.h b/include/net/bluetooth/hci.h
index 0d51970d809f..b99818df8ee7 100644
--- a/include/net/bluetooth/hci.h
+++ b/include/net/bluetooth/hci.h
@@ -354,6 +354,22 @@  enum {
 	 * during the hdev->setup vendor callback.
 	 */
 	HCI_QUIRK_FIXUP_LE_EXT_ADV_REPORT_PHY,
+
+	/* When this quirk is set, the HCI_OP_READ_VOICE_SETTING command is
+	 * skipped. This is required for a subset of the CSR controller clones
+	 * which erroneously claim to support it.
+	 *
+	 * This quirk must be set before hci_register_dev is called.
+	 */
+	HCI_QUIRK_BROKEN_READ_VOICE_SETTING,
+
+	/* When this quirk is set, the HCI_OP_READ_PAGE_SCAN_TYPE command is
+	 * skipped. This is required for a subset of the CSR controller clones
+	 * which erroneously claim to support it.
+	 *
+	 * This quirk must be set before hci_register_dev is called.
+	 */
+	HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE,
 };
 
 /* HCI device flags */
diff --git a/net/bluetooth/hci_sync.c b/net/bluetooth/hci_sync.c
index dd770ef5ec36..e76012956020 100644
--- a/net/bluetooth/hci_sync.c
+++ b/net/bluetooth/hci_sync.c
@@ -3696,6 +3696,9 @@  static int hci_read_local_name_sync(struct hci_dev *hdev)
 /* Read Voice Setting */
 static int hci_read_voice_setting_sync(struct hci_dev *hdev)
 {
+	if (test_bit(HCI_QUIRK_BROKEN_READ_VOICE_SETTING, &hdev->quirks))
+		return 0;
+
 	return __hci_cmd_sync_status(hdev, HCI_OP_READ_VOICE_SETTING,
 				     0, NULL, HCI_CMD_TIMEOUT);
 }
@@ -4132,6 +4135,9 @@  static int hci_read_page_scan_type_sync(struct hci_dev *hdev)
 	if (!(hdev->commands[13] & 0x01))
 		return 0;
 
+	if (test_bit(HCI_QUIRK_BROKEN_READ_PAGE_SCAN_TYPE, &hdev->quirks))
+		return 0;
+
 	return __hci_cmd_sync_status(hdev, HCI_OP_READ_PAGE_SCAN_TYPE,
 				     0, NULL, HCI_CMD_TIMEOUT);
 }