@@ -1534,6 +1534,7 @@ int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
struct mvs_device *mvi_dev = NULL;
struct task_status_struct *tstat;
struct domain_device *dev;
+ unsigned long flags;
u32 aborted;
void *to;
@@ -1546,12 +1547,12 @@ int mvs_slot_complete(struct mvs_info *mvi, u32 rx_desc, u32 flags)
dev = task->dev;
mvi_dev = dev->lldd_dev;
- spin_lock(&task->task_state_lock);
+ spin_lock_irqsave(&task->task_state_lock, flags);
task->task_state_flags &= ~SAS_TASK_STATE_PENDING;
task->task_state_flags |= SAS_TASK_STATE_DONE;
/* race condition*/
aborted = task->task_state_flags & SAS_TASK_STATE_ABORTED;
- spin_unlock(&task->task_state_lock);
+ spin_unlock_irqrestore(&task->task_state_lock, flags);
memset(tstat, 0, sizeof(*tstat));
tstat->resp = SAS_TASK_COMPLETE;
&mvi->lock and &task->task_state_lock could be acquired under irq context from mvs_64xx_isr(). As mvs_port_deformed() also acquire the lock, called from workqueue sas_suspend_devices() under process context, and without irq protection. <deadlock #1> mvs_port_deformed() --> mvs_port_notify_deformed() --> mvs_do_release_task() --> mvs_int_rx() --> mvs_slot_complete() --> spin_lock(&mvi->lock) <interrupt> --> mvs_64xx_isr() --> spin_lock(&mvi->lock) <deadlock #2> mvs_port_deformed() --> mvs_port_notify_deformed() --> mvs_do_release_task() --> mvs_int_rx() --> mvs_slot_complete() --> spin_lock(&task->task_state_lock) <interrupt> --> mvs_64xx_isr() --> mvs_int_rx() --> mvs_slot_complete() --> spin_lock(&task->task_state_lock) Another strange thing is that while inspecting the code I find mvs_do_release_task() should be called with phy->mvi locked held, but the call chain from mvs_port_notify_deformed() seems do not hold the lock. The current patch just switch spin_lock(&task->task_state_lock) to spin_lock_irqsave(). If I didn't miss anything, seems the better way could be adding a spin_lock_irqsave() to protect mvi->lock at mvs_port_notify_deformed()? Signed-off-by: Chengfeng Ye <dg573847474@gmail.com> --- drivers/scsi/mvsas/mv_sas.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)