Skip to content

Commit 9b57806

Browse files
Chandrakanth Patilroot
authored andcommitted
scsi: mpi3mr: Check admin reply queue from Watchdog
JIRA: https://issues.redhat.com/browse/RHEL-80698 Admin reply processing can be called from multiple contexts. The driver uses an atomic flag for synchronization among multiple threads/context for draining the admin replies. Upon entering the admin processing routine, the driver will set the atomic flag and start reply processing. When exiting the routine, the driver resets the flag. However, there is a race condition when one thread (Thread 1) has processed replies and is about to reset the flag but in the meantime few more replies are posted and another thread (Thread 2) is called to process replies. Since the synchronization flag is still set, Thread 2 will return without processing replies and those new replies will not be flushed. Make the watchdog thread monitor cases where admin ISR/poll call returns due to another thread processing admin replies. If such an instance is found, make driver call admin ISR to drain replies (if any). Co-developed-by: Sumit Saxena <sumit.saxena@broadcom.com> Signed-off-by: Sumit Saxena <sumit.saxena@broadcom.com> Signed-off-by: Ranjan Kumar <ranjan.kumar@broadcom.com> Link: https://lore.kernel.org/r/20250220142528.20837-4-ranjan.kumar@broadcom.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> (cherry picked from commit ca41929) Signed-off-by: Chandrakanth Patil <chanpati@redhat.com>
1 parent 122be43 commit 9b57806

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

drivers/scsi/mpi3mr/mpi3mr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1032,6 +1032,8 @@ struct scmd_priv {
10321032
* @admin_reply_base: Admin reply queue base virtual address
10331033
* @admin_reply_dma: Admin reply queue base dma address
10341034
* @admin_reply_q_in_use: Queue is handled by poll/ISR
1035+
* @admin_pend_isr: Count of unprocessed admin ISR/poll calls
1036+
* due to another thread processing replies
10351037
* @ready_timeout: Controller ready timeout
10361038
* @intr_info: Interrupt cookie pointer
10371039
* @intr_info_count: Number of interrupt cookies
@@ -1206,6 +1208,7 @@ struct mpi3mr_ioc {
12061208
void *admin_reply_base;
12071209
dma_addr_t admin_reply_dma;
12081210
atomic_t admin_reply_q_in_use;
1211+
atomic_t admin_pend_isr;
12091212

12101213
u32 ready_timeout;
12111214

drivers/scsi/mpi3mr/mpi3mr_fw.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,8 +446,10 @@ int mpi3mr_process_admin_reply_q(struct mpi3mr_ioc *mrioc)
446446
u16 threshold_comps = 0;
447447
struct mpi3_default_reply_descriptor *reply_desc;
448448

449-
if (!atomic_add_unless(&mrioc->admin_reply_q_in_use, 1, 1))
449+
if (!atomic_add_unless(&mrioc->admin_reply_q_in_use, 1, 1)) {
450+
atomic_inc(&mrioc->admin_pend_isr);
450451
return 0;
452+
}
451453

452454
reply_desc = (struct mpi3_default_reply_descriptor *)mrioc->admin_reply_base +
453455
admin_reply_ci;
@@ -2757,6 +2759,12 @@ static void mpi3mr_watchdog_work(struct work_struct *work)
27572759
return;
27582760
}
27592761

2762+
if (atomic_read(&mrioc->admin_pend_isr)) {
2763+
ioc_err(mrioc, "Unprocessed admin ISR instance found\n"
2764+
"flush admin replies\n");
2765+
mpi3mr_process_admin_reply_q(mrioc);
2766+
}
2767+
27602768
if (!(mrioc->facts.ioc_capabilities &
27612769
MPI3_IOCFACTS_CAPABILITY_NON_SUPERVISOR_IOC) &&
27622770
(mrioc->ts_update_counter++ >= mrioc->ts_update_interval)) {

0 commit comments

Comments
 (0)