linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] bluetooth: Take a runtime pm reference on hid connections
@ 2010-09-16 17:58 Matthew Garrett
  2010-09-16 17:58 ` [PATCH 2/3] bluetooth: Remove some unnecessary error messages Matthew Garrett
                   ` (3 more replies)
  0 siblings, 4 replies; 13+ messages in thread
From: Matthew Garrett @ 2010-09-16 17:58 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: linux-usb, marcel, Matthew Garrett

Bluetooth runtime PM interacts badly with input devices - the connection
will be dropped if the device becomes idle, resulting in noticable lag when
the user interacts with the input device again. Bump the pm runtime count
when the device is associated and release it when it's disassociated in
order to avoid this.

Signed-off-by: Matthew Garrett <mjg@redhat.com>
---
 net/bluetooth/hidp/core.c |   18 ++++++++++++++++++
 1 files changed, 18 insertions(+), 0 deletions(-)

diff --git a/net/bluetooth/hidp/core.c b/net/bluetooth/hidp/core.c
index bfe641b..a4489a7 100644
--- a/net/bluetooth/hidp/core.c
+++ b/net/bluetooth/hidp/core.c
@@ -36,6 +36,7 @@
 #include <linux/file.h>
 #include <linux/init.h>
 #include <linux/wait.h>
+#include <linux/pm_runtime.h>
 #include <net/sock.h>
 
 #include <linux/input.h>
@@ -622,6 +623,14 @@ static int hidp_session(void *arg)
 	return 0;
 }
 
+static struct hci_dev *hidp_get_hci(struct hidp_session *session)
+{
+	bdaddr_t *src = &bt_sk(session->ctrl_sock->sk)->src;
+	bdaddr_t *dst = &bt_sk(session->ctrl_sock->sk)->dst;
+
+	return hci_get_route(dst, src);
+}
+
 static struct device *hidp_get_device(struct hidp_session *session)
 {
 	bdaddr_t *src = &bt_sk(session->ctrl_sock->sk)->src;
@@ -819,6 +828,7 @@ fault:
 int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock, struct socket *intr_sock)
 {
 	struct hidp_session *session, *s;
+	struct hci_dev *hdev;
 	int err;
 
 	BT_DBG("");
@@ -889,6 +899,10 @@ int hidp_add_connection(struct hidp_connadd_req *req, struct socket *ctrl_sock,
 		hidp_input_event(session->input, EV_LED, 0, 0);
 	}
 
+	hdev = hidp_get_hci(session);
+	pm_runtime_get(hdev->parent);
+	hci_dev_put(hdev);
+
 	up_write(&hidp_session_sem);
 	return 0;
 
@@ -925,6 +939,7 @@ failed:
 int hidp_del_connection(struct hidp_conndel_req *req)
 {
 	struct hidp_session *session;
+	struct hci_dev *hdev;
 	int err = 0;
 
 	BT_DBG("");
@@ -952,6 +967,9 @@ int hidp_del_connection(struct hidp_conndel_req *req)
 	} else
 		err = -ENOENT;
 
+	hdev = hidp_get_hci(session);
+	pm_runtime_put(hdev->parent);
+	hci_dev_put(hdev);
 	up_read(&hidp_session_sem);
 	return err;
 }
-- 
1.7.2.3

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

end of thread, other threads:[~2010-10-19 16:03 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-09-16 17:58 [PATCH 1/3] bluetooth: Take a runtime pm reference on hid connections Matthew Garrett
2010-09-16 17:58 ` [PATCH 2/3] bluetooth: Remove some unnecessary error messages Matthew Garrett
2010-09-17  8:33   ` Andrei Emeltchenko
2010-09-17  8:59     ` Oliver Neukum
2010-10-18 11:55   ` Marcel Holtmann
2010-10-19 16:01     ` Matthew Garrett
2010-09-16 17:58 ` [PATCH 3/3] bluetooth: Enable USB autosuspend by default on btusb Matthew Garrett
2010-10-13 10:00   ` Marcel Holtmann
2010-10-18  6:06   ` Gustavo F. Padovan
2010-09-17  8:39 ` [PATCH 1/3] bluetooth: Take a runtime pm reference on hid connections Oliver Neukum
2010-09-17 12:24   ` Matthew Garrett
2010-10-13  9:32 ` Marcel Holtmann
2010-10-19 16:03   ` Matthew Garrett

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