Skip to contentSkip to conversation

Bluetooth: hci_qca: wait for Pre shutdown to command complete event before sending the Power off pulse

PATCH Superseded Harish Bandi 3 participants 5 messages Aug 8, 2019 – Aug 9, 2019

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Bluetooth: hci_qca: wait for Pre shutdown to command complete event before sending the Power off pulse

When SoC receives pre shut down command, it share the same with other COEX shared clients. So SoC needs a short time after sending VS pre shutdown command before turning off the regulators and sending the power off pulse.

---
 drivers/bluetooth/btqca.c   | 5 +++--
 drivers/bluetooth/hci_qca.c | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/bluetooth/btqca.c +3 -2
index 2221935..f20991e 100644
@@ -106,8 +106,9 @@ int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)
 
 	bt_dev_dbg(hdev, "QCA pre shutdown cmd");
 
-	skb = __hci_cmd_sync(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
-				NULL, HCI_INIT_TIMEOUT);
+	skb = __hci_cmd_sync_ev(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
+				NULL, HCI_EV_CMD_COMPLETE, HCI_INIT_TIMEOUT);
+
 	if (IS_ERR(skb)) {
 		err = PTR_ERR(skb);
 		bt_dev_err(hdev, "QCA preshutdown_cmd failed (%d)", err);
drivers/bluetooth/hci_qca.c +2 -0
index 16db6c0..566aa28 100644
@@ -1386,6 +1386,8 @@ static int qca_power_off(struct hci_dev *hdev)
 	/* Perform pre shutdown command */
 	qca_send_pre_shutdown_cmd(hdev);
 
+	usleep_range(8000, 10000);
+
 	qca_power_shutdown(hu);
 	return 0;
 }
Signature · 2 lines
The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum,
a Linux Foundation Collaborative Project
Reviewed-by on v1 1/1
#1 lore raw

Hi Harish,

Quoted 16 lines · Harish Bandi

When SoC receives pre shut down command, it share the same with other COEX shared clients. So SoC needs a short time after sending VS pre shutdown command before turning off the regulators and sending the power off pulse.

---
 drivers/bluetooth/btqca.c   | 5 +++--
 drivers/bluetooth/hci_qca.c | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/bluetooth/btqca.c +0 -0
index 2221935..f20991e 100644

drivers/bluetooth/btqca.c int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) · line 110

Quoted 7 lines
drivers/bluetooth/btqca.c +2 -2
@@ -106,8 +106,9 @@ int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)
 
 	bt_dev_dbg(hdev, "QCA pre shutdown cmd");
 
-	skb = __hci_cmd_sync(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
-				NULL, HCI_INIT_TIMEOUT);
+	skb = __hci_cmd_sync_ev(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
+				NULL, HCI_EV_CMD_COMPLETE, HCI_INIT_TIMEOUT);

[Bala]: nit: can you also add reason in commit text for adding HCI_EV_CMD_COMPLETE

Quoted 9 lines
drivers/bluetooth/btqca.c +1 -0
+
 	if (IS_ERR(skb)) {
 		err = PTR_ERR(skb);
 		bt_dev_err(hdev, "QCA preshutdown_cmd failed (%d)", err);
drivers/bluetooth/hci_qca.c +0 -0
index 16db6c0..566aa28 100644

drivers/bluetooth/hci_qca.c static int qca_power_off(struct hci_dev *hdev) · line 1393

Quoted 8 lines
drivers/bluetooth/hci_qca.c +2 -0
@@ -1386,6 +1386,8 @@ static int qca_power_off(struct hci_dev *hdev)
 	/* Perform pre shutdown command */
 	qca_send_pre_shutdown_cmd(hdev);
 
+	usleep_range(8000, 10000);
+
 	qca_power_shutdown(hu);
 	return 0;
 }
Signature · 2 lines
Regards
Balakrishna.
#2 lore raw

Hi Bala,

Quoted 23 lines · Balakrishna Godavarthi

Hi Harish,

Quoted 20 lines · Harish Bandi

When SoC receives pre shut down command, it share the same with other COEX shared clients. So SoC needs a short time after sending VS pre shutdown command before turning off the regulators and sending the power off pulse.

---
 drivers/bluetooth/btqca.c   | 5 +++--
 drivers/bluetooth/hci_qca.c | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/bluetooth/btqca.c +0 -0
index 2221935..f20991e 100644
@@ -106,8 +106,9 @@ int qca_send_pre_shutdown_cmd(struct hci_dev 
 *hdev)
 
 	bt_dev_dbg(hdev, "QCA pre shutdown cmd");
 
Quoted 7 lines

drivers/bluetooth/btqca.c int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) · line 110

Quoted 4 lines
drivers/bluetooth/btqca.c +2 -2
-	skb = __hci_cmd_sync(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
-				NULL, HCI_INIT_TIMEOUT);
+	skb = __hci_cmd_sync_ev(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
+				NULL, HCI_EV_CMD_COMPLETE, HCI_INIT_TIMEOUT);

[Bala]: nit: can you also add reason in commit text for adding HCI_EV_CMD_COMPLETE

[Harish] - I will add reason fo HCI_EV_CMD_COMPLETE in commit text and post new patch.

Quoted 13 lines
Quoted 13 lines
drivers/bluetooth/btqca.c +1 -0
+
 	if (IS_ERR(skb)) {
 		err = PTR_ERR(skb);
drivers/bluetooth/btqca.c +0 -0
 		bt_dev_err(hdev, "QCA preshutdown_cmd failed (%d)", err);
drivers/bluetooth/hci_qca.c +0 -0
index 16db6c0..566aa28 100644
@@ -1386,6 +1386,8 @@ static int qca_power_off(struct hci_dev *hdev)
 	/* Perform pre shutdown command */
 	qca_send_pre_shutdown_cmd(hdev);
 
Quoted 7 lines

drivers/bluetooth/hci_qca.c static int qca_power_off(struct hci_dev *hdev) · line 1393

Quoted 5 lines
drivers/bluetooth/hci_qca.c +2 -0
+	usleep_range(8000, 10000);
+
 	qca_power_shutdown(hu);
 	return 0;
 }

Thanks,
Harish

#3 lore raw
In reply to Harish Bandi
Quoted 16 lines · Harish Bandi

When SoC receives pre shut down command, it share the same with other COEX shared clients. So SoC needs a short time after sending VS pre shutdown command before turning off the regulators and sending the power off pulse.

---
 drivers/bluetooth/btqca.c   | 5 +++--
 drivers/bluetooth/hci_qca.c | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/bluetooth/btqca.c +0 -0
index 2221935..f20991e 100644

drivers/bluetooth/btqca.c int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) · line 111

Quoted 8 lines
drivers/bluetooth/btqca.c +3 -2
@@ -106,8 +106,9 @@ int qca_send_pre_shutdown_cmd(struct hci_dev *hdev)
 
 	bt_dev_dbg(hdev, "QCA pre shutdown cmd");
 
-	skb = __hci_cmd_sync(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
-				NULL, HCI_INIT_TIMEOUT);
+	skb = __hci_cmd_sync_ev(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
+				NULL, HCI_EV_CMD_COMPLETE, HCI_INIT_TIMEOUT);
+

The commit message does not mention this change, it only talks about adding a delay.

Quoted 16 lines
drivers/bluetooth/btqca.c +0 -0
 	if (IS_ERR(skb)) {
 		err = PTR_ERR(skb);
 		bt_dev_err(hdev, "QCA preshutdown_cmd failed (%d)", err);
drivers/bluetooth/hci_qca.c +2 -0
index 16db6c0..566aa28 100644
@@ -1386,6 +1386,8 @@ static int qca_power_off(struct hci_dev *hdev)
 	/* Perform pre shutdown command */
 	qca_send_pre_shutdown_cmd(hdev);
 
+	usleep_range(8000, 10000);
+
 	qca_power_shutdown(hu);
 	return 0;
 }
#4 lore raw

Hi Matthias,

Quoted 21 lines · Matthias Kaehlcke
Quoted 20 lines · Harish Bandi

When SoC receives pre shut down command, it share the same with other COEX shared clients. So SoC needs a short time after sending VS pre shutdown command before turning off the regulators and sending the power off pulse.

---
 drivers/bluetooth/btqca.c   | 5 +++--
 drivers/bluetooth/hci_qca.c | 2 ++
 2 files changed, 5 insertions(+), 2 deletions(-)
drivers/bluetooth/btqca.c +0 -0
index 2221935..f20991e 100644
@@ -106,8 +106,9 @@ int qca_send_pre_shutdown_cmd(struct hci_dev 
 *hdev)
 
 	bt_dev_dbg(hdev, "QCA pre shutdown cmd");
 
Quoted 8 lines

drivers/bluetooth/btqca.c int qca_send_pre_shutdown_cmd(struct hci_dev *hdev) · line 111

Quoted 5 lines
drivers/bluetooth/btqca.c +3 -2
-	skb = __hci_cmd_sync(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
-				NULL, HCI_INIT_TIMEOUT);
+	skb = __hci_cmd_sync_ev(hdev, QCA_PRE_SHUTDOWN_CMD, 0,
+				NULL, HCI_EV_CMD_COMPLETE, HCI_INIT_TIMEOUT);
+

The commit message does not mention this change, it only talks about adding a delay.

[Harish] - I will add reason fo HCI_EV_CMD_COMPLETE in commit text and post new patch. In commit text title I mentioned about command complete event, However I will add more details about reason for command complete in commit text

Quoted 17 lines
Quoted 17 lines
drivers/bluetooth/btqca.c +0 -0
 	if (IS_ERR(skb)) {
 		err = PTR_ERR(skb);
drivers/bluetooth/btqca.c +0 -0
 		bt_dev_err(hdev, "QCA preshutdown_cmd failed (%d)", err);
drivers/bluetooth/hci_qca.c +2 -0
index 16db6c0..566aa28 100644
@@ -1386,6 +1386,8 @@ static int qca_power_off(struct hci_dev *hdev)
 	/* Perform pre shutdown command */
 	qca_send_pre_shutdown_cmd(hdev);
 
+	usleep_range(8000, 10000);
+
 	qca_power_shutdown(hu);
 	return 0;
 }