linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support
@ 2020-06-11  1:53 Abhishek Pandit-Subedi
  2020-06-11  1:53 ` [PATCH 1/3] Bluetooth: btmrvl_sdio: Set parent dev to hdev Abhishek Pandit-Subedi
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-06-11  1:53 UTC (permalink / raw)
  To: marcel, linux-bluetooth
  Cc: alainm, chromeos-bluetooth-upstreaming, mka, dianders, linux-pm,
	Abhishek Pandit-Subedi, Johan Hedberg, Marcel Holtmann,
	linux-kernel


Hi linux-bluetooth,

This patch series is refactoring the btmrvl driver to add better support
for controlling remote wakeup during suspend. Previously, the hci device
was getting created as /sys/devices/virtual/bluetooth/hci0 and there
wasn't a way to control wakeup for the device from userspace. This
series of changes adds the proper parent for the hci device, allows irq
configuration via power/wakeup and properly disables scanning during
suspend if wakeup isn't enabled.

This was tested on a Veyron Mighty Chromebook running the 4.19 kernel
with these patches. It passes both automated and manual suspend+resume
tests that make sure wakeup is working properly.

Thanks
Abhishek



Abhishek Pandit-Subedi (3):
  Bluetooth: btmrvl_sdio: Set parent dev to hdev
  Bluetooth: btmrvl_sdio: Implement prevent_wake
  Bluetooth: btmrvl_sdio: Refactor irq wakeup

 drivers/bluetooth/btmrvl_main.c | 11 +++++++++++
 drivers/bluetooth/btmrvl_sdio.c | 13 ++++++++++---
 2 files changed, 21 insertions(+), 3 deletions(-)

-- 
2.27.0.278.ge193c7cf3a9-goog


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

* [PATCH 1/3] Bluetooth: btmrvl_sdio: Set parent dev to hdev
  2020-06-11  1:53 [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support Abhishek Pandit-Subedi
@ 2020-06-11  1:53 ` Abhishek Pandit-Subedi
  2020-06-11  1:53 ` [PATCH 2/3] Bluetooth: btmrvl_sdio: Implement prevent_wake Abhishek Pandit-Subedi
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-06-11  1:53 UTC (permalink / raw)
  To: marcel, linux-bluetooth
  Cc: alainm, chromeos-bluetooth-upstreaming, mka, dianders, linux-pm,
	Abhishek Pandit-Subedi, Johan Hedberg, Marcel Holtmann,
	linux-kernel

Set the correct parent dev when registering hdev. This allows userspace
tools to find the parent device (for example, to set the power/wakeup
property).

Before this change, the path was /sys/devices/virtual/bluetooth/hci0
and after this change, it looks more like:
/sys/bus/mmc/devices/mmc1:0001/mmc1:0001:2/bluetooth/hci0

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
---

 drivers/bluetooth/btmrvl_main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index 708ad21683eb31..47e450903af423 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -669,6 +669,7 @@ static int btmrvl_service_main_thread(void *data)
 int btmrvl_register_hdev(struct btmrvl_private *priv)
 {
 	struct hci_dev *hdev = NULL;
+	struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
 	int ret;
 
 	hdev = hci_alloc_dev();
@@ -687,6 +688,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv)
 	hdev->send  = btmrvl_send_frame;
 	hdev->setup = btmrvl_setup;
 	hdev->set_bdaddr = btmrvl_set_bdaddr;
+	SET_HCIDEV_DEV(hdev, &card->func->dev);
 
 	hdev->dev_type = priv->btmrvl_dev.dev_type;
 
-- 
2.27.0.278.ge193c7cf3a9-goog


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

* [PATCH 2/3] Bluetooth: btmrvl_sdio: Implement prevent_wake
  2020-06-11  1:53 [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support Abhishek Pandit-Subedi
  2020-06-11  1:53 ` [PATCH 1/3] Bluetooth: btmrvl_sdio: Set parent dev to hdev Abhishek Pandit-Subedi
@ 2020-06-11  1:53 ` Abhishek Pandit-Subedi
  2020-06-11  1:53 ` [PATCH 3/3] Bluetooth: btmrvl_sdio: Refactor irq wakeup Abhishek Pandit-Subedi
  2020-06-12  6:39 ` [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support Marcel Holtmann
  3 siblings, 0 replies; 5+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-06-11  1:53 UTC (permalink / raw)
  To: marcel, linux-bluetooth
  Cc: alainm, chromeos-bluetooth-upstreaming, mka, dianders, linux-pm,
	Abhishek Pandit-Subedi, Johan Hedberg, Marcel Holtmann,
	linux-kernel

Use the parent device's power/wakeup to control whether we support
remote wake. If remote wakeup is disabled, Bluetooth will not enable
scanning for incoming connections.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
---

 drivers/bluetooth/btmrvl_main.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/bluetooth/btmrvl_main.c b/drivers/bluetooth/btmrvl_main.c
index 47e450903af423..8b9d78ce6bb29e 100644
--- a/drivers/bluetooth/btmrvl_main.c
+++ b/drivers/bluetooth/btmrvl_main.c
@@ -587,6 +587,14 @@ static int btmrvl_set_bdaddr(struct hci_dev *hdev, const bdaddr_t *bdaddr)
 	return 0;
 }
 
+static bool btmrvl_prevent_wake(struct hci_dev *hdev)
+{
+	struct btmrvl_private *priv = hci_get_drvdata(hdev);
+	struct btmrvl_sdio_card *card = priv->btmrvl_dev.card;
+
+	return !device_may_wakeup(&card->func->dev);
+}
+
 /*
  * This function handles the event generated by firmware, rx data
  * received from firmware, and tx data sent from kernel.
@@ -688,6 +696,7 @@ int btmrvl_register_hdev(struct btmrvl_private *priv)
 	hdev->send  = btmrvl_send_frame;
 	hdev->setup = btmrvl_setup;
 	hdev->set_bdaddr = btmrvl_set_bdaddr;
+	hdev->prevent_wake = btmrvl_prevent_wake;
 	SET_HCIDEV_DEV(hdev, &card->func->dev);
 
 	hdev->dev_type = priv->btmrvl_dev.dev_type;
-- 
2.27.0.278.ge193c7cf3a9-goog


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

* [PATCH 3/3] Bluetooth: btmrvl_sdio: Refactor irq wakeup
  2020-06-11  1:53 [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support Abhishek Pandit-Subedi
  2020-06-11  1:53 ` [PATCH 1/3] Bluetooth: btmrvl_sdio: Set parent dev to hdev Abhishek Pandit-Subedi
  2020-06-11  1:53 ` [PATCH 2/3] Bluetooth: btmrvl_sdio: Implement prevent_wake Abhishek Pandit-Subedi
@ 2020-06-11  1:53 ` Abhishek Pandit-Subedi
  2020-06-12  6:39 ` [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support Marcel Holtmann
  3 siblings, 0 replies; 5+ messages in thread
From: Abhishek Pandit-Subedi @ 2020-06-11  1:53 UTC (permalink / raw)
  To: marcel, linux-bluetooth
  Cc: alainm, chromeos-bluetooth-upstreaming, mka, dianders, linux-pm,
	Abhishek Pandit-Subedi, Johan Hedberg, Marcel Holtmann,
	linux-kernel

Use device_init_wakeup to allow the Bluetooth dev to wake the system
from suspend. Currently, the device can wake the system but no
power/wakeup entry is created in sysfs to allow userspace to disable
wakeup.

Signed-off-by: Abhishek Pandit-Subedi <abhishekpandit@chromium.org>
Reviewed-by: Douglas Anderson <dianders@chromium.org>
---

 drivers/bluetooth/btmrvl_sdio.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/bluetooth/btmrvl_sdio.c b/drivers/bluetooth/btmrvl_sdio.c
index 4c7978cb1786fc..cfb9f9db44a0d9 100644
--- a/drivers/bluetooth/btmrvl_sdio.c
+++ b/drivers/bluetooth/btmrvl_sdio.c
@@ -111,6 +111,9 @@ static int btmrvl_sdio_probe_of(struct device *dev,
 					"Failed to request irq_bt %d (%d)\n",
 					cfg->irq_bt, ret);
 			}
+
+			/* Configure wakeup (enabled by default) */
+			device_init_wakeup(dev, true);
 			disable_irq(cfg->irq_bt);
 		}
 	}
@@ -1654,6 +1657,7 @@ static void btmrvl_sdio_remove(struct sdio_func *func)
 							MODULE_SHUTDOWN_REQ);
 				btmrvl_sdio_disable_host_int(card);
 			}
+
 			BT_DBG("unregister dev");
 			card->priv->surprise_removed = true;
 			btmrvl_sdio_unregister_dev(card);
@@ -1690,7 +1694,8 @@ static int btmrvl_sdio_suspend(struct device *dev)
 	}
 
 	/* Enable platform specific wakeup interrupt */
-	if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0) {
+	if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0 &&
+	    device_may_wakeup(dev)) {
 		card->plt_wake_cfg->wake_by_bt = false;
 		enable_irq(card->plt_wake_cfg->irq_bt);
 		enable_irq_wake(card->plt_wake_cfg->irq_bt);
@@ -1707,7 +1712,8 @@ static int btmrvl_sdio_suspend(struct device *dev)
 			BT_ERR("HS not activated, suspend failed!");
 			/* Disable platform specific wakeup interrupt */
 			if (card->plt_wake_cfg &&
-			    card->plt_wake_cfg->irq_bt >= 0) {
+			    card->plt_wake_cfg->irq_bt >= 0 &&
+			    device_may_wakeup(dev)) {
 				disable_irq_wake(card->plt_wake_cfg->irq_bt);
 				disable_irq(card->plt_wake_cfg->irq_bt);
 			}
@@ -1767,7 +1773,8 @@ static int btmrvl_sdio_resume(struct device *dev)
 	hci_resume_dev(hcidev);
 
 	/* Disable platform specific wakeup interrupt */
-	if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0) {
+	if (card->plt_wake_cfg && card->plt_wake_cfg->irq_bt >= 0 &&
+	    device_may_wakeup(dev)) {
 		disable_irq_wake(card->plt_wake_cfg->irq_bt);
 		disable_irq(card->plt_wake_cfg->irq_bt);
 		if (card->plt_wake_cfg->wake_by_bt)
-- 
2.27.0.278.ge193c7cf3a9-goog


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

* Re: [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support
  2020-06-11  1:53 [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support Abhishek Pandit-Subedi
                   ` (2 preceding siblings ...)
  2020-06-11  1:53 ` [PATCH 3/3] Bluetooth: btmrvl_sdio: Refactor irq wakeup Abhishek Pandit-Subedi
@ 2020-06-12  6:39 ` Marcel Holtmann
  3 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2020-06-12  6:39 UTC (permalink / raw)
  To: Abhishek Pandit-Subedi
  Cc: marcel, Bluez mailing list, Alain Michaud,
	ChromeOS Bluetooth Upstreaming, Matthias Kaehlcke, dianders,
	linux-pm, Johan Hedberg, linux-kernel

Hi Abhishek,

> This patch series is refactoring the btmrvl driver to add better support
> for controlling remote wakeup during suspend. Previously, the hci device
> was getting created as /sys/devices/virtual/bluetooth/hci0 and there
> wasn't a way to control wakeup for the device from userspace. This
> series of changes adds the proper parent for the hci device, allows irq
> configuration via power/wakeup and properly disables scanning during
> suspend if wakeup isn't enabled.
> 
> This was tested on a Veyron Mighty Chromebook running the 4.19 kernel
> with these patches. It passes both automated and manual suspend+resume
> tests that make sure wakeup is working properly.
> 
> Thanks
> Abhishek
> 
> 
> 
> Abhishek Pandit-Subedi (3):
>  Bluetooth: btmrvl_sdio: Set parent dev to hdev
>  Bluetooth: btmrvl_sdio: Implement prevent_wake
>  Bluetooth: btmrvl_sdio: Refactor irq wakeup
> 
> drivers/bluetooth/btmrvl_main.c | 11 +++++++++++
> drivers/bluetooth/btmrvl_sdio.c | 13 ++++++++++---
> 2 files changed, 21 insertions(+), 3 deletions(-)

all 3 patches have been applied to bluetooth-next tree.

Regards

Marcel


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

end of thread, other threads:[~2020-06-12  6:39 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-11  1:53 [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support Abhishek Pandit-Subedi
2020-06-11  1:53 ` [PATCH 1/3] Bluetooth: btmrvl_sdio: Set parent dev to hdev Abhishek Pandit-Subedi
2020-06-11  1:53 ` [PATCH 2/3] Bluetooth: btmrvl_sdio: Implement prevent_wake Abhishek Pandit-Subedi
2020-06-11  1:53 ` [PATCH 3/3] Bluetooth: btmrvl_sdio: Refactor irq wakeup Abhishek Pandit-Subedi
2020-06-12  6:39 ` [PATCH 0/3] Bluetooth: btmrvl_sdio: Refactor remote wakeup support 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).