scsi: core: Avoid that a kernel warning appears during system resume [Linux 4.19.64]

This Linux kernel change "scsi: core: Avoid that a kernel warning appears during system resume" is included in the Linux 4.19.64 release. This change is authored by Bart Van Assche <bvanassche [at]> on Fri Mar 15 16:27:58 2019 -0700. The commit for this change in Linux stable tree is 475f778 (patch) which is from upstream commit 17605af. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream 17605af.

scsi: core: Avoid that a kernel warning appears during system resume

commit 17605afaae825b0291f80c62a7f6565879edaa8a upstream.

Since scsi_device_quiesce() skips SCSI devices that have another state than
RUNNING, OFFLINE or TRANSPORT_OFFLINE, scsi_device_resume() should not
complain about SCSI devices that have been skipped. Hence this patch.  This
patch avoids that the following warning appears during resume:

WARNING: CPU: 3 PID: 1039 at blk_clear_pm_only+0x2a/0x30
CPU: 3 PID: 1039 Comm: kworker/u8:49 Not tainted 5.0.0+ #1
Hardware name: LENOVO 4180F42/4180F42, BIOS 83ET75WW (1.45 ) 05/10/2013
Workqueue: events_unbound async_run_entry_fn
RIP: 0010:blk_clear_pm_only+0x2a/0x30
Call Trace:
 ? scsi_device_resume+0x28/0x50
 ? scsi_dev_type_resume+0x2b/0x80
 ? async_run_entry_fn+0x2c/0xd0
 ? process_one_work+0x1f0/0x3f0
 ? worker_thread+0x28/0x3c0
 ? process_one_work+0x3f0/0x3f0
 ? kthread+0x10c/0x130
 ? __kthread_create_on_node+0x150/0x150
 ? ret_from_fork+0x1f/0x30

Cc: Christoph Hellwig <>
Cc: Hannes Reinecke <>
Cc: Ming Lei <>
Cc: Johannes Thumshirn <>
Cc: Oleksandr Natalenko <>
Cc: Martin Steigerwald <>
Cc: <>
Reported-by: Jisheng Zhang <>
Tested-by: Jisheng Zhang <>
Fixes: 3a0a529971ec ("block, scsi: Make SCSI quiesce and resume work reliably") # v4.15
Signed-off-by: Bart Van Assche <>
Signed-off-by: Martin K. Petersen <>
Signed-off-by: Greg Kroah-Hartman <>

There are 6 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 drivers/scsi/scsi_lib.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index 83bbcdb6..75b926e 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -3102,8 +3102,10 @@ void scsi_device_resume(struct scsi_device *sdev)
     * device deleted during suspend)
-   sdev->quiesced_by = NULL;
-   blk_clear_pm_only(sdev->request_queue);
+   if (sdev->quiesced_by) {
+       sdev->quiesced_by = NULL;
+       blk_clear_pm_only(sdev->request_queue);
+   }
    if (sdev->sdev_state == SDEV_QUIESCE)
        scsi_device_set_state(sdev, SDEV_RUNNING);

Leave a Reply

Your email address will not be published. Required fields are marked *