* [PATCH] scsi: mpt3sas: fix nr_msix underflow in _base_assign_reply_queues()
@ 2026-09-06 20:22 Ivy Lopez
0 siblings, 0 replies; only message in thread
From: Ivy Lopez @ 2026-09-06 20:22 UTC (permalink / raw)
To: sathya.prakash, sreekanth.reddy, suganath-prabu.subramani,
ranjan.kumar, James.Bottomley, martin.petersen
Cc: MPT-FusionLinux.pdl, linux-scsi, linux-kernel, Ivy Lopez
The fallback path incorrectly subtracts iopoll_q_count when computing
nr_msix, when the intent is to reserve both high_iops_queues and
iopoll_q_count reply queues from the round-robin pool. Since
iopoll_q_count can be positive, the current subtraction inflates
nr_msix instead of reducing it, leaving far more queues in the
round-robin pool than actually available once high-iops and iopoll
queues are accounted for.
Beyond producing an incorrect grouping of cpus onto msix vectors, the
corrected formula can still drive nr_msix to zero or below under
plausible queue configurations (verified arithmetically), which would
either wrap to a large unsigned value and silently break affinity
grouping, or hit a divide-by-zero in the following nr_cpus / nr_msix
computation. Add an explicit check for nr_msix == 0 and also warn if the
reply queue budget is exhausted.
Fixes: 432bc7caef4e ("scsi: mpt3sas: Add io_uring iopoll support")
Signed-off-by: Ivy Lopez <skunkolee@gmail.com>
---
drivers/scsi/mpt3sas/mpt3sas_base.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.c b/drivers/scsi/mpt3sas/mpt3sas_base.c
index ce5a5882acc8..31b80ed6ddec 100644
--- a/drivers/scsi/mpt3sas/mpt3sas_base.c
+++ b/drivers/scsi/mpt3sas/mpt3sas_base.c
@@ -3275,7 +3275,11 @@ _base_assign_reply_queues(struct MPT3SAS_ADAPTER *ioc)
fall_back:
cpu = cpumask_first(cpu_online_mask);
- nr_msix -= (ioc->high_iops_queues - iopoll_q_count);
+ nr_msix -= (ioc->high_iops_queues + iopoll_q_count);
+ if (!nr_msix) {
+ ioc_warn(ioc, "high_iops_queues and iopoll_q_count exceed available MSI-X vectors\n");
+ return;
+ }
index = 0;
list_for_each_entry(reply_q, &ioc->reply_queue_list, list) {
--
2.55.0
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-09-06 20:23 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-09-06 20:22 [PATCH] scsi: mpt3sas: fix nr_msix underflow in _base_assign_reply_queues() Ivy Lopez
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®