linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Matthias Kaehlcke <mka@chromium.org>
To: Marcel Holtmann <marcel@holtmann.org>,
	Johan Hedberg <johan.hedberg@gmail.com>
Cc: linux-bluetooth@vger.kernel.org, linux-kernel@vger.kernel.org,
	Balakrishna Godavarthi <bgodavar@codeaurora.org>,
	Hemantg <hemantg@codeaurora.org>,
	Matthias Kaehlcke <mka@chromium.org>
Subject: [PATCH 2/2] hci_qca: Reduce delay after sending baudrate request for WCN3990
Date: Tue, 26 Feb 2019 12:08:48 -0800	[thread overview]
Message-ID: <20190226200848.154216-3-mka@chromium.org> (raw)
In-Reply-To: <20190226200848.154216-1-mka@chromium.org>

The current 300ms delay after a baudrate change is extremely long.
For WCM3990 it is sufficient to wait 10ms after the baudrate change
request has been sent over the wire.

Signed-off-by: Matthias Kaehlcke <mka@chromium.org>
---
 drivers/bluetooth/hci_qca.c | 28 +++++++++++++++++++++-------
 1 file changed, 21 insertions(+), 7 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 703e099515f24..fd018cc5605c6 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -59,8 +59,7 @@
 
 #define IBS_WAKE_RETRANS_TIMEOUT_MS	100
 #define IBS_TX_IDLE_TIMEOUT_MS		2000
-#define BAUDRATE_SETTLE_TIMEOUT_MS	300
-#define POWER_PULSE_TRANS_TIMEOUT_MS	100
+#define CMD_TRANS_TIMEOUT_MS		100
 
 /* susclk rate */
 #define SUSCLK_RATE_32KHZ	32768
@@ -964,6 +963,7 @@ 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 qca_serdev *qcadev;
 	struct sk_buff *skb;
 	u8 cmd[] = { 0x01, 0x48, 0xFC, 0x01, 0x00 };
 
@@ -985,11 +985,25 @@ static int qca_set_baudrate(struct hci_dev *hdev, uint8_t baudrate)
 	skb_queue_tail(&qca->txq, skb);
 	hci_uart_tx_wakeup(hu);
 
-	/* wait 300ms to change new baudrate on controller side
-	 * controller will come back after they receive this HCI command
-	 * then host can communicate with new baudrate to controller
+	qcadev = serdev_device_get_drvdata(hu->serdev);
+
+	/* Wait for the baudrate change command to be sent and
+	 * processed by the controller.
 	 */
-	msleep(BAUDRATE_SETTLE_TIMEOUT_MS);
+	if (qcadev->btsoc_type == QCA_WCN3990) {
+		while (!skb_queue_empty(&qca->txq))
+			usleep_range(100, 200);
+
+		serdev_device_wait_until_sent(hu->serdev,
+			      msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS));
+
+		/* Make sure there is enough time for the BT
+		 * controller to process the baudrate change
+		*/
+		msleep(10);
+	} else {
+		msleep(300);
+	}
 
 	return 0;
 }
@@ -1005,7 +1019,7 @@ static inline void host_set_baudrate(struct hci_uart *hu, unsigned int speed)
 static int qca_send_power_pulse(struct hci_uart *hu, u8 cmd)
 {
 	int ret;
-	int timeout = msecs_to_jiffies(POWER_PULSE_TRANS_TIMEOUT_MS);
+	int timeout = msecs_to_jiffies(CMD_TRANS_TIMEOUT_MS);
 
 	/* These power pulses are single byte command which are sent
 	 * at required baudrate to wcn3990. On wcn3990, we have an external
-- 
2.21.0.rc2.261.ga7da99ff1b-goog


  parent reply	other threads:[~2019-02-26 20:09 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-02-26 20:08 [PATCH 0/2] Reduce delay after sending baudrate request for WCN3990 Matthias Kaehlcke
2019-02-26 20:08 ` [PATCH 1/2] hci_qca: Use msleep() instead of open coding it Matthias Kaehlcke
2019-02-26 20:08 ` Matthias Kaehlcke [this message]
2019-02-26 20:20   ` [PATCH 2/2] hci_qca: Reduce delay after sending baudrate request for WCN3990 Matthias Kaehlcke
2019-02-27  7:48 ` [PATCH 0/2] " Marcel Holtmann
2019-02-27 20:35   ` Matthias Kaehlcke

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190226200848.154216-3-mka@chromium.org \
    --to=mka@chromium.org \
    --cc=bgodavar@codeaurora.org \
    --cc=hemantg@codeaurora.org \
    --cc=johan.hedberg@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=marcel@holtmann.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).