From: sashiko-bot@kernel.org
To: "Xingui Yang" <yangxingui@huawei.com>
Cc: linux-scsi@vger.kernel.org
Subject: Re: [PATCH v3] scsi: libsas: Fix SMP IO deadlock during HA resume
Date: Fri, 18 Sep 2026 07:15:18 +0000 [thread overview]
Message-ID: <20260918071518.BD35B1F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260918070307.381207-1-yangxingui@huawei.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] scsi: libsas: concurrent SMP IO to uninitialized hardware during PM resume
--
commit 2357f5bc7ff2aaf7e480b366cb3ce830c9f21616
Author: Xingui Yang <yangxingui@huawei.com>
scsi: libsas: Fix SMP IO deadlock during HA resume
This commit replaces pm_runtime_get_sync() with a conditional
pm_runtime_get_noresume() during HA resume to prevent an SMP IO deadlock.
Outside the resume window, it converts to pm_runtime_resume_and_get() and
checks the result.
> diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c
> index 811c9eb4fef11..5a8cdd3682fe7 100644
> --- a/drivers/scsi/libsas/sas_expander.c
> +++ b/drivers/scsi/libsas/sas_expander.c
> @@ -61,8 +61,22 @@ static int smp_execute_task_sg(struct domain_device *dev,
> struct sas_internal *i =
> to_sas_internal(dev->port->ha->shost->transportt);
> struct sas_ha_struct *ha = dev->port->ha;
> -
> - pm_runtime_get_sync(ha->dev);
> + bool ha_resuming = test_bit(SAS_HA_RESUMING, &ha->state);
> +
> + /*
> + * While the host is resuming, ha->dev may be RPM_RESUMING and
> + * the resume blocked in sas_drain_work() waiting for this very
> + * SMP IO, so waiting for the host to resume here would deadlock.
> + * Hold the reference without resuming, the hardware is already
> + * initialized by the LLDD before sas_resume_ha() runs.
> + */
> + if (ha_resuming) {
> + pm_runtime_get_noresume(ha->dev);
[Severity: High]
Does this disjoint check of the global state flag followed by
pm_runtime_get_noresume() bypass power management synchronization,
potentially enabling concurrent I/Os to race with host hardware
initialization?
For instance, if userspace submits concurrent SMP I/Os via bsg, could
they race with the driver actively resetting the hardware? In
hisi_sas_v3_resume(), scsi_unblock_requests() is called before
sas_prep_resume_ha(). Could this allow concurrent requests to observe
ha_resuming == true and bypass the pm_runtime_resume_and_get() sync,
resulting in I/O submission to uninitialized hardware?
Also, is there a time-of-check to time-of-use race here? If a thread
reads ha_resuming == true, gets preempted while the device resumes and
autosuspends back to RPM_SUSPENDED, could it wake up and use
pm_runtime_get_noresume() to submit I/O to a powered-off device?
> + } else {
> + res = pm_runtime_resume_and_get(ha->dev);
> + if (res)
> + return res;
> + }
> mutex_lock(&dev->ex_dev.cmd_mutex);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260918070307.381207-1-yangxingui@huawei.com?part=1
next prev parent reply other threads:[~2026-09-18 7:15 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 7:03 [PATCH v3] scsi: libsas: Fix SMP IO deadlock during HA resume Xingui Yang
2026-09-18 7:15 ` sashiko-bot [this message]
2026-09-20 6:27 ` yangxingui
2026-09-21 11:37 ` John Garry
2026-09-21 12:21 ` yangxingui
2026-09-21 14:05 ` John Garry
2026-09-22 3:10 ` yangxingui
2026-09-22 10:37 ` John Garry
2026-09-28 3:47 ` yangxingui
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=20260918071518.BD35B1F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=yangxingui@huawei.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