Skip to contentSkip to conversation

Bluetooth: Add support to read Intel debug feature

PATCH In review Kiran K 2 participants 4 messages Jun 8, 2020 – Jun 10, 2020 Bluetooth drivers

lore
Share & tools
lore

Kiran K

author
#0 lore raw

PATCH v3 1/2 Bluetooth: Add support to read Intel debug feature

From: Chethan T N <[email protected]>

The command shall read the Intel controller supported debug feature. Based on the supported features additional debug configuration shall be enabled.

---
 drivers/bluetooth/btintel.c | 33 +++++++++++++++++++++++++++++++++
 drivers/bluetooth/btintel.h | 15 +++++++++++++++
 drivers/bluetooth/btusb.c   |  7 ++++++-
 3 files changed, 54 insertions(+), 1 deletion(-)
drivers/bluetooth/btintel.c +33 -0
index 6a0e2c5a8beb..cb7d62883b18 100644
@@ -754,6 +754,39 @@ void btintel_reset_to_bootloader(struct hci_dev *hdev)
 }
 EXPORT_SYMBOL_GPL(btintel_reset_to_bootloader);
 
+int btintel_read_debug_features(struct hci_dev *hdev,
+				struct intel_debug_features *features)
+{
+	struct sk_buff *skb;
+	u8 page_no = 1;
+
+	/* Intel controller supports two pages, each page is of 128-bit
+	 * feature bit mask. And each bit defines specific feature support
+	 */
+	skb = __hci_cmd_sync(hdev, 0xfca6, sizeof(page_no), &page_no,
+			     HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		bt_dev_err(hdev, "Reading supported features(page1) failed (%ld)",
+			   PTR_ERR(skb));
+		return PTR_ERR(skb);
+	}
+
+	if (skb->len != (sizeof(features->page1) + 3)) {
+		bt_dev_err(hdev,
+			   "Supported feature(page1) event size mismatch");
+		kfree_skb(skb);
+		return -EILSEQ;
+	}
+
+	memcpy(features->page1, skb->data + 3, sizeof(features->page1));
+
+	/* Read the supported features page2 if required in future.
+	 */
+	kfree_skb(skb);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(btintel_read_debug_features);
+
 MODULE_AUTHOR("Marcel Holtmann <[email protected]>");
 MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION);
 MODULE_VERSION(VERSION);
drivers/bluetooth/btintel.h +15 -0
index a69ea8a87b9b..7cd813fc5db4 100644
@@ -62,6 +62,10 @@ struct intel_reset {
 	__le32   boot_param;
 } __packed;
 
+struct intel_debug_features {
+	__u8    page1[16];
+} __packed;
+
 #if IS_ENABLED(CONFIG_BT_INTEL)
 
 int btintel_check_bdaddr(struct hci_dev *hdev);
@@ -88,6 +92,10 @@ int btintel_read_boot_params(struct hci_dev *hdev,
 int btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw,
 			      u32 *boot_param);
 void btintel_reset_to_bootloader(struct hci_dev *hdev);
+
+int btintel_read_debug_features(struct hci_dev *hdev,
+				struct intel_debug_features *features);
+
 #else
 
 static inline int btintel_check_bdaddr(struct hci_dev *hdev)
@@ -186,4 +194,11 @@ static inline int btintel_download_firmware(struct hci_dev *dev,
 static inline void btintel_reset_to_bootloader(struct hci_dev *hdev)
 {
 }
+
+static inline int btintel_read_debug_features(struct hci_dev *hdev,
+					      struct intel_debug_features *features)
+{
+	return -EOPNOTSUPP;
+}
+
 #endif
drivers/bluetooth/btusb.c +6 -1
index 5f022e9cf667..1d36141ebe65 100644
@@ -5,7 +5,6 @@
  *
  *  Copyright (C) 2005-2008  Marcel Holtmann <[email protected]>
  */
-
 #include <linux/dmi.h>
 #include <linux/module.h>
 #include <linux/usb.h>
@@ -2273,6 +2272,7 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
 	ktime_t calltime, delta, rettime;
 	unsigned long long duration;
 	int err;
+	struct intel_debug_features debug_features;
 
 	BT_DBG("%s", hdev->name);
 
@@ -2542,6 +2542,11 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
 	 */
 	btintel_load_ddc_config(hdev, fwname);
 
+	/* Read the Intel supported features and if new exception formats
+	 * supported, need to load the additional DDC config to enable.
+	 */
+	btintel_read_debug_features(hdev, &debug_features);
+
 	/* Read the Intel version information after loading the FW  */
 	err = btintel_read_version(hdev, &ver);
 	if (err)
Signature · 1 line
2.17.1
author
#1 lore raw

PATCH v3 2/2 Bluetooth : Config debug feature based on available support

From: Chethan T N <[email protected]>

This patch shall enable the Intel telemetry exception format based on the supported features

---
 drivers/bluetooth/btintel.c | 27 +++++++++++++++++++++++++++
 drivers/bluetooth/btintel.h |  9 +++++++--
 drivers/bluetooth/btusb.c   |  2 ++
 3 files changed, 36 insertions(+), 2 deletions(-)
drivers/bluetooth/btintel.c +27 -0
index cb7d62883b18..f9463f0c3ee2 100644
@@ -787,6 +787,33 @@ int btintel_read_debug_features(struct hci_dev *hdev,
 }
 EXPORT_SYMBOL_GPL(btintel_read_debug_features);
 
+int btintel_config_debug_features(struct hci_dev *hdev,
+				  const struct intel_debug_features *features)
+{
+	struct sk_buff *skb;
+	u8 mask_ddc[11] = { 0x0a, 0x92, 0x02, 0x07, 0x00, 0x00, 0x00,
+			0x00, 0x00, 0x00, 0x00 };
+
+	if (!features)
+		return -EINVAL;
+
+	if (!(features->page1[0] & 0x3f)) {
+		bt_dev_info(hdev, "Telemety exception format not supported");
+		return 0;
+	}
+
+	skb = __hci_cmd_sync(hdev, 0xfc8b, 11, mask_ddc, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		bt_dev_err(hdev, "Setting Intel telemetry ddc write event mask failed (%ld)",
+			   PTR_ERR(skb));
+		return PTR_ERR(skb);
+	}
+
+	kfree_skb(skb);
+	return 0;
+}
+EXPORT_SYMBOL_GPL(btintel_config_debug_features);
+
 MODULE_AUTHOR("Marcel Holtmann <[email protected]>");
 MODULE_DESCRIPTION("Bluetooth support for Intel devices ver " VERSION);
 MODULE_VERSION(VERSION);
drivers/bluetooth/btintel.h +7 -2
index 7cd813fc5db4..63743b89dad9 100644
@@ -92,10 +92,10 @@ int btintel_read_boot_params(struct hci_dev *hdev,
 int btintel_download_firmware(struct hci_dev *dev, const struct firmware *fw,
 			      u32 *boot_param);
 void btintel_reset_to_bootloader(struct hci_dev *hdev);
-
 int btintel_read_debug_features(struct hci_dev *hdev,
 				struct intel_debug_features *features);
-
+int btintel_config_debug_features(struct hci_dev *hdev,
+				  const struct intel_debug_features *features);
 #else
 
 static inline int btintel_check_bdaddr(struct hci_dev *hdev)
@@ -201,4 +201,9 @@ static inline int btintel_read_debug_features(struct hci_dev *hdev,
 	return -EOPNOTSUPP;
 }
 
+static inline int btintel_config_debug_features(struct hci_dev *hdev,
+						const struct intel_debug_features *features)
+{
+	return -EOPNOTSUPP;
+}
 #endif
drivers/bluetooth/btusb.c +2 -0
index 1d36141ebe65..b1573004ffac 100644
@@ -2547,6 +2547,8 @@ static int btusb_setup_intel_new(struct hci_dev *hdev)
 	 */
 	btintel_read_debug_features(hdev, &debug_features);
 
+	btintel_config_debug_features(hdev, &debug_features);
+
 	/* Read the Intel version information after loading the FW  */
 	err = btintel_read_version(hdev, &ver);
 	if (err)
Signature · 1 line
2.17.1
maintainer
#2 lore raw

Re: [PATCH v3 2/2] Bluetooth : Config debug feature based on available support

Hi Kiran,

Quoted 11 lines

This patch shall enable the Intel telemetry exception format based on the supported features

---

drivers/bluetooth/btintel.c | 27 +++++++++++++++++++++++++++
drivers/bluetooth/btintel.h |  9 +++++++--
drivers/bluetooth/btusb.c   |  2 ++
3 files changed, 36 insertions(+), 2 deletions(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel

maintainer
#3 lore raw
In reply to Kiran K

Hi Kiran,

Quoted 4 lines

The command shall read the Intel controller supported debug feature. Based on the supported features additional debug configuration shall be enabled.

Quoted 8 lines

---

drivers/bluetooth/btintel.c | 33 +++++++++++++++++++++++++++++++++
drivers/bluetooth/btintel.h | 15 +++++++++++++++
drivers/bluetooth/btusb.c   |  7 ++++++-
3 files changed, 54 insertions(+), 1 deletion(-)

patch has been applied to bluetooth-next tree.

Regards

Marcel