From: yangxingui <yangxingui@huawei.com>
To: John Garry <john.garry@linux.dev>, <yanaijie@huawei.com>,
<jejb@linux.ibm.com>, <martin.petersen@oracle.com>,
<mkp@kernel.org>
Cc: <linux-scsi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxarm@huawei.com>, <liuyonglong@huawei.com>,
<kangfenglong@huawei.com>
Subject: Re: [PATCH] scsi: libsas: Fix SMP IO deadlock during HA resume
Date: Thu, 17 Sep 2026 17:36:32 +0800 [thread overview]
Message-ID: <f9071dfe-2345-6ee3-c4ae-8408bdf781e4@huawei.com> (raw)
In-Reply-To: <2c1aee3c-3ea5-44f7-915c-5a812a261032@linux.dev>
Hi John
Thank you for the review.
On 2026/9/16 21:58, John Garry wrote:
> On 9/11/26 02:00, yangxingui wrote:
>> Hi John & Jason,
>>
>> Kindly ping for review...
>
> What about the sashiko comment:
>
> - [High] Bypassing PM reference counting via a global state flag creates
> a race condition where concurrent independent threads can submit SMP
> I/Os without holding a PM reference, risking premature hardware suspend.
>
> It looks correct.
Agreed. Although the possibility is very slim.
The SMP IO which sas_drain_work() waits on cannot outlive the
SAS_HA_RESUMING window, but a BSG request submitted during the window
takes no PM reference for the duration of its IO, and the controller
may autosuspend underneath it. v2 takes the reference with
pm_runtime_get_noresume()/pm_runtime_put_noidle() instead: the usage
counter stays elevated for the IO duration, without waiting for the
already ongoing resume.
>
>>
>> On 2026/8/26 11:28, Xingui Yang wrote:
>>> During sas_resume_ha() -> sas_drain_work(),
>
> This is poorly described - what does during sas_resume_ha() ->
> sas_drain_work() even mean?
The deadlock happens during a runtime resume, while
sas_resume_ha() is inside sas_drain_work(), flushing the event and
discovery workqueues. That flush includes the DISCE_RESUME work queued
when the phys come back up: sas_resume_devices() -> sas_resume_sata()
resumes the ATA ports through the libata error handler and waits for
it in sas_ata_flush_pm_eh(). So the resume is blocked in
sas_drain_work() waiting on that error handling - and the error
handling's reset of the expander-attached ATA device blocks on the
host being RPM_RESUMING, i.e. on the very resume which is waiting on
it.
>
>> ATA EH will trigger SMP
>>> IOs via
>>> sas_phy_reset() -> sas_smp_phy_control() for expander-attached ATA
>>> devices.
>
> What commands are these specifically?
SMP PHY CONTROL (hard reset or link reset) commands, sent to the
expander which owns the phy of the ATA device being recovered:
ata_eh_recover() -> ata_eh_reset() -> sas_ata_hard_reset()
-> lldd_I_T_nexus_reset() -> sas_phy_reset()
-> sas_smp_phy_control() -> smp_execute_task_sg()
A directly-attached device would take the lldd_control_phy() path
instead, which is why only the EXP topology deadlocks.
Thanks,
Xingui
.
prev parent reply other threads:[~2026-09-17 9:36 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-26 3:28 Xingui Yang
2026-09-11 1:00 ` yangxingui
2026-09-16 13:58 ` John Garry
2026-09-17 9:36 ` yangxingui [this message]
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=f9071dfe-2345-6ee3-c4ae-8408bdf781e4@huawei.com \
--to=yangxingui@huawei.com \
--cc=jejb@linux.ibm.com \
--cc=john.garry@linux.dev \
--cc=kangfenglong@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=liuyonglong@huawei.com \
--cc=martin.petersen@oracle.com \
--cc=mkp@kernel.org \
--cc=yanaijie@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
all inboxes | Powered by JetHome®