From c6c183e2ccfe3ec8b2079acb0cdd8a1bb6290c41 Mon Sep 17 00:00:00 2001 From: Greg Kroah-Hartman Date: Wed, 19 Jun 2024 13:43:19 +0200 Subject: [PATCH] 6.1-stable patches added patches: bluetooth-qca-fix-wcn3991-device-address-check.patch bluetooth-qca-generalise-device-address-check.patch --- ...qca-fix-wcn3991-device-address-check.patch | 64 ++++++++++ ...-qca-generalise-device-address-check.patch | 116 ++++++++++++++++++ queue-6.1/series | 2 + 3 files changed, 182 insertions(+) create mode 100644 queue-6.1/bluetooth-qca-fix-wcn3991-device-address-check.patch create mode 100644 queue-6.1/bluetooth-qca-generalise-device-address-check.patch diff --git a/queue-6.1/bluetooth-qca-fix-wcn3991-device-address-check.patch b/queue-6.1/bluetooth-qca-fix-wcn3991-device-address-check.patch new file mode 100644 index 00000000000..3e9ef745918 --- /dev/null +++ b/queue-6.1/bluetooth-qca-fix-wcn3991-device-address-check.patch @@ -0,0 +1,64 @@ +From 66c39332d02d65e311ec89b0051130bfcd00c9ac Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Thu, 25 Apr 2024 09:55:03 +0200 +Subject: Bluetooth: qca: fix wcn3991 device address check + +From: Johan Hovold + +commit 66c39332d02d65e311ec89b0051130bfcd00c9ac upstream. + +Qualcomm Bluetooth controllers may not have been provisioned with a +valid device address and instead end up using the default address +00:00:00:00:5a:ad. + +This address is now used to determine if a controller has a valid +address or if one needs to be provided through devicetree or by user +space before the controller can be used. + +It turns out that the WCN3991 controllers used in Chromium Trogdor +machines use a different default address, 39:98:00:00:5a:ad, which also +needs to be marked as invalid so that the correct address is fetched +from the devicetree. + +Qualcomm has unfortunately not yet provided any answers as to whether +the 39:98 encodes a hardware id and if there are other variants of the +default address that needs to be handled by the driver. + +For now, add the Trogdor WCN3991 default address to the device address +check to avoid having these controllers start with the default address +instead of their assigned addresses. + +Fixes: 32868e126c78 ("Bluetooth: qca: fix invalid device address check") +Cc: stable@vger.kernel.org # 6.5 +Cc: Doug Anderson +Cc: Janaki Ramaiah Thota +Signed-off-by: Johan Hovold +Tested-by: Douglas Anderson +Signed-off-by: Luiz Augusto von Dentz +Signed-off-by: Greg Kroah-Hartman +--- + drivers/bluetooth/btqca.c | 5 ++++- + 1 file changed, 4 insertions(+), 1 deletion(-) + +--- a/drivers/bluetooth/btqca.c ++++ b/drivers/bluetooth/btqca.c +@@ -16,6 +16,7 @@ + #define VERSION "0.1" + + #define QCA_BDADDR_DEFAULT (&(bdaddr_t) {{ 0xad, 0x5a, 0x00, 0x00, 0x00, 0x00 }}) ++#define QCA_BDADDR_WCN3991 (&(bdaddr_t) {{ 0xad, 0x5a, 0x00, 0x00, 0x98, 0x39 }}) + + int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver, + enum qca_btsoc_type soc_type) +@@ -708,8 +709,10 @@ static int qca_check_bdaddr(struct hci_d + } + + bda = (struct hci_rp_read_bd_addr *)skb->data; +- if (!bacmp(&bda->bdaddr, QCA_BDADDR_DEFAULT)) ++ if (!bacmp(&bda->bdaddr, QCA_BDADDR_DEFAULT) || ++ !bacmp(&bda->bdaddr, QCA_BDADDR_WCN3991)) { + set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks); ++ } + + kfree_skb(skb); + diff --git a/queue-6.1/bluetooth-qca-generalise-device-address-check.patch b/queue-6.1/bluetooth-qca-generalise-device-address-check.patch new file mode 100644 index 00000000000..cec95740246 --- /dev/null +++ b/queue-6.1/bluetooth-qca-generalise-device-address-check.patch @@ -0,0 +1,116 @@ +From dd336649ba89789c845618dcbc09867010aec673 Mon Sep 17 00:00:00 2001 +From: Johan Hovold +Date: Tue, 30 Apr 2024 19:07:41 +0200 +Subject: Bluetooth: qca: generalise device address check + +From: Johan Hovold + +commit dd336649ba89789c845618dcbc09867010aec673 upstream. + +The default device address apparently comes from the NVM configuration +file and can differ quite a bit between controllers. + +Store the default address when parsing the configuration file and use it +to determine whether the controller has been provisioned with an +address. + +This makes sure that devices without a unique address start as +unconfigured unless a valid address has been provided in the devicetree. + +Fixes: 32868e126c78 ("Bluetooth: qca: fix invalid device address check") +Cc: stable@vger.kernel.org # 6.5 +Cc: Doug Anderson +Cc: Janaki Ramaiah Thota +Signed-off-by: Johan Hovold +Tested-by: Douglas Anderson +Signed-off-by: Luiz Augusto von Dentz +Signed-off-by: Greg Kroah-Hartman +--- + drivers/bluetooth/btqca.c | 21 ++++++++++++--------- + drivers/bluetooth/btqca.h | 2 ++ + 2 files changed, 14 insertions(+), 9 deletions(-) + +--- a/drivers/bluetooth/btqca.c ++++ b/drivers/bluetooth/btqca.c +@@ -15,9 +15,6 @@ + + #define VERSION "0.1" + +-#define QCA_BDADDR_DEFAULT (&(bdaddr_t) {{ 0xad, 0x5a, 0x00, 0x00, 0x00, 0x00 }}) +-#define QCA_BDADDR_WCN3991 (&(bdaddr_t) {{ 0xad, 0x5a, 0x00, 0x00, 0x98, 0x39 }}) +- + int qca_read_soc_version(struct hci_dev *hdev, struct qca_btsoc_version *ver, + enum qca_btsoc_type soc_type) + { +@@ -411,6 +408,14 @@ static int qca_tlv_check_data(struct hci + + /* Update NVM tags as needed */ + switch (tag_id) { ++ case EDL_TAG_ID_BD_ADDR: ++ if (tag_len != sizeof(bdaddr_t)) ++ return -EINVAL; ++ ++ memcpy(&config->bdaddr, tlv_nvm->data, sizeof(bdaddr_t)); ++ ++ break; ++ + case EDL_TAG_ID_HCI: + if (tag_len < 3) + return -EINVAL; +@@ -685,7 +690,7 @@ int qca_set_bdaddr_rome(struct hci_dev * + } + EXPORT_SYMBOL_GPL(qca_set_bdaddr_rome); + +-static int qca_check_bdaddr(struct hci_dev *hdev) ++static int qca_check_bdaddr(struct hci_dev *hdev, const struct qca_fw_config *config) + { + struct hci_rp_read_bd_addr *bda; + struct sk_buff *skb; +@@ -709,10 +714,8 @@ static int qca_check_bdaddr(struct hci_d + } + + bda = (struct hci_rp_read_bd_addr *)skb->data; +- if (!bacmp(&bda->bdaddr, QCA_BDADDR_DEFAULT) || +- !bacmp(&bda->bdaddr, QCA_BDADDR_WCN3991)) { ++ if (!bacmp(&bda->bdaddr, &config->bdaddr)) + set_bit(HCI_QUIRK_USE_BDADDR_PROPERTY, &hdev->quirks); +- } + + kfree_skb(skb); + +@@ -740,7 +743,7 @@ int qca_uart_setup(struct hci_dev *hdev, + enum qca_btsoc_type soc_type, struct qca_btsoc_version ver, + const char *firmware_name) + { +- struct qca_fw_config config; ++ struct qca_fw_config config = {}; + int err; + u8 rom_ver = 0; + u32 soc_ver; +@@ -925,7 +928,7 @@ int qca_uart_setup(struct hci_dev *hdev, + break; + } + +- err = qca_check_bdaddr(hdev); ++ err = qca_check_bdaddr(hdev, &config); + if (err) + return err; + +--- a/drivers/bluetooth/btqca.h ++++ b/drivers/bluetooth/btqca.h +@@ -29,6 +29,7 @@ + #define EDL_PATCH_CONFIG_RES_EVT (0x00) + #define QCA_DISABLE_LOGGING_SUB_OP (0x14) + ++#define EDL_TAG_ID_BD_ADDR 2 + #define EDL_TAG_ID_HCI (17) + #define EDL_TAG_ID_DEEP_SLEEP (27) + +@@ -93,6 +94,7 @@ struct qca_fw_config { + uint8_t user_baud_rate; + enum qca_tlv_dnld_mode dnld_mode; + enum qca_tlv_dnld_mode dnld_type; ++ bdaddr_t bdaddr; + }; + + struct edl_event_hdr { diff --git a/queue-6.1/series b/queue-6.1/series index fb79adb0f87..280d2a07c8e 100644 --- a/queue-6.1/series +++ b/queue-6.1/series @@ -205,3 +205,5 @@ mptcp-pm-update-add_addr-counters-after-connect.patch revert-fork-defer-linking-file-vma-until-vma-is-fully-initialized.patch remoteproc-k3-r5-jump-to-error-handling-labels-in-start-stop-errors.patch cachefiles-erofs-fix-null-deref-in-when-cachefiles-is-not-doing-ondemand-mode.patch +bluetooth-qca-fix-wcn3991-device-address-check.patch +bluetooth-qca-generalise-device-address-check.patch -- 2.47.3