From 06c4f20d2814b534eb4fb993d0db9259b24372b9 Mon Sep 17 00:00:00 2001 From: Eddie Wai Date: Wed, 11 Dec 2013 15:30:21 -0800 Subject: [PATCH] [SCSI] bnx2fc: Fixed scsi_remove_target soft lockup when rmmod bnx2x The problem has been identified to be a change in the scsi_remove_device path where a call to the pm_runtime_set_memalloc_noio was added when del_gendisk is called in this path. Note that the new pm routine attempts to cycle through all parent devices from the FC target device to set the memalloc_noio flag. Because of this new change, a dependency was created between the FC target device and the parent netdev device in the destroy path. In order to synchronized the destroy paths, bnx2fc has been modified to flush all destroy workqueues in the NETDEV_UNREGISTER return path. [ 4.123584] BUG: soft lockup - CPU#8 stuck for 22s! [kworker/8:3:8082] [ 4.123713] Call Trace: [ 4.123719] [] klist_next+0x20/0xf0 [ 4.123725] [] ? pm_save_wakeup_count+0x70/0x70 [ 4.123731] [] device_for_each_child+0x4e/0x70 [ 4.123735] [] pm_runtime_set_memalloc_noio+0x94/0xf0 [ 4.123740] [] del_gendisk+0x264/0x2a0 [ 4.123747] [] sd_remove+0x69/0xb0 [sd_mod] [ 4.123751] [] __device_release_driver+0x7f/0xf0 [ 4.123754] [] device_release_driver+0x23/0x30 [ 4.123757] [] bus_remove_device+0xf4/0x170 [ 4.123760] [] device_del+0x135/0x1d0 [ 4.123765] [] __scsi_remove_device+0xc5/0xd0 [ 4.123768] [] scsi_remove_device+0x26/0x40 [ 4.123770] [] scsi_remove_target+0x160/0x210 [ 4.123775] [] fc_rport_final_delete+0xac/0x1f0 [scsi_transport_fc] [ 4.123780] [] process_one_work+0x17b/0x460 [ 4.123783] [] worker_thread+0x11b/0x400 [ 4.123786] [] ? rescuer_thread+0x3e0/0x3e0 [ 4.123791] [] kthread+0xc0/0xd0 [ 4.123794] [] ? kthread_create_on_node+0x110/0x110 [ 4.123798] [] ret_from_fork+0x7c/0xb0 [ 4.123801] [] ? kthread_create_on_node+0x110/0x110 Signed-off-by: Eddie Wai Signed-off-by: James Bottomley --- drivers/scsi/bnx2fc/bnx2fc_fcoe.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 9b94850..4cabd3e 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c @@ -850,6 +850,9 @@ static void bnx2fc_indicate_netevent(void *context, unsigned long event, __bnx2fc_destroy(interface); } mutex_unlock(&bnx2fc_dev_lock); + + /* Ensure ALL destroy work has been completed before return */ + flush_workqueue(bnx2fc_wq); return; default: @@ -2389,6 +2392,9 @@ static void bnx2fc_ulp_exit(struct cnic_dev *dev) __bnx2fc_destroy(interface); mutex_unlock(&bnx2fc_dev_lock); + /* Ensure ALL destroy work has been completed before return */ + flush_workqueue(bnx2fc_wq); + bnx2fc_ulp_stop(hba); /* unregister cnic device */ if (test_and_clear_bit(BNX2FC_CNIC_REGISTERED, &hba->reg_with_cnic)) -- 2.7.4