Skip to content

Commit 79fbe13

Browse files
Dongdong Dengdavem330
authored andcommitted
drivers/net: using spin_lock_irqsave() in net_send_packet()
spin_unlock_irq() will enable interrupt in net_send_packet(), this patch changes it to spin_lock_irqsave/spin_lock_irqrestore, so that it doesn't enable interrupts when already disabled, and netconsole would work properly over cs89x0/isa-skeleton. Call trace: netconsole write_msg() { ... -> spin_lock_irqsave(); -> netpoll_send_udp() -> netpoll_send_skb() -> net_send_packet() ->... -> spin_unlock_irqrestore(); ... } Signed-off-by: Dongdong Deng <dongdong.deng@windriver.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent bc23283 commit 79fbe13

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

drivers/net/cs89x0.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1524,6 +1524,7 @@ static void net_timeout(struct net_device *dev)
15241524
static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
15251525
{
15261526
struct net_local *lp = netdev_priv(dev);
1527+
unsigned long flags;
15271528

15281529
if (net_debug > 3) {
15291530
printk("%s: sent %d byte packet of type %x\n",
@@ -1535,7 +1536,7 @@ static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
15351536
ask the chip to start transmitting before the
15361537
whole packet has been completely uploaded. */
15371538

1538-
spin_lock_irq(&lp->lock);
1539+
spin_lock_irqsave(&lp->lock, flags);
15391540
netif_stop_queue(dev);
15401541

15411542
/* initiate a transmit sequence */
@@ -1549,13 +1550,13 @@ static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
15491550
* we're waiting for TxOk, so return 1 and requeue this packet.
15501551
*/
15511552

1552-
spin_unlock_irq(&lp->lock);
1553+
spin_unlock_irqrestore(&lp->lock, flags);
15531554
if (net_debug) printk("cs89x0: Tx buffer not free!\n");
15541555
return NETDEV_TX_BUSY;
15551556
}
15561557
/* Write the contents of the packet */
15571558
writewords(dev->base_addr, TX_FRAME_PORT,skb->data,(skb->len+1) >>1);
1558-
spin_unlock_irq(&lp->lock);
1559+
spin_unlock_irqrestore(&lp->lock, flags);
15591560
lp->stats.tx_bytes += skb->len;
15601561
dev->trans_start = jiffies;
15611562
dev_kfree_skb (skb);

drivers/net/isa-skeleton.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,8 @@ static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
430430
* hardware interrupt handler. Queue flow control is
431431
* thus managed under this lock as well.
432432
*/
433-
spin_lock_irq(&np->lock);
433+
unsigned long flags;
434+
spin_lock_irqsave(&np->lock, flags);
434435

435436
add_to_tx_ring(np, skb, length);
436437
dev->trans_start = jiffies;
@@ -446,7 +447,7 @@ static int net_send_packet(struct sk_buff *skb, struct net_device *dev)
446447
* is when the transmit statistics are updated.
447448
*/
448449

449-
spin_unlock_irq(&np->lock);
450+
spin_unlock_irqrestore(&np->lock, flags);
450451
#else
451452
/* This is the case for older hardware which takes
452453
* a single transmit buffer at a time, and it is

0 commit comments

Comments
 (0)