mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: yangxingui <yangxingui@huawei.com>
To: John Garry <john.g.garry@oracle.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 v2] scsi: libsas: fix HA resume deadlock and hisi_sas disk-wake race
Date: Tue, 14 Jul 2026 20:06:28 +0800	[thread overview]
Message-ID: <b1f12c52-ab0a-e146-6559-858eb5e581d6@huawei.com> (raw)
In-Reply-To: <de319ce0-ca42-46cf-87ea-98c93c73bc8e@oracle.com>

Hi, John

On 2026/7/14 16:26, John Garry wrote:
> On 14/07/2026 03:15, yangxingui wrote:
>>>>> Fixes: fbefe22811c3140 ("scsi: libsas: Don't always drain event 
>>>>> workqueue for HA resume")
>>>>> Signed-off-by: Xingui Yang <yangxingui@huawei.com>
>>>
>>> Any idea why this problem has only been discovered after 5 years 
>>> (from fbefe22811c3140 being merged)?
>>>
>>> Is there some new test case?
> 
> ok, I can check below. But another question is if this applies to only 
> hisi_sas driver? I mean, you are changing libsas and the hisi_sas, but 
> not other libsas-based drivers - why? They support suspend/resume.

There are five libsas consumers (callers of sas_register_ha): hisi_sas,
isci, pm8001, aic94xx, and mvsas. Only hisi_sas needs a driver-side 
change, because it is the only driver that satisfies all three
conditions below simultaneously.

1. Only hisi_sas used sas_resume_ha_no_sync().
isci/init.c:               sas_resume_ha(&ihost->sas_ha);
pm8001/pm8001_init.c:      sas_resume_ha(sha);
hisi_sas/hisi_sas_v3_hw.c: sas_resume_ha_no_sync(sha);  ← only caller
isci and pm8001 have always used the draining variant. aic94xx and
mvsas do not register any PM ops — their pci_driver structs have no
.driver.pm field — so they never enter the resume path.

2. Only hisi_sas establishes a device_link between SCSI devices and
the HBA. Commit 16fd4a7c5917 added device_link_add() in
hisi_sas_v3_hw.c to keep the HBA active while associated SCSI devices
are active. A side effect of this device_link is that
scsi_remove_device() in the PHYE_RESUME_TIMEOUT handler waits for the
HBA to be runtime-active — the direct cause of the original deadlock.
None of the other four drivers uses device_link_add() for PM sync, so
their sas_destruct_devices() path never blocks on host resume.
Original deadlock as follow:
[ 1335.875252] Call trace:
[ 1335.878380]  __switch_to+0x150/0x238
[ 1335.882646]  __schedule+0x388/0x880
[ 1335.886825]  schedule+0x58/0x130
[ 1335.890744]  rpm_resume+0x1e4/0x940
[ 1335.894926]  __pm_runtime_resume+0x68/0x130
[ 1335.899805]  rpm_get_suppliers+0x4c/0x158
[ 1335.904506]  __rpm_callback+0x190/0x248
[ 1335.909034]  rpm_callback+0x40/0x88
[ 1335.913215]  rpm_resume+0x6a8/0x940
[ 1335.917396]  __pm_runtime_resume+0x68/0x130
[ 1335.922271]  device_release_driver_internal+0xd4/0x238
[ 1335.928104]  device_release_driver+0x20/0x38
[ 1335.933065]  bus_remove_device+0xd8/0x158
[ 1335.937768]  device_del+0x168/0x3e0
[ 1335.941944]  __scsi_remove_device+0x120/0x198
[ 1335.946988]  __scsi_remove_target+0xe8/0x1c0
[ 1335.951943]  scsi_remove_target+0x120/0x228
[ 1335.956812]  sas_rphy_remove+0x8c/0x98 [scsi_transport_sas]
[ 1335.963075]  sas_rphy_delete+0x20/0x40 [scsi_transport_sas]
[ 1335.969336]  sas_destruct_devices+0x74/0xb8 [libsas]
[ 1335.974992]  sas_deform_port+0x218/0x270 [libsas]
[ 1335.980387]  sas_phye_resume_timeout+0x2c/0x60 [libsas]
[ 1335.986303]  sas_phy_event_worker+0x38/0x68 [libsas]
[ 1335.991961]  process_one_work+0x174/0x3e0
[ 1335.996656]  worker_thread+0x22c/0x3b0
[ 1336.001091]  kthread+0xec/0x100
[ 1336.004919]  ret_from_fork+0x10/0x20

3. Only hisi_sas supports runtime PM (autosuspend). This is
consistent with your own statement in fbefe22811c3140: "Other drivers
which use libsas don't worry about this as none support runtime
suspend."

Without runtime PM, the controller never autosuspends during disk
wake-up, so the race this patch addresses cannot occur.

Thanks,
Xingui

  reply	other threads:[~2026-07-14 12:06 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02  3:32 Xingui Yang
2026-07-13  3:10 ` yangxingui
2026-07-13 11:26   ` John Garry
2026-07-14  2:15     ` yangxingui
2026-07-14  8:26       ` John Garry
2026-07-14 12:06         ` yangxingui [this message]
2026-07-15  8:25           ` John Garry
2026-07-16  6:46             ` yangxingui
2026-07-15  8:23 ` John Garry
2026-07-16  6:50   ` 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=b1f12c52-ab0a-e146-6559-858eb5e581d6@huawei.com \
    --to=yangxingui@huawei.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=john.g.garry@oracle.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 \
    /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®