mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v5] scsi: core: Wait until device is fully resumed before doing rescan
@ 2023-06-01 15:56 Kai-Heng Feng
  2023-06-01 19:48 ` Bart Van Assche
  2023-06-02  4:25 ` kernel test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Kai-Heng Feng @ 2023-06-01 15:56 UTC (permalink / raw)
  To: jejb, martin.petersen
  Cc: dlemoal, bblock, acelan.kao, linux-pm, Kai-Heng Feng, linux-scsi,
	linux-kernel

During system resuming process, the resuming order is from top to down.
Namely, the ATA host is resumed before disks connected to it.

When an EH is scheduled while ATA host is resumed and disk device is
still suspended, the device_lock hold by scsi_rescan_device() is never
released so the dpm_resume() of the disk is blocked forerver, therefore
the system can never be resumed back.

That's because scsi_attach_vpd() is expecting the disk device is in
operational state, as it doesn't work on suspended device.

To avoid such deadlock, wait until the scsi device is fully resumed,
before continuing the rescan process.

Signed-off-by: Kai-Heng Feng <kai.heng.feng@canonical.com>
---
v5:
 - Use a different approach. Wait until the disk device is resumed.

v4: 
 - No change.

v3:
 - New patch to resolve undefined pm_suspend_target_state.

v2:
 - Schedule rescan task at the end of system resume phase.
 - Wording.

 drivers/scsi/scsi_scan.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/scsi/scsi_scan.c b/drivers/scsi/scsi_scan.c
index d217be323cc6..a59aada98ac5 100644
--- a/drivers/scsi/scsi_scan.c
+++ b/drivers/scsi/scsi_scan.c
@@ -1621,6 +1621,9 @@ void scsi_rescan_device(struct device *dev)
 {
 	struct scsi_device *sdev = to_scsi_device(dev);
 
+	if (dev->power.is_suspended)
+		wait_for_completion(&dev->power.completion);
+
 	device_lock(dev);
 
 	scsi_attach_vpd(sdev);
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-06-02  4:26 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-06-01 15:56 [PATCH v5] scsi: core: Wait until device is fully resumed before doing rescan Kai-Heng Feng
2023-06-01 19:48 ` Bart Van Assche
2023-06-02  1:00   ` Kai-Heng Feng
2023-06-02  4:25 ` kernel test robot

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®