Hi John,
在 2021/12/14 19:52, John Garry 写道:
On 17/11/2021 02:44, chenxiang wrote:
From: Xiang Chen<chenxiang66@xxxxxxxxxxxxx>
Please consider this rewrite:
Currently the HiSilicon SAS controller v3 hw driver supports runtime
PM. However a number of corner-case bugs have been reported for this
feature. These include:
a. If a directly-attached disk is removed when the host is suspended a
system hang may occur during resume. libsas drains events after
resuming the host. Draining the events causes a deadlock as we need to
ensure that the host is resumed for some libsas events processing,
however the resume process will not complete until all events are
processed.
b. If a disk is attached to an expander when the host is suspended
then this new disk will not be detected when active again.
c. The host controller may not resume from suspension when sending SMP
IOs.
d. If a phy comes up when resuming the host controller then we may get
a deadlock from processing of events DISCE_DISCOVER_DOMAIN and
PORTE_BYTES_DMAED.
e. Similar to d., the work of PORTE_BROADCAST_RCVD and
PORTE_BYTES_DMAED may deadlock.
This series addresses those issues, briefly described as follows:
a. As far as we can see, this drain is unneeded, so conditionally remove.
b. Just insert broadcast events to revalidate the topology.
c. and e. When processing any events from the LLD, make libsas keep
the host active until finished processing all work related to that
original event.
d. Defer phyup event processing in case described.
Thanks for your detailed comments.
I will improve those commit message according to your suggestions.
Right now hisi_sas driver has already supported runtime PM, and it works
well on base functions. But for some exception situations, there are
some
issues related to libsas layer:
- Remove a directly attached disk when sas host is suspended, a hang
will
occur in the resume process, patch 1~2 solve the issue;
- Insert a new disk (for expander) during suspended, and the disk is not
revalidated when resuming sas host, patch 4~7 solve the issue;
- SMP IOs from libsas may be sending when sas host is suspended, so
resume
sas host when sending SMP IOs in patch 9;
- New phyup may occur during the process of resuming controller, then
work
of DISCE_DISCOVER_DOMAIN of a new phy and work PORTE_BYTES_DMAED of
suspended
phy are blocked by each other, so defer works of new phys during suspend
in patch 10~12;
- Work PORTE_BROADCAST_RCVD and PORTE_BYTES_DMAED are in the same
workqueue, but it is possible that they are blocked by each other,
so keep sas host active until finished some work in patch 14.
And patch 3 which is related to scsi/block PM is from Alan Stern
(https://lore.kernel.org/linux-scsi/20210714161027.GC380727@xxxxxxxxxxxxxxxxxxx/)
.