Linux SCSI subsystem development
 help / color / mirror / Atom feed
From: John Garry <john.g.garry@oracle.com>
To: Xingui Yang <yangxingui@huawei.com>,
	yanaijie@huawei.com, James.Bottomley@HansenPartnership.com,
	martin.petersen@oracle.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
	linuxarm@huawei.com, liuyonglong@huawei.com,
	kangfenglong@huawei.com
Subject: Re: [PATCH v3] scsi: libsas: fix HA resume deadlock and hisi_sas disk-wake race
Date: Thu, 16 Jul 2026 12:02:32 +0100	[thread overview]
Message-ID: <160b8fcb-6020-4a97-a23c-3515bfa39e43@oracle.com> (raw)
In-Reply-To: <20260716081145.3950172-1-yangxingui@huawei.com>

On 16/07/2026 09:11, Xingui Yang wrote:
> Commit fbefe22811c3140 ("scsi: libsas: Don't always drain event workqueue
> for HA resume") introduced sas_resume_ha_no_sync() to avoid a deadlock:
> the PHYE_RESUME_TIMEOUT handler, running on the HA event workqueue, calls
> sas_deform_port() -> sas_destruct_devices(), which removes SCSI devices and
> waits for the host to become runtime-active. But the host cannot resume
> until sas_resume_ha() -> sas_drain_work() returns, and the drain is blocked
> on that very handler.
> 
> However skipping the drain reintroduces a race: hisi_sas returns from
> resume before all PHY UP work and libsas discovery work finish. The
> controller may then autosuspend while disks are still waking up. The disks
> issue IO to a suspended controller, the IO fails, and the disks get
> disabled.
> 
> Fix the deadlock at its source by moving the PHYE_RESUME_TIMEOUT
> notification to after sas_drain_work(). By then the host resume is about to
> complete, so device removal through device_link no longer blocks on the
> resume and the cycle is broken.
> 
> With the deadlock gone, restore sas_resume_ha() (the draining variant) in
> hisi_sas and remove sas_resume_ha_no_sync().
> 
> The reorder is safe for the other libsas consumers (isci, pm8001, aic94xx,
> mvsas). During suspend, sas_suspend_devices() calls
> sas_notify_lldd_dev_gone() for each device, which sets dev->lldd_dev to
> NULL. When scsi_unblock_requests re-enables I/O in resume, any I/O to a
> timed-out phy's disk is immediately rejected by the LLDD before reaching
> hardware: isci returns SAS_DEVICE_UNKNOWN (mapped to DID_BAD_TARGET), and
> pm8001 returns SAS_PHY_DOWN (mapped to DID_NO_CONNECT). Both complete
> directly via scsi_done() without entering SCSI EH. This is identical in
> both the old and new ordering since lldd_dev_gone runs during suspend,
> before resume. The reorder only affects when the PHYE_RESUME_TIMEOUT
> handler runs (synchronized by sas_drain_work() vs. asynchronous after
> resume returns), not whether I/O can reach the device. aic94xx and mvsas
> do not register any PM ops and never reach this code path.
> 
> Fixes: fbefe22811c3140 ("scsi: libsas: Don't always drain event workqueue for HA resume")
> Signed-off-by: Xingui Yang<yangxingui@huawei.com>

Can this possibly be tested on another SCSI HBA which uses libsas? And 
using SATA disks.

  parent reply	other threads:[~2026-07-16 11:02 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-16  8:11 [PATCH v3] scsi: libsas: fix HA resume deadlock and hisi_sas disk-wake race Xingui Yang
2026-07-16  8:47 ` sashiko-bot
2026-07-16  9:45   ` yangxingui
2026-07-16 11:02 ` John Garry [this message]
2026-07-16 11:48   ` yangxingui
2026-07-16 12:42     ` John Garry

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=160b8fcb-6020-4a97-a23c-3515bfa39e43@oracle.com \
    --to=john.g.garry@oracle.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --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=yanaijie@huawei.com \
    --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