Skip to content

Commit 2acc635

Browse files
Ranjan Kumarmartinkpetersen
authored andcommitted
scsi: mpi3mr: Use IRQ save variants of spinlock to protect chain frame allocation
Driver uses spin lock without irqsave when it needs to acquire a chain frame. This is done to protect chain frame allocation from multiple submission threads. If there is any I/O queued from an interrupt context, and if that requires a chain frame, and if the chain lock is held by the CPU which got interrupted, then there will be a possible deadlock. Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com> Link: https://lore.kernel.org/r/20230406101819.10109-1-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
1 parent b32283d commit 2acc635

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

drivers/scsi/mpi3mr/mpi3mr_os.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3331,19 +3331,19 @@ static int mpi3mr_get_chain_idx(struct mpi3mr_ioc *mrioc)
33313331
{
33323332
u8 retry_count = 5;
33333333
int cmd_idx = -1;
3334+
unsigned long flags;
33343335

3336+
spin_lock_irqsave(&mrioc->chain_buf_lock, flags);
33353337
do {
3336-
spin_lock(&mrioc->chain_buf_lock);
33373338
cmd_idx = find_first_zero_bit(mrioc->chain_bitmap,
33383339
mrioc->chain_buf_count);
33393340
if (cmd_idx < mrioc->chain_buf_count) {
33403341
set_bit(cmd_idx, mrioc->chain_bitmap);
3341-
spin_unlock(&mrioc->chain_buf_lock);
33423342
break;
33433343
}
3344-
spin_unlock(&mrioc->chain_buf_lock);
33453344
cmd_idx = -1;
33463345
} while (retry_count--);
3346+
spin_unlock_irqrestore(&mrioc->chain_buf_lock, flags);
33473347
return cmd_idx;
33483348
}
33493349

0 commit comments

Comments
 (0)