From: Damien Le Moal <dlemoal@kernel.org>
To: "Petr Tesařík" <petr@tesarici.cz>
Cc: "Rafael J. Wysocki" <rafael@kernel.org>,
linux-pm@vger.kernel.org, linux-ide@vger.kernel.org,
Hannes Reinecke <hare@suse.de>
Subject: Re: Thinkpad E595 system deadlock on resume from S3
Date: Wed, 4 Oct 2023 16:38:09 +0900 [thread overview]
Message-ID: <8f6dcb35-1751-5f1e-aef0-ec8c2d25d58a@kernel.org> (raw)
In-Reply-To: <20231004084359.59c5d308@meshulam.tesarici.cz>
On 10/4/23 15:43, Petr Tesařík wrote:
> On Wed, 4 Oct 2023 10:25:47 +0900
> Damien Le Moal <dlemoal@kernel.org> wrote:
>
>> On 10/4/23 05:07, Petr Tesařík wrote:
>>> I just want to confirm that my understanding of the issue is correct
>>> now. After applying the patch below, my laptop has just survived half a
>>> dozen suspend/resume cycles with autosuspend enabled for the SATA SSD
>>> disk. Without the patch, it usually freezes on first attempt.
>>>
>>> diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
>>> index a371b497035e..87000f89319e 100644
>>> --- a/drivers/ata/libata-scsi.c
>>> +++ b/drivers/ata/libata-scsi.c
>>> @@ -4768,6 +4768,14 @@ void ata_scsi_dev_rescan(struct work_struct *work)
>>> ata_for_each_dev(dev, link, ENABLED) {
>>> struct scsi_device *sdev = dev->sdev;
>>>
>>> + /*
>>> + * If the queue accepts only PM, bail out.
>>> + */
>>> + if (blk_queue_pm_only(sdev->request_queue)) {
>>> + ret = -EAGAIN;
>>> + goto unlock;
>>> + }
>>> +
>>> /*
>>> * If the port was suspended before this was scheduled,
>>> * bail out.
>>
>> This seems sensible to me: scsi_rescan_device() only checks that the device is
>> running, without checking that the device queue is also resumed. So the right
>> place for this check is scsi_rescan_device():
>>
>> diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
>> index 3db4d31a03a1..b05a55f498a2 100644
>> --- a/drivers/scsi/scsi_scan.c
>> +++ b/drivers/scsi/scsi_scan.c
>> @@ -1627,12 +1627,13 @@ int scsi_rescan_device(struct scsi_device *sdev)
>> device_lock(dev);
>>
>> /*
>> - * Bail out if the device is not running. Otherwise, the rescan may
>> - * block waiting for commands to be executed, with us holding the
>> - * device lock. This can result in a potential deadlock in the power
>> - * management core code when system resume is on-going.
>> + * Bail out if the device or its queue are not running. Otherwise,
>> + * the rescan may block waiting for commands to be executed, with us
>> + * holding the device lock. This can result in a potential deadlock
>> + * in the power management core code when system resume is on-going.
>> */
>> - if (sdev->sdev_state != SDEV_RUNNING) {
>> + if (sdev->sdev_state != SDEV_RUNNING ||
>> + blk_queue_pm_only(sdev->request_queue)) {
>> ret = -EWOULDBLOCK;
>> goto unlock;
>> }
>>
>> Can you try the above to confirm it works for you ? It should, as that is
>> essentially the same as you did.
>
> After revertung my patch and applying yours, my system can still resume
> from S3. Congrats!
>
> Tested-by: Petr Tesarik <petr@tesarici.cz>
Thanks. I will send a proper patch asap.
>
> Petr T
--
Damien Le Moal
Western Digital Research
next prev parent reply other threads:[~2023-10-04 7:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230930122054.3cf727a4@meshulam>
[not found] ` <20231003113135.38384a87@meshulam.tesarici.cz>
[not found] ` <CAJZ5v0i-FV29TUq8E=FGxB_dRKEJvdoKxzwPGAX0C9vnD7O8eg@mail.gmail.com>
[not found] ` <20231003130240.0c64bc2e@meshulam.tesarici.cz>
[not found] ` <CAJZ5v0hvEyVAwA3r5OWv4W_vTbRXt_Oxv+Avvn6N0=1RoN=NCg@mail.gmail.com>
[not found] ` <20231003144019.24566b05@meshulam.tesarici.cz>
[not found] ` <CAJZ5v0jttFqKE_CLpF+-vJ_wDAuOo_BUS33htpFUs6idNMugKg@mail.gmail.com>
[not found] ` <20231003145110.1f22adfb@meshulam.tesarici.cz>
[not found] ` <CAJZ5v0jbT0DaDpFpLbzO46-Yg6QJ-MrcZAuP+c60q9KpFHAtpQ@mail.gmail.com>
2023-10-03 15:18 ` Thinkpad E595 system deadlock on resume from S3 Petr Tesařík
2023-10-03 16:16 ` Petr Tesařík
2023-10-03 16:48 ` Rafael J. Wysocki
2023-10-03 17:19 ` Petr Tesařík
2023-10-03 20:07 ` Petr Tesařík
2023-10-04 1:25 ` Damien Le Moal
2023-10-04 6:43 ` Petr Tesařík
2023-10-04 7:38 ` Damien Le Moal [this message]
2023-10-04 6:13 ` Hannes Reinecke
2023-10-04 6:18 ` Damien Le Moal
2023-10-04 6:42 ` Petr Tesařík
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=8f6dcb35-1751-5f1e-aef0-ec8c2d25d58a@kernel.org \
--to=dlemoal@kernel.org \
--cc=hare@suse.de \
--cc=linux-ide@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=petr@tesarici.cz \
--cc=rafael@kernel.org \
/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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).