linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] Bluetooth: hci_vhci: Add force_suspend entry
@ 2021-09-29 20:38 Luiz Augusto von Dentz
  2021-09-29 20:38 ` [PATCH 2/2] Bluetooth: hci_vhci: Add force_prevent_wake entry Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-09-29 20:38 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds force_suspend which can be used to force the controller into
suspend/resume state.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 drivers/bluetooth/hci_vhci.c | 53 ++++++++++++++++++++++++++++++++++++
 1 file changed, 53 insertions(+)

diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index cc3679f3491d..6cc326c55a24 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -21,6 +21,7 @@
 
 #include <linux/skbuff.h>
 #include <linux/miscdevice.h>
+#include <linux/debugfs.h>
 
 #include <net/bluetooth/bluetooth.h>
 #include <net/bluetooth/hci_core.h>
@@ -37,6 +38,8 @@ struct vhci_data {
 
 	struct mutex open_mutex;
 	struct delayed_work open_timeout;
+
+	bool suspended;
 };
 
 static int vhci_open_dev(struct hci_dev *hdev)
@@ -91,6 +94,53 @@ static int vhci_get_codec_config_data(struct hci_dev *hdev, __u8 type,
 	return 0;
 }
 
+static ssize_t force_suspend_read(struct file *file, char __user *user_buf,
+				  size_t count, loff_t *ppos)
+{
+	struct vhci_data *data = file->private_data;
+	char buf[3];
+
+	buf[0] = data->suspended ? 'Y' : 'N';
+	buf[1] = '\n';
+	buf[2] = '\0';
+	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+}
+
+static ssize_t force_suspend_write(struct file *file,
+				   const char __user *user_buf,
+				   size_t count, loff_t *ppos)
+{
+	struct vhci_data *data = file->private_data;
+	bool enable;
+	int err;
+
+	err = kstrtobool_from_user(user_buf, count, &enable);
+	if (err)
+		return err;
+
+	if (data->suspended == enable)
+		return -EALREADY;
+
+	if (enable)
+		err = hci_suspend_dev(data->hdev);
+	else
+		err = hci_resume_dev(data->hdev);
+
+	if (err)
+		return err;
+
+	data->suspended = enable;
+
+	return count;
+}
+
+static const struct file_operations force_suspend_fops = {
+	.open		= simple_open,
+	.read		= force_suspend_read,
+	.write		= force_suspend_write,
+	.llseek		= default_llseek,
+};
+
 static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
 {
 	struct hci_dev *hdev;
@@ -149,6 +199,9 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
 		return -EBUSY;
 	}
 
+	debugfs_create_file("force_suspend", 0644, hdev->debugfs, data,
+			    &force_suspend_fops);
+
 	hci_skb_pkt_type(skb) = HCI_VENDOR_PKT;
 
 	skb_put_u8(skb, 0xff);
-- 
2.31.1


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

* [PATCH 2/2] Bluetooth: hci_vhci: Add force_prevent_wake entry
  2021-09-29 20:38 [PATCH 1/2] Bluetooth: hci_vhci: Add force_suspend entry Luiz Augusto von Dentz
@ 2021-09-29 20:38 ` Luiz Augusto von Dentz
  2021-09-29 20:49   ` Marcel Holtmann
  2021-09-29 20:49 ` [PATCH 1/2] Bluetooth: hci_vhci: Add force_suspend entry Marcel Holtmann
  2021-09-29 22:05 ` [1/2] " bluez.test.bot
  2 siblings, 1 reply; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-09-29 20:38 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds force_prevent_wake which can be used to force a certain state
while interacting with force_suspend.

Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
---
 drivers/bluetooth/hci_vhci.c | 49 ++++++++++++++++++++++++++++++++++++
 1 file changed, 49 insertions(+)

diff --git a/drivers/bluetooth/hci_vhci.c b/drivers/bluetooth/hci_vhci.c
index 6cc326c55a24..acf2544dbb05 100644
--- a/drivers/bluetooth/hci_vhci.c
+++ b/drivers/bluetooth/hci_vhci.c
@@ -40,6 +40,7 @@ struct vhci_data {
 	struct delayed_work open_timeout;
 
 	bool suspended;
+	bool prevent_wake;
 };
 
 static int vhci_open_dev(struct hci_dev *hdev)
@@ -94,6 +95,13 @@ static int vhci_get_codec_config_data(struct hci_dev *hdev, __u8 type,
 	return 0;
 }
 
+static bool vhci_prevent_wake(struct hci_dev *hdev)
+{
+	struct vhci_data *data = hci_get_drvdata(hdev);
+
+	return data->prevent_wake;
+}
+
 static ssize_t force_suspend_read(struct file *file, char __user *user_buf,
 				  size_t count, loff_t *ppos)
 {
@@ -141,6 +149,43 @@ static const struct file_operations force_suspend_fops = {
 	.llseek		= default_llseek,
 };
 
+static ssize_t force_prevent_wake_read(struct file *file, char __user *user_buf,
+				       size_t count, loff_t *ppos)
+{
+	struct vhci_data *data = file->private_data;
+	char buf[3];
+
+	buf[0] = data->prevent_wake ? 'Y' : 'N';
+	buf[1] = '\n';
+	buf[2] = '\0';
+	return simple_read_from_buffer(user_buf, count, ppos, buf, 2);
+}
+
+static ssize_t force_prevent_wake_write(struct file *file,
+					const char __user *user_buf,
+					size_t count, loff_t *ppos)
+{
+	struct vhci_data *data = file->private_data;
+	bool enable;
+	int err;
+
+	err = kstrtobool_from_user(user_buf, count, &enable);
+	if (err)
+		return err;
+
+	if (data->prevent_wake == enable)
+		return -EALREADY;
+
+	return count;
+}
+
+static const struct file_operations force_prevent_wake_fops = {
+	.open		= simple_open,
+	.read		= force_prevent_wake_read,
+	.write		= force_prevent_wake_write,
+	.llseek		= default_llseek,
+};
+
 static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
 {
 	struct hci_dev *hdev;
@@ -182,6 +227,7 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
 	hdev->send  = vhci_send_frame;
 	hdev->get_data_path_id = vhci_get_data_path_id;
 	hdev->get_codec_config_data = vhci_get_codec_config_data;
+	hdev->prevent_wake = vhci_prevent_wake;
 
 	/* bit 6 is for external configuration */
 	if (opcode & 0x40)
@@ -202,6 +248,9 @@ static int __vhci_create_device(struct vhci_data *data, __u8 opcode)
 	debugfs_create_file("force_suspend", 0644, hdev->debugfs, data,
 			    &force_suspend_fops);
 
+	debugfs_create_file("force_prevent_wake", 0644, hdev->debugfs, data,
+			    &force_prevent_wake_fops);
+
 	hci_skb_pkt_type(skb) = HCI_VENDOR_PKT;
 
 	skb_put_u8(skb, 0xff);
-- 
2.31.1


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

* Re: [PATCH 1/2] Bluetooth: hci_vhci: Add force_suspend entry
  2021-09-29 20:38 [PATCH 1/2] Bluetooth: hci_vhci: Add force_suspend entry Luiz Augusto von Dentz
  2021-09-29 20:38 ` [PATCH 2/2] Bluetooth: hci_vhci: Add force_prevent_wake entry Luiz Augusto von Dentz
@ 2021-09-29 20:49 ` Marcel Holtmann
  2021-09-29 22:05 ` [1/2] " bluez.test.bot
  2 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2021-09-29 20:49 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

> This adds force_suspend which can be used to force the controller into
> suspend/resume state.
> 
> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> ---
> drivers/bluetooth/hci_vhci.c | 53 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 53 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

* Re: [PATCH 2/2] Bluetooth: hci_vhci: Add force_prevent_wake entry
  2021-09-29 20:38 ` [PATCH 2/2] Bluetooth: hci_vhci: Add force_prevent_wake entry Luiz Augusto von Dentz
@ 2021-09-29 20:49   ` Marcel Holtmann
  0 siblings, 0 replies; 5+ messages in thread
From: Marcel Holtmann @ 2021-09-29 20:49 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hi Luiz,

> This adds force_prevent_wake which can be used to force a certain state
> while interacting with force_suspend.
> 
> Signed-off-by: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> ---
> drivers/bluetooth/hci_vhci.c | 49 ++++++++++++++++++++++++++++++++++++
> 1 file changed, 49 insertions(+)

patch has been applied to bluetooth-next tree.

Regards

Marcel


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

* RE: [1/2] Bluetooth: hci_vhci: Add force_suspend entry
  2021-09-29 20:38 [PATCH 1/2] Bluetooth: hci_vhci: Add force_suspend entry Luiz Augusto von Dentz
  2021-09-29 20:38 ` [PATCH 2/2] Bluetooth: hci_vhci: Add force_prevent_wake entry Luiz Augusto von Dentz
  2021-09-29 20:49 ` [PATCH 1/2] Bluetooth: hci_vhci: Add force_suspend entry Marcel Holtmann
@ 2021-09-29 22:05 ` bluez.test.bot
  2 siblings, 0 replies; 5+ messages in thread
From: bluez.test.bot @ 2021-09-29 22:05 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 1216 bytes --]

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=555237

---Test result---

Test Summary:
CheckPatch                    PASS      3.18 seconds
GitLint                       PASS      1.88 seconds
BuildKernel                   PASS      640.97 seconds
TestRunner: Setup             PASS      467.79 seconds
TestRunner: l2cap-tester      PASS      10.42 seconds
TestRunner: bnep-tester       PASS      5.60 seconds
TestRunner: mgmt-tester       FAIL      87.66 seconds
TestRunner: rfcomm-tester     PASS      6.91 seconds
TestRunner: sco-tester        PASS      7.10 seconds
TestRunner: smp-tester        PASS      6.99 seconds
TestRunner: userchan-tester   PASS      5.85 seconds

Details
##############################
Test: TestRunner: mgmt-tester - FAIL - 87.66 seconds
Run test-runner with mgmt-tester
Total: 452, Passed: 451 (99.8%), Failed: 1, Not Run: 0

Failed Test Cases
Read Exp Feature - Success                           Failed       0.114 seconds



---
Regards,
Linux Bluetooth


[-- Attachment #2: l2cap-tester.log --]
[-- Type: application/octet-stream, Size: 51539 bytes --]

[-- Attachment #3: bnep-tester.log --]
[-- Type: application/octet-stream, Size: 3906 bytes --]

[-- Attachment #4: mgmt-tester.log --]
[-- Type: application/octet-stream, Size: 626722 bytes --]

[-- Attachment #5: rfcomm-tester.log --]
[-- Type: application/octet-stream, Size: 14762 bytes --]

[-- Attachment #6: sco-tester.log --]
[-- Type: application/octet-stream, Size: 13924 bytes --]

[-- Attachment #7: smp-tester.log --]
[-- Type: application/octet-stream, Size: 11830 bytes --]

[-- Attachment #8: userchan-tester.log --]
[-- Type: application/octet-stream, Size: 7740 bytes --]

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

end of thread, other threads:[~2021-09-29 22:05 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-29 20:38 [PATCH 1/2] Bluetooth: hci_vhci: Add force_suspend entry Luiz Augusto von Dentz
2021-09-29 20:38 ` [PATCH 2/2] Bluetooth: hci_vhci: Add force_prevent_wake entry Luiz Augusto von Dentz
2021-09-29 20:49   ` Marcel Holtmann
2021-09-29 20:49 ` [PATCH 1/2] Bluetooth: hci_vhci: Add force_suspend entry Marcel Holtmann
2021-09-29 22:05 ` [1/2] " bluez.test.bot

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