1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
|
commit 6aa42966dea9a1fc02a714211ea489c3278bf8d4
Author: Matthew Garrett <mjg@redhat.com>
Date: Thu Sep 16 13:34:55 2010 -0400
bluetooth: Take a runtime pm reference on hid connections
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>
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;
}
commit 482eca592615e85b048753750b101d051b77fde9
Author: Matthew Garrett <mjg@redhat.com>
Date: Thu Sep 16 13:49:24 2010 -0400
bluetooth: Remove some unnecessary error messages
The main reason for these urbs to error out on submission is that runtime
pm has kicked in, which is unnecessary noise. Let's just drop them.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index d22ce3c..3ace025 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -229,11 +229,8 @@ static void btusb_intr_complete(struct urb *urb)
usb_anchor_urb(urb, &data->intr_anchor);
err = usb_submit_urb(urb, GFP_ATOMIC);
- if (err < 0) {
- BT_ERR("%s urb %p failed to resubmit (%d)",
- hdev->name, urb, -err);
+ if (err < 0)
usb_unanchor_urb(urb);
- }
}
static int btusb_submit_intr_urb(struct hci_dev *hdev, gfp_t mem_flags)
@@ -313,11 +310,8 @@ static void btusb_bulk_complete(struct urb *urb)
usb_mark_last_busy(data->udev);
err = usb_submit_urb(urb, GFP_ATOMIC);
- if (err < 0) {
- BT_ERR("%s urb %p failed to resubmit (%d)",
- hdev->name, urb, -err);
+ if (err < 0)
usb_unanchor_urb(urb);
- }
}
static int btusb_submit_bulk_urb(struct hci_dev *hdev, gfp_t mem_flags)
@@ -402,11 +396,8 @@ static void btusb_isoc_complete(struct urb *urb)
usb_anchor_urb(urb, &data->isoc_anchor);
err = usb_submit_urb(urb, GFP_ATOMIC);
- if (err < 0) {
- BT_ERR("%s urb %p failed to resubmit (%d)",
- hdev->name, urb, -err);
+ if (err < 0)
usb_unanchor_urb(urb);
- }
}
static void inline __fill_isoc_descriptor(struct urb *urb, int len, int mtu)
commit fd763c5b14ed99ac2401f8e8f1a07c3687ae01cc
Author: Matthew Garrett <mjg@redhat.com>
Date: Thu Sep 16 13:37:38 2010 -0400
bluetooth: Enable USB autosuspend by default on btusb
We've done this for a while in Fedora without any obvious problems other
than some interaction with input devices. Those should be fixed now, so
let's try this in mainline.
Signed-off-by: Matthew Garrett <mjg@redhat.com>
diff --git a/drivers/bluetooth/btusb.c b/drivers/bluetooth/btusb.c
index 3ace025..03b64e4 100644
--- a/drivers/bluetooth/btusb.c
+++ b/drivers/bluetooth/btusb.c
@@ -1014,6 +1014,8 @@ static int btusb_probe(struct usb_interface *intf,
usb_set_intfdata(intf, data);
+ usb_enable_autosuspend(interface_to_usbdev(intf));
+
return 0;
}
|