Skip to content

Commit b0e17a9

Browse files
bjking1martinkpetersen
authored andcommitted
scsi: ipr: Fix scsi-mq lockdep issue
Fixes the following lockdep warning that can occur when scsi-mq is enabled with ipr due to ipr calling scsi_unblock_requests from irq context. The fix is to move the call to scsi_unblock_requests to ipr's existing workqueue. stack backtrace: CPU: 28 PID: 0 Comm: swapper/28 Not tainted 4.13.0-rc2-gcc6x-gf74c89b #1 Call Trace: [c000001fffe97550] [c000000000b50818] dump_stack+0xe8/0x160 (unreliable) [c000001fffe97590] [c0000000001586d0] print_usage_bug+0x2d0/0x390 [c000001fffe97640] [c000000000158f34] mark_lock+0x7a4/0x8e0 [c000001fffe976f0] [c00000000015a000] __lock_acquire+0x6a0/0x1a70 [c000001fffe97860] [c00000000015befc] lock_acquire+0xec/0x2e0 [c000001fffe97930] [c000000000b71514] _raw_spin_lock+0x44/0x70 [c000001fffe97960] [c0000000005b60f4] blk_mq_sched_dispatch_requests+0xa4/0x2a0 [c000001fffe979c0] [c0000000005acac0] __blk_mq_run_hw_queue+0x100/0x2c0 [c000001fffe97a00] [c0000000005ad478] __blk_mq_delay_run_hw_queue+0x118/0x130 [c000001fffe97a40] [c0000000005ad61c] blk_mq_start_hw_queues+0x6c/0xa0 [c000001fffe97a80] [c000000000797aac] scsi_kick_queue+0x2c/0x60 [c000001fffe97aa0] [c000000000797cf0] scsi_run_queue+0x210/0x360 [c000001fffe97b10] [c00000000079b888] scsi_run_host_queues+0x48/0x80 [c000001fffe97b40] [c0000000007b6090] ipr_ioa_bringdown_done+0x70/0x1e0 [c000001fffe97bc0] [c0000000007bc860] ipr_reset_ioa_job+0x80/0xf0 [c000001fffe97bf0] [c0000000007b4d50] ipr_reset_timer_done+0xd0/0x100 [c000001fffe97c30] [c0000000001937bc] call_timer_fn+0xdc/0x4b0 [c000001fffe97cf0] [c000000000193d08] expire_timers+0x178/0x330 [c000001fffe97d60] [c0000000001940c8] run_timer_softirq+0xb8/0x120 [c000001fffe97de0] [c000000000b726a8] __do_softirq+0x168/0x6d8 [c000001fffe97ef0] [c0000000000df2c8] irq_exit+0x108/0x150 [c000001fffe97f10] [c000000000017bf4] __do_irq+0x2a4/0x4a0 [c000001fffe97f90] [c00000000002da50] call_do_irq+0x14/0x24 [c0000007fad93aa0] [c000000000017e8c] do_IRQ+0x9c/0x140 [c0000007fad93af0] [c000000000008b98] hardware_interrupt_common+0x138/0x140 Reported-by: Michael Ellerman <mpe@ellerman.id.au> Signed-off-by: Brian King <brking@linux.vnet.ibm.com> Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent 180efde commit b0e17a9

File tree

2 files changed

+21
-14
lines changed

2 files changed

+21
-14
lines changed

drivers/scsi/ipr.c

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3351,6 +3351,16 @@ static void ipr_worker_thread(struct work_struct *work)
33513351
return;
33523352
}
33533353

3354+
if (ioa_cfg->scsi_unblock) {
3355+
ioa_cfg->scsi_unblock = 0;
3356+
ioa_cfg->scsi_blocked = 0;
3357+
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
3358+
scsi_unblock_requests(ioa_cfg->host);
3359+
spin_lock_irqsave(ioa_cfg->host->host_lock, lock_flags);
3360+
if (ioa_cfg->scsi_blocked)
3361+
scsi_block_requests(ioa_cfg->host);
3362+
}
3363+
33543364
if (!ioa_cfg->scan_enabled) {
33553365
spin_unlock_irqrestore(ioa_cfg->host->host_lock, lock_flags);
33563366
return;
@@ -7211,9 +7221,8 @@ static int ipr_ioa_bringdown_done(struct ipr_cmnd *ipr_cmd)
72117221
ENTER;
72127222
if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
72137223
ipr_trace;
7214-
spin_unlock_irq(ioa_cfg->host->host_lock);
7215-
scsi_unblock_requests(ioa_cfg->host);
7216-
spin_lock_irq(ioa_cfg->host->host_lock);
7224+
ioa_cfg->scsi_unblock = 1;
7225+
schedule_work(&ioa_cfg->work_q);
72177226
}
72187227

72197228
ioa_cfg->in_reset_reload = 0;
@@ -7287,13 +7296,7 @@ static int ipr_ioa_reset_done(struct ipr_cmnd *ipr_cmd)
72877296
list_add_tail(&ipr_cmd->queue, &ipr_cmd->hrrq->hrrq_free_q);
72887297
wake_up_all(&ioa_cfg->reset_wait_q);
72897298

7290-
spin_unlock(ioa_cfg->host->host_lock);
7291-
scsi_unblock_requests(ioa_cfg->host);
7292-
spin_lock(ioa_cfg->host->host_lock);
7293-
7294-
if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].allow_cmds)
7295-
scsi_block_requests(ioa_cfg->host);
7296-
7299+
ioa_cfg->scsi_unblock = 1;
72977300
schedule_work(&ioa_cfg->work_q);
72987301
LEAVE;
72997302
return IPR_RC_JOB_RETURN;
@@ -9249,8 +9252,11 @@ static void _ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg,
92499252
spin_unlock(&ioa_cfg->hrrq[i]._lock);
92509253
}
92519254
wmb();
9252-
if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa)
9255+
if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
9256+
ioa_cfg->scsi_unblock = 0;
9257+
ioa_cfg->scsi_blocked = 1;
92539258
scsi_block_requests(ioa_cfg->host);
9259+
}
92549260

92559261
ipr_cmd = ipr_get_free_ipr_cmnd(ioa_cfg);
92569262
ioa_cfg->reset_cmd = ipr_cmd;
@@ -9306,9 +9312,8 @@ static void ipr_initiate_ioa_reset(struct ipr_ioa_cfg *ioa_cfg,
93069312
wake_up_all(&ioa_cfg->reset_wait_q);
93079313

93089314
if (!ioa_cfg->hrrq[IPR_INIT_HRRQ].removing_ioa) {
9309-
spin_unlock_irq(ioa_cfg->host->host_lock);
9310-
scsi_unblock_requests(ioa_cfg->host);
9311-
spin_lock_irq(ioa_cfg->host->host_lock);
9315+
ioa_cfg->scsi_unblock = 1;
9316+
schedule_work(&ioa_cfg->work_q);
93129317
}
93139318
return;
93149319
} else {

drivers/scsi/ipr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,8 @@ struct ipr_ioa_cfg {
14881488
u8 cfg_locked:1;
14891489
u8 clear_isr:1;
14901490
u8 probe_done:1;
1491+
u8 scsi_unblock:1;
1492+
u8 scsi_blocked:1;
14911493

14921494
u8 revid;
14931495

0 commit comments

Comments
 (0)