diff options
author | Ranjan Kumar <ranjan.kumar@broadcom.com> | 2023-04-06 15:48:19 +0530 |
---|---|---|
committer | Martin K. Petersen <martin.petersen@oracle.com> | 2023-04-11 21:17:56 -0400 |
commit | 2acc635a0e5e91c267f2cb1c25748e8d06888e63 (patch) | |
tree | 00573653251219386914116b65852c16a08ee3b6 /drivers/scsi/mpi3mr | |
parent | b32283d75335d8263fc9f5ae16c8a196f1d8b5d5 (diff) | |
download | lwn-2acc635a0e5e91c267f2cb1c25748e8d06888e63.tar.gz lwn-2acc635a0e5e91c267f2cb1c25748e8d06888e63.zip |
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>
Diffstat (limited to 'drivers/scsi/mpi3mr')
-rw-r--r-- | drivers/scsi/mpi3mr/mpi3mr_os.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index 5c2fd09b9497..d627355303d7 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -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; } |