Skip to content

Commit

Permalink
scsi: mpi3mr: Use IRQ save variants of spinlock to protect chain fram…
Browse files Browse the repository at this point in the history
…e 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>
  • Loading branch information
Ranjan Kumar authored and Martin K. Petersen committed Apr 12, 2023
1 parent b32283d commit 2acc635
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/scsi/mpi3mr/mpi3mr_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -3331,19 +3331,19 @@ static int mpi3mr_get_chain_idx(struct mpi3mr_ioc *mrioc)
{
u8 retry_count = 5;
int cmd_idx = -1;
unsigned long flags;

spin_lock_irqsave(&mrioc->chain_buf_lock, flags);
do {
spin_lock(&mrioc->chain_buf_lock);
cmd_idx = find_first_zero_bit(mrioc->chain_bitmap,
mrioc->chain_buf_count);
if (cmd_idx < mrioc->chain_buf_count) {
set_bit(cmd_idx, mrioc->chain_bitmap);
spin_unlock(&mrioc->chain_buf_lock);
break;
}
spin_unlock(&mrioc->chain_buf_lock);
cmd_idx = -1;
} while (retry_count--);
spin_unlock_irqrestore(&mrioc->chain_buf_lock, flags);
return cmd_idx;
}

Expand Down

0 comments on commit 2acc635

Please sign in to comment.