Skip to content

Commit 12c4de4

Browse files
Sebastian Andrzej Siewiordavem330
authored andcommitted
net: usb: hso: use irqsave() in USB's complete callback
The USB completion callback does not disable interrupts while acquiring the lock. We want to remove the local_irq_disable() invocation from __usb_hcd_giveback_urb() and therefore it is required for the callback handler to disable the interrupts while acquiring the lock. The callback may be invoked either in IRQ or BH context depending on the USB host controller. Use the _irqsave() variant of the locking primitives. Cc: "David S. Miller" <davem@davemloft.net> Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent fafa6b1 commit 12c4de4

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

drivers/net/usb/hso.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -999,6 +999,7 @@ static void read_bulk_callback(struct urb *urb)
999999
struct hso_net *odev = urb->context;
10001000
struct net_device *net;
10011001
int result;
1002+
unsigned long flags;
10021003
int status = urb->status;
10031004

10041005
/* is al ok? (Filip: Who's Al ?) */
@@ -1028,11 +1029,11 @@ static void read_bulk_callback(struct urb *urb)
10281029
if (urb->actual_length) {
10291030
/* Handle the IP stream, add header and push it onto network
10301031
* stack if the packet is complete. */
1031-
spin_lock(&odev->net_lock);
1032+
spin_lock_irqsave(&odev->net_lock, flags);
10321033
packetizeRx(odev, urb->transfer_buffer, urb->actual_length,
10331034
(urb->transfer_buffer_length >
10341035
urb->actual_length) ? 1 : 0);
1035-
spin_unlock(&odev->net_lock);
1036+
spin_unlock_irqrestore(&odev->net_lock, flags);
10361037
}
10371038

10381039
/* We are done with this URB, resubmit it. Prep the USB to wait for
@@ -1193,6 +1194,7 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
11931194
{
11941195
struct hso_serial *serial = urb->context;
11951196
int status = urb->status;
1197+
unsigned long flags;
11961198

11971199
hso_dbg(0x8, "--- Got serial_read_bulk callback %02x ---\n", status);
11981200

@@ -1216,10 +1218,10 @@ static void hso_std_serial_read_bulk_callback(struct urb *urb)
12161218
if (serial->parent->port_spec & HSO_INFO_CRC_BUG)
12171219
fix_crc_bug(urb, serial->in_endp->wMaxPacketSize);
12181220
/* Valid data, handle RX data */
1219-
spin_lock(&serial->serial_lock);
1221+
spin_lock_irqsave(&serial->serial_lock, flags);
12201222
serial->rx_urb_filled[hso_urb_to_index(serial, urb)] = 1;
12211223
put_rxbuf_data_and_resubmit_bulk_urb(serial);
1222-
spin_unlock(&serial->serial_lock);
1224+
spin_unlock_irqrestore(&serial->serial_lock, flags);
12231225
}
12241226

12251227
/*
@@ -1502,12 +1504,13 @@ static void tiocmget_intr_callback(struct urb *urb)
15021504
DUMP(serial_state_notification,
15031505
sizeof(struct hso_serial_state_notification));
15041506
} else {
1507+
unsigned long flags;
15051508

15061509
UART_state_bitmap = le16_to_cpu(serial_state_notification->
15071510
UART_state_bitmap);
15081511
prev_UART_state_bitmap = tiocmget->prev_UART_state_bitmap;
15091512
icount = &tiocmget->icount;
1510-
spin_lock(&serial->serial_lock);
1513+
spin_lock_irqsave(&serial->serial_lock, flags);
15111514
if ((UART_state_bitmap & B_OVERRUN) !=
15121515
(prev_UART_state_bitmap & B_OVERRUN))
15131516
icount->parity++;
@@ -1530,7 +1533,7 @@ static void tiocmget_intr_callback(struct urb *urb)
15301533
(prev_UART_state_bitmap & B_RX_CARRIER))
15311534
icount->dcd++;
15321535
tiocmget->prev_UART_state_bitmap = UART_state_bitmap;
1533-
spin_unlock(&serial->serial_lock);
1536+
spin_unlock_irqrestore(&serial->serial_lock, flags);
15341537
tiocmget->intr_completed = 1;
15351538
wake_up_interruptible(&tiocmget->waitq);
15361539
}
@@ -1852,6 +1855,7 @@ static void intr_callback(struct urb *urb)
18521855
struct hso_serial *serial;
18531856
unsigned char *port_req;
18541857
int status = urb->status;
1858+
unsigned long flags;
18551859
int i;
18561860

18571861
usb_mark_last_busy(urb->dev);
@@ -1879,7 +1883,7 @@ static void intr_callback(struct urb *urb)
18791883
if (serial != NULL) {
18801884
hso_dbg(0x1, "Pending read interrupt on port %d\n",
18811885
i);
1882-
spin_lock(&serial->serial_lock);
1886+
spin_lock_irqsave(&serial->serial_lock, flags);
18831887
if (serial->rx_state == RX_IDLE &&
18841888
serial->port.count > 0) {
18851889
/* Setup and send a ctrl req read on
@@ -1893,7 +1897,8 @@ static void intr_callback(struct urb *urb)
18931897
hso_dbg(0x1, "Already a read pending on port %d or port not open\n",
18941898
i);
18951899
}
1896-
spin_unlock(&serial->serial_lock);
1900+
spin_unlock_irqrestore(&serial->serial_lock,
1901+
flags);
18971902
}
18981903
}
18991904
}
@@ -1920,16 +1925,17 @@ static void hso_std_serial_write_bulk_callback(struct urb *urb)
19201925
{
19211926
struct hso_serial *serial = urb->context;
19221927
int status = urb->status;
1928+
unsigned long flags;
19231929

19241930
/* sanity check */
19251931
if (!serial) {
19261932
hso_dbg(0x1, "serial == NULL\n");
19271933
return;
19281934
}
19291935

1930-
spin_lock(&serial->serial_lock);
1936+
spin_lock_irqsave(&serial->serial_lock, flags);
19311937
serial->tx_urb_used = 0;
1932-
spin_unlock(&serial->serial_lock);
1938+
spin_unlock_irqrestore(&serial->serial_lock, flags);
19331939
if (status) {
19341940
handle_usb_error(status, __func__, serial->parent);
19351941
return;
@@ -1971,14 +1977,15 @@ static void ctrl_callback(struct urb *urb)
19711977
struct hso_serial *serial = urb->context;
19721978
struct usb_ctrlrequest *req;
19731979
int status = urb->status;
1980+
unsigned long flags;
19741981

19751982
/* sanity check */
19761983
if (!serial)
19771984
return;
19781985

1979-
spin_lock(&serial->serial_lock);
1986+
spin_lock_irqsave(&serial->serial_lock, flags);
19801987
serial->tx_urb_used = 0;
1981-
spin_unlock(&serial->serial_lock);
1988+
spin_unlock_irqrestore(&serial->serial_lock, flags);
19821989
if (status) {
19831990
handle_usb_error(status, __func__, serial->parent);
19841991
return;
@@ -1994,9 +2001,9 @@ static void ctrl_callback(struct urb *urb)
19942001
(USB_DIR_IN | USB_TYPE_OPTION_VENDOR | USB_RECIP_INTERFACE)) {
19952002
/* response to a read command */
19962003
serial->rx_urb_filled[0] = 1;
1997-
spin_lock(&serial->serial_lock);
2004+
spin_lock_irqsave(&serial->serial_lock, flags);
19982005
put_rxbuf_data_and_resubmit_ctrl_urb(serial);
1999-
spin_unlock(&serial->serial_lock);
2006+
spin_unlock_irqrestore(&serial->serial_lock, flags);
20002007
} else {
20012008
hso_put_activity(serial->parent);
20022009
tty_port_tty_wakeup(&serial->port);

0 commit comments

Comments
 (0)