Skip to contentSkip to conversation

Bluetooth: hci_qca: Update baudrate change wait time for wcn3990

PATCH In review Balakrishna Godavarthi 2 participants 3 messages Feb 20, 2019 – Feb 25, 2019

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: hci_qca: Update baudrate change wait time for wcn3990

This patch will update the baudrate change request wait time from 300 ms to 100 ms. When host sends the change baudrate request to the controller, controller sets its clock and wait until the clocks settle down. Here the Wait time is required for both host and controller to be on sync.

---
 drivers/bluetooth/hci_qca.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bluetooth/hci_qca.c +10 -2
index 5e03504c4e0c..22f3c983f868 100644
@@ -59,7 +59,8 @@
 
 #define IBS_WAKE_RETRANS_TIMEOUT_MS	100
 #define IBS_TX_IDLE_TIMEOUT_MS		2000
-#define BAUDRATE_SETTLE_TIMEOUT_MS	300
+#define ROME_BD_SETTLE_TIMEOUT_MS	300
+#define WCN3990_BD_SETTLE_TIMEOUT_MS	100
 #define POWER_PULSE_TRANS_TIMEOUT_MS	100
 
 /* susclk rate */
@@ -965,8 +966,11 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
 	struct hci_uart *hu = hci_get_drvdata(hdev);
 	struct qca_data *qca = hu->priv;
 	struct sk_buff *skb;
+	struct qca_serdev *qcadev;
+	unsigned int bd_settling_timeout;
 	u8 cmd[] = { 0x01, 0x48, 0xFC, 0x01, 0x00 };
 
+	qcadev = serdev_device_get_drvdata(hu->serdev);
 	if (baudrate > QCA_BAUDRATE_3200000)
 		return -EINVAL;
 
@@ -989,8 +993,12 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
 	 * controller will come back after they receive this HCI command
 	 * then host can communicate with new baudrate to controller
 	 */
+	bd_settling_timeout = qcadev->btsoc_type == QCA_WCN3990 ?
+			       WCN3990_BD_SETTLE_TIMEOUT_MS :
+			       ROME_BD_SETTLE_TIMEOUT_MS;
+
 	set_current_state(TASK_UNINTERRUPTIBLE);
-	schedule_timeout(msecs_to_jiffies(BAUDRATE_SETTLE_TIMEOUT_MS));
+	schedule_timeout(msecs_to_jiffies(bd_settling_timeout));
 	set_current_state(TASK_RUNNING);
 
 	return 0;
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
#1 lore raw

Hi Balakrishna,

Quoted 16 lines · Balakrishna Godavarthi

This patch will update the baudrate change request wait time from 300 ms to 100 ms. When host sends the change baudrate request to the controller, controller sets its clock and wait until the clocks settle down. Here the Wait time is required for both host and controller to be on sync.

---
 drivers/bluetooth/hci_qca.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bluetooth/hci_qca.c +0 -0
index 5e03504c4e0c..22f3c983f868 100644

drivers/bluetooth/hci_qca.c line 63

Quoted 6 lines
drivers/bluetooth/hci_qca.c +2 -1
@@ -59,7 +59,8 @@
 
 #define IBS_WAKE_RETRANS_TIMEOUT_MS	100
 #define IBS_TX_IDLE_TIMEOUT_MS		2000
-#define BAUDRATE_SETTLE_TIMEOUT_MS	300
+#define ROME_BD_SETTLE_TIMEOUT_MS	300
+#define WCN3990_BD_SETTLE_TIMEOUT_MS	100

nit: _BR_ instead of _BD_?

drivers/bluetooth/hci_qca.c static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) · line 970

Quoted 9 lines
drivers/bluetooth/hci_qca.c +2 -0
 #define POWER_PULSE_TRANS_TIMEOUT_MS	100
 
 /* susclk rate */
@@ -965,8 +966,11 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
 	struct hci_uart *hu = hci_get_drvdata(hdev);
 	struct qca_data *qca = hu->priv;
 	struct sk_buff *skb;
+	struct qca_serdev *qcadev;
+	unsigned int bd_settling_timeout;

nit: from the context the purpose of the variable is fairly clear, calling it just 'timeout' (or 'settling_time', it's not really a timeout) should be fine.

That said, I have a similar change in my pipeline, which further reduces the time to the 'strictly necessary'. It's slightly more code though. I guess I'll send it and we can discuss/let Marcel decide what to adopt.

Cheers

Matthias

#2 lore raw

Hi,

Quoted 42 lines · Matthias Kaehlcke

Hi Balakrishna,

Quoted 16 lines · Balakrishna Godavarthi

This patch will update the baudrate change request wait time from 300 ms to 100 ms. When host sends the change baudrate request to the controller, controller sets its clock and wait until the clocks settle down. Here the Wait time is required for both host and controller to be on sync.

---
 drivers/bluetooth/hci_qca.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/bluetooth/hci_qca.c +0 -0
index 5e03504c4e0c..22f3c983f868 100644

drivers/bluetooth/hci_qca.c line 63

Quoted 6 lines
drivers/bluetooth/hci_qca.c +2 -1
@@ -59,7 +59,8 @@
 
 #define IBS_WAKE_RETRANS_TIMEOUT_MS	100
 #define IBS_TX_IDLE_TIMEOUT_MS		2000
-#define BAUDRATE_SETTLE_TIMEOUT_MS	300
+#define ROME_BD_SETTLE_TIMEOUT_MS	300
+#define WCN3990_BD_SETTLE_TIMEOUT_MS	100

nit: _BR_ instead of _BD_?

drivers/bluetooth/hci_qca.c static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate) · line 970

Quoted 9 lines
drivers/bluetooth/hci_qca.c +2 -0
 #define POWER_PULSE_TRANS_TIMEOUT_MS	100
 
 /* susclk rate */
@@ -965,8 +966,11 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
 	struct hci_uart *hu = hci_get_drvdata(hdev);
 	struct qca_data *qca = hu->priv;
 	struct sk_buff *skb;
+	struct qca_serdev *qcadev;
+	unsigned int bd_settling_timeout;

nit: from the context the purpose of the variable is fairly clear, calling it just 'timeout' (or 'settling_time', it's not really a timeout) should be fine.

Quoted 4 lines

That said, I have a similar change in my pipeline, which further reduces the time to the 'strictly necessary'. It's slightly more code though. I guess I'll send it and we can discuss/let Marcel decide what to adopt.

I haven't sent my patches yet since I encountered initialization errors when testing, however it turns out these errors are not related with my changes.

This series fixes the problem:

https://lore.kernel.org/patchwork/project/lkml/list/?series=384571

I'm now retesting my changes and will send them soon unless I encounter other issues.

Thanks

Matthias