aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/meth.c
diff options
context:
space:
mode:
authorRalf Baechle <ralf@linux-mips.org>2009-05-15 21:21:58 -0400
committerDavid S. Miller <davem@davemloft.net>2009-05-18 00:11:36 -0400
commita8f492c6ac6072d6c5bce4b2f13dc44612991051 (patch)
tree794ad67d47a607fbf5ca1b97e28fe9aef47be2e6 /drivers/net/meth.c
parent72876a603422d3767273ffb3918033fa1bfda0f3 (diff)
NET: Meth: Fix unsafe mix of irq and non-irq spinlocks.
Mixing of normal and irq spinlocks results in the following lockdep messages on bootup on IP32: [...] Sending DHCP requests . ====================================================== [ INFO: SOFTIRQ-safe -> SOFTIRQ-unsafe lock order detected ] 2.6.30-rc5-00164-g41baeef #30 ------------------------------------------------------ swapper/1 [HC0[0]:SC0[1]:HE0:SE0] is trying to acquire: (&priv->meth_lock){+.+...}, at: [<ffffffff8026388c>] meth_tx+0x48/0x43c and this task is already holding: (_xmit_ETHER#2){+.-...}, at: [<ffffffff802d3a00>] __qdisc_run+0x118/0x30c which would create a new lock dependency: (_xmit_ETHER#2){+.-...} -> (&priv->meth_lock){+.+...} but this new dependency connects a SOFTIRQ-irq-safe lock: (_xmit_ETHER#2){+.-...} ... which became SOFTIRQ-irq-safe at: [<ffffffff80061458>] __lock_acquire+0x784/0x1a14 [<ffffffff800627e0>] lock_acquire+0xf8/0x150 [<ffffffff800128d0>] _spin_lock+0x30/0x44 [<ffffffff802d2b88>] dev_watchdog+0x70/0x398 [<ffffffff800433b8>] run_timer_softirq+0x1a8/0x248 [<ffffffff8003da5c>] __do_softirq+0xec/0x208 [<ffffffff8003dbd8>] do_softirq+0x60/0xe4 [<ffffffff8003dda0>] irq_exit+0x54/0x9c [<ffffffff80004420>] ret_from_irq+0x0/0x4 [<ffffffff80004720>] r4k_wait+0x20/0x40 [<ffffffff80015418>] cpu_idle+0x30/0x60 [<ffffffff804cd934>] start_kernel+0x3ec/0x404 to a SOFTIRQ-irq-unsafe lock: (&priv->meth_lock){+.+...} ... which became SOFTIRQ-irq-unsafe at: ... [<ffffffff800614f8>] __lock_acquire+0x824/0x1a14 [<ffffffff800627e0>] lock_acquire+0xf8/0x150 [<ffffffff800128d0>] _spin_lock+0x30/0x44 [<ffffffff80263f20>] meth_reset+0x118/0x2d8 [<ffffffff8026424c>] meth_open+0x28/0x140 [<ffffffff802c1ae8>] dev_open+0xe0/0x18c [<ffffffff802c1268>] dev_change_flags+0xd8/0x1d4 [<ffffffff804e7770>] ip_auto_config+0x1d4/0xf28 [<ffffffff80012e68>] do_one_initcall+0x58/0x170 [<ffffffff804cd190>] kernel_init+0x98/0x104 [<ffffffff8001520c>] kernel_thread_helper+0x10/0x18 other info that might help us debug this: 2 locks held by swapper/1: #0: (rcu_read_lock){.+.+..}, at: [<ffffffff802c0954>] dev_queue_xmit+0x1e0/0x4b0 #1: (_xmit_ETHER#2){+.-...}, at: [<ffffffff802d3a00>] __qdisc_run+0x118/0x30c the SOFTIRQ-irq-safe lock's dependencies: -> (_xmit_ETHER#2){+.-...} ops: 0 { HARDIRQ-ON-W at: [<ffffffff800614d0>] __lock_acquire+0x7fc/0x1a14 [<ffffffff800627e0>] lock_acquire+0xf8/0x150 [<ffffffff800128d0>] _spin_lock+0x30/0x44 [<ffffffff802d2b88>] dev_watchdog+0x70/0x398 [<ffffffff800433b8>] run_timer_softirq+0x1a8/0x248 [<ffffffff8003da5c>] __do_softirq+0xec/0x208 [<ffffffff8003dbd8>] do_softirq+0x60/0xe4 [<ffffffff8003dda0>] irq_exit+0x54/0x9c [<ffffffff80004420>] ret_from_irq+0x0/0x4 [<ffffffff80004720>] r4k_wait+0x20/0x40 [<ffffffff80015418>] cpu_idle+0x30/0x60 [<ffffffff804cd934>] start_kernel+0x3ec/0x404 IN-SOFTIRQ-W at: [<ffffffff80061458>] __lock_acquire+0x784/0x1a14 [<ffffffff800627e0>] lock_acquire+0xf8/0x150 [<ffffffff800128d0>] _spin_lock+0x30/0x44 [<ffffffff802d2b88>] dev_watchdog+0x70/0x398 [<ffffffff800433b8>] run_timer_softirq+0x1a8/0x248 [<ffffffff8003da5c>] __do_softirq+0xec/0x208 [<ffffffff8003dbd8>] do_softirq+0x60/0xe4 [<ffffffff8003dda0>] irq_exit+0x54/0x9c [<ffffffff80004420>] ret_from_irq+0x0/0x4 [<ffffffff80004720>] r4k_wait+0x20/0x40 [<ffffffff80015418>] cpu_idle+0x30/0x60 [<ffffffff804cd934>] start_kernel+0x3ec/0x404 INITIAL USE at: [<ffffffff80061570>] __lock_acquire+0x89c/0x1a14 [<ffffffff800627e0>] lock_acquire+0xf8/0x150 [<ffffffff800128d0>] _spin_lock+0x30/0x44 [<ffffffff802d2b88>] dev_watchdog+0x70/0x398 [<ffffffff800433b8>] run_timer_softirq+0x1a8/0x248 [<ffffffff8003da5c>] __do_softirq+0xec/0x208 [<ffffffff8003dbd8>] do_softirq+0x60/0xe4 [<ffffffff8003dda0>] irq_exit+0x54/0x9c [<ffffffff80004420>] ret_from_irq+0x0/0x4 [<ffffffff80004720>] r4k_wait+0x20/0x40 [<ffffffff80015418>] cpu_idle+0x30/0x60 [<ffffffff804cd934>] start_kernel+0x3ec/0x404 } ... key at: [<ffffffff80cf93f0>] netdev_xmit_lock_key+0x8/0x1c8 the SOFTIRQ-irq-unsafe lock's dependencies: -> (&priv->meth_lock){+.+...} ops: 0 { HARDIRQ-ON-W at: [<ffffffff800614d0>] __lock_acquire+0x7fc/0x1a14 [<ffffffff800627e0>] lock_acquire+0xf8/0x150 [<ffffffff800128d0>] _spin_lock+0x30/0x44 [<ffffffff80263f20>] meth_reset+0x118/0x2d8 [<ffffffff8026424c>] meth_open+0x28/0x140 [<ffffffff802c1ae8>] dev_open+0xe0/0x18c [<ffffffff802c1268>] dev_change_flags+0xd8/0x1d4 [<ffffffff804e7770>] ip_auto_config+0x1d4/0xf28 [<ffffffff80012e68>] do_one_initcall+0x58/0x170 [<ffffffff804cd190>] kernel_init+0x98/0x104 [<ffffffff8001520c>] kernel_thread_helper+0x10/0x18 SOFTIRQ-ON-W at: [<ffffffff800614f8>] __lock_acquire+0x824/0x1a14 [<ffffffff800627e0>] lock_acquire+0xf8/0x150 [<ffffffff800128d0>] _spin_lock+0x30/0x44 [<ffffffff80263f20>] meth_reset+0x118/0x2d8 [<ffffffff8026424c>] meth_open+0x28/0x140 [<ffffffff802c1ae8>] dev_open+0xe0/0x18c [<ffffffff802c1268>] dev_change_flags+0xd8/0x1d4 [<ffffffff804e7770>] ip_auto_config+0x1d4/0xf28 [<ffffffff80012e68>] do_one_initcall+0x58/0x170 [<ffffffff804cd190>] kernel_init+0x98/0x104 [<ffffffff8001520c>] kernel_thread_helper+0x10/0x18 INITIAL USE at: [<ffffffff80061570>] __lock_acquire+0x89c/0x1a14 [<ffffffff800627e0>] lock_acquire+0xf8/0x150 [<ffffffff800128d0>] _spin_lock+0x30/0x44 [<ffffffff80263f20>] meth_reset+0x118/0x2d8 [<ffffffff8026424c>] meth_open+0x28/0x140 [<ffffffff802c1ae8>] dev_open+0xe0/0x18c [<ffffffff802c1268>] dev_change_flags+0xd8/0x1d4 [<ffffffff804e7770>] ip_auto_config+0x1d4/0xf28 [<ffffffff80012e68>] do_one_initcall+0x58/0x170 [<ffffffff804cd190>] kernel_init+0x98/0x104 [<ffffffff8001520c>] kernel_thread_helper+0x10/0x18 } ... key at: [<ffffffff80cf6ce8>] __key.32424+0x0/0x8 stack backtrace: Call Trace: [<ffffffff8000ed0c>] dump_stack+0x8/0x34 [<ffffffff80060b74>] check_usage+0x470/0x4a0 [<ffffffff80060c34>] check_irq_usage+0x90/0x130 [<ffffffff80061f78>] __lock_acquire+0x12a4/0x1a14 [<ffffffff800627e0>] lock_acquire+0xf8/0x150 [<ffffffff80012a0c>] _spin_lock_irqsave+0x60/0x84 [<ffffffff8026388c>] meth_tx+0x48/0x43c [<ffffffff802d3a38>] __qdisc_run+0x150/0x30c [<ffffffff802c0aa8>] dev_queue_xmit+0x334/0x4b0 [<ffffffff804e7e6c>] ip_auto_config+0x8d0/0xf28 [<ffffffff80012e68>] do_one_initcall+0x58/0x170 [<ffffffff804cd190>] kernel_init+0x98/0x104 [<ffffffff8001520c>] kernel_thread_helper+0x10/0x18 ..... timed out! IP-Config: Retrying forever (NFS root)... Sending DHCP requests ., OK [...] Fixed by converting all locks to irq locks. Signed-off-by: Ralf Baechle <ralf@linux-mips.org> Tested-by: Andrew Randrianasulu <randrik_a@yahoo.com> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/meth.c')
-rw-r--r--drivers/net/meth.c27
1 files changed, 14 insertions, 13 deletions
diff --git a/drivers/net/meth.c b/drivers/net/meth.c
index aa08987f6e81..dbd3436912b8 100644
--- a/drivers/net/meth.c
+++ b/drivers/net/meth.c
@@ -127,11 +127,11 @@ static unsigned long mdio_read(struct meth_private *priv, unsigned long phyreg)
127static int mdio_probe(struct meth_private *priv) 127static int mdio_probe(struct meth_private *priv)
128{ 128{
129 int i; 129 int i;
130 unsigned long p2, p3; 130 unsigned long p2, p3, flags;
131 /* check if phy is detected already */ 131 /* check if phy is detected already */
132 if(priv->phy_addr>=0&&priv->phy_addr<32) 132 if(priv->phy_addr>=0&&priv->phy_addr<32)
133 return 0; 133 return 0;
134 spin_lock(&priv->meth_lock); 134 spin_lock_irqsave(&priv->meth_lock, flags);
135 for (i=0;i<32;++i){ 135 for (i=0;i<32;++i){
136 priv->phy_addr=i; 136 priv->phy_addr=i;
137 p2=mdio_read(priv,2); 137 p2=mdio_read(priv,2);
@@ -157,7 +157,7 @@ static int mdio_probe(struct meth_private *priv)
157 break; 157 break;
158 } 158 }
159 } 159 }
160 spin_unlock(&priv->meth_lock); 160 spin_unlock_irqrestore(&priv->meth_lock, flags);
161 if(priv->phy_addr<32) { 161 if(priv->phy_addr<32) {
162 return 0; 162 return 0;
163 } 163 }
@@ -373,14 +373,14 @@ static int meth_release(struct net_device *dev)
373static void meth_rx(struct net_device* dev, unsigned long int_status) 373static void meth_rx(struct net_device* dev, unsigned long int_status)
374{ 374{
375 struct sk_buff *skb; 375 struct sk_buff *skb;
376 unsigned long status; 376 unsigned long status, flags;
377 struct meth_private *priv = netdev_priv(dev); 377 struct meth_private *priv = netdev_priv(dev);
378 unsigned long fifo_rptr = (int_status & METH_INT_RX_RPTR_MASK) >> 8; 378 unsigned long fifo_rptr = (int_status & METH_INT_RX_RPTR_MASK) >> 8;
379 379
380 spin_lock(&priv->meth_lock); 380 spin_lock_irqsave(&priv->meth_lock, flags);
381 priv->dma_ctrl &= ~METH_DMA_RX_INT_EN; 381 priv->dma_ctrl &= ~METH_DMA_RX_INT_EN;
382 mace->eth.dma_ctrl = priv->dma_ctrl; 382 mace->eth.dma_ctrl = priv->dma_ctrl;
383 spin_unlock(&priv->meth_lock); 383 spin_unlock_irqrestore(&priv->meth_lock, flags);
384 384
385 if (int_status & METH_INT_RX_UNDERFLOW) { 385 if (int_status & METH_INT_RX_UNDERFLOW) {
386 fifo_rptr = (fifo_rptr - 1) & 0x0f; 386 fifo_rptr = (fifo_rptr - 1) & 0x0f;
@@ -452,12 +452,12 @@ static void meth_rx(struct net_device* dev, unsigned long int_status)
452 mace->eth.rx_fifo = priv->rx_ring_dmas[priv->rx_write]; 452 mace->eth.rx_fifo = priv->rx_ring_dmas[priv->rx_write];
453 ADVANCE_RX_PTR(priv->rx_write); 453 ADVANCE_RX_PTR(priv->rx_write);
454 } 454 }
455 spin_lock(&priv->meth_lock); 455 spin_lock_irqsave(&priv->meth_lock, flags);
456 /* In case there was underflow, and Rx DMA was disabled */ 456 /* In case there was underflow, and Rx DMA was disabled */
457 priv->dma_ctrl |= METH_DMA_RX_INT_EN | METH_DMA_RX_EN; 457 priv->dma_ctrl |= METH_DMA_RX_INT_EN | METH_DMA_RX_EN;
458 mace->eth.dma_ctrl = priv->dma_ctrl; 458 mace->eth.dma_ctrl = priv->dma_ctrl;
459 mace->eth.int_stat = METH_INT_RX_THRESHOLD; 459 mace->eth.int_stat = METH_INT_RX_THRESHOLD;
460 spin_unlock(&priv->meth_lock); 460 spin_unlock_irqrestore(&priv->meth_lock, flags);
461} 461}
462 462
463static int meth_tx_full(struct net_device *dev) 463static int meth_tx_full(struct net_device *dev)
@@ -470,11 +470,11 @@ static int meth_tx_full(struct net_device *dev)
470static void meth_tx_cleanup(struct net_device* dev, unsigned long int_status) 470static void meth_tx_cleanup(struct net_device* dev, unsigned long int_status)
471{ 471{
472 struct meth_private *priv = netdev_priv(dev); 472 struct meth_private *priv = netdev_priv(dev);
473 unsigned long status; 473 unsigned long status, flags;
474 struct sk_buff *skb; 474 struct sk_buff *skb;
475 unsigned long rptr = (int_status&TX_INFO_RPTR) >> 16; 475 unsigned long rptr = (int_status&TX_INFO_RPTR) >> 16;
476 476
477 spin_lock(&priv->meth_lock); 477 spin_lock_irqsave(&priv->meth_lock, flags);
478 478
479 /* Stop DMA notification */ 479 /* Stop DMA notification */
480 priv->dma_ctrl &= ~(METH_DMA_TX_INT_EN); 480 priv->dma_ctrl &= ~(METH_DMA_TX_INT_EN);
@@ -527,12 +527,13 @@ static void meth_tx_cleanup(struct net_device* dev, unsigned long int_status)
527 } 527 }
528 528
529 mace->eth.int_stat = METH_INT_TX_EMPTY | METH_INT_TX_PKT; 529 mace->eth.int_stat = METH_INT_TX_EMPTY | METH_INT_TX_PKT;
530 spin_unlock(&priv->meth_lock); 530 spin_unlock_irqrestore(&priv->meth_lock, flags);
531} 531}
532 532
533static void meth_error(struct net_device* dev, unsigned status) 533static void meth_error(struct net_device* dev, unsigned status)
534{ 534{
535 struct meth_private *priv = netdev_priv(dev); 535 struct meth_private *priv = netdev_priv(dev);
536 unsigned long flags;
536 537
537 printk(KERN_WARNING "meth: error status: 0x%08x\n",status); 538 printk(KERN_WARNING "meth: error status: 0x%08x\n",status);
538 /* check for errors too... */ 539 /* check for errors too... */
@@ -547,7 +548,7 @@ static void meth_error(struct net_device* dev, unsigned status)
547 printk(KERN_WARNING "meth: Rx overflow\n"); 548 printk(KERN_WARNING "meth: Rx overflow\n");
548 if (status & (METH_INT_RX_UNDERFLOW)) { 549 if (status & (METH_INT_RX_UNDERFLOW)) {
549 printk(KERN_WARNING "meth: Rx underflow\n"); 550 printk(KERN_WARNING "meth: Rx underflow\n");
550 spin_lock(&priv->meth_lock); 551 spin_lock_irqsave(&priv->meth_lock, flags);
551 mace->eth.int_stat = METH_INT_RX_UNDERFLOW; 552 mace->eth.int_stat = METH_INT_RX_UNDERFLOW;
552 /* more underflow interrupts will be delivered, 553 /* more underflow interrupts will be delivered,
553 * effectively throwing us into an infinite loop. 554 * effectively throwing us into an infinite loop.
@@ -555,7 +556,7 @@ static void meth_error(struct net_device* dev, unsigned status)
555 priv->dma_ctrl &= ~METH_DMA_RX_EN; 556 priv->dma_ctrl &= ~METH_DMA_RX_EN;
556 mace->eth.dma_ctrl = priv->dma_ctrl; 557 mace->eth.dma_ctrl = priv->dma_ctrl;
557 DPRINTK("Disabled meth Rx DMA temporarily\n"); 558 DPRINTK("Disabled meth Rx DMA temporarily\n");
558 spin_unlock(&priv->meth_lock); 559 spin_unlock_irqrestore(&priv->meth_lock, flags);
559 } 560 }
560 mace->eth.int_stat = METH_INT_ERROR; 561 mace->eth.int_stat = METH_INT_ERROR;
561} 562}