Skip to content

Commit 3f484a6

Browse files
committed
Merge branch 'usb-callbacks'
Sebastian Andrzej Siewior says: ==================== net/usb: Use irqsave in USB's complete callback This is about using _irqsave() primitives in the completion callback in order to get rid of local_irq_save() in __usb_hcd_giveback_urb(). ==================== Signed-off-by: David S. Miller <davem@davemloft.net>
2 parents f79e711 + feae641 commit 3f484a6

File tree

5 files changed

+37
-26
lines changed

5 files changed

+37
-26
lines changed

drivers/net/usb/cdc-phonet.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static void tx_complete(struct urb *req)
9999
struct net_device *dev = skb->dev;
100100
struct usbpn_dev *pnd = netdev_priv(dev);
101101
int status = req->status;
102+
unsigned long flags;
102103

103104
switch (status) {
104105
case 0:
@@ -115,10 +116,10 @@ static void tx_complete(struct urb *req)
115116
}
116117
dev->stats.tx_packets++;
117118

118-
spin_lock(&pnd->tx_lock);
119+
spin_lock_irqsave(&pnd->tx_lock, flags);
119120
pnd->tx_queue--;
120121
netif_wake_queue(dev);
121-
spin_unlock(&pnd->tx_lock);
122+
spin_unlock_irqrestore(&pnd->tx_lock, flags);
122123

123124
dev_kfree_skb_any(skb);
124125
usb_free_urb(req);

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

drivers/net/usb/kaweth.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -587,7 +587,7 @@ static void kaweth_usb_receive(struct urb *urb)
587587
struct kaweth_device *kaweth = urb->context;
588588
struct net_device *net = kaweth->net;
589589
int status = urb->status;
590-
590+
unsigned long flags;
591591
int count = urb->actual_length;
592592
int count2 = urb->transfer_buffer_length;
593593

@@ -619,12 +619,12 @@ static void kaweth_usb_receive(struct urb *urb)
619619
net->stats.rx_errors++;
620620
dev_dbg(dev, "Status was -EOVERFLOW.\n");
621621
}
622-
spin_lock(&kaweth->device_lock);
622+
spin_lock_irqsave(&kaweth->device_lock, flags);
623623
if (IS_BLOCKED(kaweth->status)) {
624-
spin_unlock(&kaweth->device_lock);
624+
spin_unlock_irqrestore(&kaweth->device_lock, flags);
625625
return;
626626
}
627-
spin_unlock(&kaweth->device_lock);
627+
spin_unlock_irqrestore(&kaweth->device_lock, flags);
628628

629629
if(status && status != -EREMOTEIO && count != 1) {
630630
dev_err(&kaweth->intf->dev,

drivers/net/usb/r8152.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1252,6 +1252,7 @@ static void read_bulk_callback(struct urb *urb)
12521252
int status = urb->status;
12531253
struct rx_agg *agg;
12541254
struct r8152 *tp;
1255+
unsigned long flags;
12551256

12561257
agg = urb->context;
12571258
if (!agg)
@@ -1281,9 +1282,9 @@ static void read_bulk_callback(struct urb *urb)
12811282
if (urb->actual_length < ETH_ZLEN)
12821283
break;
12831284

1284-
spin_lock(&tp->rx_lock);
1285+
spin_lock_irqsave(&tp->rx_lock, flags);
12851286
list_add_tail(&agg->list, &tp->rx_done);
1286-
spin_unlock(&tp->rx_lock);
1287+
spin_unlock_irqrestore(&tp->rx_lock, flags);
12871288
napi_schedule(&tp->napi);
12881289
return;
12891290
case -ESHUTDOWN:
@@ -1311,6 +1312,7 @@ static void write_bulk_callback(struct urb *urb)
13111312
struct net_device *netdev;
13121313
struct tx_agg *agg;
13131314
struct r8152 *tp;
1315+
unsigned long flags;
13141316
int status = urb->status;
13151317

13161318
agg = urb->context;
@@ -1332,9 +1334,9 @@ static void write_bulk_callback(struct urb *urb)
13321334
stats->tx_bytes += agg->skb_len;
13331335
}
13341336

1335-
spin_lock(&tp->tx_lock);
1337+
spin_lock_irqsave(&tp->tx_lock, flags);
13361338
list_add_tail(&agg->list, &tp->tx_free);
1337-
spin_unlock(&tp->tx_lock);
1339+
spin_unlock_irqrestore(&tp->tx_lock, flags);
13381340

13391341
usb_autopm_put_interface_async(tp->intf);
13401342

drivers/net/usb/rtl8150.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,7 @@ static void read_bulk_callback(struct urb *urb)
391391
u16 rx_stat;
392392
int status = urb->status;
393393
int result;
394+
unsigned long flags;
394395

395396
dev = urb->context;
396397
if (!dev)
@@ -432,9 +433,9 @@ static void read_bulk_callback(struct urb *urb)
432433
netdev->stats.rx_packets++;
433434
netdev->stats.rx_bytes += pkt_len;
434435

435-
spin_lock(&dev->rx_pool_lock);
436+
spin_lock_irqsave(&dev->rx_pool_lock, flags);
436437
skb = pull_skb(dev);
437-
spin_unlock(&dev->rx_pool_lock);
438+
spin_unlock_irqrestore(&dev->rx_pool_lock, flags);
438439
if (!skb)
439440
goto resched;
440441

0 commit comments

Comments
 (0)