linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set
@ 2020-09-10 10:30 Venkata Lakshmi Narayana Gubba
  2020-09-10 10:30 ` [RESEND v1 1/2] Bluetooth: hci_serdev: " Venkata Lakshmi Narayana Gubba
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Venkata Lakshmi Narayana Gubba @ 2020-09-10 10:30 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mka, linux-kernel, linux-bluetooth, hemantg, linux-arm-msm,
	bgodavar, rjliao, hbandi, abhishekpandit,
	Venkata Lakshmi Narayana Gubba

When HCI_QUIRK_NON_PERSISTENT_SETUP is set by drivers,
it indicates that BT SoC will be completely powered OFF
during BT OFF. On next BT ON firmware must be downloaded
again. Holding UART port open during BT OFF is draining
the battery. Now during BT OFF, UART port is closed if
qurik HCI_QUIRK_NON_PERSISTENT_SETUP is set by clearing
HCI_UART_PROTO_READY proto flag. On next BT ON, UART
port is opened if HCI_UART_PROTO_READY proto flag is cleared.

Venkata Lakshmi Narayana Gubba (2):
  Bluetooth: hci_serdev: Close UART port if NON_PERSISTENT_SETUP is set
  Bluetooth: hci_qca: Remove duplicate power off in proto close

 drivers/bluetooth/hci_qca.c    |  5 ++---
 drivers/bluetooth/hci_serdev.c | 36 +++++++++++++++++++++++++++++++++---
 2 files changed, 35 insertions(+), 6 deletions(-)

-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RESEND v1 1/2] Bluetooth: hci_serdev: Close UART port if NON_PERSISTENT_SETUP is set
  2020-09-10 10:30 [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set Venkata Lakshmi Narayana Gubba
@ 2020-09-10 10:30 ` Venkata Lakshmi Narayana Gubba
  2020-09-10 10:30 ` [RESEND v1 2/2] Bluetooth: hci_qca: Remove duplicate power off in proto close Venkata Lakshmi Narayana Gubba
  2020-09-11  7:10 ` [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set Marcel Holtmann
  2 siblings, 0 replies; 4+ messages in thread
From: Venkata Lakshmi Narayana Gubba @ 2020-09-10 10:30 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mka, linux-kernel, linux-bluetooth, hemantg, linux-arm-msm,
	bgodavar, rjliao, hbandi, abhishekpandit,
	Venkata Lakshmi Narayana Gubba

When HCI_QUIRK_NON_PERSISTENT_SETUP is set by drivers,
it indicates that BT SoC will be completely powered OFF
during BT OFF. On next BT ON firmware must be downloaded
again. Holding UART port open during BT OFF is draining
the battery. Now during BT OFF, UART port is closed if
qurik HCI_QUIRK_NON_PERSISTENT_SETUP is set by clearing
HCI_UART_PROTO_READY proto flag. On next BT ON, UART
port is opened if HCI_UART_PROTO_READY proto flag is cleared.

Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>
---
 drivers/bluetooth/hci_serdev.c | 36 +++++++++++++++++++++++++++++++++---
 1 file changed, 33 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/hci_serdev.c b/drivers/bluetooth/hci_serdev.c
index 3977bba..ef96ad0 100644
--- a/drivers/bluetooth/hci_serdev.c
+++ b/drivers/bluetooth/hci_serdev.c
@@ -113,8 +113,22 @@ static int hci_uart_flush(struct hci_dev *hdev)
 /* Initialize device */
 static int hci_uart_open(struct hci_dev *hdev)
 {
+	struct hci_uart *hu = hci_get_drvdata(hdev);
+	int err;
+
 	BT_DBG("%s %p", hdev->name, hdev);
 
+	/* When Quirk HCI_QUIRK_NON_PERSISTENT_SETUP is set by
+	 * driver, BT SoC is completely turned OFF during
+	 * BT OFF. Upon next BT ON UART port should be opened.
+	 */
+	if (!test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
+		err = serdev_device_open(hu->serdev);
+		if (err)
+			return err;
+		set_bit(HCI_UART_PROTO_READY, &hu->flags);
+	}
+
 	/* Undo clearing this from hci_uart_close() */
 	hdev->flush = hci_uart_flush;
 
@@ -124,11 +138,25 @@ static int hci_uart_open(struct hci_dev *hdev)
 /* Close device */
 static int hci_uart_close(struct hci_dev *hdev)
 {
+	struct hci_uart *hu = hci_get_drvdata(hdev);
+
 	BT_DBG("hdev %p", hdev);
 
+	if (!test_bit(HCI_UART_PROTO_READY, &hu->flags))
+		return 0;
+
 	hci_uart_flush(hdev);
 	hdev->flush = NULL;
 
+	/* When QUIRK HCI_QUIRK_NON_PERSISTENT_SETUP is set by driver,
+	 * BT SOC is completely powered OFF during BT OFF, holding port
+	 * open may drain the battery.
+	 */
+	if (test_bit(HCI_QUIRK_NON_PERSISTENT_SETUP, &hdev->quirks)) {
+		clear_bit(HCI_UART_PROTO_READY, &hu->flags);
+		serdev_device_close(hu->serdev);
+	}
+
 	return 0;
 }
 
@@ -354,8 +382,6 @@ void hci_uart_unregister_device(struct hci_uart *hu)
 {
 	struct hci_dev *hdev = hu->hdev;
 
-	clear_bit(HCI_UART_PROTO_READY, &hu->flags);
-
 	cancel_work_sync(&hu->init_ready);
 	if (test_bit(HCI_UART_REGISTERED, &hu->flags))
 		hci_unregister_dev(hdev);
@@ -364,6 +390,10 @@ void hci_uart_unregister_device(struct hci_uart *hu)
 	cancel_work_sync(&hu->write_work);
 
 	hu->proto->close(hu);
-	serdev_device_close(hu->serdev);
+
+	if (test_bit(HCI_UART_PROTO_READY, &hu->flags)) {
+		clear_bit(HCI_UART_PROTO_READY, &hu->flags);
+		serdev_device_close(hu->serdev);
+	}
 }
 EXPORT_SYMBOL_GPL(hci_uart_unregister_device);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [RESEND v1 2/2] Bluetooth: hci_qca: Remove duplicate power off in proto close
  2020-09-10 10:30 [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set Venkata Lakshmi Narayana Gubba
  2020-09-10 10:30 ` [RESEND v1 1/2] Bluetooth: hci_serdev: " Venkata Lakshmi Narayana Gubba
@ 2020-09-10 10:30 ` Venkata Lakshmi Narayana Gubba
  2020-09-11  7:10 ` [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set Marcel Holtmann
  2 siblings, 0 replies; 4+ messages in thread
From: Venkata Lakshmi Narayana Gubba @ 2020-09-10 10:30 UTC (permalink / raw)
  To: marcel, johan.hedberg
  Cc: mka, linux-kernel, linux-bluetooth, hemantg, linux-arm-msm,
	bgodavar, rjliao, hbandi, abhishekpandit,
	Venkata Lakshmi Narayana Gubba

During serdev unregister, hdev->shutdown is called before
proto close. Removing duplicates power OFF call.

Signed-off-by: Venkata Lakshmi Narayana Gubba <gubbaven@codeaurora.org>
---
 drivers/bluetooth/hci_qca.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/hci_qca.c b/drivers/bluetooth/hci_qca.c
index 20e1ded..f0d9ee3 100644
--- a/drivers/bluetooth/hci_qca.c
+++ b/drivers/bluetooth/hci_qca.c
@@ -693,8 +693,6 @@ static int qca_close(struct hci_uart *hu)
 	destroy_workqueue(qca->workqueue);
 	qca->hu = NULL;
 
-	qca_power_shutdown(hu);
-
 	kfree_skb(qca->rx_skb);
 
 	hu->priv = NULL;
@@ -2032,8 +2030,9 @@ static int qca_serdev_probe(struct serdev_device *serdev)
 static void qca_serdev_remove(struct serdev_device *serdev)
 {
 	struct qca_serdev *qcadev = serdev_device_get_drvdata(serdev);
+	struct qca_power *power = qcadev->bt_power;
 
-	if (qca_is_wcn399x(qcadev->btsoc_type))
+	if (qca_is_wcn399x(qcadev->btsoc_type) && power->vregs_on)
 		qca_power_shutdown(&qcadev->serdev_hu);
 	else if (qcadev->susclk)
 		clk_disable_unprepare(qcadev->susclk);
-- 
QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member 
of Code Aurora Forum, hosted by The Linux Foundation


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set
  2020-09-10 10:30 [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set Venkata Lakshmi Narayana Gubba
  2020-09-10 10:30 ` [RESEND v1 1/2] Bluetooth: hci_serdev: " Venkata Lakshmi Narayana Gubba
  2020-09-10 10:30 ` [RESEND v1 2/2] Bluetooth: hci_qca: Remove duplicate power off in proto close Venkata Lakshmi Narayana Gubba
@ 2020-09-11  7:10 ` Marcel Holtmann
  2 siblings, 0 replies; 4+ messages in thread
From: Marcel Holtmann @ 2020-09-11  7:10 UTC (permalink / raw)
  To: Venkata Lakshmi Narayana Gubba
  Cc: Johan Hedberg, Matthias Kaehlcke, open list, linux-bluetooth,
	Hemantg, MSM, Balakrishna Godavarthi, rjliao, hbandi,
	abhishekpandit

Hi Venkata,

> When HCI_QUIRK_NON_PERSISTENT_SETUP is set by drivers,
> it indicates that BT SoC will be completely powered OFF
> during BT OFF. On next BT ON firmware must be downloaded
> again. Holding UART port open during BT OFF is draining
> the battery. Now during BT OFF, UART port is closed if
> qurik HCI_QUIRK_NON_PERSISTENT_SETUP is set by clearing
> HCI_UART_PROTO_READY proto flag. On next BT ON, UART
> port is opened if HCI_UART_PROTO_READY proto flag is cleared.
> 
> Venkata Lakshmi Narayana Gubba (2):
>  Bluetooth: hci_serdev: Close UART port if NON_PERSISTENT_SETUP is set
>  Bluetooth: hci_qca: Remove duplicate power off in proto close
> 
> drivers/bluetooth/hci_qca.c    |  5 ++---
> drivers/bluetooth/hci_serdev.c | 36 +++++++++++++++++++++++++++++++++---
> 2 files changed, 35 insertions(+), 6 deletions(-)

both patches have been applied to bluetooth-next tree.

Regards

Marcel


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2020-09-11  7:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-10 10:30 [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set Venkata Lakshmi Narayana Gubba
2020-09-10 10:30 ` [RESEND v1 1/2] Bluetooth: hci_serdev: " Venkata Lakshmi Narayana Gubba
2020-09-10 10:30 ` [RESEND v1 2/2] Bluetooth: hci_qca: Remove duplicate power off in proto close Venkata Lakshmi Narayana Gubba
2020-09-11  7:10 ` [RESEND v1 0/2] Close UART port if NON_PERSISTENT_SETUP is set Marcel Holtmann

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).