Linux-Bluetooth Archive on lore.kernel.org
 help / Atom feed
* [Patch v1] btusb: Add shutdown routine for BTUSB_INTEL_NEW devices
@ 2019-01-29 12:24 raghuram.hegde
  2019-01-29 15:17 ` Marcel Holtmann
  0 siblings, 1 reply; 2+ messages in thread
From: raghuram.hegde @ 2019-01-29 12:24 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Raghuram Hegde, Chethan T N

From: Raghuram Hegde <raghuram.hegde@intel.com>

Observation:
If BT operations (Eg:BREDR inquiry/LE scan) were triggered
through the stack, followed by BT turn off through
'hciconfig hci0 down', the controller would still be active
and consume power.
Also, there is a possibility that a race condition/
synchronization issue might arise on the subsequent BT turn
on, as the controller might try to push the
events that were queued up before processing the HCI Reset
command.

btusb_shutdown_intel_new routine shall reset the controller
and stop all BT operation.
Advantages:
	1. Power save on the platform
	2. Host and controller will be in Sync.

Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com>
Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
---
 drivers/bluetooth/btusb.c | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 5de0c2e59b97..3aac92be0f87 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -2434,6 +2434,24 @@ static int btusb_shutdown_intel(struct hci_dev *hdev)
 	return 0;
 }
 
+static int btusb_shutdown_intel_new(struct hci_dev *hdev)
+{
+	struct sk_buff *skb;
+	
+	/* Send HCI Reset to the controller to stop any BT activity which
+	 * were triggered. This will help to save power and maintain the
+	 * sync b/w Host and controller
+	 */
+	skb = __hci_cmd_sync(hdev, HCI_OP_RESET, 0, NULL, HCI_INIT_TIMEOUT);
+	if (IS_ERR(skb)) {
+		bt_dev_err(hdev, "HCI reset during shutdown failed");
+		return PTR_ERR(skb);
+	}
+	kfree_skb(skb);
+
+	return 0;
+}
+
 #ifdef CONFIG_PM
 /* Configure an out-of-band gpio as wake-up pin, if specified in device tree */
 static int marvell_config_oob_wake(struct hci_dev *hdev)
@@ -3139,6 +3157,7 @@ static int btusb_probe(struct usb_interface *intf,
 		hdev->manufacturer = 2;
 		hdev->send = btusb_send_frame_intel;
 		hdev->setup = btusb_setup_intel_new;
+		hdev->shutdown = btusb_shutdown_intel_new;
 		hdev->hw_error = btintel_hw_error;
 		hdev->set_diag = btintel_set_diag;
 		hdev->set_bdaddr = btintel_set_bdaddr;
-- 
2.7.4


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

* Re: [Patch v1] btusb: Add shutdown routine for BTUSB_INTEL_NEW devices
  2019-01-29 12:24 [Patch v1] btusb: Add shutdown routine for BTUSB_INTEL_NEW devices raghuram.hegde
@ 2019-01-29 15:17 ` Marcel Holtmann
  0 siblings, 0 replies; 2+ messages in thread
From: Marcel Holtmann @ 2019-01-29 15:17 UTC (permalink / raw)
  To: Raghuram Hegde; +Cc: linux-bluetooth, Chethan T N

Hi Raghuram,

> Observation:
> If BT operations (Eg:BREDR inquiry/LE scan) were triggered
> through the stack, followed by BT turn off through
> 'hciconfig hci0 down', the controller would still be active
> and consume power.
> Also, there is a possibility that a race condition/
> synchronization issue might arise on the subsequent BT turn
> on, as the controller might try to push the
> events that were queued up before processing the HCI Reset
> command.
> 
> btusb_shutdown_intel_new routine shall reset the controller
> and stop all BT operation.
> Advantages:
> 	1. Power save on the platform
> 	2. Host and controller will be in Sync.
> 
> Signed-off-by: Raghuram Hegde <raghuram.hegde@intel.com>
> Signed-off-by: Chethan T N <chethan.tumkur.narayan@intel.com>
> ---
> drivers/bluetooth/btusb.c | 19 +++++++++++++++++++
> 1 file changed, 19 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

end of thread, back to index

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-01-29 12:24 [Patch v1] btusb: Add shutdown routine for BTUSB_INTEL_NEW devices raghuram.hegde
2019-01-29 15:17 ` Marcel Holtmann

Linux-Bluetooth Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-bluetooth/0 linux-bluetooth/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-bluetooth linux-bluetooth/ https://lore.kernel.org/linux-bluetooth \
		linux-bluetooth@vger.kernel.org linux-bluetooth@archiver.kernel.org
	public-inbox-index linux-bluetooth


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-bluetooth


AGPL code for this site: git clone https://public-inbox.org/ public-inbox