aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/usb/usbip
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/usb/usbip')
-rw-r--r--drivers/usb/usbip/usbip_event.c5
-rw-r--r--drivers/usb/usbip/usbip_protocol.txt358
-rw-r--r--drivers/usb/usbip/vhci_hcd.c88
-rw-r--r--drivers/usb/usbip/vhci_rx.c30
-rw-r--r--drivers/usb/usbip/vhci_sysfs.c19
-rw-r--r--drivers/usb/usbip/vhci_tx.c14
6 files changed, 91 insertions, 423 deletions
diff --git a/drivers/usb/usbip/usbip_event.c b/drivers/usb/usbip/usbip_event.c
index 64933b993d7a..2580a32bcdff 100644
--- a/drivers/usb/usbip/usbip_event.c
+++ b/drivers/usb/usbip/usbip_event.c
@@ -117,11 +117,12 @@ EXPORT_SYMBOL_GPL(usbip_event_add);
117int usbip_event_happened(struct usbip_device *ud) 117int usbip_event_happened(struct usbip_device *ud)
118{ 118{
119 int happened = 0; 119 int happened = 0;
120 unsigned long flags;
120 121
121 spin_lock(&ud->lock); 122 spin_lock_irqsave(&ud->lock, flags);
122 if (ud->event != 0) 123 if (ud->event != 0)
123 happened = 1; 124 happened = 1;
124 spin_unlock(&ud->lock); 125 spin_unlock_irqrestore(&ud->lock, flags);
125 126
126 return happened; 127 return happened;
127} 128}
diff --git a/drivers/usb/usbip/usbip_protocol.txt b/drivers/usb/usbip/usbip_protocol.txt
deleted file mode 100644
index 16b6fe27284c..000000000000
--- a/drivers/usb/usbip/usbip_protocol.txt
+++ /dev/null
@@ -1,358 +0,0 @@
1PRELIMINARY DRAFT, MAY CONTAIN MISTAKES!
228 Jun 2011
3
4The USB/IP protocol follows a server/client architecture. The server exports the
5USB devices and the clients imports them. The device driver for the exported
6USB device runs on the client machine.
7
8The client may ask for the list of the exported USB devices. To get the list the
9client opens a TCP/IP connection towards the server, and sends an OP_REQ_DEVLIST
10packet on top of the TCP/IP connection (so the actual OP_REQ_DEVLIST may be sent
11in one or more pieces at the low level transport layer). The server sends back
12the OP_REP_DEVLIST packet which lists the exported USB devices. Finally the
13TCP/IP connection is closed.
14
15 virtual host controller usb host
16 "client" "server"
17 (imports USB devices) (exports USB devices)
18 | |
19 | OP_REQ_DEVLIST |
20 | ----------------------------------------------> |
21 | |
22 | OP_REP_DEVLIST |
23 | <---------------------------------------------- |
24 | |
25
26Once the client knows the list of exported USB devices it may decide to use one
27of them. First the client opens a TCP/IP connection towards the server and
28sends an OP_REQ_IMPORT packet. The server replies with OP_REP_IMPORT. If the
29import was successful the TCP/IP connection remains open and will be used
30to transfer the URB traffic between the client and the server. The client may
31send two types of packets: the USBIP_CMD_SUBMIT to submit an URB, and
32USBIP_CMD_UNLINK to unlink a previously submitted URB. The answers of the
33server may be USBIP_RET_SUBMIT and USBIP_RET_UNLINK respectively.
34
35 virtual host controller usb host
36 "client" "server"
37 (imports USB devices) (exports USB devices)
38 | |
39 | OP_REQ_IMPORT |
40 | ----------------------------------------------> |
41 | |
42 | OP_REP_IMPORT |
43 | <---------------------------------------------- |
44 | |
45 | |
46 | USBIP_CMD_SUBMIT(seqnum = n) |
47 | ----------------------------------------------> |
48 | |
49 | USBIP_RET_SUBMIT(seqnum = n) |
50 | <---------------------------------------------- |
51 | . |
52 | : |
53 | |
54 | USBIP_CMD_SUBMIT(seqnum = m) |
55 | ----------------------------------------------> |
56 | |
57 | USBIP_CMD_SUBMIT(seqnum = m+1) |
58 | ----------------------------------------------> |
59 | |
60 | USBIP_CMD_SUBMIT(seqnum = m+2) |
61 | ----------------------------------------------> |
62 | |
63 | USBIP_RET_SUBMIT(seqnum = m) |
64 | <---------------------------------------------- |
65 | |
66 | USBIP_CMD_SUBMIT(seqnum = m+3) |
67 | ----------------------------------------------> |
68 | |
69 | USBIP_RET_SUBMIT(seqnum = m+1) |
70 | <---------------------------------------------- |
71 | |
72 | USBIP_CMD_SUBMIT(seqnum = m+4) |
73 | ----------------------------------------------> |
74 | |
75 | USBIP_RET_SUBMIT(seqnum = m+2) |
76 | <---------------------------------------------- |
77 | . |
78 | : |
79 | |
80 | USBIP_CMD_UNLINK |
81 | ----------------------------------------------> |
82 | |
83 | USBIP_RET_UNLINK |
84 | <---------------------------------------------- |
85 | |
86
87The fields are in network (big endian) byte order meaning that the most significant
88byte (MSB) is stored at the lowest address.
89
90
91OP_REQ_DEVLIST: Retrieve the list of exported USB devices.
92
93 Offset | Length | Value | Description
94-----------+--------+------------+---------------------------------------------------
95 0 | 2 | 0x0100 | Binary-coded decimal USBIP version number: v1.0.0
96-----------+--------+------------+---------------------------------------------------
97 2 | 2 | 0x8005 | Command code: Retrieve the list of exported USB
98 | | | devices.
99-----------+--------+------------+---------------------------------------------------
100 4 | 4 | 0x00000000 | Status: unused, shall be set to 0
101
102OP_REP_DEVLIST: Reply with the list of exported USB devices.
103
104 Offset | Length | Value | Description
105-----------+--------+------------+---------------------------------------------------
106 0 | 2 | 0x0100 | Binary-coded decimal USBIP version number: v1.0.0.
107-----------+--------+------------+---------------------------------------------------
108 2 | 2 | 0x0005 | Reply code: The list of exported USB devices.
109-----------+--------+------------+---------------------------------------------------
110 4 | 4 | 0x00000000 | Status: 0 for OK
111-----------+--------+------------+---------------------------------------------------
112 8 | 4 | n | Number of exported devices: 0 means no exported
113 | | | devices.
114-----------+--------+------------+---------------------------------------------------
115 0x0C | | | From now on the exported n devices are described,
116 | | | if any. If no devices are exported the message
117 | | | ends with the previous "number of exported
118 | | | devices" field.
119-----------+--------+------------+---------------------------------------------------
120 | 256 | | path: Path of the device on the host exporting the
121 | | | USB device, string closed with zero byte, e.g.
122 | | | "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2"
123 | | | The unused bytes shall be filled with zero
124 | | | bytes.
125-----------+--------+------------+---------------------------------------------------
126 0x10C | 32 | | busid: Bus ID of the exported device, string
127 | | | closed with zero byte, e.g. "3-2". The unused
128 | | | bytes shall be filled with zero bytes.
129-----------+--------+------------+---------------------------------------------------
130 0x12C | 4 | | busnum
131-----------+--------+------------+---------------------------------------------------
132 0x130 | 4 | | devnum
133-----------+--------+------------+---------------------------------------------------
134 0x134 | 4 | | speed
135-----------+--------+------------+---------------------------------------------------
136 0x138 | 2 | | idVendor
137-----------+--------+------------+---------------------------------------------------
138 0x13A | 2 | | idProduct
139-----------+--------+------------+---------------------------------------------------
140 0x13C | 2 | | bcdDevice
141-----------+--------+------------+---------------------------------------------------
142 0x13E | 1 | | bDeviceClass
143-----------+--------+------------+---------------------------------------------------
144 0x13F | 1 | | bDeviceSubClass
145-----------+--------+------------+---------------------------------------------------
146 0x140 | 1 | | bDeviceProtocol
147-----------+--------+------------+---------------------------------------------------
148 0x141 | 1 | | bConfigurationValue
149-----------+--------+------------+---------------------------------------------------
150 0x142 | 1 | | bNumConfigurations
151-----------+--------+------------+---------------------------------------------------
152 0x143 | 1 | | bNumInterfaces
153-----------+--------+------------+---------------------------------------------------
154 0x144 | | m_0 | From now on each interface is described, all
155 | | | together bNumInterfaces times, with the
156 | | | the following 4 fields:
157-----------+--------+------------+---------------------------------------------------
158 | 1 | | bInterfaceClass
159-----------+--------+------------+---------------------------------------------------
160 0x145 | 1 | | bInterfaceSubClass
161-----------+--------+------------+---------------------------------------------------
162 0x146 | 1 | | bInterfaceProtocol
163-----------+--------+------------+---------------------------------------------------
164 0x147 | 1 | | padding byte for alignment, shall be set to zero
165-----------+--------+------------+---------------------------------------------------
166 0xC + | | | The second exported USB device starts at i=1
167 i*0x138 + | | | with the busid field.
168 m_(i-1)*4 | | |
169
170OP_REQ_IMPORT: Request to import (attach) a remote USB device.
171
172 Offset | Length | Value | Description
173-----------+--------+------------+---------------------------------------------------
174 0 | 2 | 0x0100 | Binary-coded decimal USBIP version number: v1.0.0
175-----------+--------+------------+---------------------------------------------------
176 2 | 2 | 0x8003 | Command code: import a remote USB device.
177-----------+--------+------------+---------------------------------------------------
178 4 | 4 | 0x00000000 | Status: unused, shall be set to 0
179-----------+--------+------------+---------------------------------------------------
180 8 | 32 | | busid: the busid of the exported device on the
181 | | | remote host. The possible values are taken
182 | | | from the message field OP_REP_DEVLIST.busid.
183 | | | A string closed with zero, the unused bytes
184 | | | shall be filled with zeros.
185-----------+--------+------------+---------------------------------------------------
186
187OP_REP_IMPORT: Reply to import (attach) a remote USB device.
188
189 Offset | Length | Value | Description
190-----------+--------+------------+---------------------------------------------------
191 0 | 2 | 0x0100 | Binary-coded decimal USBIP version number: v1.0.0
192-----------+--------+------------+---------------------------------------------------
193 2 | 2 | 0x0003 | Reply code: Reply to import.
194-----------+--------+------------+---------------------------------------------------
195 4 | 4 | 0x00000000 | Status: 0 for OK
196 | | | 1 for error
197-----------+--------+------------+---------------------------------------------------
198 8 | | | From now on comes the details of the imported
199 | | | device, if the previous status field was OK (0),
200 | | | otherwise the reply ends with the status field.
201-----------+--------+------------+---------------------------------------------------
202 | 256 | | path: Path of the device on the host exporting the
203 | | | USB device, string closed with zero byte, e.g.
204 | | | "/sys/devices/pci0000:00/0000:00:1d.1/usb3/3-2"
205 | | | The unused bytes shall be filled with zero
206 | | | bytes.
207-----------+--------+------------+---------------------------------------------------
208 0x108 | 32 | | busid: Bus ID of the exported device, string
209 | | | closed with zero byte, e.g. "3-2". The unused
210 | | | bytes shall be filled with zero bytes.
211-----------+--------+------------+---------------------------------------------------
212 0x128 | 4 | | busnum
213-----------+--------+------------+---------------------------------------------------
214 0x12C | 4 | | devnum
215-----------+--------+------------+---------------------------------------------------
216 0x130 | 4 | | speed
217-----------+--------+------------+---------------------------------------------------
218 0x134 | 2 | | idVendor
219-----------+--------+------------+---------------------------------------------------
220 0x136 | 2 | | idProduct
221-----------+--------+------------+---------------------------------------------------
222 0x138 | 2 | | bcdDevice
223-----------+--------+------------+---------------------------------------------------
224 0x139 | 1 | | bDeviceClass
225-----------+--------+------------+---------------------------------------------------
226 0x13A | 1 | | bDeviceSubClass
227-----------+--------+------------+---------------------------------------------------
228 0x13B | 1 | | bDeviceProtocol
229-----------+--------+------------+---------------------------------------------------
230 0x13C | 1 | | bConfigurationValue
231-----------+--------+------------+---------------------------------------------------
232 0x13D | 1 | | bNumConfigurations
233-----------+--------+------------+---------------------------------------------------
234 0x13E | 1 | | bNumInterfaces
235
236USBIP_CMD_SUBMIT: Submit an URB
237
238 Offset | Length | Value | Description
239-----------+--------+------------+---------------------------------------------------
240 0 | 4 | 0x00000001 | command: Submit an URB
241-----------+--------+------------+---------------------------------------------------
242 4 | 4 | | seqnum: the sequence number of the URB to submit
243-----------+--------+------------+---------------------------------------------------
244 8 | 4 | | devid
245-----------+--------+------------+---------------------------------------------------
246 0xC | 4 | | direction: 0: USBIP_DIR_OUT
247 | | | 1: USBIP_DIR_IN
248-----------+--------+------------+---------------------------------------------------
249 0x10 | 4 | | ep: endpoint number, possible values are: 0...15
250-----------+--------+------------+---------------------------------------------------
251 0x14 | 4 | | transfer_flags: possible values depend on the
252 | | | URB transfer type, see below
253-----------+--------+------------+---------------------------------------------------
254 0x18 | 4 | | transfer_buffer_length
255-----------+--------+------------+---------------------------------------------------
256 0x1C | 4 | | start_frame: specify the selected frame to
257 | | | transmit an ISO frame, ignored if URB_ISO_ASAP
258 | | | is specified at transfer_flags
259-----------+--------+------------+---------------------------------------------------
260 0x20 | 4 | | number_of_packets: number of ISO packets
261-----------+--------+------------+---------------------------------------------------
262 0x24 | 4 | | interval: maximum time for the request on the
263 | | | server-side host controller
264-----------+--------+------------+---------------------------------------------------
265 0x28 | 8 | | setup: data bytes for USB setup, filled with
266 | | | zeros if not used
267-----------+--------+------------+---------------------------------------------------
268 0x30 | | | URB data. For ISO transfers the padding between
269 | | | each ISO packets is not transmitted.
270
271
272 Allowed transfer_flags | value | control | interrupt | bulk | isochronous
273 -------------------------+------------+---------+-----------+----------+-------------
274 URB_SHORT_NOT_OK | 0x00000001 | only in | only in | only in | no
275 URB_ISO_ASAP | 0x00000002 | no | no | no | yes
276 URB_NO_TRANSFER_DMA_MAP | 0x00000004 | yes | yes | yes | yes
277 URB_NO_FSBR | 0x00000020 | yes | no | no | no
278 URB_ZERO_PACKET | 0x00000040 | no | no | only out | no
279 URB_NO_INTERRUPT | 0x00000080 | yes | yes | yes | yes
280 URB_FREE_BUFFER | 0x00000100 | yes | yes | yes | yes
281 URB_DIR_MASK | 0x00000200 | yes | yes | yes | yes
282
283
284USBIP_RET_SUBMIT: Reply for submitting an URB
285
286 Offset | Length | Value | Description
287-----------+--------+------------+---------------------------------------------------
288 0 | 4 | 0x00000003 | command
289-----------+--------+------------+---------------------------------------------------
290 4 | 4 | | seqnum: URB sequence number
291-----------+--------+------------+---------------------------------------------------
292 8 | 4 | | devid
293-----------+--------+------------+---------------------------------------------------
294 0xC | 4 | | direction: 0: USBIP_DIR_OUT
295 | | | 1: USBIP_DIR_IN
296-----------+--------+------------+---------------------------------------------------
297 0x10 | 4 | | ep: endpoint number
298-----------+--------+------------+---------------------------------------------------
299 0x14 | 4 | | status: zero for successful URB transaction,
300 | | | otherwise some kind of error happened.
301-----------+--------+------------+---------------------------------------------------
302 0x18 | 4 | n | actual_length: number of URB data bytes
303-----------+--------+------------+---------------------------------------------------
304 0x1C | 4 | | start_frame: for an ISO frame the actually
305 | | | selected frame for transmit.
306-----------+--------+------------+---------------------------------------------------
307 0x20 | 4 | | number_of_packets
308-----------+--------+------------+---------------------------------------------------
309 0x24 | 4 | | error_count
310-----------+--------+------------+---------------------------------------------------
311 0x28 | 8 | | setup: data bytes for USB setup, filled with
312 | | | zeros if not used
313-----------+--------+------------+---------------------------------------------------
314 0x30 | n | | URB data bytes. For ISO transfers the padding
315 | | | between each ISO packets is not transmitted.
316
317USBIP_CMD_UNLINK: Unlink an URB
318
319 Offset | Length | Value | Description
320-----------+--------+------------+---------------------------------------------------
321 0 | 4 | 0x00000002 | command: URB unlink command
322-----------+--------+------------+---------------------------------------------------
323 4 | 4 | | seqnum: URB sequence number to unlink: FIXME: is this so?
324-----------+--------+------------+---------------------------------------------------
325 8 | 4 | | devid
326-----------+--------+------------+---------------------------------------------------
327 0xC | 4 | | direction: 0: USBIP_DIR_OUT
328 | | | 1: USBIP_DIR_IN
329-----------+--------+------------+---------------------------------------------------
330 0x10 | 4 | | ep: endpoint number: zero
331-----------+--------+------------+---------------------------------------------------
332 0x14 | 4 | | seqnum: the URB sequence number given previously
333 | | | at USBIP_CMD_SUBMIT.seqnum field
334-----------+--------+------------+---------------------------------------------------
335 0x30 | n | | URB data bytes. For ISO transfers the padding
336 | | | between each ISO packets is not transmitted.
337
338USBIP_RET_UNLINK: Reply for URB unlink
339
340 Offset | Length | Value | Description
341-----------+--------+------------+---------------------------------------------------
342 0 | 4 | 0x00000004 | command: reply for the URB unlink command
343-----------+--------+------------+---------------------------------------------------
344 4 | 4 | | seqnum: the unlinked URB sequence number
345-----------+--------+------------+---------------------------------------------------
346 8 | 4 | | devid
347-----------+--------+------------+---------------------------------------------------
348 0xC | 4 | | direction: 0: USBIP_DIR_OUT
349 | | | 1: USBIP_DIR_IN
350-----------+--------+------------+---------------------------------------------------
351 0x10 | 4 | | ep: endpoint number
352-----------+--------+------------+---------------------------------------------------
353 0x14 | 4 | | status: This is the value contained in the
354 | | | urb->status in the URB completition handler.
355 | | | FIXME: a better explanation needed.
356-----------+--------+------------+---------------------------------------------------
357 0x30 | n | | URB data bytes. For ISO transfers the padding
358 | | | between each ISO packets is not transmitted.
diff --git a/drivers/usb/usbip/vhci_hcd.c b/drivers/usb/usbip/vhci_hcd.c
index 7fbe19d5279e..fca51105974e 100644
--- a/drivers/usb/usbip/vhci_hcd.c
+++ b/drivers/usb/usbip/vhci_hcd.c
@@ -121,9 +121,11 @@ static void dump_port_status_diff(u32 prev_status, u32 new_status)
121 121
122void rh_port_connect(int rhport, enum usb_device_speed speed) 122void rh_port_connect(int rhport, enum usb_device_speed speed)
123{ 123{
124 unsigned long flags;
125
124 usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport); 126 usbip_dbg_vhci_rh("rh_port_connect %d\n", rhport);
125 127
126 spin_lock(&the_controller->lock); 128 spin_lock_irqsave(&the_controller->lock, flags);
127 129
128 the_controller->port_status[rhport] |= USB_PORT_STAT_CONNECTION 130 the_controller->port_status[rhport] |= USB_PORT_STAT_CONNECTION
129 | (1 << USB_PORT_FEAT_C_CONNECTION); 131 | (1 << USB_PORT_FEAT_C_CONNECTION);
@@ -139,22 +141,24 @@ void rh_port_connect(int rhport, enum usb_device_speed speed)
139 break; 141 break;
140 } 142 }
141 143
142 spin_unlock(&the_controller->lock); 144 spin_unlock_irqrestore(&the_controller->lock, flags);
143 145
144 usb_hcd_poll_rh_status(vhci_to_hcd(the_controller)); 146 usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
145} 147}
146 148
147static void rh_port_disconnect(int rhport) 149static void rh_port_disconnect(int rhport)
148{ 150{
151 unsigned long flags;
152
149 usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport); 153 usbip_dbg_vhci_rh("rh_port_disconnect %d\n", rhport);
150 154
151 spin_lock(&the_controller->lock); 155 spin_lock_irqsave(&the_controller->lock, flags);
152 156
153 the_controller->port_status[rhport] &= ~USB_PORT_STAT_CONNECTION; 157 the_controller->port_status[rhport] &= ~USB_PORT_STAT_CONNECTION;
154 the_controller->port_status[rhport] |= 158 the_controller->port_status[rhport] |=
155 (1 << USB_PORT_FEAT_C_CONNECTION); 159 (1 << USB_PORT_FEAT_C_CONNECTION);
156 160
157 spin_unlock(&the_controller->lock); 161 spin_unlock_irqrestore(&the_controller->lock, flags);
158 usb_hcd_poll_rh_status(vhci_to_hcd(the_controller)); 162 usb_hcd_poll_rh_status(vhci_to_hcd(the_controller));
159} 163}
160 164
@@ -182,13 +186,14 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
182 int retval; 186 int retval;
183 int rhport; 187 int rhport;
184 int changed = 0; 188 int changed = 0;
189 unsigned long flags;
185 190
186 retval = DIV_ROUND_UP(VHCI_NPORTS + 1, 8); 191 retval = DIV_ROUND_UP(VHCI_NPORTS + 1, 8);
187 memset(buf, 0, retval); 192 memset(buf, 0, retval);
188 193
189 vhci = hcd_to_vhci(hcd); 194 vhci = hcd_to_vhci(hcd);
190 195
191 spin_lock(&vhci->lock); 196 spin_lock_irqsave(&vhci->lock, flags);
192 if (!HCD_HW_ACCESSIBLE(hcd)) { 197 if (!HCD_HW_ACCESSIBLE(hcd)) {
193 usbip_dbg_vhci_rh("hw accessible flag not on?\n"); 198 usbip_dbg_vhci_rh("hw accessible flag not on?\n");
194 goto done; 199 goto done;
@@ -209,7 +214,7 @@ static int vhci_hub_status(struct usb_hcd *hcd, char *buf)
209 usb_hcd_resume_root_hub(hcd); 214 usb_hcd_resume_root_hub(hcd);
210 215
211done: 216done:
212 spin_unlock(&vhci->lock); 217 spin_unlock_irqrestore(&vhci->lock, flags);
213 return changed ? retval : 0; 218 return changed ? retval : 0;
214} 219}
215 220
@@ -231,6 +236,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
231 struct vhci_hcd *dum; 236 struct vhci_hcd *dum;
232 int retval = 0; 237 int retval = 0;
233 int rhport; 238 int rhport;
239 unsigned long flags;
234 240
235 u32 prev_port_status[VHCI_NPORTS]; 241 u32 prev_port_status[VHCI_NPORTS];
236 242
@@ -249,7 +255,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
249 255
250 dum = hcd_to_vhci(hcd); 256 dum = hcd_to_vhci(hcd);
251 257
252 spin_lock(&dum->lock); 258 spin_lock_irqsave(&dum->lock, flags);
253 259
254 /* store old status and compare now and old later */ 260 /* store old status and compare now and old later */
255 if (usbip_dbg_flag_vhci_rh) { 261 if (usbip_dbg_flag_vhci_rh) {
@@ -403,7 +409,7 @@ static int vhci_hub_control(struct usb_hcd *hcd, u16 typeReq, u16 wValue,
403 } 409 }
404 usbip_dbg_vhci_rh(" bye\n"); 410 usbip_dbg_vhci_rh(" bye\n");
405 411
406 spin_unlock(&dum->lock); 412 spin_unlock_irqrestore(&dum->lock, flags);
407 413
408 return retval; 414 return retval;
409} 415}
@@ -426,6 +432,7 @@ static void vhci_tx_urb(struct urb *urb)
426{ 432{
427 struct vhci_device *vdev = get_vdev(urb->dev); 433 struct vhci_device *vdev = get_vdev(urb->dev);
428 struct vhci_priv *priv; 434 struct vhci_priv *priv;
435 unsigned long flags;
429 436
430 if (!vdev) { 437 if (!vdev) {
431 pr_err("could not get virtual device"); 438 pr_err("could not get virtual device");
@@ -438,7 +445,7 @@ static void vhci_tx_urb(struct urb *urb)
438 return; 445 return;
439 } 446 }
440 447
441 spin_lock(&vdev->priv_lock); 448 spin_lock_irqsave(&vdev->priv_lock, flags);
442 449
443 priv->seqnum = atomic_inc_return(&the_controller->seqnum); 450 priv->seqnum = atomic_inc_return(&the_controller->seqnum);
444 if (priv->seqnum == 0xffff) 451 if (priv->seqnum == 0xffff)
@@ -452,7 +459,7 @@ static void vhci_tx_urb(struct urb *urb)
452 list_add_tail(&priv->list, &vdev->priv_tx); 459 list_add_tail(&priv->list, &vdev->priv_tx);
453 460
454 wake_up(&vdev->waitq_tx); 461 wake_up(&vdev->waitq_tx);
455 spin_unlock(&vdev->priv_lock); 462 spin_unlock_irqrestore(&vdev->priv_lock, flags);
456} 463}
457 464
458static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb, 465static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
@@ -461,6 +468,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
461 struct device *dev = &urb->dev->dev; 468 struct device *dev = &urb->dev->dev;
462 int ret = 0; 469 int ret = 0;
463 struct vhci_device *vdev; 470 struct vhci_device *vdev;
471 unsigned long flags;
464 472
465 usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n", 473 usbip_dbg_vhci_hc("enter, usb_hcd %p urb %p mem_flags %d\n",
466 hcd, urb, mem_flags); 474 hcd, urb, mem_flags);
@@ -468,11 +476,11 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
468 /* patch to usb_sg_init() is in 2.5.60 */ 476 /* patch to usb_sg_init() is in 2.5.60 */
469 BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length); 477 BUG_ON(!urb->transfer_buffer && urb->transfer_buffer_length);
470 478
471 spin_lock(&the_controller->lock); 479 spin_lock_irqsave(&the_controller->lock, flags);
472 480
473 if (urb->status != -EINPROGRESS) { 481 if (urb->status != -EINPROGRESS) {
474 dev_err(dev, "URB already unlinked!, status %d\n", urb->status); 482 dev_err(dev, "URB already unlinked!, status %d\n", urb->status);
475 spin_unlock(&the_controller->lock); 483 spin_unlock_irqrestore(&the_controller->lock, flags);
476 return urb->status; 484 return urb->status;
477 } 485 }
478 486
@@ -484,7 +492,7 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
484 vdev->ud.status == VDEV_ST_ERROR) { 492 vdev->ud.status == VDEV_ST_ERROR) {
485 dev_err(dev, "enqueue for inactive port %d\n", vdev->rhport); 493 dev_err(dev, "enqueue for inactive port %d\n", vdev->rhport);
486 spin_unlock(&vdev->ud.lock); 494 spin_unlock(&vdev->ud.lock);
487 spin_unlock(&the_controller->lock); 495 spin_unlock_irqrestore(&the_controller->lock, flags);
488 return -ENODEV; 496 return -ENODEV;
489 } 497 }
490 spin_unlock(&vdev->ud.lock); 498 spin_unlock(&vdev->ud.lock);
@@ -557,14 +565,14 @@ static int vhci_urb_enqueue(struct usb_hcd *hcd, struct urb *urb,
557 565
558out: 566out:
559 vhci_tx_urb(urb); 567 vhci_tx_urb(urb);
560 spin_unlock(&the_controller->lock); 568 spin_unlock_irqrestore(&the_controller->lock, flags);
561 569
562 return 0; 570 return 0;
563 571
564no_need_xmit: 572no_need_xmit:
565 usb_hcd_unlink_urb_from_ep(hcd, urb); 573 usb_hcd_unlink_urb_from_ep(hcd, urb);
566no_need_unlink: 574no_need_unlink:
567 spin_unlock(&the_controller->lock); 575 spin_unlock_irqrestore(&the_controller->lock, flags);
568 if (!ret) 576 if (!ret)
569 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), 577 usb_hcd_giveback_urb(vhci_to_hcd(the_controller),
570 urb, urb->status); 578 urb, urb->status);
@@ -621,16 +629,17 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
621{ 629{
622 struct vhci_priv *priv; 630 struct vhci_priv *priv;
623 struct vhci_device *vdev; 631 struct vhci_device *vdev;
632 unsigned long flags;
624 633
625 pr_info("dequeue a urb %p\n", urb); 634 pr_info("dequeue a urb %p\n", urb);
626 635
627 spin_lock(&the_controller->lock); 636 spin_lock_irqsave(&the_controller->lock, flags);
628 637
629 priv = urb->hcpriv; 638 priv = urb->hcpriv;
630 if (!priv) { 639 if (!priv) {
631 /* URB was never linked! or will be soon given back by 640 /* URB was never linked! or will be soon given back by
632 * vhci_rx. */ 641 * vhci_rx. */
633 spin_unlock(&the_controller->lock); 642 spin_unlock_irqrestore(&the_controller->lock, flags);
634 return -EIDRM; 643 return -EIDRM;
635 } 644 }
636 645
@@ -639,7 +648,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
639 648
640 ret = usb_hcd_check_unlink_urb(hcd, urb, status); 649 ret = usb_hcd_check_unlink_urb(hcd, urb, status);
641 if (ret) { 650 if (ret) {
642 spin_unlock(&the_controller->lock); 651 spin_unlock_irqrestore(&the_controller->lock, flags);
643 return ret; 652 return ret;
644 } 653 }
645 } 654 }
@@ -667,10 +676,10 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
667 676
668 usb_hcd_unlink_urb_from_ep(hcd, urb); 677 usb_hcd_unlink_urb_from_ep(hcd, urb);
669 678
670 spin_unlock(&the_controller->lock); 679 spin_unlock_irqrestore(&the_controller->lock, flags);
671 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, 680 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
672 urb->status); 681 urb->status);
673 spin_lock(&the_controller->lock); 682 spin_lock_irqsave(&the_controller->lock, flags);
674 683
675 } else { 684 } else {
676 /* tcp connection is alive */ 685 /* tcp connection is alive */
@@ -682,7 +691,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
682 unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC); 691 unlink = kzalloc(sizeof(struct vhci_unlink), GFP_ATOMIC);
683 if (!unlink) { 692 if (!unlink) {
684 spin_unlock(&vdev->priv_lock); 693 spin_unlock(&vdev->priv_lock);
685 spin_unlock(&the_controller->lock); 694 spin_unlock_irqrestore(&the_controller->lock, flags);
686 usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC); 695 usbip_event_add(&vdev->ud, VDEV_EVENT_ERROR_MALLOC);
687 return -ENOMEM; 696 return -ENOMEM;
688 } 697 }
@@ -703,7 +712,7 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
703 spin_unlock(&vdev->priv_lock); 712 spin_unlock(&vdev->priv_lock);
704 } 713 }
705 714
706 spin_unlock(&the_controller->lock); 715 spin_unlock_irqrestore(&the_controller->lock, flags);
707 716
708 usbip_dbg_vhci_hc("leave\n"); 717 usbip_dbg_vhci_hc("leave\n");
709 return 0; 718 return 0;
@@ -712,8 +721,9 @@ static int vhci_urb_dequeue(struct usb_hcd *hcd, struct urb *urb, int status)
712static void vhci_device_unlink_cleanup(struct vhci_device *vdev) 721static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
713{ 722{
714 struct vhci_unlink *unlink, *tmp; 723 struct vhci_unlink *unlink, *tmp;
724 unsigned long flags;
715 725
716 spin_lock(&the_controller->lock); 726 spin_lock_irqsave(&the_controller->lock, flags);
717 spin_lock(&vdev->priv_lock); 727 spin_lock(&vdev->priv_lock);
718 728
719 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) { 729 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
@@ -747,19 +757,19 @@ static void vhci_device_unlink_cleanup(struct vhci_device *vdev)
747 list_del(&unlink->list); 757 list_del(&unlink->list);
748 758
749 spin_unlock(&vdev->priv_lock); 759 spin_unlock(&vdev->priv_lock);
750 spin_unlock(&the_controller->lock); 760 spin_unlock_irqrestore(&the_controller->lock, flags);
751 761
752 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, 762 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
753 urb->status); 763 urb->status);
754 764
755 spin_lock(&the_controller->lock); 765 spin_lock_irqsave(&the_controller->lock, flags);
756 spin_lock(&vdev->priv_lock); 766 spin_lock(&vdev->priv_lock);
757 767
758 kfree(unlink); 768 kfree(unlink);
759 } 769 }
760 770
761 spin_unlock(&vdev->priv_lock); 771 spin_unlock(&vdev->priv_lock);
762 spin_unlock(&the_controller->lock); 772 spin_unlock_irqrestore(&the_controller->lock, flags);
763} 773}
764 774
765/* 775/*
@@ -826,8 +836,9 @@ static void vhci_shutdown_connection(struct usbip_device *ud)
826static void vhci_device_reset(struct usbip_device *ud) 836static void vhci_device_reset(struct usbip_device *ud)
827{ 837{
828 struct vhci_device *vdev = container_of(ud, struct vhci_device, ud); 838 struct vhci_device *vdev = container_of(ud, struct vhci_device, ud);
839 unsigned long flags;
829 840
830 spin_lock(&ud->lock); 841 spin_lock_irqsave(&ud->lock, flags);
831 842
832 vdev->speed = 0; 843 vdev->speed = 0;
833 vdev->devid = 0; 844 vdev->devid = 0;
@@ -841,14 +852,16 @@ static void vhci_device_reset(struct usbip_device *ud)
841 } 852 }
842 ud->status = VDEV_ST_NULL; 853 ud->status = VDEV_ST_NULL;
843 854
844 spin_unlock(&ud->lock); 855 spin_unlock_irqrestore(&ud->lock, flags);
845} 856}
846 857
847static void vhci_device_unusable(struct usbip_device *ud) 858static void vhci_device_unusable(struct usbip_device *ud)
848{ 859{
849 spin_lock(&ud->lock); 860 unsigned long flags;
861
862 spin_lock_irqsave(&ud->lock, flags);
850 ud->status = VDEV_ST_ERROR; 863 ud->status = VDEV_ST_ERROR;
851 spin_unlock(&ud->lock); 864 spin_unlock_irqrestore(&ud->lock, flags);
852} 865}
853 866
854static void vhci_device_init(struct vhci_device *vdev) 867static void vhci_device_init(struct vhci_device *vdev)
@@ -938,12 +951,13 @@ static int vhci_get_frame_number(struct usb_hcd *hcd)
938static int vhci_bus_suspend(struct usb_hcd *hcd) 951static int vhci_bus_suspend(struct usb_hcd *hcd)
939{ 952{
940 struct vhci_hcd *vhci = hcd_to_vhci(hcd); 953 struct vhci_hcd *vhci = hcd_to_vhci(hcd);
954 unsigned long flags;
941 955
942 dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__); 956 dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
943 957
944 spin_lock(&vhci->lock); 958 spin_lock_irqsave(&vhci->lock, flags);
945 hcd->state = HC_STATE_SUSPENDED; 959 hcd->state = HC_STATE_SUSPENDED;
946 spin_unlock(&vhci->lock); 960 spin_unlock_irqrestore(&vhci->lock, flags);
947 961
948 return 0; 962 return 0;
949} 963}
@@ -952,15 +966,16 @@ static int vhci_bus_resume(struct usb_hcd *hcd)
952{ 966{
953 struct vhci_hcd *vhci = hcd_to_vhci(hcd); 967 struct vhci_hcd *vhci = hcd_to_vhci(hcd);
954 int rc = 0; 968 int rc = 0;
969 unsigned long flags;
955 970
956 dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__); 971 dev_dbg(&hcd->self.root_hub->dev, "%s\n", __func__);
957 972
958 spin_lock(&vhci->lock); 973 spin_lock_irqsave(&vhci->lock, flags);
959 if (!HCD_HW_ACCESSIBLE(hcd)) 974 if (!HCD_HW_ACCESSIBLE(hcd))
960 rc = -ESHUTDOWN; 975 rc = -ESHUTDOWN;
961 else 976 else
962 hcd->state = HC_STATE_RUNNING; 977 hcd->state = HC_STATE_RUNNING;
963 spin_unlock(&vhci->lock); 978 spin_unlock_irqrestore(&vhci->lock, flags);
964 979
965 return rc; 980 return rc;
966} 981}
@@ -1058,17 +1073,18 @@ static int vhci_hcd_suspend(struct platform_device *pdev, pm_message_t state)
1058 int rhport = 0; 1073 int rhport = 0;
1059 int connected = 0; 1074 int connected = 0;
1060 int ret = 0; 1075 int ret = 0;
1076 unsigned long flags;
1061 1077
1062 hcd = platform_get_drvdata(pdev); 1078 hcd = platform_get_drvdata(pdev);
1063 1079
1064 spin_lock(&the_controller->lock); 1080 spin_lock_irqsave(&the_controller->lock, flags);
1065 1081
1066 for (rhport = 0; rhport < VHCI_NPORTS; rhport++) 1082 for (rhport = 0; rhport < VHCI_NPORTS; rhport++)
1067 if (the_controller->port_status[rhport] & 1083 if (the_controller->port_status[rhport] &
1068 USB_PORT_STAT_CONNECTION) 1084 USB_PORT_STAT_CONNECTION)
1069 connected += 1; 1085 connected += 1;
1070 1086
1071 spin_unlock(&the_controller->lock); 1087 spin_unlock_irqrestore(&the_controller->lock, flags);
1072 1088
1073 if (connected > 0) { 1089 if (connected > 0) {
1074 dev_info(&pdev->dev, 1090 dev_info(&pdev->dev,
diff --git a/drivers/usb/usbip/vhci_rx.c b/drivers/usb/usbip/vhci_rx.c
index 00e4a54308e4..d656e0edc3d5 100644
--- a/drivers/usb/usbip/vhci_rx.c
+++ b/drivers/usb/usbip/vhci_rx.c
@@ -72,10 +72,11 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
72{ 72{
73 struct usbip_device *ud = &vdev->ud; 73 struct usbip_device *ud = &vdev->ud;
74 struct urb *urb; 74 struct urb *urb;
75 unsigned long flags;
75 76
76 spin_lock(&vdev->priv_lock); 77 spin_lock_irqsave(&vdev->priv_lock, flags);
77 urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum); 78 urb = pickup_urb_and_free_priv(vdev, pdu->base.seqnum);
78 spin_unlock(&vdev->priv_lock); 79 spin_unlock_irqrestore(&vdev->priv_lock, flags);
79 80
80 if (!urb) { 81 if (!urb) {
81 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum); 82 pr_err("cannot find a urb of seqnum %u\n", pdu->base.seqnum);
@@ -104,9 +105,9 @@ static void vhci_recv_ret_submit(struct vhci_device *vdev,
104 105
105 usbip_dbg_vhci_rx("now giveback urb %p\n", urb); 106 usbip_dbg_vhci_rx("now giveback urb %p\n", urb);
106 107
107 spin_lock(&the_controller->lock); 108 spin_lock_irqsave(&the_controller->lock, flags);
108 usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb); 109 usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
109 spin_unlock(&the_controller->lock); 110 spin_unlock_irqrestore(&the_controller->lock, flags);
110 111
111 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status); 112 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, urb->status);
112 113
@@ -117,8 +118,9 @@ static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
117 struct usbip_header *pdu) 118 struct usbip_header *pdu)
118{ 119{
119 struct vhci_unlink *unlink, *tmp; 120 struct vhci_unlink *unlink, *tmp;
121 unsigned long flags;
120 122
121 spin_lock(&vdev->priv_lock); 123 spin_lock_irqsave(&vdev->priv_lock, flags);
122 124
123 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) { 125 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_rx, list) {
124 pr_info("unlink->seqnum %lu\n", unlink->seqnum); 126 pr_info("unlink->seqnum %lu\n", unlink->seqnum);
@@ -127,12 +129,12 @@ static struct vhci_unlink *dequeue_pending_unlink(struct vhci_device *vdev,
127 unlink->seqnum); 129 unlink->seqnum);
128 list_del(&unlink->list); 130 list_del(&unlink->list);
129 131
130 spin_unlock(&vdev->priv_lock); 132 spin_unlock_irqrestore(&vdev->priv_lock, flags);
131 return unlink; 133 return unlink;
132 } 134 }
133 } 135 }
134 136
135 spin_unlock(&vdev->priv_lock); 137 spin_unlock_irqrestore(&vdev->priv_lock, flags);
136 138
137 return NULL; 139 return NULL;
138} 140}
@@ -142,6 +144,7 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
142{ 144{
143 struct vhci_unlink *unlink; 145 struct vhci_unlink *unlink;
144 struct urb *urb; 146 struct urb *urb;
147 unsigned long flags;
145 148
146 usbip_dump_header(pdu); 149 usbip_dump_header(pdu);
147 150
@@ -152,9 +155,9 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
152 return; 155 return;
153 } 156 }
154 157
155 spin_lock(&vdev->priv_lock); 158 spin_lock_irqsave(&vdev->priv_lock, flags);
156 urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum); 159 urb = pickup_urb_and_free_priv(vdev, unlink->unlink_seqnum);
157 spin_unlock(&vdev->priv_lock); 160 spin_unlock_irqrestore(&vdev->priv_lock, flags);
158 161
159 if (!urb) { 162 if (!urb) {
160 /* 163 /*
@@ -171,9 +174,9 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
171 urb->status = pdu->u.ret_unlink.status; 174 urb->status = pdu->u.ret_unlink.status;
172 pr_info("urb->status %d\n", urb->status); 175 pr_info("urb->status %d\n", urb->status);
173 176
174 spin_lock(&the_controller->lock); 177 spin_lock_irqsave(&the_controller->lock, flags);
175 usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb); 178 usb_hcd_unlink_urb_from_ep(vhci_to_hcd(the_controller), urb);
176 spin_unlock(&the_controller->lock); 179 spin_unlock_irqrestore(&the_controller->lock, flags);
177 180
178 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb, 181 usb_hcd_giveback_urb(vhci_to_hcd(the_controller), urb,
179 urb->status); 182 urb->status);
@@ -185,10 +188,11 @@ static void vhci_recv_ret_unlink(struct vhci_device *vdev,
185static int vhci_priv_tx_empty(struct vhci_device *vdev) 188static int vhci_priv_tx_empty(struct vhci_device *vdev)
186{ 189{
187 int empty = 0; 190 int empty = 0;
191 unsigned long flags;
188 192
189 spin_lock(&vdev->priv_lock); 193 spin_lock_irqsave(&vdev->priv_lock, flags);
190 empty = list_empty(&vdev->priv_rx); 194 empty = list_empty(&vdev->priv_rx);
191 spin_unlock(&vdev->priv_lock); 195 spin_unlock_irqrestore(&vdev->priv_lock, flags);
192 196
193 return empty; 197 return empty;
194} 198}
diff --git a/drivers/usb/usbip/vhci_sysfs.c b/drivers/usb/usbip/vhci_sysfs.c
index 211f43f67ea2..5b5462eb1665 100644
--- a/drivers/usb/usbip/vhci_sysfs.c
+++ b/drivers/usb/usbip/vhci_sysfs.c
@@ -32,10 +32,11 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr,
32{ 32{
33 char *s = out; 33 char *s = out;
34 int i = 0; 34 int i = 0;
35 unsigned long flags;
35 36
36 BUG_ON(!the_controller || !out); 37 BUG_ON(!the_controller || !out);
37 38
38 spin_lock(&the_controller->lock); 39 spin_lock_irqsave(&the_controller->lock, flags);
39 40
40 /* 41 /*
41 * output example: 42 * output example:
@@ -70,7 +71,7 @@ static ssize_t status_show(struct device *dev, struct device_attribute *attr,
70 spin_unlock(&vdev->ud.lock); 71 spin_unlock(&vdev->ud.lock);
71 } 72 }
72 73
73 spin_unlock(&the_controller->lock); 74 spin_unlock_irqrestore(&the_controller->lock, flags);
74 75
75 return out - s; 76 return out - s;
76} 77}
@@ -80,11 +81,12 @@ static DEVICE_ATTR_RO(status);
80static int vhci_port_disconnect(__u32 rhport) 81static int vhci_port_disconnect(__u32 rhport)
81{ 82{
82 struct vhci_device *vdev; 83 struct vhci_device *vdev;
84 unsigned long flags;
83 85
84 usbip_dbg_vhci_sysfs("enter\n"); 86 usbip_dbg_vhci_sysfs("enter\n");
85 87
86 /* lock */ 88 /* lock */
87 spin_lock(&the_controller->lock); 89 spin_lock_irqsave(&the_controller->lock, flags);
88 90
89 vdev = port_to_vdev(rhport); 91 vdev = port_to_vdev(rhport);
90 92
@@ -94,14 +96,14 @@ static int vhci_port_disconnect(__u32 rhport)
94 96
95 /* unlock */ 97 /* unlock */
96 spin_unlock(&vdev->ud.lock); 98 spin_unlock(&vdev->ud.lock);
97 spin_unlock(&the_controller->lock); 99 spin_unlock_irqrestore(&the_controller->lock, flags);
98 100
99 return -EINVAL; 101 return -EINVAL;
100 } 102 }
101 103
102 /* unlock */ 104 /* unlock */
103 spin_unlock(&vdev->ud.lock); 105 spin_unlock(&vdev->ud.lock);
104 spin_unlock(&the_controller->lock); 106 spin_unlock_irqrestore(&the_controller->lock, flags);
105 107
106 usbip_event_add(&vdev->ud, VDEV_EVENT_DOWN); 108 usbip_event_add(&vdev->ud, VDEV_EVENT_DOWN);
107 109
@@ -177,6 +179,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
177 int sockfd = 0; 179 int sockfd = 0;
178 __u32 rhport = 0, devid = 0, speed = 0; 180 __u32 rhport = 0, devid = 0, speed = 0;
179 int err; 181 int err;
182 unsigned long flags;
180 183
181 /* 184 /*
182 * @rhport: port number of vhci_hcd 185 * @rhport: port number of vhci_hcd
@@ -202,14 +205,14 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
202 /* now need lock until setting vdev status as used */ 205 /* now need lock until setting vdev status as used */
203 206
204 /* begin a lock */ 207 /* begin a lock */
205 spin_lock(&the_controller->lock); 208 spin_lock_irqsave(&the_controller->lock, flags);
206 vdev = port_to_vdev(rhport); 209 vdev = port_to_vdev(rhport);
207 spin_lock(&vdev->ud.lock); 210 spin_lock(&vdev->ud.lock);
208 211
209 if (vdev->ud.status != VDEV_ST_NULL) { 212 if (vdev->ud.status != VDEV_ST_NULL) {
210 /* end of the lock */ 213 /* end of the lock */
211 spin_unlock(&vdev->ud.lock); 214 spin_unlock(&vdev->ud.lock);
212 spin_unlock(&the_controller->lock); 215 spin_unlock_irqrestore(&the_controller->lock, flags);
213 216
214 sockfd_put(socket); 217 sockfd_put(socket);
215 218
@@ -227,7 +230,7 @@ static ssize_t store_attach(struct device *dev, struct device_attribute *attr,
227 vdev->ud.status = VDEV_ST_NOTASSIGNED; 230 vdev->ud.status = VDEV_ST_NOTASSIGNED;
228 231
229 spin_unlock(&vdev->ud.lock); 232 spin_unlock(&vdev->ud.lock);
230 spin_unlock(&the_controller->lock); 233 spin_unlock_irqrestore(&the_controller->lock, flags);
231 /* end the lock */ 234 /* end the lock */
232 235
233 vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx"); 236 vdev->ud.tcp_rx = kthread_get_run(vhci_rx_loop, &vdev->ud, "vhci_rx");
diff --git a/drivers/usb/usbip/vhci_tx.c b/drivers/usb/usbip/vhci_tx.c
index 409fd99f3257..3e7878fe2fd4 100644
--- a/drivers/usb/usbip/vhci_tx.c
+++ b/drivers/usb/usbip/vhci_tx.c
@@ -47,16 +47,17 @@ static void setup_cmd_submit_pdu(struct usbip_header *pdup, struct urb *urb)
47static struct vhci_priv *dequeue_from_priv_tx(struct vhci_device *vdev) 47static struct vhci_priv *dequeue_from_priv_tx(struct vhci_device *vdev)
48{ 48{
49 struct vhci_priv *priv, *tmp; 49 struct vhci_priv *priv, *tmp;
50 unsigned long flags;
50 51
51 spin_lock(&vdev->priv_lock); 52 spin_lock_irqsave(&vdev->priv_lock, flags);
52 53
53 list_for_each_entry_safe(priv, tmp, &vdev->priv_tx, list) { 54 list_for_each_entry_safe(priv, tmp, &vdev->priv_tx, list) {
54 list_move_tail(&priv->list, &vdev->priv_rx); 55 list_move_tail(&priv->list, &vdev->priv_rx);
55 spin_unlock(&vdev->priv_lock); 56 spin_unlock_irqrestore(&vdev->priv_lock, flags);
56 return priv; 57 return priv;
57 } 58 }
58 59
59 spin_unlock(&vdev->priv_lock); 60 spin_unlock_irqrestore(&vdev->priv_lock, flags);
60 61
61 return NULL; 62 return NULL;
62} 63}
@@ -136,16 +137,17 @@ static int vhci_send_cmd_submit(struct vhci_device *vdev)
136static struct vhci_unlink *dequeue_from_unlink_tx(struct vhci_device *vdev) 137static struct vhci_unlink *dequeue_from_unlink_tx(struct vhci_device *vdev)
137{ 138{
138 struct vhci_unlink *unlink, *tmp; 139 struct vhci_unlink *unlink, *tmp;
140 unsigned long flags;
139 141
140 spin_lock(&vdev->priv_lock); 142 spin_lock_irqsave(&vdev->priv_lock, flags);
141 143
142 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) { 144 list_for_each_entry_safe(unlink, tmp, &vdev->unlink_tx, list) {
143 list_move_tail(&unlink->list, &vdev->unlink_rx); 145 list_move_tail(&unlink->list, &vdev->unlink_rx);
144 spin_unlock(&vdev->priv_lock); 146 spin_unlock_irqrestore(&vdev->priv_lock, flags);
145 return unlink; 147 return unlink;
146 } 148 }
147 149
148 spin_unlock(&vdev->priv_lock); 150 spin_unlock_irqrestore(&vdev->priv_lock, flags);
149 151
150 return NULL; 152 return NULL;
151} 153}