• Frank Li's avatar
    net: fec: put tx to napi poll function to fix dead lock · de5fb0a0
    Frank Li authored
    up stack ndo_start_xmit already hold lock.
    fec_enet_start_xmit needn't spin lock.
    stat_xmit just update fep->cur_tx
    fec_enet_tx just update fep->dirty_tx
    
    Reserve a empty bdb to check full or empty
    cur_tx == dirty_tx    means full
    cur_tx == dirty_tx +1 means empty
    
    So needn't is_full variable.
    
    Fix spin lock deadlock
    
    =================================
    [ INFO: inconsistent lock state ]
    3.8.0-rc5+ #107 Not tainted
    ---------------------------------
    inconsistent {HARDIRQ-ON-W} -> {IN-HARDIRQ-W} usage.
    ptp4l/615 [HC1[1]:SC0[0]:HE0:SE1] takes:
     (&(&list->lock)->rlock#3){?.-...}, at: [<8042c3c4>] skb_queue_tail+0x20/0x50
     {HARDIRQ-ON-W} state was registered at:
     [<80067250>] mark_lock+0x154/0x4e8
     [<800676f4>] mark_irqflags+0x110/0x1a4
     [<80069208>] __lock_acquire+0x494/0x9c0
     [<80069ce8>] lock_acquire+0x90/0xa4
     [<80527ad0>] _raw_spin_lock_bh+0x44/0x54
     [<804877e0>] first_packet_length+0x38/0x1f0
     [<804879e4>] udp_poll+0x4c/0x5c
     [<804231f8>] sock_poll+0x24/0x28
     [<800d27f0>] do_poll.isra.10+0x120/0x254
     [<800d36e4>] do_sys_poll+0x15c/0x1e8
     [<800d3828>] sys_poll+0x60/0xc8
     [<8000e780>] ret_fast_syscall+0x0/0x3c
    
     *** DEADLOCK ***
    
     1 lock held by ptp4l/615:
      #0:  (&(&fep->hw_lock)->rlock){-.-...}, at: [<80355f9c>] fec_enet_tx+0x24/0x268
      stack backtrace:
      Backtrace:
      [<800121e0>] (dump_backtrace+0x0/0x10c) from [<80516210>] (dump_stack+0x18/0x1c)
      r6:8063b1fc r5:bf38b2f8 r4:bf38b000 r3:bf38b000
      [<805161f8>] (dump_stack+0x0/0x1c) from [<805189d0>] (print_usage_bug.part.34+0x164/0x1a4)
      [<8051886c>] (print_usage_bug.part.34+0x0/0x1a4) from [<80518a88>] (print_usage_bug+0x78/0x88)
      r8:80065664 r7:bf38b2f8 r6:00000002 r5:00000000 r4:bf38b000
      [<80518a10>] (print_usage_bug+0x0/0x88) from [<80518b58>] (mark_lock_irq+0xc0/0x270)
      r7:bf38b000 r6:00000002 r5:bf38b2f8 r4:00000000
      [<80518a98>] (mark_lock_irq+0x0/0x270) from [<80067270>] (mark_lock+0x174/0x4e8)
      [<800670fc>] (mark_lock+0x0/0x4e8) from [<80067744>] (mark_irqflags+0x160/0x1a4)
      [<800675e4>] (mark_irqflags+0x0/0x1a4) from [<80069208>] (__lock_acquire+0x494/0x9c0)
      r5:00000002 r4:bf38b2f8
      [<80068d74>] (__lock_acquire+0x0/0x9c0) from [<80069ce8>] (lock_acquire+0x90/0xa4)
      [<80069c58>] (lock_acquire+0x0/0xa4) from [<805278d8>] (_raw_spin_lock_irqsave+0x4c/0x60)
      [<8052788c>] (_raw_spin_lock_irqsave+0x0/0x60) from [<8042c3c4>] (skb_queue_tail+0x20/0x50)
      r6:bfbb2180 r5:bf1d0190 r4:bf1d0184
      [<8042c3a4>] (skb_queue_tail+0x0/0x50) from [<8042c4cc>] (sock_queue_err_skb+0xd8/0x188)
      r6:00000056 r5:bfbb2180 r4:bf1d0000 r3:00000000
      [<8042c3f4>] (sock_queue_err_skb+0x0/0x188) from [<8042d15c>] (skb_tstamp_tx+0x70/0xa0)
      r6:bf0dddb0 r5:bf1d0000 r4:bfbb2180 r3:00000004
      [<8042d0ec>] (skb_tstamp_tx+0x0/0xa0) from [<803561d0>] (fec_enet_tx+0x258/0x268)
      r6:c089d260 r5:00001c00 r4:bfbd0000
      [<80355f78>] (fec_enet_tx+0x0/0x268) from [<803562cc>] (fec_enet_interrupt+0xec/0xf8)
      [<803561e0>] (fec_enet_interrupt+0x0/0xf8) from [<8007d5b0>] (handle_irq_event_percpu+0x54/0x1a0)
      [<8007d55c>] (handle_irq_event_percpu+0x0/0x1a0) from [<8007d740>] (handle_irq_event+0x44/0x64)
      [<8007d6fc>] (handle_irq_event+0x0/0x64) from [<80080690>] (handle_fasteoi_irq+0xc4/0x15c)
      r6:bf0dc000 r5:bf811290 r4:bf811240 r3:00000000
      [<800805cc>] (handle_fasteoi_irq+0x0/0x15c) from [<8007ceec>] (generic_handle_irq+0x28/0x38)
      r5:807130c8 r4:00000096
      [<8007cec4>] (generic_handle_irq+0x0/0x38) from [<8000f16c>] (handle_IRQ+0x54/0xb4)
      r4:8071d280 r3:00000180
      [<8000f118>] (handle_IRQ+0x0/0xb4) from [<80008544>] (gic_handle_irq+0x30/0x64)
      r8:8000e924 r7:f4000100 r6:bf0ddef8 r5:8071c974 r4:f400010c
      r3:00000000
      [<80008514>] (gic_handle_irq+0x0/0x64) from [<8000e2e4>] (__irq_svc+0x44/0x5c)
      Exception stack(0xbf0ddef8 to 0xbf0ddf40)
    Signed-off-by: default avatarFrank Li <Frank.Li@freescale.com>
    Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
    de5fb0a0
fec.c 49.5 KB