linux_dsm_epyc7002/drivers/net/ethernet
Stephen Boyd c5a99937a9 ks8851: Fix mutex deadlock in ks8851_net_stop()
There is a potential deadlock scenario when the ks8851 driver
is removed. The interrupt handler schedules a workqueue which
acquires a mutex that ks8851_net_stop() also acquires before
flushing the workqueue. Previously lockdep wouldn't be able
to find this problem but now that it has the support we can
trigger this lockdep warning by rmmoding the driver after
an ifconfig up.

Fix the possible deadlock by disabling the interrupts in
the chip and then release the lock across the workqueue
flushing. The mutex is only there to proect the registers
anyway so this should be ok.

=======================================================
[ INFO: possible circular locking dependency detected ]
3.0.21-00021-g8b33780-dirty #2911
-------------------------------------------------------
rmmod/125 is trying to acquire lock:
 ((&ks->irq_work)){+.+...}, at: [<c019e0b8>] flush_work+0x0/0xac

but task is already holding lock:
 (&ks->lock){+.+...}, at: [<bf00b850>] ks8851_net_stop+0x64/0x138 [ks8851]

which lock already depends on the new lock.

the existing dependency chain (in reverse order) is:

-> #1 (&ks->lock){+.+...}:
       [<c01b89c8>] __lock_acquire+0x940/0x9f8
       [<c01b9058>] lock_acquire+0x10c/0x130
       [<c083dbec>] mutex_lock_nested+0x68/0x3dc
       [<bf00bd48>] ks8851_irq_work+0x24/0x46c [ks8851]
       [<c019c580>] process_one_work+0x2d8/0x518
       [<c019cb98>] worker_thread+0x220/0x3a0
       [<c01a2ad4>] kthread+0x88/0x94
       [<c0107008>] kernel_thread_exit+0x0/0x8

-> #0 ((&ks->irq_work)){+.+...}:
       [<c01b7984>] validate_chain+0x914/0x1018
       [<c01b89c8>] __lock_acquire+0x940/0x9f8
       [<c01b9058>] lock_acquire+0x10c/0x130
       [<c019e104>] flush_work+0x4c/0xac
       [<bf00b858>] ks8851_net_stop+0x6c/0x138 [ks8851]
       [<c06b209c>] __dev_close_many+0x98/0xcc
       [<c06b2174>] dev_close_many+0x68/0xd0
       [<c06b22ec>] rollback_registered_many+0xcc/0x2b8
       [<c06b2554>] rollback_registered+0x28/0x34
       [<c06b25b8>] unregister_netdevice_queue+0x58/0x7c
       [<c06b25f4>] unregister_netdev+0x18/0x20
       [<bf00c1f4>] ks8851_remove+0x64/0xb4 [ks8851]
       [<c049ddf0>] spi_drv_remove+0x18/0x1c
       [<c0468e98>] __device_release_driver+0x7c/0xbc
       [<c0468f64>] driver_detach+0x8c/0xb4
       [<c0467f00>] bus_remove_driver+0xb8/0xe8
       [<c01c1d20>] sys_delete_module+0x1e8/0x27c
       [<c0105ec0>] ret_fast_syscall+0x0/0x3c

other info that might help us debug this:

 Possible unsafe locking scenario:

       CPU0                    CPU1
       ----                    ----
  lock(&ks->lock);
                               lock((&ks->irq_work));
                               lock(&ks->lock);
  lock((&ks->irq_work));

 *** DEADLOCK ***

4 locks held by rmmod/125:
 #0:  (&__lockdep_no_validate__){+.+.+.}, at: [<c0468f44>] driver_detach+0x6c/0xb4
 #1:  (&__lockdep_no_validate__){+.+.+.}, at: [<c0468f50>] driver_detach+0x78/0xb4
 #2:  (rtnl_mutex){+.+.+.}, at: [<c06b25e8>] unregister_netdev+0xc/0x20
 #3:  (&ks->lock){+.+...}, at: [<bf00b850>] ks8851_net_stop+0x64/0x138 [ks8851]

Cc: Ben Dooks <ben-linux@fluff.org>
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
2012-04-21 15:33:14 -04:00
..
3com Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
8390 Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
adaptec netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-06 11:41:20 -05:00
adi adi: adapt to eth_hw_addr_random() and changes in arch/blackfin 2012-02-19 19:03:04 -05:00
aeroflex ethernet: unify return value of .ndo_set_mac_address if address is invalid 2012-02-23 17:03:20 -05:00
alteon Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
amd Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
apple netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-08 18:46:38 -05:00
atheros atl1: fix kernel panic in case of DMA errors 2012-04-13 13:34:20 -04:00
broadcom bnx2x: off by one in bnx2x_ets_e3b0_sp_pri_to_cos_set() 2012-04-19 15:22:44 -04:00
brocade Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2012-03-21 13:36:41 -07:00
cadence net: replace random_ether_addr() with eth_hw_addr_random() 2012-02-15 15:34:16 -05:00
calxeda net: use eth_hw_addr_random() and reset addr_assign_type 2012-02-15 15:34:17 -05:00
chelsio simple_open: automatically convert to simple_open() 2012-04-05 15:25:50 -07:00
cirrus Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
cisco enic: Fix addr valid check in enic_set_vf_mac 2012-03-08 00:28:19 -08:00
davicom net: replace random_ether_addr() with eth_hw_addr_random() 2012-02-15 15:34:16 -05:00
dec dec/tulip/de4x5: print MAC via printk format specifier 2012-02-24 15:40:59 -05:00
dlink Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
emulex be2net: fix programming of VLAN tags for VF 2012-03-19 16:52:17 -04:00
faraday net: replace random_ether_addr() with eth_hw_addr_random() 2012-02-15 15:34:16 -05:00
freescale Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2012-04-02 17:53:39 -07:00
fujitsu Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
hp netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-06 11:52:27 -05:00
i825xx Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
ibm powerpc+sparc/vio: Modernize driver registration 2012-03-28 11:33:24 +11:00
icplus netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-06 11:52:27 -05:00
intel ixgbe: Identify FCoE rings earlier to resolve memory corruption w/ FCoE 2012-04-17 15:43:02 -07:00
marvell sky2: copy received packets on inefficient unaligned architecture 2012-04-04 18:14:04 -04:00
mellanox mlx4: allocate just enough pages instead of always 4 pages 2012-04-04 20:34:29 -04:00
micrel ks8851: Fix mutex deadlock in ks8851_net_stop() 2012-04-21 15:33:14 -04:00
microchip net: use eth_hw_addr_random() and reset addr_assign_type 2012-02-15 15:34:17 -05:00
myricom drivers/net: Remove alloc_etherdev error messages 2012-01-31 16:20:48 -05:00
natsemi Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
neterion Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
nuvoton netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-08 18:46:38 -05:00
nvidia Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
nxp net: lpc_eth: Fix rename of dev_hw_addr_random 2012-04-01 16:47:12 -04:00
octeon octeon: fix PHY name to match MDIO bus name 2012-02-13 16:04:09 -05:00
oki-semi net/pch_gbe: supports eg20t ptp clock 2012-03-09 13:55:38 -08:00
packetengines Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2012-03-05 21:16:26 -05:00
pasemi ethernet: unify return value of .ndo_set_mac_address if address is invalid 2012-02-23 17:03:20 -05:00
qlogic qlcnic: Bug fix for LRO 2012-03-23 14:51:31 -04:00
racal netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-08 18:46:38 -05:00
rdc net: replace random_ether_addr() with eth_hw_addr_random() 2012-02-15 15:34:16 -05:00
realtek 8139cp: set intr mask after its handler is registered 2012-04-13 13:41:52 -04:00
renesas net: sh_eth: fix endian check for architecture independent 2012-04-01 23:22:11 -04:00
seeq Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
sfc MTD merge for 3.4 2012-03-30 17:31:56 -07:00
sgi net: meth: Add set_rx_mode hook to fix ICMPv6 neighbor discovery 2011-12-27 13:17:34 -05:00
silan
sis net: replace random_ether_addr() with eth_hw_addr_random() 2012-02-15 15:34:16 -05:00
smsc net: smsc911x: fix skb handling in receive path 2012-04-13 14:07:51 -04:00
stmicro stmmac: re-add IFF_UNICAST_FLT for dwmac1000 2012-04-04 18:38:31 -04:00
sun Disintegrate and delete asm/system.h 2012-03-28 15:58:21 -07:00
tehuti netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-08 18:46:38 -05:00
ti davinci_mdio: Fix MDIO timeout check 2012-04-17 22:31:59 -04:00
tile drivers/net/ethernet/tile: fix netdev_alloc_skb() bombing 2012-04-02 13:17:37 -04:00
toshiba net: replace random_ether_addr() with eth_hw_addr_random() 2012-02-15 15:34:16 -05:00
tundra Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
via via-rhine: fix wait-bit inversion. 2012-04-01 23:09:36 -04:00
xilinx drivers/net/ethernet/xilinx/axi ethernet: Correct Copyright 2012-04-13 13:58:42 -04:00
xircom Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
xscale xscale/ixp2000/ixpdev: print MAC via printk format specifier 2012-02-24 15:41:00 -05:00
dnet.c net: replace random_ether_addr() with eth_hw_addr_random() 2012-02-15 15:34:16 -05:00
dnet.h
ethoc.c ethoc: set addr_assign_type if random_ether_addr() used 2012-02-17 15:58:06 -05:00
fealnx.c netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-06 11:48:09 -05:00
jme.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net 2012-02-26 21:55:51 -05:00
jme.h jme: Fix FIFO flush issue 2012-02-22 14:44:41 -05:00
Kconfig lpc32xx: Added ethernet driver 2012-03-12 17:08:34 -07:00
korina.c Remove all #inclusions of asm/system.h 2012-03-28 18:30:03 +01:00
lantiq_etop.c ethernet: Fix typo in lantiq_etop.c 2012-02-19 19:02:42 -05:00
Makefile lpc32xx: Added ethernet driver 2012-03-12 17:08:34 -07:00
mipsnet.c net: replace random_ether_addr() with eth_hw_addr_random() 2012-02-15 15:34:16 -05:00
netx-eth.c netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-08 18:46:38 -05:00
s6gmac.c netdev: ethernet dev_alloc_skb to netdev_alloc_skb 2012-02-08 18:46:38 -05:00