From: Praneeth Balasubramanian <praneethb2002@gmail.com>
To: Sathya Prakash <sathya.prakash@broadcom.com>,
Sreekanth Reddy <sreekanth.reddy@broadcom.com>,
Suganath Prabu Subramani <suganath-prabu.subramani@broadcom.com>,
Ranjan Kumar <ranjan.kumar@broadcom.com>
Cc: "Martin K . Petersen" <martin.petersen@oracle.com>,
"James E . J . Bottomley" <James.Bottomley@HansenPartnership.com>,
Bhaktipriya Shridhar <bhaktipriya96@gmail.com>,
MPT-FusionLinux.pdl@broadcom.com, linux-scsi@vger.kernel.org,
linux-kernel@vger.kernel.org,
Praneeth Balasubramanian <praneethb2002@gmail.com>,
stable@vger.kernel.org
Subject: [PATCH] scsi: mptfusion: Handle firmware events one at a time again
Date: Fri, 4 Dec 2026 10:49:15 -0800 [thread overview]
Message-ID: <20261204184915.1686726-1-praneethb2002@gmail.com> (raw)
mptsas handles firmware events, such as device hot plug and expander
status changes, as work items on ioc->fw_event_q. The SAS topology code
relies on these handlers running one at a time. For example,
mptsas_hotplug_work() looks up an expander's port_info with
mptsas_find_portinfo_by_handle() without sas_topology_mutex, although
the comment above that function says the mutex must be held, and then
passes it to mptsas_expander_refresh(). mptsas_expander_delete(), run
for an expander "not responding" event, unlinks and frees the same
port_info, also without the mutex.
The queue used to be single threaded. Commit b2990536f447 ("scsi: mpt:
Remove deprecated create_singlethread_workqueue") made it an unordered
workqueue, reasoning that only a single work item is queued on it. But
mptsas queues a separate work item for every firmware event. Since that
change, two events can be handled at the same time, and a hot plug event
can use a port_info that an expander removal event has just freed.
Use an ordered workqueue again, so firmware events are handled one at a
time as the topology code expects. An ordered workqueue is unbound, so
WQ_PERCPU is dropped.
The unlocked lookup was found by a static check that turns the locking
rule in a function's comment into a Clang context-analysis requirement
on its callers.
Fixes: b2990536f447 ("scsi: mpt: Remove deprecated create_singlethread_workqueue")
Cc: stable@vger.kernel.org
Signed-off-by: Praneeth Balasubramanian <praneethb2002@gmail.com>
---
Notes:
This was found by a compiler-based check, part of research at UCSB SecLab.
The locking rule stated in the kernel-doc comment of the called function
was turned into a Clang context-analysis requirement (__must_hold) on that
function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every
caller. An LLM was used only to turn the comment into a machine-readable
rule; the report itself comes from the compiler. The patch and changelog
were drafted with Claude Opus 5.5. I reviewed the patch and take
responsibility for it.
Testing: builds without new warnings with W=1 (x86_64, clang 23,
allmodconfig). Not runtime-tested; I do not have this hardware, and I
have not observed the race myself.
drivers/message/fusion/mptbase.c | 5 ++---
1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/drivers/message/fusion/mptbase.c b/drivers/message/fusion/mptbase.c
index 3a431ffd3e2e..f6814c465175 100644
--- a/drivers/message/fusion/mptbase.c
+++ b/drivers/message/fusion/mptbase.c
@@ -1985,9 +1985,8 @@ mpt_attach(struct pci_dev *pdev, const struct pci_device_id *id)
INIT_LIST_HEAD(&ioc->fw_event_list);
spin_lock_init(&ioc->fw_event_lock);
- ioc->fw_event_q = alloc_workqueue("mpt/%d",
- WQ_MEM_RECLAIM | WQ_PERCPU, 0,
- ioc->id);
+ ioc->fw_event_q = alloc_ordered_workqueue("mpt/%d", WQ_MEM_RECLAIM,
+ ioc->id);
if (!ioc->fw_event_q) {
printk(MYIOC_s_ERR_FMT "Insufficient memory to add adapter!\n",
ioc->name);
--
2.25.1
reply other threads:[~2026-12-04 18:49 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261204184915.1686726-1-praneethb2002@gmail.com \
--to=praneethb2002@gmail.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=MPT-FusionLinux.pdl@broadcom.com \
--cc=bhaktipriya96@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=ranjan.kumar@broadcom.com \
--cc=sathya.prakash@broadcom.com \
--cc=sreekanth.reddy@broadcom.com \
--cc=stable@vger.kernel.org \
--cc=suganath-prabu.subramani@broadcom.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox