Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

scst.h, scst, device handlers: Fix scst_replace_port_info #212

Merged

Conversation

bmeagherix
Copy link
Contributor

scst_pass_through_cmd_done can run in interrupt context, and call scst_replace_port_info, which in turn was calling scst_lookup_tg_id. Since scst_lookup_tg_id does a mutex_lock, we should not call it from interrupt context.

The call path was added in e72eae3 and could lead to:

BUG: scheduling while atomic: swapper/14/0/0x00000102

Preemption disabled at:
Call Trace:
[<ffffffffa1d1b146>] ___slab_alloc.constprop.0+0x4d6/0x750
 <IRQ>
 dump_stack_lvl+0x44/0x5c
 __schedule_bug.cold+0x80/0x8d
 __schedule+0x76c/0x860
 schedule+0x5a/0xb0
 schedule_preempt_disabled+0x14/0x30
 __mutex_lock.constprop.0+0x6ce/0x700
 scst_lookup_tg_id+0x19/0xa0 [scst]
 scst_pass_through_cmd_done+0x14f/0x2e0 [scst]
 scsi_end_async+0x44/0x70 [scst]
 __blk_mq_end_request+0x42/0x120
 scsi_end_request+0xdd/0x1c0 [scsi_mod]
 scsi_io_completion+0x56/0x880 [scsi_mod]
 ? scsi_device_unbusy+0x1e/0x90 [scsi_mod]
 blk_complete_reqs+0x3d/0x50
 __do_softirq+0xed/0x2fe
 ? ktime_get+0x38/0xa0
 do_softirq.part.0+0x95/0xd0
 </IRQ>
 <TASK>
 flush_smp_call_function_queue+0x78/0x90
 do_idle+0x177/0x2b0
 cpu_startup_entry+0x26/0x30
 start_secondary+0x130/0x150
 secondary_startup_64_no_verify+0xe5/0xeb
 </TASK>

(BTW, the fix suggested in this PR was influenced by the current location of scst_pass_through_cmd_done & scst_lookup_tg_id.)

scst_pass_through_cmd_done can run in interrupt context, and call
scst_replace_port_info, which in turn was calling scst_lookup_tg_id.
Since scst_lookup_tg_id does a mutex_lock, we should not call it from
interrupt context.

Add scst_cmd_inquired_dev_ident and use in various locations.
@bmeagherix bmeagherix force-pushed the fix_scst_replace_port_info branch from 1745f7c to f958663 Compare January 11, 2024 20:33
@bmeagherix bmeagherix requested a review from lnocturno January 11, 2024 20:40
@lnocturno lnocturno merged commit df039cb into SCST-project:master Jan 12, 2024
3 checks passed
@bmeagherix bmeagherix deleted the fix_scst_replace_port_info branch January 12, 2024 15:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants